@gruum/cli 0.1.5 → 0.1.6

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 +69 -67
  2. package/package.json +1 -1
package/gruum.mjs CHANGED
@@ -1,83 +1,83 @@
1
1
  #!/usr/bin/env node
2
- import{chmodSync as dc,existsSync as Ee,rmSync as Ln}from"node:fs";import T from"node:path";import{createInterface as lo}from"node:readline";var ho=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"]),bo=new Set(["page","index","layout","route","default"]);function yo(t){return ho.has(t.property)||/^(margin|transition|grid-)/.test(t.property)?!0:(t.property==="width"||t.property==="height")&&/^(100%|auto)$/.test(t.value)}function Ot(t){return t.flatMap(e=>e.declarations.filter(n=>!yo(n)).map(n=>`${e.state}|${e.context}|${n.property}:${n.value}`)).sort().join(";")}function xo(t){return Ot(t.states)}function ko(t){return t.states.filter(e=>e.state==="default"&&e.context==="").flatMap(e=>e.declarations)}function Nn(t){return t.charAt(0).toUpperCase()+t.slice(1)}function wo(t){let e=t.via?/^bg-([\w-]+?)(?:\/(\d+))?$/.exec(t.via):null;if(e){let s=e[1].replace(/-/g," ");return Nn(e[2]?`${s} ${e[2]}%`:s)}let n=/var\(\s*--(?:color-)?([\w-]+)/.exec(t.value)?.[1];return Nn((n??t.value).replace(/-/g," "))}function vo(t){let e=ko(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?`${wo(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 $o(t){let e=t.split("/"),n=(e.pop()??t).replace(/\.[^.]+$/,""),s=e.pop();return bo.has(n)&&s?`${s}/${n}`:n}function Co(t){let e=[...new Set(t.map(s=>$o(s.path)))],n=e.slice(0,2).join(", ");return e.length>2?`${n} +${e.length-2}`:n}var Tn=(t,e)=>t.path.localeCompare(e.path)||t.line-e.line;function Vn(t){let e=new Map;for(let r of t){let o=vo(r.variant),i=e.get(o)??new Map,a=xo(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(Tn);i.sort((b,k)=>k.sites.length-b.sites.length||Tn(b.sites[0],k.sites[0]));let[a,...l]=i,c=a.looks[0],u=l.map(b=>Co(b.sites)),f=l.map((b,k)=>{let w=b.looks[0],g={title:u.filter(p=>p===u[k]).length>1?`${u[k]} \xB7 line ${b.sites[0].line}`:u[k],selector:w.selector,path:b.sites[0].path,line:b.sites[0].line,element:w.element,usage:w.usage,states:w.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 zn=1,Un=["style.new","state.changed","state.missing","token.unknown","value.hardcoded","native.element","prop.unknown","style.removed","guidance.rule"],Pe={"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 De(t){let e=0;for(let n=0;n<t.length;n++)e=e*33+t.charCodeAt(n)>>>0;return e.toString(36)}function Bn(t){let e=`${t.path}::${t.selector}`;return`v2-style-${e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48)}-${De(e)}`}function rt(t){return t.context?`${t.state} @ ${t.context}`:t.state}var So=/var\(\s*(--[\w-]+)/g;function Ro(t){let e=new Set;for(let n of t)for(let s of n.declarations)for(let r of s.value.matchAll(So))e.add(r[1]);return[...e].sort()}function Ao(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 _o(t){let e=new Map;for(let n of t){let s=rt(n),r=e.get(s),o=Ao([...r?.declarations??[],...n.declarations]);e.set(s,{state:n.state,context:n.context,declarations:o})}return[...e.values()]}function Wn(t){let e=new Map,n=(s,r,o)=>{let i=Bn(s),a=e.get(i),l=_o([...a?Eo(a.states):[],...r]),c=a?.stateLines??new Map;for(let u of r)c.has(rt(u))||c.set(rt(u),u.line);e.set(i,{...a??s,id:i,states:l,tokens:Ro(l),line:a?.line??o,stateLines:c})};for(let s of t){let r=Bn(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 Eo(t){return t.map(e=>({state:e.state,context:e.context,line:0,declarations:e.declarations}))}function jo(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 Fn=/^(\d+) native /;function Io(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 Zt={hardcoded:"value.hardcoded",native:"native.element",props:"prop.unknown"},Mo=new Set(Object.values(Zt));var Lo={"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 Gn(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:Io(n.id,s)});return e}function Ie(t){return`${t.path}#${De(t.text.replace(/\s+/g," ").trim())}`}function Hn(t,e={}){let n=jo(t.previewCss),s=[...Wn(t.variants).values()].map(({line:o,stateLines:i,...a})=>a),r=[];for(let o of t.guidance.files)if(o.kind!=="record")for(let i of o.passages)i.rule&&r.push({path:i.path,headings:i.headings,text:i.text,styles:i.styles});return{schema:zn,concept:t.concept,label:t.label,version:e.version??0,sourceRef:t.repo.ref,publishedAt:e.publishedAt??null,components:[...t.components].sort(),tokens:t.tokens.map(o=>{let i=n.get(o.name);return i===void 0?{name:o.name}:{name:o.name,value:i}}).sort((o,i)=>o.name.localeCompare(i.name)),styles:s,rules:r,content:t.content.map(o=>o.id),acceptedFindings:Gn(t).filter(({check:o})=>o in Zt).map(({check:o,finding:i,key:a})=>({check:o,key:a,message:i.message})),settings:{severity:{...Pe,...e.settings?.severity??{}}}}}function Po(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 Le(t){return t.map(e=>`${e.property}: ${e.value}`).join("; ")}function Me(t,e){return t.length>e?`${t.slice(0,e).join(", ")}, and ${t.length-e} more`:t.join(", ")}function Do(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 Kn(t,e){let n={...Pe,...e.settings.severity},s=[],r=(p,d="")=>{s.push({id:`${p.kind}:${De(`${p.styleId??""}|${p.state??""}|${d}`)}`,severity:n[p.kind],...p})},o=Wn(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)),c=[...l],u=new Map;for(let p of e.styles)p.markup&&u.set(Ot(p.states),p);let f=new Map;for(let p of o.values()){if(!p.markup)continue;let d=u.get(Ot(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,v=y.filter(j=>j.path===p.path),x=(v.length?v:y).map(b),C=p.markup?`This one-off ${p.element??"button"} (${Me((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 ${Me(x,3)},`:"use a spec style,":d?`restyle ${d.selector} only through spec modifiers`:x.length?`use ${Me(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; ${I} or ask for an exception.`},p.markup?Ot(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=>[rt(v),v]));for(let v of p.states){let x=rt(v),C=y.get(x),I=Po(C?.declarations??[],v.declarations);I.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 (${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.`},Le(v.declarations))}}for(let p of o.values()){let d=i.get(p.id);if(!d)continue;let y=new Set(p.states.map(rt));for(let v of d.states){let x=rt(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: ${Le(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=Do(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 w=Gn(t).filter(({check:p})=>p in Zt);for(let p of Un)if(Mo.has(p))for(let{check:d,finding:y,key:v}of w){if(Zt[d]!==p)continue;let x=k.get(v)??[];if(x.some(A=>!Oo(d,A.message,y.message)))continue;let C=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: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:Lo[p](e)},v)}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 $=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(Ie(d));for(let p of e.rules){if(g.has(Ie(p)))continue;let d=$.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.`},Ie(p))}return s}function Oo(t,e,n){if(e===n)return!1;if(t==="native"){let s=Fn.exec(e)?.[1],r=Fn.exec(n)?.[1];if(s&&r)return Number(r)>Number(s)}return!0}var No={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 Oe(t){let e=(n,s)=>t.styles.filter(r=>r.hostId===n&&r.kind===s).map(r=>r.selector);return{about:{...No,drift:Un.map(n=>({kind:n,severity:t.settings.severity[n]??Pe[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=>[rt(s),Le(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 Xt(t){if(!t||typeof t!="object")return null;let e=t;return e.schema!==zn||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 To(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 Ne(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 Jn(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 To(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 Zn(t){return{schema:1,checkedAt:t,baselineVersion:null,items:[],followups:{}}}function Xn(t,e){if(!t||typeof t!="object")return Zn(e);let n=t;return n.schema!==1||!Array.isArray(n.items)?Zn(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 Nt(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},Te=8;function Yn(t){let e=t.slice(0,Te).map(n=>{let s=n.refs[0],r=s?` (${s.path}${s.line?`:${s.line}`:""})`:"";return`- ${n.title}${r}. ${n.fix}`});return t.length>Te&&e.push(`- and ${t.length-Te} more; run \`gruum check\`.`),e.join(`
5
- `)}function qn(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 Qn(t,e,n=Ct,s={}){let r=Nt(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:
6
- ${Yn(r)}
2
+ import{chmodSync as kc,existsSync as Ee,rmSync as Pn}from"node:fs";import V from"node:path";import{createInterface as On}from"node:readline";var $o=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"]),Co=new Set(["page","index","layout","route","default"]);function So(t){return $o.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=>!So(n)).map(n=>`${e.state}|${e.context}|${n.property}:${n.value}`)).sort().join(";")}function Ro(t){return Dt(t.states)}function Ao(t){return t.states.filter(e=>e.state==="default"&&e.context==="").flatMap(e=>e.declarations)}function Vn(t){return t.charAt(0).toUpperCase()+t.slice(1)}function _o(t){let e=t.via?/^bg-([\w-]+?)(?:\/(\d+))?$/.exec(t.via):null;if(e){let s=e[1].replace(/-/g," ");return Vn(e[2]?`${s} ${e[2]}%`:s)}let n=/var\(\s*--(?:color-)?([\w-]+)/.exec(t.value)?.[1];return Vn((n??t.value).replace(/-/g," "))}function Eo(t){let e=Ao(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?`${_o(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 jo(t){let e=t.split("/"),n=(e.pop()??t).replace(/\.[^.]+$/,""),s=e.pop();return Co.has(n)&&s?`${s}/${n}`:n}function Io(t){let e=[...new Set(t.map(s=>jo(s.path)))],n=e.slice(0,2).join(", ");return e.length>2?`${n} +${e.length-2}`:n}var Bn=(t,e)=>t.path.localeCompare(e.path)||t.line-e.line;function Fn(t){let e=new Map;for(let r of t){let o=Eo(r.variant),i=e.get(o)??new Map,a=Ro(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(Bn);i.sort((b,k)=>k.sites.length-b.sites.length||Bn(b.sites[0],k.sites[0]));let[a,...l]=i,c=a.looks[0],u=l.map(b=>Io(b.sites)),f=l.map((b,k)=>{let w=b.looks[0],g={title:u.filter(p=>p===u[k]).length>1?`${u[k]} \xB7 line ${b.sites[0].line}`:u[k],selector:w.selector,path:b.sites[0].path,line:b.sites[0].line,element:w.element,usage:w.usage,states:w.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 Wn=1,Gn=["style.new","state.changed","state.missing","token.unknown","value.hardcoded","native.element","prop.unknown","style.removed","guidance.rule"],Oe={"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 De(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)}-${De(e)}`}function ot(t){return t.context?`${t.state} @ ${t.context}`:t.state}var Mo=/var\(\s*(--[\w-]+)/g;function Lo(t){let e=new Set;for(let n of t)for(let s of n.declarations)for(let r of s.value.matchAll(Mo))e.add(r[1]);return[...e].sort()}function Po(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 Oo(t){let e=new Map;for(let n of t){let s=ot(n),r=e.get(s),o=Po([...r?.declarations??[],...n.declarations]);e.set(s,{state:n.state,context:n.context,declarations:o})}return[...e.values()]}function Hn(t){let e=new Map,n=(s,r,o)=>{let i=zn(s),a=e.get(i),l=Oo([...a?Do(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:Lo(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 Do(t){return t.map(e=>({state:e.state,context:e.context,line:0,declarations:e.declarations}))}function To(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 Un=/^(\d+) native /;function No(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"},Vo=new Set(Object.values(Xt));var Bo={"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 Kn(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:No(n.id,s)});return e}function Me(t){return`${t.path}#${De(t.text.replace(/\s+/g," ").trim())}`}function Jn(t,e={}){let n=To(t.previewCss),s=[...Hn(t.variants).values()].map(({line:o,stateLines:i,...a})=>a),r=[];for(let o of t.guidance.files)if(o.kind!=="record")for(let i of o.passages)i.rule&&r.push({path:i.path,headings:i.headings,text:i.text,styles:i.styles});return{schema:Wn,concept:t.concept,label:t.label,version:e.version??0,sourceRef:t.repo.ref,publishedAt:e.publishedAt??null,components:[...t.components].sort(),tokens:t.tokens.map(o=>{let i=n.get(o.name);return i===void 0?{name:o.name}:{name:o.name,value:i}}).sort((o,i)=>o.name.localeCompare(i.name)),styles:s,rules:r,content:t.content.map(o=>o.id),acceptedFindings:Kn(t).filter(({check:o})=>o in Xt).map(({check:o,finding:i,key:a})=>({check:o,key:a,message:i.message})),settings:{severity:{...Oe,...e.settings?.severity??{}}}}}function Fo(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 Pe(t){return t.map(e=>`${e.property}: ${e.value}`).join("; ")}function Le(t,e){return t.length>e?`${t.slice(0,e).join(", ")}, and ${t.length-e} more`:t.join(", ")}function zo(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 Zn(t,e){let n={...Oe,...e.settings.severity},s=[],r=(p,d="")=>{s.push({id:`${p.kind}:${De(`${p.styleId??""}|${p.state??""}|${d}`)}`,severity:n[p.kind],...p})},o=Hn(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)),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,v=y.filter(j=>j.path===p.path),x=(v.length?v:y).map(b),C=p.markup?`This one-off ${p.element??"button"} (${Le((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 ${Le(x,3)},`:"use a spec style,":d?`restyle ${d.selector} only through spec modifiers`:x.length?`use ${Le(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; ${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(v=>[ot(v),v]));for(let v of p.states){let x=ot(v),C=y.get(x),I=Fo(C?.declarations??[],v.declarations);I.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 (${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.`},Pe(v.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 v of d.states){let x=ot(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: ${Pe(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=zo(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 w=Kn(t).filter(({check:p})=>p in Xt);for(let p of Gn)if(Vo.has(p))for(let{check:d,finding:y,key:v}of w){if(Xt[d]!==p)continue;let x=k.get(v)??[];if(x.some(A=>!Uo(d,A.message,y.message)))continue;let C=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: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:Bo[p](e)},v)}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 $=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=$.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 Uo(t,e,n){if(e===n)return!1;if(t==="native"){let s=Un.exec(e)?.[1],r=Un.exec(n)?.[1];if(s&&r)return Number(r)>Number(s)}return!0}var Wo={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 Te(t){let e=(n,s)=>t.styles.filter(r=>r.hostId===n&&r.kind===s).map(r=>r.selector);return{about:{...Wo,drift:Gn.map(n=>({kind:n,severity:t.settings.severity[n]??Oe[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),Pe(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!==Wn||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 Go(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 Ne(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 Xn(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 Go(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 qn(t){return{schema:1,checkedAt:t,baselineVersion:null,items:[],followups:{}}}function Yn(t,e){if(!t||typeof t!="object")return qn(e);let n=t;return n.schema!==1||!Array.isArray(n.items)?qn(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},Ve=8;function Qn(t){let e=t.slice(0,Ve).map(n=>{let s=n.refs[0],r=s?` (${s.path}${s.line?`:${s.line}`:""})`:"";return`- ${n.title}${r}. ${n.fix}`});return t.length>Ve&&e.push(`- and ${t.length-Ve} more; run \`gruum check\`.`),e.join(`
5
+ `)}function ts(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 es(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:
6
+ ${Qn(r)}
7
7
 
8
- ${qn(n)}`},ledger:{...t,followups:{...t.followups,[o]:i+1}}}}function Ve(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 ts(t,e,n=Ct,s={}){let r=Ve(e.command??"").filter(i=>n.denyGit.includes(i));if(r.length===0)return{permission:"allow"};let o=Nt(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:
9
- ${Yn(o)}
8
+ ${ts(n)}`},ledger:{...t,followups:{...t.followups,[o]:i+1}}}}function Be(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 ns(t,e,n=Ct,s={}){let r=Be(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:
9
+ ${Qn(o)}
10
10
 
11
- ${qn(n)}`}}var Tt="npx --no-install @gruum/cli",es={afterFileEdit:"after-file-edit",stop:"stop",beforeShellExecution:"before-shell"},Vo=/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+hook\s+(after-file-edit|stop|before-shell)\s*$/;function Be(t){return typeof t=="string"&&Vo.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 ns(t,e=Tt){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(es)){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 ${es[a]}`,u=l.filter(f=>Be(f?.command));u.length===1&&u[0].command===c||(o[a]=[...l.filter(f=>!Be(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 ss(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=>!Be(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 Bo(t){let[e,...n]=t.trim().split(/\s+/);return{command:e,args:[...n,"mcp"]}}function rs(t,e=Tt){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=Bo(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 os(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 ft=".cursor/rules/gruum-buttons.mdc",is="<!-- written by gruum init cursor -->",Fo=20,zo=["**/*.css","**/*.scss","**/*.tsx","**/*.jsx"];function as(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,Fo);return n.length?n:zo}function ls(t){return["---","description: Buttons in this repository follow a spec published in Gruum.",`globs: ${t.join(",")}`,"alwaysApply: false","---",is,"","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 cs(t){return t.includes(is)}function us(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
+ ${ts(n)}`}}var Nt="npx --no-install @gruum/cli",ss={afterFileEdit:"after-file-edit",stop:"stop",beforeShellExecution:"before-shell"},Ho=/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+hook\s+(after-file-edit|stop|before-shell)\s*$/;function Fe(t){return typeof t=="string"&&Ho.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 rs(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(ss)){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 ${ss[a]}`,u=l.filter(f=>Fe(f?.command));u.length===1&&u[0].command===c||(o[a]=[...l.filter(f=>!Fe(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 os(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=>!Fe(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 Ko(t){let[e,...n]=t.trim().split(/\s+/);return{command:e,args:[...n,"mcp"]}}function is(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=Ko(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 as(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",ls="<!-- written by gruum init cursor -->",Jo=20,Zo=["**/*.css","**/*.scss","**/*.tsx","**/*.jsx"];function cs(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,Jo);return n.length?n:Zo}function us(t){return["---","description: Buttons in this repository follow a spec published in Gruum.",`globs: ${t.join(",")}`,"alwaysApply: false","---",ls,"","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 ps(t){return t.includes(ls)}function fs(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(`
14
14
  `)?"":`
15
15
  `;return{text:`${e}${s}# Gruum local state
16
16
  .gruum/
17
- `,changed:!0}}function ps(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 Uo=t=>`${t} check --staged`;function fs(t,e=Tt){let n=Uo(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 ds(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 Xo=t=>`${t} check --staged`;function gs(t,e=Nt){let n=Xo(e);if(t.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
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=>ds(l)))return{kind:s,path:r,text:o,changed:!1};let i=o===null?s==="git"?`#!/bin/sh
22
+ `};let r=t.husky?".husky/pre-commit":`${t.gitHooksDir}/pre-commit`,o=t.hookText;if(o!==null&&o.split(/\r?\n/).some(l=>ms(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 ds(t){return/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+check\s+--staged\s*$/.test(t.trim())}function gs(t){let e=t.split(`
27
- `),n=e.filter(o=>!ds(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 ms(t){let e=St.map((n,s)=>` ${s+1} ${n.name.padEnd(10)} ${n.blurb}`);return`gruum ${t}
26
+ `,changed:!0}}function ms(t){return/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+check\s+--staged\s*$/.test(t.trim())}function hs(t){let e=t.split(`
27
+ `),n=e.filter(o=>!ms(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 bs(t){let e=St.map((n,s)=>` ${s+1} ${n.name.padEnd(10)} ${n.blurb}`);return`gruum ${t}
29
29
 
30
30
  ${e.join(`
31
31
  `)}
32
- `}function hs(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 Wo="2025-06-18",Qt="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.",te={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. ${Qt}`,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. ${Qt}`,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. ${Qt}`,gruum_exception_status:`Pending, accepted, or rejected for this branch's exception requests. Pass an id to read one. ${Qt}`};function bs(t){return[{name:"gruum_button_spec",description:te.gruum_button_spec,inputSchema:{type:"object",properties:{},additionalProperties:!1},run:()=>t.spec()},{name:"gruum_check_buttons",description:te.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:te.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:te.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 ee(t,e,n){return{jsonrpc:"2.0",id:t,error:{code:e,message:n}}}async function ys(t,e,n){if(!t||typeof t!="object")return ee(null,-32600,"Invalid request");let s=t,r=!("id"in s),o=s.id??null;if(typeof s.method!="string")return r?null:ee(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:Wo,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 ee(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:ee(o,-32601,`Method not found: ${s.method}`)}}var Go=/(^|\/)(node_modules|\.git|\.next|dist|build|out|coverage|vendor|\.turbo|\.cache|__pycache__|target|\.venv|venv)\//,Ho=/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb|Cargo\.lock|poetry\.lock|composer\.lock|Gemfile\.lock)$/,Ko=/\.(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,Jo=/(^|\/)\.gruum\//;function Fe(t){return!Go.test(`${t}/`)&&!Jo.test(`${t}/`)}function ze(t,e){return Ho.test(t)||Ko.test(t)?!1:e<=3e5}function xs(t){let e=Math.min(t.length,8e3);for(let n=0;n<e;n++)if(t[n]===0)return!0;return!1}var Zo=/\.(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 ks(t){return Zo.test(t)}function Ue(t){return t.replace(/\\/g,"/").replace(/^\.\/?/,"").replace(/^\/+|\/+$/g,"")}function We(t,e){let n=Ue(e),s=t.replace(/\\/g,"/");return n?s.startsWith(`${n}/`)?s.slice(n.length+1):null:s}function ws(t,e,n){let s=new Map(t);for(let r of e){let o=We(r.path,n);o===null||!Fe(o.split("/").slice(0,-1).join("/")||".")||(r.content===null?s.delete(o):ze(o,r.content.length)&&s.set(o,r.content))}return s}function vs(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 ne(t){let e=/^(?:git@|ssh:\/\/git@|https?:\/\/(?:[^@/]+@)?)github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(t.trim());return e?`${e[1]}/${e[2]}`:null}var $s=t=>t.replace(/\\(.)/g,"$1");function Xo(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 Ge=/\*|[a-z][\w-]*|\.((?:\\.|[\w-])+)|#((?:\\.|[\w-])+)|\[\s*([\w-]+)\s*(?:([~|^$*]?=)\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*[is]?\s*\]|::([\w-]+)|:([\w-]+)(\((?:[^()]|\([^()]*\))*\))?/giy;function Rs(t){let e=[];Ge.lastIndex=0;let n=0;for(;n<t.length;){Ge.lastIndex=n;let s=Ge.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:$s(s[1])});else if(s[2]!==void 0)e.push({kind:"id",raw:r,name:$s(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=Xo(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=Rs(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 As=t=>t.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(e=>e.toLowerCase());function Cs(t,e){let n=t.toLowerCase();return e.some(s=>n.includes(s.toLowerCase()))}function He(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"&&As(r.name).some(o=>s.has(o)))}var Yo=new Set(["html","body"]),qo=new Set(["svg","path","use","img","picture","video","i","em","strong","b","small","kbd","sup","sub"]);function re(t,e){for(let n of t)switch(n.kind){case"tag":if(e.elements.includes(n.name))return!0;break;case"class":if(Cs(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&&Cs(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&&re(r[r.length-1].simples,e)))return!0}break;default:break}return!1}function _s(t){return t.some(n=>n.kind==="universal")?t.length===1:t.some(n=>n.kind==="tag"&&Yo.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 Es(t){return t.some(e=>e.kind==="tag"&&qo.has(e.name))}var se=["hover","focus","active","selected","current","loading","disabled"],Qo={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"},ti={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",checked:"selected",disabled:"disabled"},ei={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"},ni=new Set(["active","selected","pressed","checked","loading","busy","disabled","open","current","hover","focus","show","expanded","collapsed"]),Ss=t=>Qo[t.toLowerCase()]??t.toLowerCase(),ot={hover:"__gs-hover",focus:"__gs-focus",active:"__gs-active"};function js(t){if(t.kind==="pseudo"){let e=ti[t.name];if(!e)return null;let n=ot[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:Ss(t.value),marker:{classes:[],attrs:{"data-state":t.value}}};let e=ei[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]:ni.has(t.name.toLowerCase())?t.name:null;return n?{state:Ss(n),marker:{classes:[t.name],attrs:{}}}:null}return null}function si(t){return t.kind!=="pseudo"||t.name!=="not"||!t.args?!1:z(t.args).every(e=>{let n=Rs(e);return n!==null&&n.every(s=>js(s)!==null)})}function oe(t){let e=[],n=new Map;for(let o of t){if(si(o))continue;let i=js(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=se.indexOf(t);return e===-1?se.length:e}function dt(t){return t.length?t.join(" + "):"default"}function Ke(t){return t.replace(/:hover\b/g,`.${ot.hover}`).replace(/:focus(?:-visible|-within)?\b/g,`.${ot.focus}`).replace(/:active\b/g,`.${ot.active}`)}var ri=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"]),oi=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"]),ii=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 zt(t){let e=t.toLowerCase();return ri.has(e)?"paint":oi.has(e)?"layout":ii.has(e)?"hint":"box"}var ai={shadow:/^box-shadow$/,cursor:/^cursor$/,rounded:/^border(?:-[a-z]+)*-radius$/,radius:/^border(?:-[a-z]+)*-radius$/};function Is(t,e){let n=t.filter(o=>o.kind==="class");if(n.length!==1||t.length!==1)return!1;let s=As(n[0].name)[0],r=s?ai[s]:void 0;return r?e.length>0&&e.every(o=>r.test(o.property.toLowerCase())):!1}var Nc={hover:{classes:[ot.hover],attrs:{}},focus:{classes:[ot.focus],attrs:{}},active:{classes:[ot.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 li="data-gs-sheet";function Ls(t){return`[${li}="${t.replace(/["\\]/g,"")}"]`}function Ms(t){return/\.module\.[a-z]+$/i.test(t)}var ci=new Set(["button","a","div","span","input","summary","label"]);function gt(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 ui(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 ie(t,e){let n=X(t);if(!n||n.some(c=>c.combinator==="+"||c.combinator==="~"))return null;let s=n.map(c=>ui(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(!ci.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 Je(t,e){let n="";for(let s of t)s.property.toLowerCase()===e&&(n=s.value.replace(/!important\s*$/i,"").trim());return n}function ae(t){let e=Je(t,"display");if(/^none\b/i.test(e))return"display: none";let n=Je(t,"visibility");if(/^(hidden|collapse)\b/i.test(n))return`visibility: ${n.split(/\s+/)[0].toLowerCase()}`;let s=Je(t,"opacity");return/^(0|0\.0+)$/.test(s)?"opacity: 0":null}function Ps(t,e){return t===e||!Ms(t)&&!Ms(e)}function tt(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 pi=40,Y=(t,e)=>({path:t,line:e});function q(t,e,n,s){return{...t,status:e.length===0?"ok":"attention",summary:e.length===0?n:s(e.length),findings:e.slice(0,pi)}}function mt(t,e){return{...t,status:"na",summary:e,findings:[]}}var Ze=t=>t.state.split(" + ");function Vs(t,e){if(!t.element||!e.element||t!==e&&!Ps(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 Bs(t,e){return e.filter(n=>Vs(n,t)).flatMap(n=>n.states)}function fi(t,e,n){return Bs(t,e).some(s=>Ze(s).includes(n))||e.filter(s=>Vs(s,t)).some(s=>(s.parts??[]).some(r=>r.state.split(" + ").includes(n)))}var di=[{state:"hover",severity:"issue"},{state:"focus",severity:"issue"},{state:"disabled",severity:"issue"},{state:"active",severity:"note"}];function gi(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 mt(e,"No styles that can be drawn on their own.");let s=[];for(let{state:r,severity:o}of di){let i=n.filter(a=>!fi(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=>Y(a.path,a.line))})}return q(e,s,"Every style has hover, focus, disabled, and active rules.",r=>`${r} state${r===1?"":"s"} missing on some styles.`)}var Ds=new Set(["outline","outline-style","outline-width"]),Os=/^(?: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 hi(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 mt(e,"No styles that can be drawn on their own.");let s=[];for(let r of n){let o=Bs(r,t.variants),i=o.filter(l=>{let c=Ze(l);return c.includes("default")||c.includes("focus")}).flatMap(l=>l.declarations.map(c=>({s:l,d:c}))).find(({d:l})=>Ds.has(l.property)&&Os.test(l.value.replace(/\s*!important/i,"")));!i||o.filter(l=>Ze(l).includes("focus")).some(l=>l.declarations.some(c=>mi.test(c.property)&&!(Ds.has(c.property)&&Os.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:[Y(r.path,i.s.line)]})}return q(e,s,"No style removes the outline without a focus replacement.",r=>`${r} style${r===1?"":"s"} lose the focus indicator.`)}function bi(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 mt(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=>Y(i.path,i.line))}});return q(e,s,`All ${t.tokens.length} tokens read are defined.`,r=>`${r} token${r===1?"":"s"} with no definition.`)}var yi=/var\((?:[^()]|\([^()]*\))*\)/g,Ns=/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?)\([^)]*\)/gi,xi=/^(?:padding|margin|gap|row-gap|column-gap|height|min-height|max-height|border-radius|font-size|letter-spacing)(?:-[a-z]+)*$/,ki=/(?<![\w.-])(\d+(?:\.\d+)?)px\b/g;function Ts(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 Xe(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?Xe(i,e,n+1):o!==void 0?Xe(o.trim(),e,n+1):s})}var wi=[[/^(?: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 vi(t,e){if(!e)return null;let n=wi.find(([s])=>s.test(t))?.[1];return e.find(s=>!n||n.test(s))??null}function $i(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=Xe(i,t.tokenValues).trim();if(new RegExp(`^(?:${Ns.source})$`,"i").test(a)){let l=Ts(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 mt(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(yi," ");for(let m of f.matchAll(Ns)){let b=n.get(Ts(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(xi.test(u.property))for(let m of f.matchAll(ki)){let b=vi(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:[Y(o.path,a.line)]})}return q(e,r,`No ${t.noun} style hard-codes a value a token already has.`,o=>`${o} style${o===1?"":"s"} hard-code values.`)}function Ci(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 mt(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:[Y(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:[Y(r.path,r.line),...r.usage.files.slice(0,2)]});return s.sort((r,o)=>+(o.severity==="issue")-+(r.severity==="issue")),q(e,s,`All ${n.length} styles are referenced.`,r=>`${r} style${r===1?"":"s"} unreferenced or unconfirmed.`)}function Si(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=>Y(o.path,o.line))}));return q(e,s,"No two styles share the same default declarations.",r=>`${r} group${r===1?"":"s"} of identical styles.`)}function Ri(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 mt(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:[Y(s.path,s.line)]}));return q(e,n,`Every <${t.element}> goes through the component.`,s=>`${s} file${s===1?"":"s"} bypass the component.`)}function Ai(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 mt(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:[Y(s.path,s.line)]}));return q(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 _i(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 q(e,[],"Every style is named in written guidance.",()=>"");let s=t.variants.filter(r=>r.element&&n.undocumented.includes(r.title));return q(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=>Y(r.path,r.line))}],"",r=>`${r} finding${r===1?"":"s"}.`)}function Fs(t){return[gi(t),hi(t),Ci(t),Si(t),bi(t),$i(t),Ri(t),Ai(t),_i(t)]}var Ei=/\.(erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,zs=/^<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/,ji=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Ii=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),Mi=new Set(["classNames","classnames","clsx","cn","cx"]),Li=/^(?:ref|key|style|dangerouslySetInnerHTML)$/i;function Gs(t,e){let n=1;for(let s=0;s<e&&s<t.length;s++)t[s]===`
33
- `&&n++;return n}function Us(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Hs(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(`
34
- `)}function Pi(t,e,n){let s=Math.max(0,Math.min(e,t.length)),r=Math.max(s,Math.min(n,t.length)),o=Gs(t,s),i=t.slice(s,r).split(`
32
+ `}var ys="Would you like to run a (c) check, (b) baseline, or (q) quit? ",xs="You have no baseline. Would you like to run it? (b) baseline, (q) quit: ";function ks(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 ws(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 vs(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 qo="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 $s(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 Cs(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:qo,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 Yo=/(^|\/)(node_modules|\.git|\.next|dist|build|out|coverage|vendor|\.turbo|\.cache|__pycache__|target|\.venv|venv)\//,Qo=/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb|Cargo\.lock|poetry\.lock|composer\.lock|Gemfile\.lock)$/,ti=/\.(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,ei=/(^|\/)\.gruum\//;function ze(t){return!Yo.test(`${t}/`)&&!ei.test(`${t}/`)}function Ue(t,e){return Qo.test(t)||ti.test(t)?!1:e<=3e5}function Ss(t){let e=Math.min(t.length,8e3);for(let n=0;n<e;n++)if(t[n]===0)return!0;return!1}var ni=/\.(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 Rs(t){return ni.test(t)}function We(t){return t.replace(/\\/g,"/").replace(/^\.\/?/,"").replace(/^\/+|\/+$/g,"")}function Ge(t,e){let n=We(e),s=t.replace(/\\/g,"/");return n?s.startsWith(`${n}/`)?s.slice(n.length+1):null:s}function As(t,e,n){let s=new Map(t);for(let r of e){let o=Ge(r.path,n);o===null||!ze(o.split("/").slice(0,-1).join("/")||".")||(r.content===null?s.delete(o):Ue(o,r.content.length)&&s.set(o,r.content))}return s}function _s(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 Es=t=>t.replace(/\\(.)/g,"$1");function si(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 He=/\*|[a-z][\w-]*|\.((?:\\.|[\w-])+)|#((?:\\.|[\w-])+)|\[\s*([\w-]+)\s*(?:([~|^$*]?=)\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*[is]?\s*\]|::([\w-]+)|:([\w-]+)(\((?:[^()]|\([^()]*\))*\))?/giy;function Ms(t){let e=[];He.lastIndex=0;let n=0;for(;n<t.length;){He.lastIndex=n;let s=He.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:Es(s[1])});else if(s[2]!==void 0)e.push({kind:"id",raw:r,name:Es(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=si(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=Ms(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 U(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 Ls=t=>t.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(e=>e.toLowerCase());function js(t,e){let n=t.toLowerCase();return e.some(s=>n.includes(s.toLowerCase()))}function Ke(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"&&Ls(r.name).some(o=>s.has(o)))}var ri=new Set(["html","body"]),oi=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(js(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&&js(n.value,e.classKeywords))return!0;break;case"pseudo":if((n.name==="is"||n.name==="where")&&n.args){let s=U(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 Ps(t){return t.some(n=>n.kind==="universal")?t.length===1:t.some(n=>n.kind==="tag"&&ri.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 Os(t){return t.some(e=>e.kind==="tag"&&oi.has(e.name))}var re=["hover","focus","active","selected","current","loading","disabled"],ii={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"},ai={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",checked:"selected",disabled:"disabled"},li={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"},ci=new Set(["active","selected","pressed","checked","loading","busy","disabled","open","current","hover","focus","show","expanded","collapsed"]),Is=t=>ii[t.toLowerCase()]??t.toLowerCase(),it={hover:"__gs-hover",focus:"__gs-focus",active:"__gs-active"};function Ds(t){if(t.kind==="pseudo"){let e=ai[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:Is(t.value),marker:{classes:[],attrs:{"data-state":t.value}}};let e=li[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]:ci.has(t.name.toLowerCase())?t.name:null;return n?{state:Is(n),marker:{classes:[t.name],attrs:{}}}:null}return null}function ui(t){return t.kind!=="pseudo"||t.name!=="not"||!t.args?!1:U(t.args).every(e=>{let n=Ms(e);return n!==null&&n.every(s=>Ds(s)!==null)})}function ie(t){let e=[],n=new Map;for(let o of t){if(ui(o))continue;let i=Ds(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 Je(t){return t.replace(/:hover\b/g,`.${it.hover}`).replace(/:focus(?:-visible|-within)?\b/g,`.${it.focus}`).replace(/:active\b/g,`.${it.active}`)}var pi=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"]),fi=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"]),di=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 zt(t){let e=t.toLowerCase();return pi.has(e)?"paint":fi.has(e)?"layout":di.has(e)?"hint":"box"}var gi={shadow:/^box-shadow$/,cursor:/^cursor$/,rounded:/^border(?:-[a-z]+)*-radius$/,radius:/^border(?:-[a-z]+)*-radius$/};function Ts(t,e){let n=t.filter(o=>o.kind==="class");if(n.length!==1||t.length!==1)return!1;let s=Ls(n[0].name)[0],r=s?gi[s]:void 0;return r?e.length>0&&e.every(o=>r.test(o.property.toLowerCase())):!1}var Uc={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 mi="data-gs-sheet";function Vs(t){return`[${mi}="${t.replace(/["\\]/g,"")}"]`}function Ns(t){return/\.module\.[a-z]+$/i.test(t)}var hi=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 bi(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=>bi(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(!hi.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 Ze(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=Ze(t,"display");if(/^none\b/i.test(e))return"display: none";let n=Ze(t,"visibility");if(/^(hidden|collapse)\b/i.test(n))return`visibility: ${n.split(/\s+/)[0].toLowerCase()}`;let s=Ze(t,"opacity");return/^(0|0\.0+)$/.test(s)?"opacity: 0":null}function Bs(t,e){return t===e||!Ns(t)&&!Ns(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 yi=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,yi)}}function ht(t,e){return{...t,status:"na",summary:e,findings:[]}}var Xe=t=>t.state.split(" + ");function Gs(t,e){if(!t.element||!e.element||t!==e&&!Bs(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 Hs(t,e){return e.filter(n=>Gs(n,t)).flatMap(n=>n.states)}function xi(t,e,n){return Hs(t,e).some(s=>Xe(s).includes(n))||e.filter(s=>Gs(s,t)).some(s=>(s.parts??[]).some(r=>r.state.split(" + ").includes(n)))}var ki=[{state:"hover",severity:"issue"},{state:"focus",severity:"issue"},{state:"disabled",severity:"issue"},{state:"active",severity:"note"}];function wi(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 ki){let i=n.filter(a=>!xi(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 Fs=new Set(["outline","outline-style","outline-width"]),zs=/^(?:none|0|0px)(?:\s+(?:none|0|0px))*$/i,vi=/^(?:outline(?:-color|-width|-style)?|box-shadow|border(?:-[a-z]+)*|background(?:-color)?|text-decoration(?:-[a-z]+)?|color)$/;function $i(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=Hs(r,t.variants),i=o.filter(l=>{let c=Xe(l);return c.includes("default")||c.includes("focus")}).flatMap(l=>l.declarations.map(c=>({s:l,d:c}))).find(({d:l})=>Fs.has(l.property)&&zs.test(l.value.replace(/\s*!important/i,"")));!i||o.filter(l=>Xe(l).includes("focus")).some(l=>l.declarations.some(c=>vi.test(c.property)&&!(Fs.has(c.property)&&zs.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 Ci(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 Si=/var\((?:[^()]|\([^()]*\))*\)/g,Us=/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?)\([^)]*\)/gi,Ri=/^(?:padding|margin|gap|row-gap|column-gap|height|min-height|max-height|border-radius|font-size|letter-spacing)(?:-[a-z]+)*$/,Ai=/(?<![\w.-])(\d+(?:\.\d+)?)px\b/g;function Ws(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 qe(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?qe(i,e,n+1):o!==void 0?qe(o.trim(),e,n+1):s})}var _i=[[/^(?: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 Ei(t,e){if(!e)return null;let n=_i.find(([s])=>s.test(t))?.[1];return e.find(s=>!n||n.test(s))??null}function ji(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=qe(i,t.tokenValues).trim();if(new RegExp(`^(?:${Us.source})$`,"i").test(a)){let l=Ws(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(Si," ");for(let m of f.matchAll(Us)){let b=n.get(Ws(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(Ri.test(u.property))for(let m of f.matchAll(Ai)){let b=Ei(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 Ii(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 Mi(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 Li(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 Pi(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 Oi(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 Ks(t){return[wi(t),$i(t),Ii(t),Mi(t),Ci(t),ji(t),Li(t),Pi(t),Oi(t)]}var Di=/\.(erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,Js=/^<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/,Ti=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Ni=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),Vi=new Set(["classNames","classnames","clsx","cn","cx"]),Bi=/^(?:ref|key|style|dangerouslySetInnerHTML)$/i;function qs(t,e){let n=1;for(let s=0;s<e&&s<t.length;s++)t[s]===`
33
+ `&&n++;return n}function Zs(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Ys(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(`
34
+ `)}function Fi(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(`
35
35
  `).slice(0,12),a=t.slice(s,r).split(`
36
- `).length>12;return{source:Hs(i)+(a?`
37
- \u2026`:""),startLine:o}}function Di(t,e){let n=Gs(t,Math.max(0,e)),s=t.split(`
38
- `),r=Math.max(0,n-1);return{source:Hs(s.slice(r,r+12)),startLine:r+1}}function Ws(t,e){return{kind:"other",...Di(t,e)}}function pe(t,e){let n=zs.exec(t.slice(e));if(!n)return null;let s=n[1],r=n[2]??"",o=e+n[0].length;if(/\/\s*$/.test(r)||ji.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=zs.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 qe(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=pe(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 Ks(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 it(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 Js(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 ce(t=new Map,e=new Map){return{values:t,aliases:e,flags:new Set,strings:new Set,prefixes:new Map}}var Ye=/^[A-Za-z_$][\w$]*$/;function Qe(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 tn(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 Zs(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=tn(t);for(let c of["||","&&"]){let u=Qe(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=Zs(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 Xs(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=ce()){let n=tn(t);if(!n)return{classes:[],dynamic:!1};let s=Xs(n);if(s){let c=_t(s.condition,e);return c===null?{classes:[],dynamic:!0}:Rt(c?s.yes:s.no,e)}let r=Qe(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(Ye.test(k)){let w=e.values.get(k);if(typeof w!="string")return{classes:[],dynamic:!0};e.strings.add(k);let $=/[\w-]*$/.exec(u)?.[0];$&&e.prefixes.set(k,$),u+=w}else{let w=Rt(k,e);if(w.dynamic)return{classes:[],dynamic:!0};u+=w.classes.join(" ")}f=b+1}return{classes:At(u),dynamic:!1}}if(Ye.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:[Ks(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&&Mi.has(l[1])){let c=[];for(let u of Js(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 fe(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=it(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=it(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 en(t,e){let n=fe(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 Ys(t,e){return/[<>]/.test(e)?!1:t==="href"||t==="src"||t==="action"?/^(?:https?:|mailto:|\/|#)/i.test(e):!0}function Oi(t){return t==="class"||t==="className"?!1:!Li.test(t)&&!/^on/i.test(t)}function qs(t){let e={};for(let n of fe(t).list){if(!Oi(n.name)||n.expr!==void 0)continue;let s=n.value??"";Ys(n.name,s)&&(e[n.name]=s)}return e}var Ni=/^(?:data-[\w-]+|aria-[\w-]+|disabled|hidden)$/,Ti=new Set(["disabled","hidden"]);function le(t,e,n=0){if(n>4)return null;let s=tn(t),r=it(s,0);if(r&&r.end===s.length)return r.value;let o=Xs(s);if(o){let l=_t(o.condition,e);return l===null?null:le(l?o.yes:o.no,e,n+1)}let i=Qe(s,"||");if(i>=0){let l=le(s.slice(0,i),e,n+1);return l===null?null:l!==void 0?l:le(s.slice(i+2),e,n+1)}if(s==="undefined"||s==="null"||s==="false")return;if(s==="true")return"true";if(!Ye.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=Zs(s,e,n);return l===null?null:l?"true":void 0}return e.values.has(s)?void 0:null}function Vi(t,e){let n={};for(let s of fe(t).list){if(s.expr===void 0||!Ni.test(s.name))continue;let r=le(s.expr,e);if(r!=null){if(Ti.has(s.name)){r!=="false"&&(n[s.name]="");continue}Ys(s.name,r)&&(n[s.name]=r)}}return n}function Bi(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 ue(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=pe(t,s);if(!i||i==="too-big"){s++;continue}let a=i.tag.toLowerCase();if(/^[A-Z]/.test(i.tag))n+=ue(i.body,e+1);else if(Ii.has(a)){let l=en(i.attrs),c=l&&!l.dynamic&&l.classes.length?` class="${Us(l.classes.join(" "))}"`:"",u=ue(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+=Us(t.slice(s,o)),s=o}return n}function Fi(t){let e=en(t.attrs);return!e||e.dynamic||e.classes.length===0?null:{tag:t.tag.toLowerCase(),classes:e.classes,attrs:qs(t.attrs)}}function Qs(t,e){let n=[],s=e-1;for(;n.length<3&&s>=0;){let r=qe(t,s);if(!r||r==="too-big"||/^[A-Z]/.test(r.tag))break;let o=Fi(r);if(!o)break;n.push(o),s=r.openStart-1}return n.reverse()}var zi=8;function Ui(t){let e=t.trim(),n=it(e,0);return n&&n.end===e.length?n.value:e==="true"?!0:e==="false"?!1:/^-?\d+(?:\.\d+)?$/.test(e)?e:null}function Wi(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=it(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 Js(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=Ui(a[3]);c!==null&&o.set(l,c)}return{values:o,end:s}}function Gi(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=Wi(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 ce(l.values,c)}return ce()}function Hi(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 Ki(t,e,n,s){let r=Pi(t,e.openStart,e.closeEnd);if(/^[A-Z]/.test(e.tag)){let m=Bi(t.slice(e.openStart,e.openEnd),n-e.openStart);return{kind:"component",...r,component:{tag:e.tag,...m}}}let o=Gi(t,e);for(let[m,b]of Hi(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=ce(new Map(o.values),o.aliases),c=Ji(a.attrs,l);if(!c)return{kind:"dynamic",...r};let u={tag:e.tag.toLowerCase(),...c,ancestors:Qs(t,e.openStart),bodyHtml:ue(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,zi).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 Ji(t,e){let n=en(t,e);return n?.dynamic?null:{classes:n?.classes??[],attrs:{...qs(t),...Vi(t,e)}}}function nn(t,e,n,s){if(Ei.test(s))return Ws(t,e);let r=qe(t,e);return r==="too-big"||!r?Ws(t,e):Ki(t,r,e,n)}function Zi(t){let e={},n=new Set,{list:s,spread:r}=fe(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 tr(t,e){let n=Zi(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 sn(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 Xi(t,e,n,s,r){for(let o of sn(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 er(t,e,n,s,r,o){if(t.kind!=="component"||!t.component||r.length===0)return t;let i=Xi(s,e,t.component.tag,r,o);if(!i)return t;let a=qe(e,n),l=t.component.tag;if(!a||a==="too-big"||a.tag!==l&&a.tag!==i.component)return t;let c=tr(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:Qs(e,a.openStart),bodyHtml:ue(a.body)}}:t}function de(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 sn(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=pe(e,m);if(!k||k==="too-big"){u=m+f.length;continue}let w=tr(c,k.attrs);(w.selects.length||w.unknown.length)&&a.push({offset:m,component:l,selects:w.selects,unknown:w.unknown}),u=Math.max(k.closeEnd,m+f.length)}}return a}function Yi(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 qi(t){let e=/\bclassName\s*=\s*/.exec(t);if(!e)return null;let n=e.index+e[0].length,s=it(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 Qi(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=it(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=it(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 ta(t,e,n,s){let r=[];for(let o of sn(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 ea(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:Ks(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 na(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 nr(t,e,n){let s=[];for(let r of t){let o=ta(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)),w=Yi(r.source,f),$=0;for(;$<k.length;){if(k[$]!=="<"||k[$+1]==="/"||k[$+1]==="!"){$++;continue}let g=pe(k,$);if(!g||g==="too-big"){$++;continue}if($=g.openEnd,/^[A-Z]/.test(g.tag))continue;let p=qi(g.attrs);if(!p)continue;let d=ea(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*\\(`)),I=p.indexOf("(",C),j=I<0?null:Qi(p,I);if(j){y=3,v=na(x.recipe,j,w,d.staticClasses,d.classNameProp);for(let A of d.prefixes)v.axes.push({prop:A.prop,values:[],prefix:A.prefix,defaultValue:w[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:w[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 sa=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,ra=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,oa=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),ia=new Set(["icon","glyph","svg"]),aa=new Set(["label","text","title","caption"]),la=t=>t.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(e=>e.toLowerCase());function rr(t){let e=t.flatMap(la);return e.some(n=>ia.has(n))?"icon":e.some(n=>aa.has(n))?"label":null}function ca(t){let e=t.replace(/\{\s*\/\*[\s\S]*?\*\/\s*\}/g," "),n=[];for(let s of e.matchAll(sa)){let r=s[1];if(!oa.has(r.toLowerCase())||r!==r.toLowerCase())continue;let o=[...s[2].matchAll(ra)].map(a=>a[1]??a[2]),i=rr(o);i&&n.push({index:s.index??0,role:i,tag:r.toLowerCase(),classes:o})}return n}function ua(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 pa=["text","icon-start","icon-end","icon"],sr={text:"Text","icon-start":"Icon left","icon-end":"Icon right",icon:"Icon"};function fa(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 or(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(ca),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=>rr([k])==="label"))),c=null,u=null;for(let b of i){let k=fa(b,o),w=o.reduce(($,g)=>{let p=Math.abs(g.index-b.index);return!$||p<$.dist?{hit:g,dist:p}:$},null);k==="start"&&w&&!c&&(c={icon:b,label:w.hit}),k==="end"&&w&&!u&&(u={icon:b,label:w.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=ua(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:sr.text,sheets:e.get("text")??[]},...pa.filter(s=>s!=="text"&&e.has(s)).map(s=>({id:s,label:sr[s],sheets:e.get(s)??[]}))]}function da(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 ga=/^@(?:-\w+-)?(?:keyframes|font-face|property)\b/i;function ht(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===`
39
- `&&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":da(m?.resolved??null,l),isAt:f,skip:(c?.skip??!1)||f&&ga.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 at(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 ma=25,ha=12,ir=700,ba=/\b(?:must(?: not)?|never|always|should(?: not|n't)?|do not|don't|avoid|prefer|forbidden|not allowed|no more than)\b/i,et=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function ya(t){let e=t.split(`
36
+ `).length>12;return{source:Ys(i)+(a?`
37
+ \u2026`:""),startLine:o}}function zi(t,e){let n=qs(t,Math.max(0,e)),s=t.split(`
38
+ `),r=Math.max(0,n-1);return{source:Ys(s.slice(r,r+12)),startLine:r+1}}function Xs(t,e){return{kind:"other",...zi(t,e)}}function fe(t,e){let n=Js.exec(t.slice(e));if(!n)return null;let s=n[1],r=n[2]??"",o=e+n[0].length;if(/\/\s*$/.test(r)||Ti.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=Js.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 Qe(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 Qs(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 tr(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 Ye=/^[A-Za-z_$][\w$]*$/;function tn(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 en(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 er(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=en(t);for(let c of["||","&&"]){let u=tn(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=er(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 nr(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=en(t);if(!n)return{classes:[],dynamic:!1};let s=nr(n);if(s){let c=_t(s.condition,e);return c===null?{classes:[],dynamic:!0}:Rt(c?s.yes:s.no,e)}let r=tn(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(Ye.test(k)){let w=e.values.get(k);if(typeof w!="string")return{classes:[],dynamic:!0};e.strings.add(k);let $=/[\w-]*$/.exec(u)?.[0];$&&e.prefixes.set(k,$),u+=w}else{let w=Rt(k,e);if(w.dynamic)return{classes:[],dynamic:!0};u+=w.classes.join(" ")}f=b+1}return{classes:At(u),dynamic:!1}}if(Ye.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:[Qs(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&&Vi.has(l[1])){let c=[];for(let u of tr(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 nn(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 sr(t,e){return/[<>]/.test(e)?!1:t==="href"||t==="src"||t==="action"?/^(?:https?:|mailto:|\/|#)/i.test(e):!0}function Ui(t){return t==="class"||t==="className"?!1:!Bi.test(t)&&!/^on/i.test(t)}function rr(t){let e={};for(let n of de(t).list){if(!Ui(n.name)||n.expr!==void 0)continue;let s=n.value??"";sr(n.name,s)&&(e[n.name]=s)}return e}var Wi=/^(?:data-[\w-]+|aria-[\w-]+|disabled|hidden)$/,Gi=new Set(["disabled","hidden"]);function ce(t,e,n=0){if(n>4)return null;let s=en(t),r=at(s,0);if(r&&r.end===s.length)return r.value;let o=nr(s);if(o){let l=_t(o.condition,e);return l===null?null:ce(l?o.yes:o.no,e,n+1)}let i=tn(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(!Ye.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=er(s,e,n);return l===null?null:l?"true":void 0}return e.values.has(s)?void 0:null}function Hi(t,e){let n={};for(let s of de(t).list){if(s.expr===void 0||!Wi.test(s.name))continue;let r=ce(s.expr,e);if(r!=null){if(Gi.has(s.name)){r!=="false"&&(n[s.name]="");continue}sr(s.name,r)&&(n[s.name]=r)}}return n}function Ki(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(Ni.has(a)){let l=nn(i.attrs),c=l&&!l.dynamic&&l.classes.length?` class="${Zs(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+=Zs(t.slice(s,o)),s=o}return n}function Ji(t){let e=nn(t.attrs);return!e||e.dynamic||e.classes.length===0?null:{tag:t.tag.toLowerCase(),classes:e.classes,attrs:rr(t.attrs)}}function or(t,e){let n=[],s=e-1;for(;n.length<3&&s>=0;){let r=Qe(t,s);if(!r||r==="too-big"||/^[A-Z]/.test(r.tag))break;let o=Ji(r);if(!o)break;n.push(o),s=r.openStart-1}return n.reverse()}var Zi=8;function Xi(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 qi(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 tr(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=Xi(a[3]);c!==null&&o.set(l,c)}return{values:o,end:s}}function Yi(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=qi(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 Qi(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 ta(t,e,n,s){let r=Fi(t,e.openStart,e.closeEnd);if(/^[A-Z]/.test(e.tag)){let m=Ki(t.slice(e.openStart,e.openEnd),n-e.openStart);return{kind:"component",...r,component:{tag:e.tag,...m}}}let o=Yi(t,e);for(let[m,b]of Qi(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=ea(a.attrs,l);if(!c)return{kind:"dynamic",...r};let u={tag:e.tag.toLowerCase(),...c,ancestors:or(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,Zi).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 ea(t,e){let n=nn(t,e);return n?.dynamic?null:{classes:n?.classes??[],attrs:{...rr(t),...Hi(t,e)}}}function sn(t,e,n,s){if(Di.test(s))return Xs(t,e);let r=Qe(t,e);return r==="too-big"||!r?Xs(t,e):ta(t,r,e,n)}function na(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 ir(t,e){let n=na(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 rn(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 sa(t,e,n,s,r){for(let o of rn(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 ar(t,e,n,s,r,o){if(t.kind!=="component"||!t.component||r.length===0)return t;let i=sa(s,e,t.component.tag,r,o);if(!i)return t;let a=Qe(e,n),l=t.component.tag;if(!a||a==="too-big"||a.tag!==l&&a.tag!==i.component)return t;let c=ir(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:or(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 rn(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 w=ir(c,k.attrs);(w.selects.length||w.unknown.length)&&a.push({offset:m,component:l,selects:w.selects,unknown:w.unknown}),u=Math.max(k.closeEnd,m+f.length)}}return a}function ra(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 oa(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 ia(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 aa(t,e,n,s){let r=[];for(let o of rn(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 la(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:Qs(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 ca(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 lr(t,e,n){let s=[];for(let r of t){let o=aa(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)),w=ra(r.source,f),$=0;for(;$<k.length;){if(k[$]!=="<"||k[$+1]==="/"||k[$+1]==="!"){$++;continue}let g=fe(k,$);if(!g||g==="too-big"){$++;continue}if($=g.openEnd,/^[A-Z]/.test(g.tag))continue;let p=oa(g.attrs);if(!p)continue;let d=la(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*\\(`)),I=p.indexOf("(",C),j=I<0?null:ia(p,I);if(j){y=3,v=ca(x.recipe,j,w,d.staticClasses,d.classNameProp);for(let A of d.prefixes)v.axes.push({prop:A.prop,values:[],prefix:A.prefix,defaultValue:w[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:w[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 ua=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,pa=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,fa=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),da=new Set(["icon","glyph","svg"]),ga=new Set(["label","text","title","caption"]),ma=t=>t.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(e=>e.toLowerCase());function ur(t){let e=t.flatMap(ma);return e.some(n=>da.has(n))?"icon":e.some(n=>ga.has(n))?"label":null}function ha(t){let e=t.replace(/\{\s*\/\*[\s\S]*?\*\/\s*\}/g," "),n=[];for(let s of e.matchAll(ua)){let r=s[1];if(!fa.has(r.toLowerCase())||r!==r.toLowerCase())continue;let o=[...s[2].matchAll(pa)].map(a=>a[1]??a[2]),i=ur(o);i&&n.push({index:s.index??0,role:i,tag:r.toLowerCase(),classes:o})}return n}function ba(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 U(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 ya=["text","icon-start","icon-end","icon"],cr={text:"Text","icon-start":"Icon left","icon-end":"Icon right",icon:"Icon"};function xa(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 pr(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(ha),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=>ur([k])==="label"))),c=null,u=null;for(let b of i){let k=xa(b,o),w=o.reduce(($,g)=>{let p=Math.abs(g.index-b.index);return!$||p<$.dist?{hit:g,dist:p}:$},null);k==="start"&&w&&!c&&(c={icon:b,label:w.hit}),k==="end"&&w&&!u&&(u={icon:b,label:w.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=ba(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:cr.text,sheets:e.get("text")??[]},...ya.filter(s=>s!=="text"&&e.has(s)).map(s=>({id:s,label:cr[s],sheets:e.get(s)??[]}))]}function ka(t,e){if(!t)return e;let n=U(t);return U(e).flatMap(s=>n.map(r=>s.includes("&")?s.replaceAll("&",r):`${r} ${s}`)).join(", ")}var wa=/^@(?:-\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===`
39
+ `&&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":ka(m?.resolved??null,l),isAt:f,skip:(c?.skip??!1)||f&&wa.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 va=25,$a=12,fr=700,Ca=/\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 Sa(t){let e=t.split(`
40
40
  `),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(`
41
- `).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 xa(t,e){let n=t.map(et).join("|"),s=t.map(r=>et(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 ka(t,e){let n=e.map(et).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(gt(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-])${et(c)}(?![\\w-])`:`(?:\\.|["'\`])${et(c)}(?![\\w-])`))}if(!r.title.includes(" + ")){let l=r.title.toLowerCase().split(/\s+/).map(et).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${et(r.axis)}\\s*[=:]\\s*\\{?\\s*["'\`]${et(r.title.toLowerCase())}["'\`]`,"i")),i.heading=r.title.toLowerCase()}s.set(r.title,i)}return[...s.values()]}function wa(t,e){return t.toLowerCase().replace(new RegExp(`\\b(?:${e.map(et).join("|")})s?\\b`,"g")," ").replace(/[^a-z0-9]+/g," ").trim()}function va(t){return t.length>ir?`${t.slice(0,ir).trimEnd()}\u2026`:t}function ar(t,e,n,s){let r=xa(n.classKeywords,n.prose),o=ka(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 ya(f)){if(!r.test(b.text)&&!b.headings.some($=>r.test($)))continue;let k=b.headings.length?wa(b.headings[b.headings.length-1],n.classKeywords):"",w=o.filter($=>$.tests.some(g=>g.test(b.text))||k!==""&&$.heading===k).map($=>$.title);for(let $ of w)i.add($);m.push({path:u.path,line:b.start,endLine:b.end,headings:b.headings,text:va(b.text),rule:ba.test(b.text),styles:w})}m.length!==0&&a.push({path:u.path,kind:u.kind,passages:m.slice(0,ha),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 lr=new Set(["tone","size","variant","kind","type","style","theme","color","colour","appearance","intent","emphasis","shape","level"]),$a=new Set(["is","has","js","c","component","comp","el","ui","the","root"]),Ca={xs:["extra","small"],sm:["small"],md:["medium"],lg:["large"],xl:["extra","large"],xxl:["extra","extra","large"]},Sa=new Set(["cta","ui","ux","faq","cms","api","url","ios"]);function on(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 Ra(t){return new Set(t.flatMap(e=>[e,`${e}s`]))}function rn(t){let e=t.map(n=>Sa.has(n)?n.toUpperCase():n).join(" ");return e.charAt(0).toUpperCase()+e.slice(1)}function jt(t,e){let n=on(t).filter(r=>!e.has(r)&&!$a.has(r)),s=null;return n.length>1&&lr.has(n[0])&&(s=n[0],n=n.slice(1)),{words:n.flatMap(r=>Ca[r]??[r]),axis:s}}var cr=/\.((?:\\.|[\w-])+)/g,Aa=/\[\s*([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*))\s*\]/g;function _a(t,e){let n=t.split("/"),s=(n.pop()??"").replace(/(\.module)?\.[a-z]+$/i,""),r=n.pop()??"";return on(s).some(a=>e.has(a))||on(r).some(a=>e.has(a))?jt(s,e).words:[]}function Ea(t,e){let n=[];for(let s of t.split(/[\s>+~]+/).filter(Boolean)){let r=[...s.matchAll(cr)].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=Ra(e),s=gt(t.selector),r=t.selector.slice(0,s),o=t.selector.slice(s),i=[...o.matchAll(cr)].map(u=>jt(u[1],n));for(let u of o.matchAll(Aa)){let f=u[1].replace(/^data-/,"").toLowerCase();if(!lr.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=>rn(u.words)).join(" + "),axis:a.length===1?a[0].axis:null};let l=Ea(r,n);if(l.length>0)return{title:`In ${l.join(" ")}`,axis:null};let c=_a(t.path,n);if(c.length>0)return{title:rn(c),axis:null};if(t.base){let u=ja(t.path,n);return u.length>0?{title:`${rn(u)} Base`,axis:null}:{title:"Base",axis:null}}return{title:"Unnamed",axis:null}}function ja(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 Ia=60;function Ut(t,e,n){let s=X(t);if(!s)return null;let r=s.length-1,o=s[r].simples;if(_s(o)||He(o,e))return null;if(re(o,e))return{compounds:s,at:r};for(let i=r-1;i>=0;i--){let a=s[i].simples;if(re(a,e)&&!He(a,e))return{compounds:s,at:i}}return!n||r===0&&Es(o)?null:{compounds:s,at:0}}function ur(t,e,n){return Ft([...t,{combinator:t.length?e.combinator:null,simples:n}])}function pr(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 Ma(t,e){return t.length>=e.length?!1:t.every(n=>e.some(s=>pr(n,s)))}function La(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 Pa(t,e){for(let n of e.classes)t.classes.includes(n)||t.classes.push(n);Object.assign(t.attrs,e.attrs)}function fr(t){let e=new Set(t.map(n=>zt(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 Da(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)===se.length);return r.length===1?r[0]:null}function an(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 dr(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=Ut(p,n,s);if(!d)continue;let{compounds:y,at:v}=d,x=y[v],C=oe(x.simples);if(C.identity.length===0)continue;let I=y.slice(0,v),j=ur(I,x,C.identity),A=dt(C.states);if(v<y.length-1){i.push({hostKey:j,part:{selector:Ft(y),path:t,line:g.line,state:A}});continue}if(Is(C.identity,g.declarations))continue;let R=o.get(j);if(!R){if(o.size>=Ia)continue;R={key:j,prefix:I,identity:C.identity,line:g.line,states:[],modifiers:[],contexts:[],parts:[],movedInto:null},o.set(j,R)}let M=R.states.find(N=>N.state===A&&N.context===g.context);M||(M={state:A,context:g.context,line:g.line,declarations:[]},C.states.length&&(M.marker={classes:[],attrs:{}}),R.states.push(M)),M.marker&&Pa(M.marker,C.marker),M.declarations.push(...g.declarations)}for(let[g,p]of o){let d=p.states.flatMap(x=>x.declarations),y=p.states.every(x=>ae(x.declarations)),v=d.every(x=>zt(x.property)==="hint");(y||v)&&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=>Da(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],I={combinator:x.prefix.length?" ":null,simples:C},j=ur(x.prefix,I,C);for(let A of x.states){let R=A.state.split(" + ").filter(M=>M!==d);if(A.state=dt(R),R.length===0)delete A.marker;else if(A.marker){A.marker.classes=A.marker.classes.filter(M=>!y.classes.includes(M));for(let M of Object.keys(y.attrs))delete A.marker.attrs[M]}}o.delete(x.key),o.set(j,{...x,key:j,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=>La(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 w=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 w){let p=b.filter(y=>y!==g&&y!==u&&y.prefix.length===0&&Ma(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=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 $=g=>{let p=g===u,d=ie(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:an(g.states),modifiers:g.modifiers.length?g.modifiers.map(y=>{let v=y.identity.filter(x=>!g.identity.some(C=>pr(C,x)));return{title:It({selector:v.map(x=>x.raw).join(""),path:t,base:!1},n.classKeywords).title,selector:y.key,path:t,line:y.line,element:ie(y.key,f),usage:{status:"unknown",files:[],fileCount:0},states:an(y.states)}}):void 0,contexts:g.contexts.length?g.contexts.map(y=>{let v=fr(y.states.flatMap(x=>x.declarations));return{selector:y.key,path:t,line:y.line,role:v,element:v==="override"?ie(y.key,f):null,states:an(y.states)}}):void 0,parts:g.parts.length?g.parts:void 0}};return[...o.values()].map($)}function gr(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=fr(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 Oa={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 mr(t){let e=t.lastIndexOf("-");return e<=0?null:Oa[t.slice(0,e)]?.[t.slice(e+1)]??null}var E=(t,e)=>({property:t,value:e});function fn(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 pn(t){let e=fn(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 Na(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 hr(t,e){return{full:"100%",screen:e==="w"?"100vw":"100vh",auto:"auto",fit:"fit-content",min:"min-content",max:"max-content"}[t]??Na(t)??fn(t)??pn(t)}var Ta={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"}},Va={thin:"100",extralight:"200",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"},Ba={none:"1",tight:"1.25",snug:"1.375",normal:"1.5",relaxed:"1.625",loose:"2"},Fa={none:"0",sm:"0.125rem","":"0.25rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem","3xl":"1.5rem",full:"9999px"},za={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"},Ua={"":"3px",0:"0px",1:"1px",2:"2px",4:"4px",8:"8px"};function ln(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=mr(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 Wa(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 cn(){return E("box-shadow","0 0 0 var(--gs-ring-w, 3px) var(--gs-ring-c, currentColor)")}var Ga={flex:"flex","inline-flex":"inline-flex",block:"block","inline-block":"inline-block",inline:"inline",grid:"grid","inline-grid":"inline-grid",hidden:"none",contents:"contents"},un={start:"flex-start",end:"flex-end",center:"center",baseline:"baseline",stretch:"stretch",between:"space-between",around:"space-around",evenly:"space-evenly"};function br(t){let e=t.startsWith("-"),n=e?t.slice(1):t,{body:s,opacity:r}=Wa(n),o=Ga[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",un[a[1]])];let l=/^justify-(start|end|center|between|around|evenly)$/.exec(s);if(l&&!e)return[E("justify-content",un[l[1]])];let c=/^self-(start|end|center|stretch|auto)$/.exec(s);if(c&&!e)return[E("align-self",c[1]==="auto"?"auto":un[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=Ta[s.replace(/^text-/,"")];if(s.startsWith("text-")&&m&&!r&&!e)return[E("font-size",m.size),E("line-height",m.leading)];let b=Va[s.replace(/^font-/,"")];if(s.startsWith("font-")&&b&&!r)return[E("font-weight",b)];if(s.startsWith("leading-")&&!r){let R=s.slice(8),N=Ba[R]??pn(R);if(N)return[E("line-height",N)]}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 w=/^opacity-(\d+)$/.exec(s);if(w&&!e)return[E("opacity",String(Number(w[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 $=/^duration-(\d+)$/.exec(s);if($)return[E("transition-duration",`${$[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),M=za[R];if(M)return[E("box-shadow",M)]}if(s==="ring"||/^ring(?:-(?:0|1|2|4|8))?$/.test(s)){let R=s==="ring"?"":s.slice(5),M=Ua[R];if(M)return[E("--gs-ring-w",M),cn()]}if(s.startsWith("ring-")&&r===null){let R=ln(s.slice(5),null);if(R)return[E("--gs-ring-c",R),cn()]}if(s.startsWith("ring-")&&r){let R=ln(s.slice(5),r);if(R)return[E("--gs-ring-c",R),cn()]}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),M=R?R[2]??"":d,N=Fa[M];if(!N)return null;if(!R)return[E("border-radius",N)];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(Jt=>E(Jt,N)):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],I=x?.[2];if(C&&I&&!r){let R=C==="w"||C==="min-w"||C==="max-w"?hr(I,"w"):C==="h"||C==="min-h"||C==="max-h"?hr(I,"h"):pn(I);if(!R)return null;let M=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"]}[C];return G?G.map(Z=>E(Z,M)):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,M]of Object.entries(j))if(s===R||s.startsWith(`${R}-`)){let N=s===R?"":s.slice(R.length+1);if(!N||/^(?:gradient|clip|ellipsis|wrap|nowrap|balance|pretty|opacity)/.test(N))return null;if(R==="text"&&!e){let Z=fn(N);if(Z)return[E("font-size",Z)]}let G=ln(N,r);return!G||e?null:[E(M,G)]}let A=/^\[([a-z-]+):(.+)\]$/i.exec(s);if(A&&!e&&!r){let R=A[1].toLowerCase(),M=A[2].replace(/_/g," ").trim();if(/^[a-z][\w-]*$/.test(R)&&M&&!/[<>]/.test(M))return[E(R,M)]}return null}var Ha=48,Ka={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",disabled:"disabled"},Ja=new Set(["cn","clsx","classNames","classnames","cx","twMerge"]);function lt(t,e){let n=1;for(let s=0;s<e&&s<t.length;s++)t[s]===`
42
- `&&n++;return n}function Za(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 ge(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"?`
43
- `: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 mn(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=ge(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 Xa(t,e){let n=0;for(let s=e;s<t.length;s++){let r=t[s];if(r==='"'||r==="'"||r==="`"){let o=ge(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 yr(t){if(t.t==="str")return t.v;if(t.t==="arr"){let e=[];for(let n of t.items){let s=yr(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 Ya(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=yr(r.val);i&&s.push(i),n=r.end;continue}n=Xa(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=ge(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=ge(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=mn(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(Ja.has(o)){let a=Ya(t,i);return a?{val:{t:"str",v:a.v,at:s},end:a.end}:null}return{val:{t:"other",at:s},end:mn(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 me(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 xr(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 dn={sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"};function qa(t,e,n,s){let r=Ka[t];if(r)return e.includes(r)||e.push(r),!0;if(t==="dark")return s.on=!0,!0;if(dn[t])return n.min.push(dn[t]),!0;let o=/^max-(sm|md|lg|xl|2xl)$/.exec(t);if(o)return n.below.push(dn[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 Qa(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 kr(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||!qa(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:dt(a),context:Qa(l,c.on),utility:i,important:n,stem:u}}function wr(t){let e=br(t.utility);return e?e.map(n=>({property:n.property,value:t.important?`${n.value} !important`:n.value,via:t.token})):[]}function tl(t){return t.some(e=>zt(e.property)!=="hint")}function he(t){let e=[];for(let n of t.matchAll(/@apply\s+([^;{}]+)/g))for(let s of xr(n[1])){let r=kr(s);if(!r)continue;let o=wr(r).filter(i=>tt(i.property,i.value));o.length!==0&&e.push({state:r.state,context:r.context,declarations:o})}return e}function vr(t){return t==="default"?"":t.split(" + ").map(e=>e==="hover"?":hover":e==="focus"?":focus":e==="active"?":active":e==="disabled"?":disabled":"").join("")}function yn(t,e,n){let s=e.map(f=>`${f.property}:${f.value}`).join(";");if(!s)return[];let r=Ke(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 el(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 nl(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 sl(t,e,n,s,r){let o=Q(t,e),i={slots:[],defaults:{}};if(!o)return i;let a=me(o.val)??"",l=W(t,o.end);if(t[l]!==",")return a.trim()?{slots:[gn(a,lt(t,e),r)],defaults:{}}:i;let c=Q(t,l+1);if(!c||c.val.t!=="obj")return a.trim()?{slots:[gn(a,lt(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(gn(a,lt(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 w=me(k.value);if(!w||!w.trim()||k.key==="false")continue;m.set(`${b.key}\0${k.key}`,w);let $=k.key==="true"?`.${b.key}`:`.${b.key}-${k.key}`,g=It({selector:$,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} ${w}`.trim(),line:lt(t,k.at),group:r,prop:b.key,value:k.key})}}return f.push(...rl(c.val,a,m,n,s,t,r)),{slots:f,defaults:nl(c.val)}}function $r(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=$r(n);if(!s||s.length!==1)return null;e.push(s[0])}return e.length?e:null}return null}function rl(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 w of c.entries){if(w.key==="class"||w.key==="className"){f=me(w.value)??"",m=w.at,w.value.t!=="str"&&w.value.t!=="arr"&&f===""&&(b=!0);continue}let $=$r(w.value);if(!$){b=!0;break}u.push({axis:w.key,values:$})}if(b)continue;let k=[[]];for(let w of u){let $=[];for(let g of k){for(let p of w.values)if($.push([...g,{axis:w.axis,value:p}]),$.length>=8)break;if($.length>=8)break}k=$}for(let w of k){if(w.length<2&&!f.trim())continue;let $=[e],g=[];for(let y of w){let v=n.get(`${y.axis}\0${y.value}`);v&&$.push(v),g.push(y.value==="true"?y.axis:y.value)}f.trim()&&$.push(f);let p=$.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:lt(o,m),group:i,when:w.map(y=>({prop:y.axis,value:y.value}))})}}return l}function gn(t,e,n){return{title:"Base",axis:null,base:!0,classes:t,line:e,group:n}}function Cr(t,e){return e.elements.includes(t.toLowerCase())?!0:e.identifier.test(t)}function ol(t){let e=t.match(/\bclassName\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*"([^"]*)"\s*\}|\{\s*'([^']*)'\s*\})/);return e?.[1]??e?.[2]??e?.[3]??e?.[4]??null}var il=new Set(["opacity","z-index","font-weight","line-height","flex","flex-grow","flex-shrink","order","zoom"]);function al(t){return t.replace(/^[A-Z]/,e=>`-${e.toLowerCase()}`).replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function ll(t,e){return e.t==="str"?e.v:e.t==="num"?il.has(t)?String(e.v):`${e.v}px`:null}function be(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(...be(o.value,c));continue}let i=al(o.key),a=ll(i,o.value);!a||!tt(i,a)||n.push({property:i,value:a,via:"style"})}return[...n.length?[{state:e,context:"",declarations:n}]:[],...s]}function hn(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"?`
44
- `: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 cl(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)),dt(n)}function bn(t){let e=[];for(let n of ht(`.__gs {
41
+ `).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 Ra(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 Aa(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 _a(t,e){return t.toLowerCase().replace(new RegExp(`\\b(?:${e.map(nt).join("|")})s?\\b`,"g")," ").replace(/[^a-z0-9]+/g," ").trim()}function Ea(t){return t.length>fr?`${t.slice(0,fr).trimEnd()}\u2026`:t}function dr(t,e,n,s){let r=Ra(n.classKeywords,n.prose),o=Aa(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 Sa(f)){if(!r.test(b.text)&&!b.headings.some($=>r.test($)))continue;let k=b.headings.length?_a(b.headings[b.headings.length-1],n.classKeywords):"",w=o.filter($=>$.tests.some(g=>g.test(b.text))||k!==""&&$.heading===k).map($=>$.title);for(let $ of w)i.add($);m.push({path:u.path,line:b.start,endLine:b.end,headings:b.headings,text:Ea(b.text),rule:Ca.test(b.text),styles:w})}m.length!==0&&a.push({path:u.path,kind:u.kind,passages:m.slice(0,$a),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,va).map(({rules:u,...f})=>f),documented:[...i].sort(),undocumented:[...c.keys()].filter(u=>!i.has(u))}}var gr=new Set(["tone","size","variant","kind","type","style","theme","color","colour","appearance","intent","emphasis","shape","level"]),ja=new Set(["is","has","js","c","component","comp","el","ui","the","root"]),Ia={xs:["extra","small"],sm:["small"],md:["medium"],lg:["large"],xl:["extra","large"],xxl:["extra","extra","large"]},Ma=new Set(["cta","ui","ux","faq","cms","api","url","ios"]);function an(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 La(t){return new Set(t.flatMap(e=>[e,`${e}s`]))}function on(t){let e=t.map(n=>Ma.has(n)?n.toUpperCase():n).join(" ");return e.charAt(0).toUpperCase()+e.slice(1)}function jt(t,e){let n=an(t).filter(r=>!e.has(r)&&!ja.has(r)),s=null;return n.length>1&&gr.has(n[0])&&(s=n[0],n=n.slice(1)),{words:n.flatMap(r=>Ia[r]??[r]),axis:s}}var mr=/\.((?:\\.|[\w-])+)/g,Pa=/\[\s*([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*))\s*\]/g;function Oa(t,e){let n=t.split("/"),s=(n.pop()??"").replace(/(\.module)?\.[a-z]+$/i,""),r=n.pop()??"";return an(s).some(a=>e.has(a))||an(r).some(a=>e.has(a))?jt(s,e).words:[]}function Da(t,e){let n=[];for(let s of t.split(/[\s>+~]+/).filter(Boolean)){let r=[...s.matchAll(mr)].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=La(e),s=mt(t.selector),r=t.selector.slice(0,s),o=t.selector.slice(s),i=[...o.matchAll(mr)].map(u=>jt(u[1],n));for(let u of o.matchAll(Pa)){let f=u[1].replace(/^data-/,"").toLowerCase();if(!gr.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=>on(u.words)).join(" + "),axis:a.length===1?a[0].axis:null};let l=Da(r,n);if(l.length>0)return{title:`In ${l.join(" ")}`,axis:null};let c=Oa(t.path,n);if(c.length>0)return{title:on(c),axis:null};if(t.base){let u=Ta(t.path,n);return u.length>0?{title:`${on(u)} Base`,axis:null}:{title:"Base",axis:null}}return{title:"Unnamed",axis:null}}function Ta(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 Na=60;function Ut(t,e,n){let s=X(t);if(!s)return null;let r=s.length-1,o=s[r].simples;if(Ps(o)||Ke(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)&&!Ke(a,e))return{compounds:s,at:i}}return!n||r===0&&Os(o)?null:{compounds:s,at:0}}function hr(t,e,n){return Ft([...t,{combinator:t.length?e.combinator:null,simples:n}])}function br(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 Va(t,e){return t.length>=e.length?!1:t.every(n=>e.some(s=>br(n,s)))}function Ba(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 Fa(t,e){for(let n of e.classes)t.classes.includes(n)||t.classes.push(n);Object.assign(t.attrs,e.attrs)}function yr(t){let e=new Set(t.map(n=>zt(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 za(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 ln(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 xr(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 U(g.selector)){let d=Ut(p,n,s);if(!d)continue;let{compounds:y,at:v}=d,x=y[v],C=ie(x.simples);if(C.identity.length===0)continue;let I=y.slice(0,v),j=hr(I,x,C.identity),A=gt(C.states);if(v<y.length-1){i.push({hostKey:j,part:{selector:Ft(y),path:t,line:g.line,state:A}});continue}if(Ts(C.identity,g.declarations))continue;let R=o.get(j);if(!R){if(o.size>=Na)continue;R={key:j,prefix:I,identity:C.identity,line:g.line,states:[],modifiers:[],contexts:[],parts:[],movedInto:null},o.set(j,R)}let M=R.states.find(T=>T.state===A&&T.context===g.context);M||(M={state:A,context:g.context,line:g.line,declarations:[]},C.states.length&&(M.marker={classes:[],attrs:{}}),R.states.push(M)),M.marker&&Fa(M.marker,C.marker),M.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)),v=d.every(x=>zt(x.property)==="hint");(y||v)&&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=>za(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],I={combinator:x.prefix.length?" ":null,simples:C},j=hr(x.prefix,I,C);for(let A of x.states){let R=A.state.split(" + ").filter(M=>M!==d);if(A.state=gt(R),R.length===0)delete A.marker;else if(A.marker){A.marker.classes=A.marker.classes.filter(M=>!y.classes.includes(M));for(let M of Object.keys(y.attrs))delete A.marker.attrs[M]}}o.delete(x.key),o.set(j,{...x,key:j,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=>Ba(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 w=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 w){let p=b.filter(y=>y!==g&&y!==u&&y.prefix.length===0&&Va(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=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 $=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:ln(g.states),modifiers:g.modifiers.length?g.modifiers.map(y=>{let v=y.identity.filter(x=>!g.identity.some(C=>br(C,x)));return{title:It({selector:v.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:ln(y.states)}}):void 0,contexts:g.contexts.length?g.contexts.map(y=>{let v=yr(y.states.flatMap(x=>x.declarations));return{selector:y.key,path:t,line:y.line,role:v,element:v==="override"?ae(y.key,f):null,states:ln(y.states)}}):void 0,parts:g.parts.length?g.parts:void 0}};return[...o.values()].map($)}function kr(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=yr(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 Ua={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 wr(t){let e=t.lastIndexOf("-");return e<=0?null:Ua[t.slice(0,e)]?.[t.slice(e+1)]??null}var E=(t,e)=>({property:t,value:e});function dn(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 fn(t){let e=dn(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 Wa(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 vr(t,e){return{full:"100%",screen:e==="w"?"100vw":"100vh",auto:"auto",fit:"fit-content",min:"min-content",max:"max-content"}[t]??Wa(t)??dn(t)??fn(t)}var Ga={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"}},Ha={thin:"100",extralight:"200",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"},Ka={none:"1",tight:"1.25",snug:"1.375",normal:"1.5",relaxed:"1.625",loose:"2"},Ja={none:"0",sm:"0.125rem","":"0.25rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem","3xl":"1.5rem",full:"9999px"},Za={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"},Xa={"":"3px",0:"0px",1:"1px",2:"2px",4:"4px",8:"8px"};function cn(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=wr(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 qa(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 un(){return E("box-shadow","0 0 0 var(--gs-ring-w, 3px) var(--gs-ring-c, currentColor)")}var Ya={flex:"flex","inline-flex":"inline-flex",block:"block","inline-block":"inline-block",inline:"inline",grid:"grid","inline-grid":"inline-grid",hidden:"none",contents:"contents"},pn={start:"flex-start",end:"flex-end",center:"center",baseline:"baseline",stretch:"stretch",between:"space-between",around:"space-around",evenly:"space-evenly"};function $r(t){let e=t.startsWith("-"),n=e?t.slice(1):t,{body:s,opacity:r}=qa(n),o=Ya[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",pn[a[1]])];let l=/^justify-(start|end|center|between|around|evenly)$/.exec(s);if(l&&!e)return[E("justify-content",pn[l[1]])];let c=/^self-(start|end|center|stretch|auto)$/.exec(s);if(c&&!e)return[E("align-self",c[1]==="auto"?"auto":pn[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=Ga[s.replace(/^text-/,"")];if(s.startsWith("text-")&&m&&!r&&!e)return[E("font-size",m.size),E("line-height",m.leading)];let b=Ha[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=Ka[R]??fn(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 w=/^opacity-(\d+)$/.exec(s);if(w&&!e)return[E("opacity",String(Number(w[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 $=/^duration-(\d+)$/.exec(s);if($)return[E("transition-duration",`${$[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),M=Za[R];if(M)return[E("box-shadow",M)]}if(s==="ring"||/^ring(?:-(?:0|1|2|4|8))?$/.test(s)){let R=s==="ring"?"":s.slice(5),M=Xa[R];if(M)return[E("--gs-ring-w",M),un()]}if(s.startsWith("ring-")&&r===null){let R=cn(s.slice(5),null);if(R)return[E("--gs-ring-c",R),un()]}if(s.startsWith("ring-")&&r){let R=cn(s.slice(5),r);if(R)return[E("--gs-ring-c",R),un()]}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),M=R?R[2]??"":d,T=Ja[M];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 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],I=x?.[2];if(C&&I&&!r){let R=C==="w"||C==="min-w"||C==="max-w"?vr(I,"w"):C==="h"||C==="min-h"||C==="max-h"?vr(I,"h"):fn(I);if(!R)return null;let M=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"]}[C];return G?G.map(Z=>E(Z,M)):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,M]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=dn(T);if(Z)return[E("font-size",Z)]}let G=cn(T,r);return!G||e?null:[E(M,G)]}let A=/^\[([a-z-]+):(.+)\]$/i.exec(s);if(A&&!e&&!r){let R=A[1].toLowerCase(),M=A[2].replace(/_/g," ").trim();if(/^[a-z][\w-]*$/.test(R)&&M&&!/[<>]/.test(M))return[E(R,M)]}return null}var Qa=48,tl={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",disabled:"disabled"},el=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]===`
42
+ `&&n++;return n}function nl(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"?`
43
+ `: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 hn(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 sl(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 Cr(t){if(t.t==="str")return t.v;if(t.t==="arr"){let e=[];for(let n of t.items){let s=Cr(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 rl(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=Cr(r.val);i&&s.push(i),n=r.end;continue}n=sl(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=hn(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(el.has(o)){let a=rl(t,i);return a?{val:{t:"str",v:a.v,at:s},end:a.end}:null}return{val:{t:"other",at:s},end:hn(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 Sr(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 gn={sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"};function ol(t,e,n,s){let r=tl[t];if(r)return e.includes(r)||e.push(r),!0;if(t==="dark")return s.on=!0,!0;if(gn[t])return n.min.push(gn[t]),!0;let o=/^max-(sm|md|lg|xl|2xl)$/.exec(t);if(o)return n.below.push(gn[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 il(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 Rr(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||!ol(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:il(l,c.on),utility:i,important:n,stem:u}}function Ar(t){let e=$r(t.utility);return e?e.map(n=>({property:n.property,value:t.important?`${n.value} !important`:n.value,via:t.token})):[]}function al(t){return t.some(e=>zt(e.property)!=="hint")}function be(t){let e=[];for(let n of t.matchAll(/@apply\s+([^;{}]+)/g))for(let s of Sr(n[1])){let r=Rr(s);if(!r)continue;let o=Ar(r).filter(i=>et(i.property,i.value));o.length!==0&&e.push({state:r.state,context:r.context,declarations:o})}return e}function _r(t){return t==="default"?"":t.split(" + ").map(e=>e==="hover"?":hover":e==="focus"?":focus":e==="active"?":active":e==="disabled"?":disabled":"").join("")}function xn(t,e,n){let s=e.map(f=>`${f.property}:${f.value}`).join(";");if(!s)return[];let r=Je(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 ll(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 cl(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 ul(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:[mn(a,ct(t,e),r)],defaults:{}}:i;let c=Q(t,l+1);if(!c||c.val.t!=="obj")return a.trim()?{slots:[mn(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(mn(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 w=he(k.value);if(!w||!w.trim()||k.key==="false")continue;m.set(`${b.key}\0${k.key}`,w);let $=k.key==="true"?`.${b.key}`:`.${b.key}-${k.key}`,g=It({selector:$,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} ${w}`.trim(),line:ct(t,k.at),group:r,prop:b.key,value:k.key})}}return f.push(...pl(c.val,a,m,n,s,t,r)),{slots:f,defaults:cl(c.val)}}function Er(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=Er(n);if(!s||s.length!==1)return null;e.push(s[0])}return e.length?e:null}return null}function pl(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 w of c.entries){if(w.key==="class"||w.key==="className"){f=he(w.value)??"",m=w.at,w.value.t!=="str"&&w.value.t!=="arr"&&f===""&&(b=!0);continue}let $=Er(w.value);if(!$){b=!0;break}u.push({axis:w.key,values:$})}if(b)continue;let k=[[]];for(let w of u){let $=[];for(let g of k){for(let p of w.values)if($.push([...g,{axis:w.axis,value:p}]),$.length>=8)break;if($.length>=8)break}k=$}for(let w of k){if(w.length<2&&!f.trim())continue;let $=[e],g=[];for(let y of w){let v=n.get(`${y.axis}\0${y.value}`);v&&$.push(v),g.push(y.value==="true"?y.axis:y.value)}f.trim()&&$.push(f);let p=$.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:w.map(y=>({prop:y.axis,value:y.value}))})}}return l}function mn(t,e,n){return{title:"Base",axis:null,base:!0,classes:t,line:e,group:n}}function jr(t,e){return e.elements.includes(t.toLowerCase())?!0:e.identifier.test(t)}function fl(t){let e=t.match(/\bclassName\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*"([^"]*)"\s*\}|\{\s*'([^']*)'\s*\})/);return e?.[1]??e?.[2]??e?.[3]??e?.[4]??null}var dl=new Set(["opacity","z-index","font-weight","line-height","flex","flex-grow","flex-shrink","order","zoom"]);function gl(t){return t.replace(/^[A-Z]/,e=>`-${e.toLowerCase()}`).replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function ml(t,e){return e.t==="str"?e.v:e.t==="num"?dl.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=gl(o.key),a=ml(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 bn(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"?`
44
+ `: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 hl(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 yn(t){let e=[];for(let n of bt(`.__gs {
45
45
  ${t}
46
- }`)){let s=X(n.selector),r=s?.[s.length-1];if(!r)continue;let o=oe(r.simples),i=dt(o.states),a=at(n.ownBody).filter(l=>tt(l.property,l.value));a.length&&e.push({state:i,context:n.context,declarations:a});for(let l of he(n.ownBody))e.push({state:cl(i,l.state),context:[n.context,l.context].filter(Boolean).join(" \xB7 "),declarations:l.declarations})}return e}function ul(t){let e=t.match(/\bstyle\s*=\s*"([^"]*)"/);if(e){let i=at(e[1]).filter(a=>tt(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?be(o.val,"default"):[]}function pl(t){let e=ol(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=hn(t,i);return{classes:"",painted:a?bn(a.css):[]}}if(t[i]==="("){let a=Q(t,i+1);return{classes:"",painted:a?be(a.val,"default"):[]}}}let o=Q(t,r);return o?{classes:me(o.val)??"",painted:[]}:{classes:"",painted:[]}}function fl(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 dl(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(!Cr(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=mn(t,a,"(",")")),a=W(t,a));let l=[];if(t[a]==="`"){let c=hn(t,a);c&&(l=bn(c.css))}else if(t[a]==="("){let c=Q(t,a+1);c&&(l=be(c.val,"default"))}l.length!==0&&n.push({title:"Styled",axis:null,base:!0,classes:"",line:lt(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(!fl(i,e))continue;let a=t.indexOf("`",o.index??0),l=a<0?null:hn(t,a);if(!l)continue;let c=bn(l.css);c.length!==0&&n.push({title:"Css",axis:null,base:!0,classes:"",line:lt(t,o.index??0),painted:c})}return n}function gl(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 ml(t,e,n,s,r){let o=xr(t.classes).map(kr).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,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=wr(d).filter(v=>tt(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(!tl(f))return null;let m=l.get("default\0")?.declarations??[];if(ae(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))],w=k.length?k.map(d=>`.${d}`).join(""):n.elements[0]??"button",$=b.flatMap(d=>yn(gl(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:w,path:e,line:t.line,base:t.base,states:b},rules:$}}function Sr(t,e,n,s,r){let o=Za(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,v=a.length,x=sl(o,y,n,t,v);a.push({name:el(o,d),defaults:x.defaults}),i.push(...x.slots)}i.push(...dl(o,n));let c=/<([A-Za-z][\w.]*)\b([^>]*?)>/g;for(let p of o.matchAll(c)){let d=p[1];if(!Cr(d,n))continue;let y=p[2]??"",v=pl(y),x=[...v.painted,...ul(y)],C=v.classes.trim();if(!C&&x.length===0)continue;let I=p.index??0,j=lt(o,I);i.push({title:C?"Base":v.painted.length?"Css":"Inline",axis:null,base:!0,classes:C,line:j,painted:x,...C&&x.length===0?{site:{path:t,line:j,offset:I}}:{}})}let u=[],f=[],m=new Map,b=[],k=new Map,w=new Map,$=r;for(let p=0;p<i.length;p++){let d=i[p];if(u.length+f.length>=Ha)break;let y=(d.painted??[]).map(j=>`${j.state}|${j.context}|${j.declarations.map(A=>`${A.property}:${A.value}`).join(";")}`).join("||"),v=`${d.classes.replace(/\s+/g," ").trim()}##${y}`,x=k.get(v);if(x){d.group!==void 0&&w.set(p,x),d.site&&m.get(x)?.sites.push(d.site);continue}$+=1;let C=`__gs-recipe-${$}`,I=ml(d,t,n,s,C);if(I){if(k.set(v,C),d.group!==void 0&&w.set(p,C),d.site){let j={variant:I.variant,sites:[d.site]};m.set(C,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:[]},v=new Map;for(let x=0;x<i.length;x++){let C=i[x];if(C.group!==p)continue;let I=w.get(x);if(!I)continue;if(!C.prop&&!C.when){y.staticClasses.push(I);continue}if(C.when){y.compounds.push({when:C.when,classes:[I]});continue}let j=v.get(C.prop)??[];j.push({value:C.value,classes:[I]}),v.set(C.prop,j)}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:$,recipes:g}}function Rr(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 xn=6,hl=/"([^"\\\n]{0,400})"|'([^'\\\n]{0,400})'|`([^`\\]{0,400})`/g,bl=/\bclass(?:Name)?\s*=\s*(?:"([^"]*)"|'([^']*)')/g,yl=/\b(?:styles?|classes|css|cls|s)\.([A-Za-z_]\w*)/g,Wt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function xl(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 kl(t,e){let n=xl(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(hl))i(a[1]??a[2]??a[3]??"",a.index);for(let a of n.matchAll(bl))i(a[1]??a[2]??"",a.index);for(let a of n.matchAll(yl))o(r,a[1],a.index);return{path:t,text:n,original:e,words:s,ids:r}}function Ar(t,e){let n=1;for(let s=t.indexOf(`
46
+ }`)){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:hl(i,l.state),context:[n.context,l.context].filter(Boolean).join(" \xB7 "),declarations:l.declarations})}return e}function bl(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 yl(t){let e=fl(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=bn(t,i);return{classes:"",painted:a?yn(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 xl(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 kl(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(!jr(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=hn(t,a,"(",")")),a=W(t,a));let l=[];if(t[a]==="`"){let c=bn(t,a);c&&(l=yn(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(!xl(i,e))continue;let a=t.indexOf("`",o.index??0),l=a<0?null:bn(t,a);if(!l)continue;let c=yn(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 wl(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 vl(t,e,n,s,r){let o=Sr(t.classes).map(Rr).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,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=Ar(d).filter(v=>et(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(!al(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))],w=k.length?k.map(d=>`.${d}`).join(""):n.elements[0]??"button",$=b.flatMap(d=>xn(wl(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:w,path:e,line:t.line,base:t.base,states:b},rules:$}}function Ir(t,e,n,s,r){let o=nl(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,v=a.length,x=ul(o,y,n,t,v);a.push({name:ll(o,d),defaults:x.defaults}),i.push(...x.slots)}i.push(...kl(o,n));let c=/<([A-Za-z][\w.]*)\b([^>]*?)>/g;for(let p of o.matchAll(c)){let d=p[1];if(!jr(d,n))continue;let y=p[2]??"",v=yl(y),x=[...v.painted,...bl(y)],C=v.classes.trim();if(!C&&x.length===0)continue;let I=p.index??0,j=ct(o,I);i.push({title:C?"Base":v.painted.length?"Css":"Inline",axis:null,base:!0,classes:C,line:j,painted:x,...C&&x.length===0?{site:{path:t,line:j,offset:I}}:{}})}let u=[],f=[],m=new Map,b=[],k=new Map,w=new Map,$=r;for(let p=0;p<i.length;p++){let d=i[p];if(u.length+f.length>=Qa)break;let y=(d.painted??[]).map(j=>`${j.state}|${j.context}|${j.declarations.map(A=>`${A.property}:${A.value}`).join(";")}`).join("||"),v=`${d.classes.replace(/\s+/g," ").trim()}##${y}`,x=k.get(v);if(x){d.group!==void 0&&w.set(p,x),d.site&&m.get(x)?.sites.push(d.site);continue}$+=1;let C=`__gs-recipe-${$}`,I=vl(d,t,n,s,C);if(I){if(k.set(v,C),d.group!==void 0&&w.set(p,C),d.site){let j={variant:I.variant,sites:[d.site]};m.set(C,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:[]},v=new Map;for(let x=0;x<i.length;x++){let C=i[x];if(C.group!==p)continue;let I=w.get(x);if(!I)continue;if(!C.prop&&!C.when){y.staticClasses.push(I);continue}if(C.when){y.compounds.push({when:C.when,classes:[I]});continue}let j=v.get(C.prop)??[];j.push({value:C.value,classes:[I]}),v.set(C.prop,j)}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:$,recipes:g}}function Mr(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 kn=6,$l=/"([^"\\\n]{0,400})"|'([^'\\\n]{0,400})'|`([^`\\]{0,400})`/g,Cl=/\bclass(?:Name)?\s*=\s*(?:"([^"]*)"|'([^']*)')/g,Sl=/\b(?:styles?|classes|css|cls|s)\.([A-Za-z_]\w*)/g,Wt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Rl(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 Al(t,e){let n=Rl(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($l))i(a[1]??a[2]??a[3]??"",a.index);for(let a of n.matchAll(Cl))i(a[1]??a[2]??"",a.index);for(let a of n.matchAll(Sl))o(r,a[1],a.index);return{path:t,text:n,original:e,words:s,ids:r}}function Lr(t,e){let n=1;for(let s=t.indexOf(`
47
47
  `);s!==-1&&s<e;)n++,s=t.indexOf(`
48
- `,s+1);return n}var wl=t=>t.replace(/[-_]+(\w)/g,(e,n)=>n.toUpperCase()),vl=/\[\s*([\w-]+)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*\]/g,$l=new Set(["data-component","data-slot","role"]);function Cl(t,e){return[...t.slice(gt(t)).matchAll(vl)].map(s=>({name:s[1],value:s[2]??s[3]??s[4]??null})).filter(s=>!$l.has(s.name)&&!(s.value!==null&&e.has(s.value.toLowerCase())))}function Sl(t){return[...t.slice(gt(t)).matchAll(/\.((?:\\.|[\w-])+)/g)].map(n=>n[1].replace(/\\(.)/g,"$1"))}function kn(t,e,n,s,r=!1,o=[],i=()=>null){let a=null,l=()=>a??=e.map(g=>kl(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)=>er(nn(g.original,p,d,g.path),g.original,p,g.path,o,i),m=(g,p)=>({files:g.slice(0,xn).map(({file:d,offset:y,example:v})=>({path:d.path,line:Ar(d.text,y),...r?{example:v??f(d,y,p)}:{}})),fileCount:g.length}),b=(g,p)=>{let d=[],y=wl(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 I=C,j;if(r)for(let A of x){let R=f(v,A,p);if(R.kind!=="other"){I=A,j=R;break}}d.push({file:v,offset:I,example:j})}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),I=u(x);if(I.length===0||!C)continue;let j=x.slice(0,-1),A=new RegExp(`\\b${Wt(j)}\\s*[=:]\\s*\\{?\\s*["'\`]${Wt(C)}["'\`]`),R=[];for(let M of l()){let N=A.exec(M.text);N&&R.push({file:M,offset:N.index})}return R.length?{status:"used",via:`via ${j} prop`,...m(R,p)}:{status:"dynamic",via:`built as ${x}\${\u2026}`,...m(I.map(M=>({file:M,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)}["'\`]`),v=[];for(let I of l()){let j=y.exec(I.text);j&&v.push({file:I,offset:j.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 I of l()){let j=x.exec(I.text);j&&C.push({file:I,offset:j.index})}return C.length?{status:"dynamic",via:`${g.name} is set from a variable`,...m(C,p)}:{status:"unreferenced",files:[],fileCount:0}},w=new Map;if(r&&o.length>0)for(let g of l())for(let p of de(g.path,g.text,o,i))for(let d of p.selects){let y=w.get(d)??[];y.push({file:g,offset:p.offset}),w.set(d,y)}let $={used:0,unknown:0,dynamic:1,unreferenced:2};for(let g of n){let p=Sl(g.selector),d=Cl(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)=>$[R.status]>=$[A.status]?R:A);let v=g.element?.classes.find(A=>A.startsWith("__gs-recipe-")),x=v?w.get(v):void 0;if(!x||x.length===0)continue;let C=new Set(g.usage.files.map(A=>A.path)),I=g.usage.fileCount,j=[...g.usage.files];for(let A of x)C.has(A.file.path)||(C.add(A.file.path),I+=1,!(j.length>=xn)&&j.push({path:A.file.path,line:Ar(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 _r(t,e,n){let s=[],r=new Set;for(let o of e)r.has(o.path)||(r.add(o.path),!(s.length>=xn)&&s.push({path:o.path,line:o.line,...n?{example:nn(t.get(o.path)??"",o.offset,[],o.path)}:{}}));return{status:"used",files:s,fileCount:r.size}}var Rl={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},Pr={button:Rl},Dr=12,vn=200,bt=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro)$/i,Er=/\.(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,jr=/\.(mdx?|markdown|txt|rst|adoc)$/i,Ir=/(^|\/)(tokens?|design-tokens?|theme)[^/]*\.json$/i,J=/(^|\/)(__tests__|tests?|spec|e2e|cypress|playwright)(\/|$)|\.(test|spec)\.[a-z]+$/i,Al=/(^|\/)(plans?|results?|changelogs?|history|archive)(\/|\.|$)|(^|\/)CHANGELOG/i;function _l(t){return ye.test(t)&&!/(^|\/)README\.md$/i.test(t)?"instruction":Al.test(t)?"record":"documentation"}var ye=/(^|\/)(AGENTS|CLAUDE|CONTRIBUTING|README|GUIDELINES?)\.md$|(^|\/)(eslint|stylelint|\.eslintrc|\.stylelintrc)[^/]*$|(^|\/)\.cursor\/|(^|\/)\.claude\//i;function ct(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function El(t){return(t.split("/").pop()??"").replace(/(\.module)?\.[^.]+$/i,"")}function Mr(t,e){let n=El(t).toLowerCase();return e.some(s=>{let r=s.toLowerCase();return n===r||n===`${r}s`})}function jl(t,e){let n=1;for(let s=0;s<e;s++)t.charCodeAt(s)===10&&n++;return n}function ut(t,e){let n=t.split(`
49
- `),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<Dr)){let a=i.trim();r.push({line:o+1,text:a.length>vn?`${a.slice(0,vn)}\u2026`:a})}}return{count:s,lines:r}}function Or(t){let e=t.lastIndexOf("/");return e<0?"":t.slice(0,e)}function Nr(t){let e=[];for(let n of t.split("/"))!n||n==="."||(n===".."?e.pop():e.push(n));return e.join("/")}var Il=["",".tsx",".ts",".jsx",".js",".mjs",".vue",".svelte",".css",".module.css",".scss","/index.tsx","/index.ts","/index.js"];function yt(t,e,n){let s;if(e.startsWith("."))s=Nr(`${Or(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 Il)if(n(s+r))return s+r;return null}var Ml=/import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]|require\(\s*['"]([^'"]+)['"]\s*\)|@import\s+(?:url\()?['"]([^'"]+)['"]/g;function wn(t){let e=[];for(let n of t.matchAll(Ml)){let s=n[1]??n[2]??n[3];s&&e.push(s)}return e}var Ll=/export\s+(?:default\s+)?(?:async\s+)?(?:function|const|let|class|var)\s+([A-Za-z_$][\w$]*)|export\s*\{([^}]*)\}/g;function Lr(t){let e=new Set;for(let n of t.matchAll(Ll))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 $n=/var\(\s*(--[\w-]+)/g;function xe(t){return t.split(" \xB7 ").every(e=>e===""||/^@layer\b/i.test(e))}function Tr(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 Pl(t,e,n){let s=e.startsWith(".")?Nr(`${Or(t)}/${e}`):e.startsWith("@/")?e.slice(2):e.startsWith("~/")||e.startsWith("/")?e.replace(/^~?\//,""):null;return s&&n(s)?s:yt(t,e.replace(/\.(?:module\.)?(?:css|scss|sass|less)$/i,""),n)}function Dl(t){let e=new Map;for(let[n,s]of t)if(Gt.test(n)){for(let r of ht(s))if(xe(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(...at(r.ownBody));for(let c of he(r.ownBody))c.state==="default"&&c.context===""&&l.decls.push(...c.declarations);l.composes.push(...Tr(r.ownBody)),e.set(a,l)}}return e}function Ol(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=Pl(l,c.from,s);m&&i(m,f,u)}else i(l,f,u)};for(let l of Tr(e))a(t,l,0);return r}function Nl(t,e){let n=vr(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 Tl=/^(?::root|html|body|\*)$/i,Vl=25e4,Bl=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,Fl=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,zl=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]);function Ul(t){let e=new Set,n=new Set;for(let s of t.matchAll(Bl)){let r=s[1],o=zl.has(r.toLowerCase())&&r===r.toLowerCase()?e:n;for(let i of s[2].matchAll(Fl))o.add(i[1]??i[2])}return{parts:new Set([...e].filter(s=>!n.has(s))),controls:n}}function Wl(t,e){let n=new Map;for(let s of e)if(Gt.test(s)){for(let r of ht(t.get(s)))if(xe(r.context)&&z(r.selector).some(o=>Tl.test(o)))for(let o of at(r.ownBody))o.property.startsWith("--")&&!n.has(o.property)&&n.set(o.property,o.value)}return n}function Gl(t,e){let n=new Set,s=[],r=a=>{for(let l of a.matchAll($n))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||!tt(a,l)||(o.push(`${a}:${l}`),r(l))}return`${o.length?`:root{${o.join(";")}}
48
+ `,s+1);return n}var _l=t=>t.replace(/[-_]+(\w)/g,(e,n)=>n.toUpperCase()),El=/\[\s*([\w-]+)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*\]/g,jl=new Set(["data-component","data-slot","role"]);function Il(t,e){return[...t.slice(mt(t)).matchAll(El)].map(s=>({name:s[1],value:s[2]??s[3]??s[4]??null})).filter(s=>!jl.has(s.name)&&!(s.value!==null&&e.has(s.value.toLowerCase())))}function Ml(t){return[...t.slice(mt(t)).matchAll(/\.((?:\\.|[\w-])+)/g)].map(n=>n[1].replace(/\\(.)/g,"$1"))}function wn(t,e,n,s,r=!1,o=[],i=()=>null){let a=null,l=()=>a??=e.map(g=>Al(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)=>ar(sn(g.original,p,d,g.path),g.original,p,g.path,o,i),m=(g,p)=>({files:g.slice(0,kn).map(({file:d,offset:y,example:v})=>({path:d.path,line:Lr(d.text,y),...r?{example:v??f(d,y,p)}:{}})),fileCount:g.length}),b=(g,p)=>{let d=[],y=_l(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 I=C,j;if(r)for(let A of x){let R=f(v,A,p);if(R.kind!=="other"){I=A,j=R;break}}d.push({file:v,offset:I,example:j})}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),I=u(x);if(I.length===0||!C)continue;let j=x.slice(0,-1),A=new RegExp(`\\b${Wt(j)}\\s*[=:]\\s*\\{?\\s*["'\`]${Wt(C)}["'\`]`),R=[];for(let M of l()){let T=A.exec(M.text);T&&R.push({file:M,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(M=>({file:M,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)}["'\`]`),v=[];for(let I of l()){let j=y.exec(I.text);j&&v.push({file:I,offset:j.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 I of l()){let j=x.exec(I.text);j&&C.push({file:I,offset:j.index})}return C.length?{status:"dynamic",via:`${g.name} is set from a variable`,...m(C,p)}:{status:"unreferenced",files:[],fileCount:0}},w=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=w.get(d)??[];y.push({file:g,offset:p.offset}),w.set(d,y)}let $={used:0,unknown:0,dynamic:1,unreferenced:2};for(let g of n){let p=Ml(g.selector),d=Il(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)=>$[R.status]>=$[A.status]?R:A);let v=g.element?.classes.find(A=>A.startsWith("__gs-recipe-")),x=v?w.get(v):void 0;if(!x||x.length===0)continue;let C=new Set(g.usage.files.map(A=>A.path)),I=g.usage.fileCount,j=[...g.usage.files];for(let A of x)C.has(A.file.path)||(C.add(A.file.path),I+=1,!(j.length>=kn)&&j.push({path:A.file.path,line:Lr(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 Pr(t,e,n){let s=[],r=new Set;for(let o of e)r.has(o.path)||(r.add(o.path),!(s.length>=kn)&&s.push({path:o.path,line:o.line,...n?{example:sn(t.get(o.path)??"",o.offset,[],o.path)}:{}}));return{status:"used",files:s,fileCount:r.size}}var Ll={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},Br={button:Ll},Fr=12,$n=200,yt=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro)$/i,Or=/\.(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,Dr=/\.(mdx?|markdown|txt|rst|adoc)$/i,Tr=/(^|\/)(tokens?|design-tokens?|theme)[^/]*\.json$/i,J=/(^|\/)(__tests__|tests?|spec|e2e|cypress|playwright)(\/|$)|\.(test|spec)\.[a-z]+$/i,Pl=/(^|\/)(plans?|results?|changelogs?|history|archive)(\/|\.|$)|(^|\/)CHANGELOG/i;function Ol(t){return xe.test(t)&&!/(^|\/)README\.md$/i.test(t)?"instruction":Pl.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 Dl(t){return(t.split("/").pop()??"").replace(/(\.module)?\.[^.]+$/i,"")}function Nr(t,e){let n=Dl(t).toLowerCase();return e.some(s=>{let r=s.toLowerCase();return n===r||n===`${r}s`})}function Tl(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(`
49
+ `),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<Fr)){let a=i.trim();r.push({line:o+1,text:a.length>$n?`${a.slice(0,$n)}\u2026`:a})}}return{count:s,lines:r}}function zr(t){let e=t.lastIndexOf("/");return e<0?"":t.slice(0,e)}function Ur(t){let e=[];for(let n of t.split("/"))!n||n==="."||(n===".."?e.pop():e.push(n));return e.join("/")}var Nl=["",".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=Ur(`${zr(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 Nl)if(n(s+r))return s+r;return null}var Vl=/import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]|require\(\s*['"]([^'"]+)['"]\s*\)|@import\s+(?:url\()?['"]([^'"]+)['"]/g;function vn(t){let e=[];for(let n of t.matchAll(Vl)){let s=n[1]??n[2]??n[3];s&&e.push(s)}return e}var Bl=/export\s+(?:default\s+)?(?:async\s+)?(?:function|const|let|class|var)\s+([A-Za-z_$][\w$]*)|export\s*\{([^}]*)\}/g;function Vr(t){let e=new Set;for(let n of t.matchAll(Bl))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 Cn=/var\(\s*(--[\w-]+)/g;function ke(t){return t.split(" \xB7 ").every(e=>e===""||/^@layer\b/i.test(e))}function Wr(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 Fl(t,e,n){let s=e.startsWith(".")?Ur(`${zr(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 zl(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 U(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(...Wr(r.ownBody)),e.set(a,l)}}return e}function Ul(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=Fl(l,c.from,s);m&&i(m,f,u)}else i(l,f,u)};for(let l of Wr(e))a(t,l,0);return r}function Wl(t,e){let n=_r(e);return n?U(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 Gl=/^(?::root|html|body|\*)$/i,Hl=25e4,Kl=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,Jl=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,Zl=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]);function Xl(t){let e=new Set,n=new Set;for(let s of t.matchAll(Kl)){let r=s[1],o=Zl.has(r.toLowerCase())&&r===r.toLowerCase()?e:n;for(let i of s[2].matchAll(Jl))o.add(i[1]??i[2])}return{parts:new Set([...e].filter(s=>!n.has(s))),controls:n}}function ql(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)&&U(r.selector).some(o=>Gl.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 Yl(t,e){let n=new Set,s=[],r=a=>{for(let l of a.matchAll(Cn))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(";")}}
50
50
  `:""}${e.join(`
51
- `)}`.slice(0,Vl)}function Vr(t,e){let n=[...t.keys()].sort(),s=h=>t.has(h),r=new Map,o=(h,S,_,L)=>{let D=`${S}:${h}`,V=r.get(D);if(V){V.note.includes(_)||(V.note+=`; ${_}`);return}r.set(D,{path:h,role:S,note:_,matches:L.count,lines:L.lines})},i=new Set,a=new Set;for(let h of n){if(!bt.test(h)||J.test(h))continue;let S=t.get(h),_=Lr(S).filter(P=>e.identifier.test(P)),L=h.split("/").pop()??"",D=new RegExp(e.classKeywords.join("|"),"i").test(L);if(_.length===0&&!D)continue;for(let P of _)i.add(P);a.add(h);let V=_.length?new RegExp(`\\b(?:${_.map(ct).join("|")})\\b`,"g"):e.prose;o(h,"implements",_.length?`exports ${_.join(", ")}`:"named for the concept",ut(S,V))}let l=new Set,c=[],u=[],f=new Map,m=h=>Mr(h,e.classKeywords)||/\.module\.[a-z]+$/i.test(h)&&f.has(h),b=null,k=()=>b??=Dl(t),w=h=>{let S=m(h),_=[],L=0;for(let P of ht(t.get(h))){let B=z(P.selector).filter(O=>Ut(O,e,S));if(B.length===0)continue;L+=1;for(let O of P.ownBody.matchAll($n))l.add(O[1]);let F=he(P.ownBody),st=[...Ol(h,P.ownBody,k(),s),...at(P.ownBody),...F.filter(O=>O.state==="default"&&O.context==="").flatMap(O=>O.declarations)];for(let O of st)for(let K of O.value.matchAll($n))l.add(K[1]);_.push({block:P,parts:B,declarations:st,previewContext:xe(P.context)?"":null,listed:!0});for(let O of F){if(O.state==="default"&&O.context==="")continue;let K=Nl(B.join(", "),O.state),Dt=z(K).filter(mo=>Ut(mo,e,S));if(Dt.length===0)continue;let go=[P.context,O.context].filter(Boolean).join(" \xB7 ");_.push({block:{...P,selector:K,context:go},parts:Dt,declarations:O.declarations,previewContext:xe(P.context)?O.context:null,listed:!1})}}let D={parts:new Set,controls:new Set};for(let P of f.get(h)??[]){let B=Ul(t.get(P)??"");for(let F of B.parts)D.parts.add(F);for(let F of B.controls)D.controls.add(F)}c.push(...dr(h,_.map(({block:P,parts:B,declarations:F})=>({selector:B.join(", "),declarations:F,line:P.line,context:P.context})),e,S,D));let V=/\.module\.[a-z]+$/i.test(h)?`${Ls(h)} `:"";for(let{parts:P,declarations:B,previewContext:F}of _){if(F===null)continue;let st=P.flatMap(K=>{let Dt=Ut(K,e,S);return Dt?[`${V}${Ft(Dt.compounds)}`]:[]}),O=B.filter(K=>tt(K.property,K.value));if(!(st.length===0||O.length===0))for(let K of st)u.push(...yn(K,O,F))}return{count:L,lines:_.filter(P=>P.listed).slice(0,Dr).map(({block:P})=>({line:P.line,text:P.selector.replace(/\s+/g," ").slice(0,vn)}))}},$=new Map;for(let h of a)for(let S of wn(t.get(h))){let _=yt(h,S,s);if(_&&Gt.test(_)){let L=$.get(_)??[];L.push(h.split("/").pop()??h),$.set(_,L),Mr(h,e.classKeywords)&&f.set(_,[...f.get(_)??[],h])}}for(let h of n){if(!Gt.test(h))continue;let S=w(h),_=$.get(h);if(S.count===0)continue;let L=[];_&&L.push(`imported by ${_.join(", ")}`),S.count>0&&L.push(`${S.count} matching rule${S.count===1?"":"s"}`),o(h,"styles",L.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=>`<${ct(h)}\\b`),...e.roles.map(h=>`role=["']${ct(h)}["']`)].join("|"));for(let h of n)!bt.test(h)||J.test(h)||d.test(t.get(h)??"")&&p.add(h);for(let h of a)for(let S of wn(t.get(h))){let _=yt(h,S,s);!_||!bt.test(_)||J.test(_)||Rr(_,e.classKeywords)&&p.add(_)}let y=0,v=[],x=[];for(let h of p){let S=Sr(h,t.get(h)??"",e,g,y);y=S.nextId,v.push(...S.recipes),c.push(...S.variants),x.push(...S.inline),u.push(...S.previewRules)}let C=Vn(x);c.push(...C.variants);let I=nr([...a].map(h=>({path:h,source:t.get(h)??"",names:Lr(t.get(h)??"").filter(S=>e.identifier.test(S))})),v,(h,S)=>yt(h,S,s)),j=[];if(l.size>0){let h=new RegExp(`(?:^|[\\s{;])(${[...l].map(ct).join("|")})\\s*:`),S=new Map;for(let _ of n){if(!Gt.test(_)&&!Ir.test(_))continue;let L=t.get(_),D=ut(L,h);if(D.count!==0){for(let V of L.matchAll(new RegExp(h.source,"gm"))){let P=S.get(V[1])??[];P.includes(_)||P.push(_),S.set(V[1],P)}o(_,"tokens",`defines ${D.count} token${D.count===1?"":"s"} read by ${e.label.toLowerCase()} styles`,D)}}for(let _ of[...l].sort())j.push({name:_,definedIn:S.get(_)??[]})}for(let h of n){if(!Ir.test(h))continue;let S=ut(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(ct).join("|")})\\b`]:[],...e.elements.map(h=>`<${ct(h)}\\b`),...e.roles.map(h=>`role=["']${ct(h)}["']`)].join("|"));for(let h of n){if(!bt.test(h)||a.has(h))continue;let S=t.get(h),_=J.test(h),L=ut(S,R),D=wn(S).some(P=>{let B=yt(h,P,s);return B!=null&&a.has(B)});if(L.count===0&&!D)continue;let V=L.count>0?`${L.count} render${L.count===1?"":"s"}`:"imports a button component";o(h,_?"tests":"uses",V,L.count?L:ut(S,e.prose))}for(let h of n){if(!(jr.test(h)||ye.test(h)))continue;let _=t.get(h),L=ut(_,e.prose);L.count!==0&&o(h,J.test(h)?"tests":"describes",ye.test(h)?"repo rules / instructions":"documentation",L)}for(let h of n){if(!J.test(h)||r.has(`tests:${h}`)||!bt.test(h))continue;let S=ut(t.get(h),e.prose);S.count>0&&o(h,"tests","mentions the concept",S)}let M=[...r.values()].sort((h,S)=>S.matches-h.matches||h.path.localeCompare(S.path)),N={implements:0,styles:0,tokens:0,uses:0,describes:0,tests:0};for(let h of M)N[h.role]++;let G=gr(c);kn(t,n.filter(h=>Er.test(h)&&!J.test(h)),G,new Set(e.elements),!0,I,(h,S)=>yt(h,S,s)),kn(t,n.filter(h=>Er.test(h)&&!J.test(h)),G.flatMap(h=>h.modifiers??[]),new Set(e.elements));for(let[h,S]of C.sites)h.usage=_r(t,S,!("alike"in h));let Z=Wl(t,n),Jt=[];if(i.size>0){let h=new RegExp(e.elements.map(S=>`<${ct(S)}\\b`).join("|"),"g");for(let S of n){if(!bt.test(S)||J.test(S)||a.has(S))continue;let _=t.get(S),L=(_.match(h)??[]).length;if(L===0)continue;let D=ut(_,new RegExp(h.source));Jt.push({path:S,line:D.lines[0]?.line??1,count:L})}}let Pn=[],Dn=new Set;for(let h of n){if(!bt.test(h)||J.test(h))continue;let S=t.get(h),_=de(h,S,I,(L,D)=>yt(L,D,s));for(let L of _)for(let D of L.unknown){let V=[...D.known].sort();if(D.cls!==void 0){if(g.has(D.cls))continue;let F=D.cls.slice(0,D.cls.length-D.value.length),st=[...g].filter(O=>O.startsWith(F)&&O.length>F.length).map(O=>O.slice(F.length));if(st.length===0)continue;V=[...new Set([...D.known,...st])].sort()}if(V.length===0)continue;let P=jl(S,L.offset),B=`${h}\0${L.component}\0${D.prop}\0${D.value}`;Dn.has(B)||(Dn.add(B),Pn.push({path:h,line:P,component:L.component,prop:D.prop,value:D.value,known:V}))}}let po=n.filter(h=>(jr.test(h)||ye.test(h))&&!J.test(h)).map(h=>({path:h,kind:_l(h)}));G.sort((h,S)=>Number(S.base)-Number(h.base)||h.path.localeCompare(S.path)||h.line-S.line);let On=ar(t,po,e,G),fo=or([...f.entries()].map(([h,S])=>({sheet:h,sources:S.map(_=>t.get(_)??""),rules:ht(t.get(h)??"").map(_=>({selector:_.selector,declarations:at(_.ownBody)}))})));return{components:A.sort(),tokens:j,findings:M,variants:G,audit:Fs({variants:G,tokens:j,tokenValues:Z,hasComponent:i.size>0,nativeUses:Jt,unknownProps:Pn,guidance:On,noun:e.label.toLowerCase(),element:e.elements[0]??e.id}),guidance:On,content:fo,previewCss:Gl(Z,u),counts:N}}import{execFileSync as Kl}from"node:child_process";import{readdirSync as Jl,readFileSync as Zl,statSync as Xl}from"node:fs";import ke from"node:path";function xt(t,e){try{return Kl("git",e,{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:64*1024*1024})}catch{return null}}function Cn(t,e=""){let s=xt(t,["rev-parse","--show-toplevel"])?.trim()||t;return{repoDir:s,root:Ue(e),stateDir:ke.join(s,".gruum")}}function Br(t){let e=ke.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=Jl(l).sort()}catch{return}for(let f of u){let m=c?`${c}/${f}`:f,b=ke.join(l,f),k;try{k=Xl(b)}catch{continue}if(k.isDirectory()){Fe(m)&&a(b,m);continue}if(!k.isFile())continue;if(!ze(m,k.size)){o++;continue}let w=Zl(b);if(xs(w)){o++;continue}if(r+w.length>4e7){i=!0;return}r+=w.length,n.set(m,s.decode(w))}};return a(e,""),{files:n,truncated:i,skipped:o}}function Fr(t,e){let n=xt(t.repoDir,["diff","--cached","--name-status","-z"]);if(n===null)return e;let s=vs(n).map(({path:r,deleted:o})=>({path:r,content:o?null:xt(t.repoDir,["show",`:${r}`])}));return{...e,files:ws(e.files,s,t.root)}}function zr(t){let e=xt(t.repoDir,["remote","get-url","origin"])?.trim()??"",n=ne(e)??ke.basename(t.repoDir),s=xt(t.repoDir,["rev-parse","HEAD"])?.trim()||"working-tree";return{fullName:n,ref:s,rootPath:t.root,htmlUrl:n.includes("/")?`https://github.com/${n}`:""}}function Ur(t){let e=xt(t.repoDir,["config","--get","core.hooksPath"])?.trim();return e||xt(t.repoDir,["rev-parse","--git-path","hooks"])?.trim()||null}function we(t,e={}){let n=Pr[e.concept??"button"],s=Br(t);return e.staged&&(s=Fr(t,s)),{concept:n.id,label:n.label,...Vr(s.files,n),repo:zr(t),index:{files:s.files.size,truncated:s.truncated,skipped:s.skipped}}}function kt(t,e,n={}){let s=we(t,{concept:e.concept,...n});return{result:s,baseline:e,items:Kn(s,e)}}import{mkdirSync as Yl,readFileSync as ql,writeFileSync as Ql}from"node:fs";import Mt from"node:path";function ve(t){try{return ql(t,"utf8")}catch{return null}}function $e(t){let e=ve(t);if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function wt(t,e){Yl(Mt.dirname(t),{recursive:!0}),Ql(t,e)}function vt(t,e){wt(t,`${JSON.stringify(e,null,2)}
52
- `)}var Ht=t=>Mt.join(t.stateDir,"baseline.json"),Wr=t=>Mt.join(t.stateDir,"drift.json"),Sn=t=>Mt.join(t.stateDir,"exceptions.json"),tc=t=>Mt.join(t.stateDir,"config.json");function $t(t,e){return Xt($e(e?Mt.resolve(e):Ht(t)))}function Ce(t){return Xn($e(Wr(t)),new Date().toISOString())}function Rn(t,e){vt(Wr(t),e)}function ec(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 Se(t){return ec($e(Sn(t)))}function An(t){let e=$e(tc(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 nc,mkdirSync as sc,readFileSync as Zr,writeFileSync as rc}from"node:fs";import{hostname as oc,homedir as ic}from"node:os";import En from"node:path";import{createInterface as ac}from"node:readline/promises";function Gr(t){return`/v2/projects/${encodeURIComponent(t)}`}function Hr(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 Kr(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}}import{spawnSync as lc}from"node:child_process";var Lt="https://app.getgruum.com",Xr=()=>En.join(ic(),".config","gruum","credentials.json");function Yr(){let t=process.env.GRUUM_TOKEN?.trim();if(t)return{token:t,apiOrigin:process.env.GRUUM_API_ORIGIN?.trim()||Lt};try{let e=JSON.parse(Zr(Xr(),"utf8"));return typeof e.token!="string"||!e.token?null:{token:e.token,apiOrigin:typeof e.apiOrigin=="string"&&e.apiOrigin?e.apiOrigin:Lt}}catch{return null}}function cc(t){let e=Xr();sc(En.dirname(e),{recursive:!0}),rc(e,`${JSON.stringify(t,null,2)}
53
- `,{mode:384}),nc(e,384)}function jn(t){return(t?.apiOrigin||Lt).replace(/\/$/,"")}async function nt(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(`${jn(t)}${e}`,{...n,headers:s})}function In(t,e){let n=lc("git",e,{cwd:t,encoding:"utf8"});return n.status!==0?null:n.stdout.trim()||null}function uc(t){let e=In(t,["remote","get-url","origin"]);return e?ne(e):null}function Re(t){let e=In(t,["rev-parse","--abbrev-ref","HEAD"]);return e&&e!=="HEAD"?e:""}function qr(t){return In(t,["rev-parse","HEAD"])}function Qr(t){return En.join(t.stateDir,"project.json")}function pc(t){try{let e=JSON.parse(Zr(Qr(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 to(t,e){return`${t}${Gr(e)}`}function Jr(t,e,n){let s=to(t,e.id);process.stderr.write(n?`Created a Gruum project for ${e.repo}.
51
+ `)}`.slice(0,Hl)}function Gr(t,e){let n=[...t.keys()].sort(),s=h=>t.has(h),r=new Map,o=(h,S,_,L)=>{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:L.count,lines:L.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),_=Vr(S).filter(P=>e.identifier.test(P)),L=h.split("/").pop()??"",O=new RegExp(e.classKeywords.join("|"),"i").test(L);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=>Nr(h,e.classKeywords)||/\.module\.[a-z]+$/i.test(h)&&f.has(h),b=null,k=()=>b??=zl(t),w=h=>{let S=m(h),_=[],L=0;for(let P of bt(t.get(h))){let F=U(P.selector).filter(D=>Ut(D,e,S));if(F.length===0)continue;L+=1;for(let D of P.ownBody.matchAll(Cn))l.add(D[1]);let z=be(P.ownBody),rt=[...Ul(h,P.ownBody,k(),s),...lt(P.ownBody),...z.filter(D=>D.state==="default"&&D.context==="").flatMap(D=>D.declarations)];for(let D of rt)for(let K of D.value.matchAll(Cn))l.add(K[1]);_.push({block:P,parts:F,declarations:rt,previewContext:ke(P.context)?"":null,listed:!0});for(let D of z){if(D.state==="default"&&D.context==="")continue;let K=Wl(F.join(", "),D.state),Ot=U(K).filter(vo=>Ut(vo,e,S));if(Ot.length===0)continue;let wo=[P.context,D.context].filter(Boolean).join(" \xB7 ");_.push({block:{...P,selector:K,context:wo},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=Xl(t.get(P)??"");for(let z of F.parts)O.parts.add(z);for(let z of F.controls)O.controls.add(z)}c.push(...xr(h,_.map(({block:P,parts:F,declarations:z})=>({selector:F.join(", "),declarations:z,line:P.line,context:P.context})),e,S,O));let B=/\.module\.[a-z]+$/i.test(h)?`${Vs(h)} `:"";for(let{parts:P,declarations:F,previewContext:z}of _){if(z===null)continue;let rt=P.flatMap(K=>{let Ot=Ut(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(...xn(K,D,z))}return{count:L,lines:_.filter(P=>P.listed).slice(0,Fr).map(({block:P})=>({line:P.line,text:P.selector.replace(/\s+/g," ").slice(0,$n)}))}},$=new Map;for(let h of a)for(let S of vn(t.get(h))){let _=xt(h,S,s);if(_&&Gt.test(_)){let L=$.get(_)??[];L.push(h.split("/").pop()??h),$.set(_,L),Nr(h,e.classKeywords)&&f.set(_,[...f.get(_)??[],h])}}for(let h of n){if(!Gt.test(h))continue;let S=w(h),_=$.get(h);if(S.count===0)continue;let L=[];_&&L.push(`imported by ${_.join(", ")}`),S.count>0&&L.push(`${S.count} matching rule${S.count===1?"":"s"}`),o(h,"styles",L.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 vn(t.get(h))){let _=xt(h,S,s);!_||!yt.test(_)||J.test(_)||Mr(_,e.classKeywords)&&p.add(_)}let y=0,v=[],x=[];for(let h of p){let S=Ir(h,t.get(h)??"",e,g,y);y=S.nextId,v.push(...S.recipes),c.push(...S.variants),x.push(...S.inline),u.push(...S.previewRules)}let C=Fn(x);c.push(...C.variants);let I=lr([...a].map(h=>({path:h,source:t.get(h)??"",names:Vr(t.get(h)??"").filter(S=>e.identifier.test(S))})),v,(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(_)&&!Tr.test(_))continue;let L=t.get(_),O=pt(L,h);if(O.count!==0){for(let B of L.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(!Tr.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),L=pt(S,R),O=vn(S).some(P=>{let F=xt(h,P,s);return F!=null&&a.has(F)});if(L.count===0&&!O)continue;let B=L.count>0?`${L.count} render${L.count===1?"":"s"}`:"imports a button component";o(h,_?"tests":"uses",B,L.count?L:pt(S,e.prose))}for(let h of n){if(!(Dr.test(h)||xe.test(h)))continue;let _=t.get(h),L=pt(_,e.prose);L.count!==0&&o(h,J.test(h)?"tests":"describes",xe.test(h)?"repo rules / instructions":"documentation",L)}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 M=[...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 M)T[h.role]++;let G=kr(c);wn(t,n.filter(h=>Or.test(h)&&!J.test(h)),G,new Set(e.elements),!0,I,(h,S)=>xt(h,S,s)),wn(t,n.filter(h=>Or.test(h)&&!J.test(h)),G.flatMap(h=>h.modifiers??[]),new Set(e.elements));for(let[h,S]of C.sites)h.usage=Pr(t,S,!("alike"in h));let Z=ql(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),L=(_.match(h)??[]).length;if(L===0)continue;let O=pt(_,new RegExp(h.source));Zt.push({path:S,line:O.lines[0]?.line??1,count:L})}}let Dn=[],Tn=new Set;for(let h of n){if(!yt.test(h)||J.test(h))continue;let S=t.get(h),_=ge(h,S,I,(L,O)=>xt(L,O,s));for(let L of _)for(let O of L.unknown){let B=[...O.known].sort();if(O.cls!==void 0){if(g.has(O.cls))continue;let z=O.cls.slice(0,O.cls.length-O.value.length),rt=[...g].filter(D=>D.startsWith(z)&&D.length>z.length).map(D=>D.slice(z.length));if(rt.length===0)continue;B=[...new Set([...O.known,...rt])].sort()}if(B.length===0)continue;let P=Tl(S,L.offset),F=`${h}\0${L.component}\0${O.prop}\0${O.value}`;Tn.has(F)||(Tn.add(F),Dn.push({path:h,line:P,component:L.component,prop:O.prop,value:O.value,known:B}))}}let xo=n.filter(h=>(Dr.test(h)||xe.test(h))&&!J.test(h)).map(h=>({path:h,kind:Ol(h)}));G.sort((h,S)=>Number(S.base)-Number(h.base)||h.path.localeCompare(S.path)||h.line-S.line);let Nn=dr(t,xo,e,G),ko=pr([...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:M,variants:G,audit:Ks({variants:G,tokens:j,tokenValues:Z,hasComponent:i.size>0,nativeUses:Zt,unknownProps:Dn,guidance:Nn,noun:e.label.toLowerCase(),element:e.elements[0]??e.id}),guidance:Nn,content:ko,previewCss:Yl(Z,u),counts:T}}import{execFileSync as tc}from"node:child_process";import{readdirSync as ec,readFileSync as nc,statSync as sc}from"node:fs";import we from"node:path";function kt(t,e){try{return tc("git",e,{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:64*1024*1024})}catch{return null}}function Sn(t,e=""){let s=kt(t,["rev-parse","--show-toplevel"])?.trim()||t;return{repoDir:s,root:We(e),stateDir:we.join(s,".gruum")}}function Hr(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=ec(l).sort()}catch{return}for(let f of u){let m=c?`${c}/${f}`:f,b=we.join(l,f),k;try{k=sc(b)}catch{continue}if(k.isDirectory()){ze(m)&&a(b,m);continue}if(!k.isFile())continue;if(!Ue(m,k.size)){o++;continue}let w=nc(b);if(Ss(w)){o++;continue}if(r+w.length>4e7){i=!0;return}r+=w.length,n.set(m,s.decode(w))}};return a(e,""),{files:n,truncated:i,skipped:o}}function Kr(t,e){let n=kt(t.repoDir,["diff","--cached","--name-status","-z"]);if(n===null)return e;let s=_s(n).map(({path:r,deleted:o})=>({path:r,content:o?null:kt(t.repoDir,["show",`:${r}`])}));return{...e,files:As(e.files,s,t.root)}}function Jr(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 Zr(t){let e=kt(t.repoDir,["config","--get","core.hooksPath"])?.trim();return e||kt(t.repoDir,["rev-parse","--git-path","hooks"])?.trim()||null}function ve(t,e={}){let n=Br[e.concept??"button"],s=Hr(t);return e.staged&&(s=Kr(t,s)),{concept:n.id,label:n.label,...Gr(s.files,n),repo:Jr(t),index:{files:s.files.size,truncated:s.truncated,skipped:s.skipped}}}function wt(t,e,n={}){let s=ve(t,{concept:e.concept,...n});return{result:s,baseline:e,items:Zn(s,e)}}import{mkdirSync as rc,readFileSync as oc,writeFileSync as ic}from"node:fs";import Mt from"node:path";function $e(t){try{return oc(t,"utf8")}catch{return null}}function Ce(t){let e=$e(t);if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function vt(t,e){rc(Mt.dirname(t),{recursive:!0}),ic(t,e)}function $t(t,e){vt(t,`${JSON.stringify(e,null,2)}
52
+ `)}var Ht=t=>Mt.join(t.stateDir,"baseline.json"),Xr=t=>Mt.join(t.stateDir,"drift.json"),Rn=t=>Mt.join(t.stateDir,"exceptions.json"),ac=t=>Mt.join(t.stateDir,"config.json");function ft(t,e){return qt(Ce(e?Mt.resolve(e):Ht(t)))}function Se(t){return Yn(Ce(Xr(t)),new Date().toISOString())}function An(t,e){$t(Xr(t),e)}function lc(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 Re(t){return lc(Ce(Rn(t)))}function _n(t){let e=Ce(ac(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 cc,mkdirSync as uc,readFileSync as eo,writeFileSync as pc}from"node:fs";import{hostname as fc,homedir as dc}from"node:os";import jn from"node:path";import{createInterface as gc}from"node:readline/promises";function qr(t){return`/v2/projects/${encodeURIComponent(t)}`}function Yr(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 Qr(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}}import{spawnSync as mc}from"node:child_process";var Lt="https://app.getgruum.com",no=()=>jn.join(dc(),".config","gruum","credentials.json");function so(){let t=process.env.GRUUM_TOKEN?.trim();if(t)return{token:t,apiOrigin:process.env.GRUUM_API_ORIGIN?.trim()||Lt};try{let e=JSON.parse(eo(no(),"utf8"));return typeof e.token!="string"||!e.token?null:{token:e.token,apiOrigin:typeof e.apiOrigin=="string"&&e.apiOrigin?e.apiOrigin:Lt}}catch{return null}}function hc(t){let e=no();uc(jn.dirname(e),{recursive:!0}),pc(e,`${JSON.stringify(t,null,2)}
53
+ `,{mode:384}),cc(e,384)}function In(t){return(t?.apiOrigin||Lt).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(`${In(t)}${e}`,{...n,headers:s})}function Mn(t,e){let n=mc("git",e,{cwd:t,encoding:"utf8"});return n.status!==0?null:n.stdout.trim()||null}function bc(t){let e=Mn(t,["remote","get-url","origin"]);return e?se(e):null}function Ae(t){let e=Mn(t,["rev-parse","--abbrev-ref","HEAD"]);return e&&e!=="HEAD"?e:""}function ro(t){return Mn(t,["rev-parse","HEAD"])}function oo(t){return jn.join(t.stateDir,"project.json")}function yc(t){try{let e=JSON.parse(eo(oo(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 io(t,e){return`${t}${qr(e)}`}function to(t,e,n){let s=io(t,e.id);process.stderr.write(n?`Created a Gruum project for ${e.repo}.
54
54
  ${s}
55
55
  `:`Gruum project: ${s}
56
- `)}async function fc(){let t=ac({input:process.stdin,output:process.stderr});try{for(;;){let e=(await t.question("Live URL for this project (https://\u2026), or press Enter to skip: ")).trim();if(!e)return null;let n=Kr(e);if("error"in n){process.stderr.write(`gruum: ${n.error}
57
- `);continue}return e}}finally{t.close()}}async function eo(){let t=`Cursor on ${oc()}`,e=await nt(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 ${Lt}?
56
+ `)}async function xc(){let t=gc({input:process.stdin,output:process.stderr});try{for(;;){let e=(await t.question("Live URL for this project (https://\u2026), or press Enter to skip: ")).trim();if(!e)return null;let n=Qr(e);if("error"in n){process.stderr.write(`gruum: ${n.error}
57
+ `);continue}return e}}finally{t.close()}}async function ao(){let t=`Cursor on ${fc()}`,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 ${Lt}?
58
58
  `),1;let n=await e.json(),s=`${Lt}/extension/connect?code=${encodeURIComponent(n.userCode)}`;process.stdout.write(`Sign in to Gruum to connect this CLI.
59
59
 
60
60
  Code: ${n.userCode}
61
61
  ${s}
62
62
 
63
63
  Waiting for confirmation\u2026
64
- `);let r=Date.now()+600*1e3;for(;Date.now()<r;){await new Promise(a=>setTimeout(a,2e3));let o=await nt(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 cc({token:i.token,apiOrigin:Lt}),process.stdout.write(`Signed in. This CLI can read specs for your projects.
65
- `),0}return process.stderr.write("gruum: sign-in timed out. Run `npx @gruum/cli login` again.\n"),1}function _n(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 no(t,e){let n=uc(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.
66
- `),null;let s=!!process.stdin.isTTY,r=pc(t);if(r&&r.repo===n&&(r.host||r.hostDeclined||!s))return r;let o=jn(e),i=await nt(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(_n).filter(k=>k!==null):[],c=!1;if(l.length===0){let k=await nt(e,"/api/v2/cli/projects",{method:"POST",body:JSON.stringify({repo:n,rootPath:t.root})}),w=await k.json().catch(()=>({})),$=_n(w.project);if(c=w.created!==!1,!k.ok||!$){let g=typeof w.path=="string"?w.path:"";return process.stderr.write(`gruum: ${w.error||`couldn't create a project (${k.status})`}
64
+ `);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 hc({token:i.token,apiOrigin:Lt}),process.stdout.write(`Signed in. This CLI can read specs for your projects.
65
+ `),0}return process.stderr.write("gruum: sign-in timed out. Run `npx @gruum/cli login` again.\n"),1}function En(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 lo(t,e){let n=bc(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.
66
+ `),null;let s=!!process.stdin.isTTY,r=yc(t);if(r&&r.repo===n&&(r.host||r.hostDeclined||!s))return r;let o=In(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(En).filter(k=>k!==null):[],c=!1;if(l.length===0){let k=await st(e,"/api/v2/cli/projects",{method:"POST",body:JSON.stringify({repo:n,rootPath:t.root})}),w=await k.json().catch(()=>({})),$=En(w.project);if(c=w.created!==!1,!k.ok||!$){let g=typeof w.path=="string"?w.path:"";return process.stderr.write(`gruum: ${w.error||`couldn't create a project (${k.status})`}
67
67
  `),g&&process.stderr.write(`${o}${g}
68
- `),null}l=[$]}let u=Hr(l,t.root);if(!u){let k=l.map(w=>` ${w.name}${w.rootPath?` #${w.rootPath}`:""}
69
- ${to(o,w.id)}`).join(`
68
+ `),null}l=[$]}let u=Yr(l,t.root);if(!u){let k=l.map(w=>` ${w.name}${w.rootPath?` #${w.rootPath}`:""}
69
+ ${io(o,w.id)}`).join(`
70
70
  `);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.
71
71
  ${k}
72
- `),null}let f=u.host??null,m=!1;if(!f&&s&&!r?.hostDeclined){Jr(o,{...u,host:f},c);let k=await fc();if(!k)m=!0;else{let w=await nt(e,`/api/v2/cli/projects/${encodeURIComponent(u.id)}/url`,{method:"POST",body:JSON.stringify({url:k})}),$=await w.json().catch(()=>({})),g=_n($.project);!w.ok||!g?.host?process.stderr.write(`gruum: ${$.error||`couldn't save that URL (${w.status})`}
72
+ `),null}let f=u.host??null,m=!1;if(!f&&s&&!r?.hostDeclined){to(o,{...u,host:f},c);let k=await xc();if(!k)m=!0;else{let w=await st(e,`/api/v2/cli/projects/${encodeURIComponent(u.id)}/url`,{method:"POST",body:JSON.stringify({url:k})}),$=await w.json().catch(()=>({})),g=En($.project);!w.ok||!g?.host?process.stderr.write(`gruum: ${$.error||`couldn't save that URL (${w.status})`}
73
73
  `):(f=g.host,process.stderr.write(`Live URL set to https://${f}.
74
- `))}}else Jr(o,{...u,host:f},c),!f&&!s&&process.stderr.write(`No live URL yet. Add one on that page.
75
- `);let b={...u,host:f,hostDeclined:m};return vt(Qr(t),b),b}async function Ae(t,e){if(e)return"local";let n=Yr();if(!n)return"local";try{let s=await no(t,n);if(!s)return"local";let r=Re(t.repoDir),o=await nt(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=Xt(i.baseline);return a?(vt(Ht(t),a),vt(Sn(t),i.exceptions??{}),"remote"):"local"}catch{return process.stderr.write(`gruum: couldn't reach Gruum. Checking the spec cached in .gruum/baseline.json.
76
- `),"local"}}async function Mn(t){let e=Yr();if(!e)return null;let n=await no(t,e);return n?{credentials:e,project:n}:null}async function so(t,e,n,s){let r=await Mn(t);if(!r)return;let o=Re(t.repoDir);if(o)try{let i=await nt(r.credentials,`/api/v2/cli/projects/${encodeURIComponent(r.project.id)}/drift`,{method:"POST",body:JSON.stringify({action:"observe",concept:"button",branch:o,commit:qr(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.
74
+ `))}}else to(o,{...u,host:f},c),!f&&!s&&process.stderr.write(`No live URL yet. Add one on that page.
75
+ `);let b={...u,host:f,hostDeclined:m};return $t(oo(t),b),b}async function _e(t,e){if(e)return"local";let n=so();if(!n)return"local";try{let s=await lo(t,n);if(!s)return"local";let r=Ae(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(Rn(t),i.exceptions??{}),"remote"):"local"}catch{return process.stderr.write(`gruum: couldn't reach Gruum. Checking the spec cached in .gruum/baseline.json.
76
+ `),"local"}}async function Ln(t){let e=so();if(!e)return null;let n=await lo(t,e);return n?{credentials:e,project:n}:null}async function co(t,e,n,s){let r=await Ln(t);if(!r)return;let o=Ae(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:ro(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.
77
77
  `)}catch{process.stderr.write(`gruum: couldn't reach Gruum to report this check. The local result still stands.
78
- `)}}async function ro(t,e,n){let s=await Mn(t);if(!s)return{ok:!1,text:"Sign in with gruum login before requesting an exception."};let r=Re(t.repoDir);if(!r)return{ok:!1,text:"This folder is not on a named git branch."};try{let o=await nt(s.credentials,`/api/v2/cli/projects/${encodeURIComponent(s.project.id)}/drift`,{method:"POST",body:JSON.stringify({action:"request",concept:"button",branch:r,commit:qr(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?`${jn(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}
79
- ${a}`:l}}catch{return{ok:!1,text:"Couldn't reach Gruum to request an exception."}}}async function oo(t,e){let n=await Mn(t);if(!n)return{ok:!1,text:"Sign in with gruum login to see exception status."};let s=Re(t.repoDir);try{let r=await nt(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(`
80
- `)}}catch{return{ok:!1,text:"Couldn't reach Gruum to read exception status."}}}var je="0.1.5",io=`gruum ${je}: keep buttons on the Gruum spec
78
+ `)}}async function uo(t,e,n){let s=await Ln(t);if(!s)return{ok:!1,text:"Sign in with gruum login before requesting an exception."};let r=Ae(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:ro(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?`${In(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}
79
+ ${a}`:l}}catch{return{ok:!1,text:"Couldn't reach Gruum to request an exception."}}}async function po(t,e){let n=await Ln(t);if(!n)return{ok:!1,text:"Sign in with gruum login to see exception status."};let s=Ae(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(`
80
+ `)}}catch{return{ok:!1,text:"Couldn't reach Gruum to read exception status."}}}var Ie="0.1.6",fo=`gruum ${Ie}: keep buttons on the Gruum spec
81
81
 
82
82
  Run it as \`npx @gruum/cli <command>\`.
83
83
 
@@ -106,34 +106,36 @@ Usage:
106
106
  gruum mcp
107
107
  Stdio MCP server: gruum_button_spec, gruum_check_buttons,
108
108
  gruum_request_exception, and gruum_exception_status.
109
- `,gc=new Set(["--baseline","--root","--out","--cli","--files"]);function mc(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 gc.has(i)&&t[s+1]!==void 0&&l.push(t[++s]);n.set(i,l)}return{positional:e,flags:n}}var U=(t,e)=>t.flags.has(e),pt=(t,e)=>t.flags.get(e)?.[0];function Pt(t,e=process.cwd()){let n=Cn(e),s=pt(t,"--root")??An(n).root??"";return Cn(e,s)}var _e="No spec found. Publish one from Gruum, or draft one locally with `npx @gruum/cli baseline --write`.";function co(t,e){let n=$t(t,pt(e,"--baseline"));return n||process.stderr.write(`gruum: ${_e}
110
- `),n}function Kt(t,e,n){let s={...e,checkedAt:new Date().toISOString(),baselineVersion:n.baseline.version,items:n.items};return Rn(t,s),s}async function hc(t){let e=Pt(t);await Ae(e,U(t,"--baseline"));let n=co(e,t);if(!n)return 0;let s=kt(e,n,{staged:U(t,"--staged")});U(t,"--staged")||Kt(e,Ce(e),s);let r=(t.flags.get("--files")??[]).map(l=>T.relative(T.join(e.repoDir,e.root),T.resolve(l)).split(T.sep).join("/")),o=Ne(s.items,r),i=Se(e);(U(t,"--ci")||U(t,"--report"))&&await so(e,o,n.version,U(t,"--ci")?"ci":"local"),U(t,"--json")?process.stdout.write(`${JSON.stringify({baselineVersion:n.version,items:o,exceptions:i},null,2)}
111
- `):process.stdout.write(`${Jn(o,{baselineVersion:n.version,files:s.result.index.files,skipped:s.result.index.skipped},i)}
112
- `);let a=Nt(o,i);if(U(t,"--strict")){let l=o.some(c=>c.severity==="block"&&i[c.id]==="pending");return a.length>0||l?1:0}if(U(t,"--ci")&&a.length===0){let l=o.filter(c=>i[c.id]==="pending");l.length>0&&process.stdout.write(`${l.length} pending exception${l.length===1?"":"s"}; this run does not fail on them.
113
- `)}return a.length>0?1:0}async function bc(t){let e=Pt(t);await Ae(e,U(t,"--baseline"));let n=co(e,t);return n?(process.stdout.write(`${JSON.stringify(Oe(n),null,2)}
114
- `),0):1}function yc(t){if(!U(t,"--write"))return process.stderr.write(`gruum: pass --write to draft a local spec from the working tree.
115
- `),2;let e=Pt(t),n=we(e),s=Hn(n,{version:0}),r=pt(t,"--out")?T.resolve(pt(t,"--out")):Ht(e);return vt(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.
116
- Wrote ${T.relative(process.cwd(),r)||r}.
117
- `),0}function ao(t,e,n,s){if(!n.ok)return process.stderr.write(`gruum: ${n.error}
118
- `),!1;if(!n.changed)return s.push(`unchanged ${e}`),!0;let r=T.join(t.repoDir,e);return n.text===""?(Ln(r,{force:!0}),s.push(`removed ${e}`)):(wt(r,n.text),s.push(`wrote ${e}`)),!0}function xc(t){if(t.positional[1]!=="cursor")return process.stderr.write(`gruum: usage: gruum init cursor [--remove] [--force] [--cli "<command>"]
119
- `),2;let e=Pt(t),n=pt(t,"--cli")??Tt,s=U(t,"--remove"),r=$=>ve(T.join(e.repoDir,$)),o=[],i=s?ss(r(".cursor/hooks.json")):ns(r(".cursor/hooks.json"),n),a=s?os(r(".cursor/mcp.json")):rs(r(".cursor/mcp.json"),n);for(let $ of[i,a])if(!$.ok)return process.stderr.write(`gruum: ${$.error}
120
- `),1;ao(e,".cursor/hooks.json",i,o),ao(e,".cursor/mcp.json",a,o);let l=r(ft);if(s)l!==null&&cs(l)&&(Ln(T.join(e.repoDir,ft)),o.push(`removed ${ft}`));else if(l===null||U(t,"--force")){let $=$t(e,pt(t,"--baseline")),g=as($?null:kc(e)),p=$?[...new Set($.styles.map(d=>d.path))].sort():[];wt(T.join(e.repoDir,ft),ls(p.length?p:g)),o.push(`wrote ${ft}`)}else o.push(`kept ${ft} (exists; --force replaces it)`);let c=s?ps(r(".gitignore")):us(r(".gitignore"));c.changed&&(wt(T.join(e.repoDir,".gitignore"),c.text),o.push("wrote .gitignore"));let u=Ee(T.join(e.repoDir,".husky")),f=["lefthook.yml","lefthook.yaml",".lefthook.yml"].some($=>Ee(T.join(e.repoDir,$))),m=Ur(e),b=u?".husky/pre-commit":m?`${m}/pre-commit`:null,k=b?T.resolve(e.repoDir,b):null,w=k?ve(k):null;if(s){if(k&&w!==null){let $=gs(w);$.changed&&$.text===""?(Ln(k,{force:!0}),o.push(`removed ${b}`)):$.changed&&(wt(k,$.text),o.push(`edited ${b}`))}}else{let $=fs({husky:u,lefthook:f,hookText:w,gitHooksDir:m},n);if($.kind==="print")o.push(`pre-commit ${$.reason}:
121
- ${$.snippet}`);else if($.changed&&k){if(wt(k,$.text),$.kind==="git")try{dc(k,493)}catch{}o.push(`wrote ${b}${$.kind==="git"?" (local only; not shared through git)":""}`)}else o.push(`unchanged ${b}`)}return process.stdout.write(`${o.join(`
109
+ `,wc=new Set(["--baseline","--root","--out","--cli","--files"]);function mo(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 wc.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=Sn(e),s=tt(t,"--root")??_n(n).root??"";return Sn(e,s)}var Kt="No spec found. Publish one from Gruum, or draft one locally with `npx @gruum/cli baseline --write`.";function vc(t,e){let n=ft(t,tt(e,"--baseline"));return n||process.stderr.write(`gruum: ${Kt}
110
+ `),n}function Jt(t,e,n){let s={...e,checkedAt:new Date().toISOString(),baselineVersion:n.baseline.version,items:n.items};return An(t,s),s}async function ho(t,e){let n=On({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.
111
+ `)}}finally{n.close()}}function $c(t){return!!process.stdin.isTTY&&!N(t,"--ci")&&!N(t,"--json")&&!N(t,"--staged")}async function bo(t,e=!1){let n=Pt(t);await _e(n,N(t,"--baseline"));let s=ft(n,tt(t,"--baseline"));if(!s){if(!e&&$c(t)){if(await ho(xs,ws)!=="baseline")return 0;let u=["baseline","--write"],f=tt(t,"--root");f&&u.push("--root",f);let m=yo(mo(u));return m!==0?m:bo(t,!0)}return process.stderr.write(`gruum: ${Kt}
112
+ `),0}let r=wt(n,s,{staged:N(t,"--staged")});N(t,"--staged")||Jt(n,Se(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=Ne(r.items,o),a=Re(n);(N(t,"--ci")||N(t,"--report"))&&await co(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)}
113
+ `):process.stdout.write(`${Xn(i,{baselineVersion:s.version,files:r.result.index.files,skipped:r.result.index.skipped},a)}
114
+ `);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.
115
+ `)}return l.length>0?1:0}async function Cc(t){let e=Pt(t);await _e(e,N(t,"--baseline"));let n=vc(e,t);return n?(process.stdout.write(`${JSON.stringify(Te(n),null,2)}
116
+ `),0):1}function yo(t){if(!N(t,"--write"))return process.stderr.write(`gruum: pass --write to draft a local spec from the working tree.
117
+ `),2;let e=Pt(t),n=ve(e),s=Jn(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.
118
+ Wrote ${V.relative(process.cwd(),r)||r}.
119
+ `),0}function go(t,e,n,s){if(!n.ok)return process.stderr.write(`gruum: ${n.error}
120
+ `),!1;if(!n.changed)return s.push(`unchanged ${e}`),!0;let r=V.join(t.repoDir,e);return n.text===""?(Pn(r,{force:!0}),s.push(`removed ${e}`)):(vt(r,n.text),s.push(`wrote ${e}`)),!0}function Sc(t){if(t.positional[1]!=="cursor")return process.stderr.write(`gruum: usage: gruum init cursor [--remove] [--force] [--cli "<command>"]
121
+ `),2;let e=Pt(t),n=tt(t,"--cli")??Nt,s=N(t,"--remove"),r=$=>$e(V.join(e.repoDir,$)),o=[],i=s?os(r(".cursor/hooks.json")):rs(r(".cursor/hooks.json"),n),a=s?as(r(".cursor/mcp.json")):is(r(".cursor/mcp.json"),n);for(let $ of[i,a])if(!$.ok)return process.stderr.write(`gruum: ${$.error}
122
+ `),1;go(e,".cursor/hooks.json",i,o),go(e,".cursor/mcp.json",a,o);let l=r(dt);if(s)l!==null&&ps(l)&&(Pn(V.join(e.repoDir,dt)),o.push(`removed ${dt}`));else if(l===null||N(t,"--force")){let $=ft(e,tt(t,"--baseline")),g=cs($?null:Rc(e)),p=$?[...new Set($.styles.map(d=>d.path))].sort():[];vt(V.join(e.repoDir,dt),us(p.length?p:g)),o.push(`wrote ${dt}`)}else o.push(`kept ${dt} (exists; --force replaces it)`);let c=s?ds(r(".gitignore")):fs(r(".gitignore"));c.changed&&(vt(V.join(e.repoDir,".gitignore"),c.text),o.push("wrote .gitignore"));let u=Ee(V.join(e.repoDir,".husky")),f=["lefthook.yml","lefthook.yaml",".lefthook.yml"].some($=>Ee(V.join(e.repoDir,$))),m=Zr(e),b=u?".husky/pre-commit":m?`${m}/pre-commit`:null,k=b?V.resolve(e.repoDir,b):null,w=k?$e(k):null;if(s){if(k&&w!==null){let $=hs(w);$.changed&&$.text===""?(Pn(k,{force:!0}),o.push(`removed ${b}`)):$.changed&&(vt(k,$.text),o.push(`edited ${b}`))}}else{let $=gs({husky:u,lefthook:f,hookText:w,gitHooksDir:m},n);if($.kind==="print")o.push(`pre-commit ${$.reason}:
123
+ ${$.snippet}`);else if($.changed&&k){if(vt(k,$.text),$.kind==="git")try{kc(k,493)}catch{}o.push(`wrote ${b}${$.kind==="git"?" (local only; not shared through git)":""}`)}else o.push(`unchanged ${b}`)}return process.stdout.write(`${o.join(`
122
124
  `)}
123
125
  `),s||process.stdout.write(`
124
126
  Commit the .cursor/ files so teammates get the same guardrails. Tokens never go in the repository.
125
- `),0}function kc(t){try{return we(t)}catch{return null}}async function wc(){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"&&Ee(e[0])?e[0]:typeof t.cwd=="string"&&Ee(t.cwd)?t.cwd:process.cwd();return Pt({positional:[],flags:new Map},n)}async function $c(t){let e=t.positional[1],n=await wc(),s=e==="before-shell"?{permission:"allow"}:{};try{let r=vc(n),o=An(r),i={...o.hooks,exceptions:!0},a=$t(r),l=Ce(r),c=Se(r),u=s;if(e==="after-file-edit"){let f=typeof n.file_path=="string"?n.file_path:"",m=We(T.relative(r.repoDir,T.resolve(r.repoDir,f)).split(T.sep).join("/"),r.root);a&&m!==null&&ks(m)&&Kt(r,l,kt(r,a))}else if(e==="stop"){if(a){let f=Kt(r,l,kt(r,a)),m=Qn(f,n,i,c);Rn(r,m.ledger),u=m.output}}else if(e==="before-shell"){let f=typeof n.command=="string"?n.command:"",m=Ve(f).some(b=>o.hooks.denyGit.includes(b));if(a&&m){let b=Kt(r,l,kt(r,a));u=ts(b,n,i,c)}}else return process.stderr.write(`gruum: unknown hook ${String(e)}
127
+ `),0}function Rc(t){try{return ve(t)}catch{return null}}async function Ac(){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 _c(t){let e=t.workspace_roots,n=Array.isArray(e)&&typeof e[0]=="string"&&Ee(e[0])?e[0]:typeof t.cwd=="string"&&Ee(t.cwd)?t.cwd:process.cwd();return Pt({positional:[],flags:new Map},n)}async function Ec(t){let e=t.positional[1],n=await Ac(),s=e==="before-shell"?{permission:"allow"}:{};try{let r=_c(n),o=_n(r),i={...o.hooks,exceptions:!0},a=ft(r),l=Se(r),c=Re(r),u=s;if(e==="after-file-edit"){let f=typeof n.file_path=="string"?n.file_path:"",m=Ge(V.relative(r.repoDir,V.resolve(r.repoDir,f)).split(V.sep).join("/"),r.root);a&&m!==null&&Rs(m)&&Jt(r,l,wt(r,a))}else if(e==="stop"){if(a){let f=Jt(r,l,wt(r,a)),m=es(f,n,i,c);An(r,m.ledger),u=m.output}}else if(e==="before-shell"){let f=typeof n.command=="string"?n.command:"",m=Be(f).some(b=>o.hooks.denyGit.includes(b));if(a&&m){let b=Jt(r,l,wt(r,a));u=ns(b,n,i,c)}}else return process.stderr.write(`gruum: unknown hook ${String(e)}
126
128
  `),2;process.stdout.write(`${JSON.stringify(u)}
127
129
  `)}catch(r){process.stderr.write(`gruum hook ${e}: ${r instanceof Error?r.message:String(r)}
128
130
  `),process.stdout.write(`${JSON.stringify(s)}
129
- `)}return 0}async function Cc(t){let e=Pt(t),n=bs({spec:async()=>{let o=$t(e,pt(t,"--baseline"));return o?{text:JSON.stringify(Oe(o),null,2)}:{text:_e,isError:!0}},check:async o=>{let i=$t(e,pt(t,"--baseline"));if(!i)return{text:_e,isError:!0};let a=kt(e,i);Kt(e,Ce(e),a);let l=Ne(a.items,o);return{text:JSON.stringify({baselineVersion:i.version,blocking:Nt(l,Se(e)).length,items:l},null,2)}},request:async(o,i)=>{await Ae(e,!1);let a=$t(e);if(!a)return{text:_e,isError:!0};let c=kt(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 ro(e,c,i);return{text:u.text,isError:!u.ok}},status:async o=>{let i=await oo(e,o);return{text:i.text,isError:!i.ok}}}),s={name:"gruum",version:je},r=lo({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"}})}
130
- `);continue}let a=await ys(i,n,s);a&&process.stdout.write(`${JSON.stringify(a)}
131
- `)}return 0}async function Sc(){if(process.stdout.write(ms(je)),!process.stdin.isTTY)return process.stdout.write(`
131
+ `)}return 0}async function jc(t){let e=Pt(t),n=$s({spec:async()=>{let o=ft(e,tt(t,"--baseline"));return o?{text:JSON.stringify(Te(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,Se(e),a);let l=Ne(a.items,o);return{text:JSON.stringify({baselineVersion:i.version,blocking:Tt(l,Re(e)).length,items:l},null,2)}},request:async(o,i)=>{await _e(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 uo(e,c,i);return{text:u.text,isError:!u.ok}},status:async o=>{let i=await po(e,o);return{text:i.text,isError:!i.ok}}}),s={name:"gruum",version:Ie},r=On({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"}})}
132
+ `);continue}let a=await Cs(i,n,s);a&&process.stdout.write(`${JSON.stringify(a)}
133
+ `)}return 0}async function Ic(){if(process.stdout.write(bs(Ie)),!process.stdin.isTTY)return process.stdout.write(`
132
134
  ${St.map(n=>n.usage).join(`
133
135
  `)}
134
- `),0;let t=lo({input:process.stdin,output:process.stdout}),e=null;try{for(;;){let n=await new Promise(s=>{t.question("Choose 1\u20133, or press Enter to quit: ",s)});if(e=hs(n),e==="quit"||e)break;process.stdout.write(`Enter 1, 2, or 3.
135
- `)}}finally{t.close()}return!e||e==="quit"?0:uo([e.name,...e.args])}async function uo(t){let e=mc(t),n=e.positional[0];if(U(e,"--version"))return process.stdout.write(`${je}
136
- `),0;if(U(e,"--help")||n==="help")return process.stdout.write(io),0;switch(n){case"login":return eo();case"check":return hc(e);case"spec":return bc(e);case"baseline":return yc(e);case"init":return xc(e);case"hook":return $c(e);case"mcp":return Cc(e);case void 0:return Sc();default:return process.stderr.write(`gruum: unknown command ${n}
136
+ `),0;let t=On({input:process.stdin,output:process.stdout}),e=null;try{for(;;){let n=await new Promise(s=>{t.question("Choose 1\u20133, or press Enter to quit: ",s)});if(e=vs(n),e==="quit"||e)break;process.stdout.write(`Enter 1, 2, or 3.
137
+ `)}}finally{t.close()}return!e||e==="quit"?0:je([e.name,...e.args])}async function je(t){let e=mo(t),n=e.positional[0];if(N(e,"--version"))return process.stdout.write(`${Ie}
138
+ `),0;if(N(e,"--help")||n==="help")return process.stdout.write(fo),0;switch(n){case"login":{let s=await ao();if(s!==0||!process.stdin.isTTY)return s;let r=await ho(ys,ks);return r==="check"?je(["check"]):r==="baseline"?je(["baseline","--write"]):0}case"check":return bo(e);case"spec":return Cc(e);case"baseline":return yo(e);case"init":return Sc(e);case"hook":return Ec(e);case"mcp":return jc(e);case void 0:return Ic();default:return process.stderr.write(`gruum: unknown command ${n}
137
139
 
138
- ${io}`),2}}uo(process.argv.slice(2)).then(t=>{process.exitCode=t},t=>{process.stderr.write(`gruum: ${t instanceof Error?t.message:String(t)}
140
+ ${fo}`),2}}je(process.argv.slice(2)).then(t=>{process.exitCode=t},t=>{process.stderr.write(`gruum: ${t instanceof Error?t.message:String(t)}
139
141
  `),process.exitCode=1});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gruum/cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
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": {