@gruum/cli 0.1.19 → 0.1.20

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 +95 -95
  2. package/package.json +1 -1
package/gruum.mjs CHANGED
@@ -1,124 +1,124 @@
1
1
  #!/usr/bin/env node
2
- import{chmodSync as ru,existsSync as Te,rmSync as Gn}from"node:fs";import D from"node:path";import{createInterface as Hn}from"node:readline";function Be(e){return e instanceof Error&&e.name==="AbortError"&&(e.message==="Aborted with Ctrl+C"||e.message==="Aborted with Ctrl+D")}function Ae(e){e.on("SIGINT",()=>{process.stderr.write(`
3
- `),process.exit(130)})}var ei=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"]),ti=new Set(["page","index","layout","route","default"]);function ni(e){return ei.has(e.property)||/^(margin|transition|grid-)/.test(e.property)?!0:(e.property==="width"||e.property==="height")&&/^(100%|auto)$/.test(e.value)}function Fe(e){return e.flatMap(t=>t.declarations.filter(n=>!ni(n)).map(n=>`${t.state}|${t.context}|${n.property}:${n.value}`)).sort().join(";")}function si(e){return Fe(e.states)}function ri(e){return e.states.filter(t=>t.state==="default"&&t.context==="").flatMap(t=>t.declarations)}function Yn(e){return e.charAt(0).toUpperCase()+e.slice(1)}function oi(e){let t=e.via?/^bg-([\w-]+?)(?:\/(\d+))?$/.exec(e.via):null;if(t){let s=t[1].replace(/-/g," ");return Yn(t[2]?`${s} ${t[2]}%`:s)}let n=/var\(\s*--(?:color-)?([\w-]+)/.exec(e.value)?.[1];return Yn((n??e.value).replace(/-/g," "))}function ii(e){let t=ri(e),n=u=>t.findLast(f=>f.property===u),s=n("background-color")??n("background"),r=s!==void 0&&!/^(transparent|none|initial|inherit)\b/.test(s.value),o=n("border-width")?.value,i=o!==void 0&&!/^0(px)?$/.test(o)&&n("border-style")?.value!=="none",a=n("width")?.value,l=a!==void 0&&a===n("height")?.value&&!/^(auto|100%|fit-content)$/.test(a);return n("inset")?.value==="0"?"Overlay":i?l?"Outline icon":"Outline":r?`${oi(s)} ${l?"icon":"fill"}`:l?"Icon":t.some(u=>u.property.startsWith("padding")||u.property==="border-radius"||u.property==="height"&&u.value!=="auto")?"Ghost":"Text"}function ai(e){let t=e.split("/"),n=(t.pop()??e).replace(/\.[^.]+$/,""),s=t.pop();return ti.has(n)&&s?`${s}/${n}`:n}function li(e){let t=[...new Set(e.map(s=>ai(s.path)))],n=t.slice(0,2).join(", ");return t.length>2?`${n} +${t.length-2}`:n}var Qn=(e,t)=>e.path.localeCompare(t.path)||e.line-t.line;function es(e){let t=new Map;for(let r of e){let o=ii(r.variant),i=t.get(o)??new Map,a=si(r.variant),l=i.get(a)??{looks:[],sites:[]};l.looks.push(r.variant),l.sites.push(...r.sites),i.set(a,l),t.set(o,i)}let n=[],s=new Map;for(let[r,o]of t){let i=[...o.values()];for(let h of i)h.sites.sort(Qn);i.sort((h,$)=>$.sites.length-h.sites.length||Qn(h.sites[0],$.sites[0]));let[a,...l]=i,c=a.looks[0],u=l.map(h=>li(h.sites)),f=l.map((h,$)=>{let k=h.looks[0],g={title:u.filter(p=>p===u[$]).length>1?`${u[$]} \xB7 line ${h.sites[0].line}`:u[$],selector:k.selector,path:h.sites[0].path,line:h.sites[0].line,element:k.element,usage:k.usage,states:k.states,alike:!0};return s.set(g,h.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 ss=1,rs=["style.new","state.changed","state.missing","token.unknown","value.hardcoded","native.element","prop.unknown","style.removed","guidance.rule"],Bt={"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 Ft(e){let t=0;for(let n=0;n<e.length;n++)t=t*33+e.charCodeAt(n)>>>0;return t.toString(36)}function ts(e){let t=`${e.path}::${e.selector}`;return`v2-style-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48)}-${Ft(t)}`}function ae(e){return e.context?`${e.state} @ ${e.context}`:e.state}var ci=/var\(\s*(--[\w-]+)/g;function ui(e){let t=new Set;for(let n of e)for(let s of n.declarations)for(let r of s.value.matchAll(ci))t.add(r[1]);return[...t].sort()}function pi(e){let t=new Map;for(let n of e)t.set(n.property,n.value.trim());return[...t].map(([n,s])=>({property:n,value:s})).sort((n,s)=>n.property.localeCompare(s.property))}function fi(e){let t=new Map;for(let n of e){let s=ae(n),r=t.get(s),o=pi([...r?.declarations??[],...n.declarations]);t.set(s,{state:n.state,context:n.context,declarations:o})}return[...t.values()]}function os(e){let t=new Map,n=(s,r,o)=>{let i=ts(s),a=t.get(i),l=fi([...a?di(a.states):[],...r]),c=a?.stateLines??new Map;for(let u of r)c.has(ae(u))||c.set(ae(u),u.line);t.set(i,{...a??s,id:i,states:l,tokens:ui(l),line:a?.line??o,stateLines:c})};for(let s of e){let r=ts(s);n({kind:"look",title:s.title,selector:s.selector,path:s.path,axis:s.axis,...s.usage.via?{selectedBy:s.usage.via}:{},...s.element?{element:s.element.tag}:{},...s.markup?{markup:!0}:{}},s.states,s.line);for(let o of s.modifiers??[])n({kind:"modifier",title:`${s.title} \xB7 ${o.title}`,selector:o.selector,path:o.path,hostId:r,...o.usage.via?{selectedBy:o.usage.via}:{},...o.element?{element:o.element.tag}:{},...o.alike?{markup:!0}:{}},o.states,o.line);for(let o of s.contexts??[])n({kind:"context",title:`${s.title} in ${o.selector}`,selector:o.selector,path:o.path,hostId:r,role:o.role,...o.element?{element:o.element.tag}:{}},o.states,o.line)}return t}function di(e){return e.map(t=>({state:t.state,context:t.context,line:0,declarations:t.declarations}))}function gi(e){let t=new Map,n=/^:root\{([^}]*)\}/.exec(e);if(!n)return t;for(let s of n[1].split(";")){let r=s.indexOf(":");if(r<=0)continue;let o=s.slice(0,r).trim();o.startsWith("--")&&t.set(o,s.slice(r+1).trim())}return t}var ns=/^(\d+) native /;function mi(e,t){if(e==="native")return`native:${t.refs[0]?.path??""}`;if(t.styles?.length){let n=[...new Set(t.refs.map(s=>s.path))].sort().join(",");return`${e}:${[...t.styles].sort().join(",")}:${n}`}return`${e}:${t.refs.map(n=>n.path).join(",")}:${t.message}`}var nt={hardcoded:"value.hardcoded",native:"native.element",props:"prop.unknown"},hi=new Set(Object.values(nt));var bi={"value.hardcoded":()=>"Replace each literal with the spec token named, or with a spec token for that property.","native.element":e=>`Render ${e.components[0]??"the shared component"} instead of a raw <button>, or ask for an exception.`,"prop.unknown":()=>"Use one of the values listed, or ask for an exception to add the look."};function is(e){let t=[];for(let n of e.audit)if(n.status==="attention")for(let s of n.findings)t.push({check:n.id,finding:s,key:mi(n.id,s)});return t}function Tt(e){return`${e.path}#${Ft(e.text.replace(/\s+/g," ").trim())}`}function as(e,t={}){let n=gi(e.previewCss),s=[...os(e.variants).values()].map(({line:i,stateLines:a,...l})=>l),r=new Set(e.tokens.map(i=>i.name)),o=[];for(let i of e.guidance.files)if(i.kind!=="record")for(let a of i.passages)a.rule&&o.push({path:a.path,headings:a.headings,text:a.text,styles:a.styles});return{schema:ss,concept:e.concept,label:e.label,version:t.version??0,sourceRef:e.repo.ref,publishedAt:t.publishedAt??null,components:[...e.components].sort(),tokens:[...new Set([...e.tokens.map(i=>i.name),...s.flatMap(i=>i.tokens).filter(i=>!r.has(i))])].map(i=>{let a=n.get(i);return a===void 0?{name:i}:{name:i,value:a}}).sort((i,a)=>i.name.localeCompare(a.name)),styles:s,rules:o,content:e.content.map(i=>i.id),acceptedFindings:is(e).filter(({check:i})=>i in nt).map(({check:i,finding:a,key:l})=>({check:i,key:l,message:a.message})),settings:{severity:{...Bt,...t.settings?.severity??{}}}}}function yi(e,t){let n=new Map(e.map(o=>[o.property,o.value])),s=new Map(t.map(o=>[o.property,o.value])),r=[];for(let[o,i]of s){let a=n.get(o);a===void 0?r.push(`added ${o}: ${i}`):a!==i&&r.push(`${o}: ${a} \u2192 ${i}`)}for(let[o,i]of n)s.has(o)||r.push(`removed ${o}: ${i}`);return r}function Vt(e){return e.map(t=>`${t.property}: ${t.value}`).join("; ")}function Dt(e,t){return e.length>t?`${e.slice(0,t).join(", ")}, and ${e.length-t} more`:e.join(", ")}function xi(e,t){let n=e.replace(/^--/,"").split("-")[0]??"",s=n?t.filter(r=>r.startsWith(`--${n}`)):[];return(s.length?s:t).slice(0,3)}function ls(e,t){let n={...Bt,...t.settings.severity},s=[],r=(p,d="")=>{s.push({id:`${p.kind}:${Ft(`${p.styleId??""}|${p.state??""}|${d}`)}`,severity:n[p.kind],...p})},o=os(e.variants),i=new Map(t.styles.map(p=>[p.id,p])),a=t.styles.filter(p=>p.kind==="look"),l=new Set([...t.tokens.map(p=>p.name),...t.styles.flatMap(p=>p.tokens)]),c=[...l],u=new Map;for(let p of t.styles)p.markup&&u.set(Fe(p.states),p);let f=new Map;for(let p of o.values()){if(!p.markup)continue;let d=u.get(Fe(p.states));d&&f.set(p.id,d)}let m=new Set([...f.values()].map(p=>p.id)),h=p=>p.markup?`${p.title} (as in ${p.path})`:p.selector;for(let p of o.values()){if(i.has(p.id)||f.has(p.id))continue;let d=p.hostId?i.get(p.hostId):void 0,y=p.markup?a.filter(I=>I.markup):a,v=y.filter(I=>I.path===p.path),x=(v.length?v:y).map(h),C=p.markup?`This one-off ${p.element??"button"} (${Dt((p.states[0]?.declarations??[]).map(I=>`${I.property}: ${I.value}`),3)})`:p.selector,j=p.markup?t.components.length?`render ${t.components[0]} with a spec look,`:x.length?`copy ${Dt(x,3)},`:"use a spec style,":d?`restyle ${d.selector} only through spec modifiers`:x.length?`use ${Dt(x,3)},`:"use a spec style,";r({kind:"style.new",styleId:p.id,title:`${p.title} is not in the spec`,baseline:null,observed:{declarations:p.states[0]?.declarations??[],states:p.states,...p.markup?{markup:!0}:{}},refs:[{path:p.path,line:p.line}],fix:`${C} is not in the spec; ${j} or ask for an exception.`},p.markup?Fe(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=>[ae(v),v]));for(let v of p.states){let x=ae(v),C=y.get(x),j=yi(C?.declarations??[],v.declarations);j.length!==0&&r({kind:"state.changed",styleId:p.id,title:C?`${p.title}: ${x} changed`:`${p.title}: new ${x} state`,state:x,baseline:C?{declarations:C.declarations}:null,observed:{declarations:v.declarations},refs:[{path:p.path,line:p.stateLines.get(x)??p.line}],fix:C?`Restore ${p.selector} ${x} to the spec (${j.slice(0,3).join("; ")}), or ask for an exception.`:`${x} is not a spec state of ${p.selector}; remove it, or ask for an exception.`},Vt(v.declarations))}}for(let p of o.values()){let d=i.get(p.id);if(!d)continue;let y=new Set(p.states.map(ae));for(let v of d.states){let x=ae(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: ${Vt(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=xi(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 $=new Map;for(let p of t.acceptedFindings)$.set(p.key,[...$.get(p.key)??[],p]);let k=is(e).filter(({check:p})=>p in nt);for(let p of rs)if(hi.has(p))for(let{check:d,finding:y,key:v}of k){if(nt[d]!==p)continue;let x=$.get(v)??[];if(x.some(A=>!wi(d,A.message,y.message)))continue;let C=x[0],j=y.styles?.[0],I=j?[...o.values()].find(A=>A.title===j):void 0;r({kind:p,styleId:I?.id??null,title:y.message,baseline:C?{message:C.message}:null,observed:{message:y.message,...p==="native.element"?{element:"button"}:{}},waiverKey:v,refs:y.refs.map(({path:A,line:R})=>({path:A,line:R})),fix:bi[p](t)},v)}for(let p of t.styles)o.has(p.id)||m.has(p.id)||r({kind:"style.removed",styleId:p.id,title:p.markup?`${p.title} is in the spec but no longer written anywhere`:`${p.title} is in the spec but no longer in CSS`,baseline:{declarations:p.states[0]?.declarations??[]},observed:null,refs:[{path:p.path,line:0}],fix:p.markup?`Nothing renders ${p.title} any more; ask the designer to retire it from the spec if that is intended.`:`Restore ${p.selector} in ${p.path}, or ask the designer to retire it from the spec.`});let w=new Map(e.guidance.files.map(p=>[p.path,p])),g=new Set;for(let p of e.guidance.files)for(let d of p.passages)d.rule&&g.add(Tt(d));for(let p of t.rules){if(g.has(Tt(p)))continue;let d=w.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.`},Tt(p))}return s}function wi(e,t,n){if(t===n)return!1;if(e==="native"){let s=ns.exec(t)?.[1],r=ns.exec(n)?.[1];if(s&&r)return Number(r)>Number(s)}return!0}var ki={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 Ut(e){let t=(n,s)=>e.styles.filter(r=>r.hostId===n&&r.kind===s).map(r=>r.selector);return{about:{...ki,drift:rs.map(n=>({kind:n,severity:e.settings.severity[n]??Bt[n]}))},spec:{concept:e.concept,version:e.version,sourceRef:e.sourceRef,components:e.components,looks:e.styles.filter(n=>n.kind==="look").map(n=>({title:n.title,selector:n.selector,path:n.path,...n.selectedBy?{selectedBy:n.selectedBy}:{},tokens:n.tokens,states:Object.fromEntries(n.states.map(s=>[ae(s),Vt(s.declarations)])),modifiers:t(n.id,"modifier"),contexts:t(n.id,"context")})),tokens:e.tokens,rules:e.rules.map(n=>({path:n.path,under:n.headings.join(" \u203A "),text:n.text}))}}}function Ue(e){if(!e||typeof e!="object")return null;let t=e;return t.schema!==ss||typeof t.concept!="string"||!Array.isArray(t.styles)||!Array.isArray(t.tokens)||!Array.isArray(t.acceptedFindings)||!Array.isArray(t.rules)||!t.settings?.severity?null:t}function vi(e){let t=new Map;for(let n of e){let s=n.refs[0]?.path??"(no file)";t.set(s,[...t.get(s)??[],n])}return[...t].sort(([n],[s])=>n.localeCompare(s))}function zt(e,t){if(t.length===0)return e;let n=new Set(t.map(s=>s.replace(/^\.\//,"")));return e.filter(s=>s.refs.some(r=>n.has(r.path)))}function cs(e,t,n={}){let s=[];if(e.length===0)return s.push(`No drift against spec v${t.baselineVersion} (${t.files} files indexed, ${t.skipped} skipped).`),s.join(`
4
- `);for(let[o,i]of vi(e)){s.push(o);for(let a of i){let l=a.refs[0]?.line,c=n[a.id],u=c?`${a.severity}, exception ${c}`:a.severity;s.push(` ${l?`${l}: `:""}[${u}] ${a.kind} ${a.title}`),s.push(` fix: ${a.fix}`)}s.push("")}let r=e.filter(o=>o.severity==="block").length;return s.push(`${e.length} drift item${e.length===1?"":"s"} against spec v${t.baselineVersion}: ${r} block, ${e.length-r} warn (${t.files} files indexed, ${t.skipped} skipped).`),s.join(`
5
- `)}function us(e){return{schema:1,checkedAt:e,baselineVersion:null,items:[],followups:{}}}function ps(e,t){if(!e||typeof e!="object")return us(t);let n=e;return n.schema!==1||!Array.isArray(n.items)?us(t):{schema:1,checkedAt:typeof n.checkedAt=="string"?n.checkedAt:t,baselineVersion:typeof n.baselineVersion=="number"?n.baselineVersion:null,items:n.items,followups:n.followups&&typeof n.followups=="object"?n.followups:{}}}function ze(e,t={}){return e.filter(n=>{if(n.severity!=="block")return!1;let s=t[n.id];return s!=="pending"&&s!=="accepted"})}var _e={exceptions:!1,denyGit:["commit","push"],maxFollowups:2},Wt=8;function fs(e){let t=e.slice(0,Wt).map(n=>{let s=n.refs[0],r=s?` (${s.path}${s.line?`:${s.line}`:""})`:"";return`- ${n.title}${r}. ${n.fix}`});return e.length>Wt&&t.push(`- and ${e.length-Wt} more; run \`gruum check\`.`),t.join(`
6
- `)}function ds(e){return e.exceptions?"Fix each to the spec (call gruum_button_spec), or call gruum_request_exception with a reason when the spec has no button for the job.":"Fix each to the spec (call gruum_button_spec). If the spec has no button for the job, stop and tell the developer which exception you need; do not invent a style."}function gs(e,t,n=_e,s={}){let r=ze(e.items,s),o=t.conversation_id??"",i=typeof t.loop_count=="number"?t.loop_count:e.followups[o]??0;return r.length===0||t.status==="aborted"?{output:{},ledger:e}:i>=n.maxFollowups?{output:{},ledger:e}:{output:{followup_message:`Gruum found ${r.length} button${r.length===1?"":"s"} that drift from the published spec:
7
- ${fs(r)}
2
+ import{chmodSync as lu,existsSync as Te,rmSync as Zn}from"node:fs";import T from"node:path";import{createInterface as Xn}from"node:readline";function Be(e){return e instanceof Error&&e.name==="AbortError"&&(e.message==="Aborted with Ctrl+C"||e.message==="Aborted with Ctrl+D")}function Ae(e){e.on("SIGINT",()=>{process.stderr.write(`
3
+ `),process.exit(130)})}var ri=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"]),oi=new Set(["page","index","layout","route","default"]);function ii(e){return ri.has(e.property)||/^(margin|transition|grid-)/.test(e.property)?!0:(e.property==="width"||e.property==="height")&&/^(100%|auto)$/.test(e.value)}function Ve(e){return e.flatMap(t=>t.declarations.filter(n=>!ii(n)).map(n=>`${t.state}|${t.context}|${n.property}:${n.value}`)).sort().join(";")}function ai(e){return Ve(e.states)}function li(e){return e.states.filter(t=>t.state==="default"&&t.context==="").flatMap(t=>t.declarations)}function ns(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ci(e){let t=e.via?/^bg-([\w-]+?)(?:\/(\d+))?$/.exec(e.via):null;if(t){let s=t[1].replace(/-/g," ");return ns(t[2]?`${s} ${t[2]}%`:s)}let n=/var\(\s*--(?:color-)?([\w-]+)/.exec(e.value)?.[1];return ns((n??e.value).replace(/-/g," "))}function ui(e){let t=li(e),n=p=>t.findLast(f=>f.property===p),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?`${ci(s)} ${l?"icon":"fill"}`:l?"Icon":t.some(p=>p.property.startsWith("padding")||p.property==="border-radius"||p.property==="height"&&p.value!=="auto")?"Ghost":"Text"}function pi(e){let t=e.split("/"),n=(t.pop()??e).replace(/\.[^.]+$/,""),s=t.pop();return oi.has(n)&&s?`${s}/${n}`:n}function fi(e){let t=[...new Set(e.map(s=>pi(s.path)))],n=t.slice(0,2).join(", ");return t.length>2?`${n} +${t.length-2}`:n}var ss=(e,t)=>e.path.localeCompare(t.path)||e.line-t.line;function rs(e){let t=new Map;for(let r of e){let o=ui(r.variant),i=t.get(o)??new Map,a=ai(r.variant),l=i.get(a)??{looks:[],sites:[]};l.looks.push(r.variant),l.sites.push(...r.sites),i.set(a,l),t.set(o,i)}let n=[],s=new Map;for(let[r,o]of t){let i=[...o.values()];for(let h of i)h.sites.sort(ss);i.sort((h,C)=>C.sites.length-h.sites.length||ss(h.sites[0],C.sites[0]));let[a,...l]=i,c=a.looks[0],p=l.map(h=>fi(h.sites)),f=l.map((h,C)=>{let w=h.looks[0],d={title:p.filter(u=>u===p[C]).length>1?`${p[C]} \xB7 line ${h.sites[0].line}`:p[C],selector:w.selector,path:h.sites[0].path,line:h.sites[0].line,element:w.element,usage:w.usage,states:w.states,alike:!0};return s.set(d,h.sites),d}),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 as=1,ls=["style.new","state.changed","state.missing","token.unknown","value.hardcoded","native.element","prop.unknown","style.removed","guidance.rule"],Bt={"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 Vt(e){let t=0;for(let n=0;n<e.length;n++)t=t*33+e.charCodeAt(n)>>>0;return t.toString(36)}function os(e){let t=`${e.path}::${e.selector}`;return`v2-style-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48)}-${Vt(t)}`}function le(e){return e.context?`${e.state} @ ${e.context}`:e.state}var di=/var\(\s*(--[\w-]+)/g;function gi(e){let t=new Set;for(let n of e)for(let s of n.declarations)for(let r of s.value.matchAll(di))t.add(r[1]);return[...t].sort()}function mi(e){let t=new Map;for(let n of e)t.set(n.property,n.value.trim());return[...t].map(([n,s])=>({property:n,value:s})).sort((n,s)=>n.property.localeCompare(s.property))}function hi(e){let t=new Map;for(let n of e){let s=le(n),r=t.get(s),o=mi([...r?.declarations??[],...n.declarations]);t.set(s,{state:n.state,context:n.context,declarations:o})}return[...t.values()]}function cs(e){let t=new Map,n=(s,r,o)=>{let i=os(s),a=t.get(i),l=hi([...a?bi(a.states):[],...r]),c=a?.stateLines??new Map;for(let p of r)c.has(le(p))||c.set(le(p),p.line);t.set(i,{...a??s,id:i,states:l,tokens:gi(l),line:a?.line??o,stateLines:c})};for(let s of e){let r=os(s);n({kind:"look",title:s.title,selector:s.selector,path:s.path,axis:s.axis,...s.usage.via?{selectedBy:s.usage.via}:{},...s.element?{element:s.element.tag}:{},...s.markup?{markup:!0}:{}},s.states,s.line);for(let o of s.modifiers??[])n({kind:"modifier",title:`${s.title} \xB7 ${o.title}`,selector:o.selector,path:o.path,hostId:r,...o.usage.via?{selectedBy:o.usage.via}:{},...o.element?{element:o.element.tag}:{},...o.alike?{markup:!0}:{}},o.states,o.line);for(let o of s.contexts??[])n({kind:"context",title:`${s.title} in ${o.selector}`,selector:o.selector,path:o.path,hostId:r,role:o.role,...o.element?{element:o.element.tag}:{}},o.states,o.line)}return t}function bi(e){return e.map(t=>({state:t.state,context:t.context,line:0,declarations:t.declarations}))}function yi(e){let t=new Map,n=/^:root\{([^}]*)\}/.exec(e);if(!n)return t;for(let s of n[1].split(";")){let r=s.indexOf(":");if(r<=0)continue;let o=s.slice(0,r).trim();o.startsWith("--")&&t.set(o,s.slice(r+1).trim())}return t}var is=/^(\d+) native /;function xi(e,t){if(e==="native")return`native:${t.refs[0]?.path??""}`;if(t.styles?.length){let n=[...new Set(t.refs.map(s=>s.path))].sort().join(",");return`${e}:${[...t.styles].sort().join(",")}:${n}`}return`${e}:${t.refs.map(n=>n.path).join(",")}:${t.message}`}var tt={hardcoded:"value.hardcoded",native:"native.element",props:"prop.unknown"},wi=new Set(Object.values(tt));var ki={"value.hardcoded":()=>"Replace each literal with the spec token named, or with a spec token for that property.","native.element":e=>`Render ${e.components[0]??"the shared component"} instead of a raw <button>, or ask for an exception.`,"prop.unknown":()=>"Use one of the values listed, or ask for an exception to add the look."};function us(e){let t=[];for(let n of e.audit)if(n.status==="attention")for(let s of n.findings)t.push({check:n.id,finding:s,key:xi(n.id,s)});return t}function Tt(e){return`${e.path}#${Vt(e.text.replace(/\s+/g," ").trim())}`}function ps(e,t={}){let n=yi(e.previewCss),s=[...cs(e.variants).values()].map(({line:i,stateLines:a,...l})=>l),r=new Set(e.tokens.map(i=>i.name)),o=[];for(let i of e.guidance.files)if(i.kind!=="record")for(let a of i.passages)a.rule&&o.push({path:a.path,headings:a.headings,text:a.text,styles:a.styles});return{schema:as,concept:e.concept,label:e.label,version:t.version??0,sourceRef:e.repo.ref,publishedAt:t.publishedAt??null,components:[...e.components].sort(),tokens:[...new Set([...e.tokens.map(i=>i.name),...s.flatMap(i=>i.tokens).filter(i=>!r.has(i))])].map(i=>{let a=n.get(i);return a===void 0?{name:i}:{name:i,value:a}}).sort((i,a)=>i.name.localeCompare(a.name)),styles:s,rules:o,content:e.content.map(i=>i.id),acceptedFindings:us(e).filter(({check:i})=>i in tt).map(({check:i,finding:a,key:l})=>({check:i,key:l,message:a.message})),settings:{severity:{...Bt,...t.settings?.severity??{}}}}}function vi(e,t){let n=new Map(e.map(o=>[o.property,o.value])),s=new Map(t.map(o=>[o.property,o.value])),r=[];for(let[o,i]of s){let a=n.get(o);a===void 0?r.push(`added ${o}: ${i}`):a!==i&&r.push(`${o}: ${a} \u2192 ${i}`)}for(let[o,i]of n)s.has(o)||r.push(`removed ${o}: ${i}`);return r}function Ft(e){return e.map(t=>`${t.property}: ${t.value}`).join("; ")}function Dt(e,t){return e.length>t?`${e.slice(0,t).join(", ")}, and ${e.length-t} more`:e.join(", ")}function $i(e,t){let n=e.replace(/^--/,"").split("-")[0]??"",s=n?t.filter(r=>r.startsWith(`--${n}`)):[];return(s.length?s:t).slice(0,3)}function fs(e,t){let n={...Bt,...t.settings.severity},s=[],r=(u,g="")=>{s.push({id:`${u.kind}:${Vt(`${u.styleId??""}|${u.state??""}|${g}`)}`,severity:n[u.kind],...u})},o=cs(e.variants),i=new Map(t.styles.map(u=>[u.id,u])),a=t.styles.filter(u=>u.kind==="look"),l=new Set([...t.tokens.map(u=>u.name),...t.styles.flatMap(u=>u.tokens)]),c=[...l],p=new Map;for(let u of t.styles)u.markup&&p.set(Ve(u.states),u);let f=new Map;for(let u of o.values()){if(!u.markup)continue;let g=p.get(Ve(u.states));g&&f.set(u.id,g)}let m=new Set([...f.values()].map(u=>u.id)),h=u=>u.markup?`${u.title} (as in ${u.path})`:u.selector;for(let u of o.values()){if(i.has(u.id)||f.has(u.id))continue;let g=u.hostId?i.get(u.hostId):void 0,y=u.markup?a.filter(I=>I.markup):a,k=y.filter(I=>I.path===u.path),x=(k.length?k:y).map(h),$=u.markup?`This one-off ${u.element??"button"} (${Dt((u.states[0]?.declarations??[]).map(I=>`${I.property}: ${I.value}`),3)})`:u.selector,j=u.markup?t.components.length?`render ${t.components[0]} with a spec look,`:x.length?`copy ${Dt(x,3)},`:"use a spec style,":g?`restyle ${g.selector} only through spec modifiers`:x.length?`use ${Dt(x,3)},`:"use a spec style,";r({kind:"style.new",styleId:u.id,title:`${u.title} is not in the spec`,baseline:null,observed:{declarations:u.states[0]?.declarations??[],states:u.states,...u.markup?{markup:!0}:{}},refs:[{path:u.path,line:u.line}],fix:`${$} is not in the spec; ${j} or ask for an exception.`},u.markup?Ve(u.states):u.selector)}for(let u of o.values()){let g=i.get(u.id);if(!g)continue;let y=new Map(g.states.map(k=>[le(k),k]));for(let k of u.states){let x=le(k),$=y.get(x),j=vi($?.declarations??[],k.declarations);j.length!==0&&r({kind:"state.changed",styleId:u.id,title:$?`${u.title}: ${x} changed`:`${u.title}: new ${x} state`,state:x,baseline:$?{declarations:$.declarations}:null,observed:{declarations:k.declarations},refs:[{path:u.path,line:u.stateLines.get(x)??u.line}],fix:$?`Restore ${u.selector} ${x} to the spec (${j.slice(0,3).join("; ")}), or ask for an exception.`:`${x} is not a spec state of ${u.selector}; remove it, or ask for an exception.`},Ft(k.declarations))}}for(let u of o.values()){let g=i.get(u.id);if(!g)continue;let y=new Set(u.states.map(le));for(let k of g.states){let x=le(k);y.has(x)||r({kind:"state.missing",styleId:u.id,title:`${u.title}: ${x} state is missing`,state:x,baseline:{declarations:k.declarations},observed:null,refs:[{path:u.path,line:u.line}],fix:`Define ${u.selector} ${x} again: ${Ft(k.declarations)||"as in the spec"}.`})}}for(let u of o.values())for(let g of u.tokens){if(l.has(g))continue;let y=$i(g,c);r({kind:"token.unknown",styleId:u.id,title:`${u.title} reads ${g}, which is not a spec token`,baseline:null,observed:{token:g},refs:[{path:u.path,line:u.line}],fix:y.length?`Use a spec token such as ${y.join(", ")} instead of ${g}, or ask for an exception.`:`${g} is not a spec token; ask for an exception to add it.`},g)}let C=new Map;for(let u of t.acceptedFindings)C.set(u.key,[...C.get(u.key)??[],u]);let w=us(e).filter(({check:u})=>u in tt);for(let u of ls)if(wi.has(u))for(let{check:g,finding:y,key:k}of w){if(tt[g]!==u)continue;let x=C.get(k)??[];if(x.some(A=>!Ci(g,A.message,y.message)))continue;let $=x[0],j=y.styles?.[0],I=j?[...o.values()].find(A=>A.title===j):void 0;r({kind:u,styleId:I?.id??null,title:y.message,baseline:$?{message:$.message}:null,observed:{message:y.message,...u==="native.element"?{element:"button"}:{}},waiverKey:k,refs:y.refs.map(({path:A,line:R})=>({path:A,line:R})),fix:ki[u](t)},k)}for(let u of t.styles)o.has(u.id)||m.has(u.id)||r({kind:"style.removed",styleId:u.id,title:u.markup?`${u.title} is in the spec but no longer written anywhere`:`${u.title} is in the spec but no longer in CSS`,baseline:{declarations:u.states[0]?.declarations??[]},observed:null,refs:[{path:u.path,line:0}],fix:u.markup?`Nothing renders ${u.title} any more; ask the designer to retire it from the spec if that is intended.`:`Restore ${u.selector} in ${u.path}, or ask the designer to retire it from the spec.`});let v=new Map(e.guidance.files.map(u=>[u.path,u])),d=new Set;for(let u of e.guidance.files)for(let g of u.passages)g.rule&&d.add(Tt(g));for(let u of t.rules){if(d.has(Tt(u)))continue;let g=v.get(u.path);g&&g.total>g.passages.length||r({kind:"guidance.rule",styleId:null,title:`A written rule in ${u.path} changed or was removed`,baseline:{text:u.text},observed:null,refs:[{path:u.path,line:0}],fix:`Restore the rule under ${u.headings.join(" \u203A ")||u.path}, or publish a new spec.`},Tt(u))}return s}function Ci(e,t,n){if(t===n)return!1;if(e==="native"){let s=is.exec(t)?.[1],r=is.exec(n)?.[1];if(s&&r)return Number(r)>Number(s)}return!0}var Si={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, stop and ask the user: "You asked for a design element that is not in the spec. 1. Use an existing spec style for it. 2. Add it as it is and request review." Do not write that look, and do not request a review, until they answer. Never edit generated Gruum files to make a check pass.']};function Ut(e){let t=(n,s)=>e.styles.filter(r=>r.hostId===n&&r.kind===s).map(r=>r.selector);return{about:{...Si,drift:ls.map(n=>({kind:n,severity:e.settings.severity[n]??Bt[n]}))},spec:{concept:e.concept,version:e.version,sourceRef:e.sourceRef,components:e.components,looks:e.styles.filter(n=>n.kind==="look").map(n=>({title:n.title,selector:n.selector,path:n.path,...n.selectedBy?{selectedBy:n.selectedBy}:{},tokens:n.tokens,states:Object.fromEntries(n.states.map(s=>[le(s),Ft(s.declarations)])),modifiers:t(n.id,"modifier"),contexts:t(n.id,"context")})),tokens:e.tokens,rules:e.rules.map(n=>({path:n.path,under:n.headings.join(" \u203A "),text:n.text}))}}}function Ue(e){if(!e||typeof e!="object")return null;let t=e;return t.schema!==as||typeof t.concept!="string"||!Array.isArray(t.styles)||!Array.isArray(t.tokens)||!Array.isArray(t.acceptedFindings)||!Array.isArray(t.rules)||!t.settings?.severity?null:t}function Ri(e){let t=new Map;for(let n of e){let s=n.refs[0]?.path??"(no file)";t.set(s,[...t.get(s)??[],n])}return[...t].sort(([n],[s])=>n.localeCompare(s))}function zt(e,t){if(t.length===0)return e;let n=new Set(t.map(s=>s.replace(/^\.\//,"")));return e.filter(s=>s.refs.some(r=>n.has(r.path)))}function ds(e,t,n={}){let s=[];if(e.length===0)return s.push(`No drift against spec v${t.baselineVersion} (${t.files} files indexed, ${t.skipped} skipped).`),s.join(`
4
+ `);for(let[o,i]of Ri(e)){s.push(o);for(let a of i){let l=a.refs[0]?.line,c=n[a.id],p=c?`${a.severity}, exception ${c}`:a.severity;s.push(` ${l?`${l}: `:""}[${p}] ${a.kind} ${a.title}`),s.push(` fix: ${a.fix}`)}s.push("")}let r=e.filter(o=>o.severity==="block").length;return s.push(`${e.length} drift item${e.length===1?"":"s"} against spec v${t.baselineVersion}: ${r} block, ${e.length-r} warn (${t.files} files indexed, ${t.skipped} skipped).`),s.join(`
5
+ `)}function gs(e){return{schema:1,checkedAt:e,baselineVersion:null,items:[],followups:{}}}function ms(e,t){if(!e||typeof e!="object")return gs(t);let n=e;return n.schema!==1||!Array.isArray(n.items)?gs(t):{schema:1,checkedAt:typeof n.checkedAt=="string"?n.checkedAt:t,baselineVersion:typeof n.baselineVersion=="number"?n.baselineVersion:null,items:n.items,followups:n.followups&&typeof n.followups=="object"?n.followups:{}}}function ze(e,t={}){return e.filter(n=>{if(n.severity!=="block")return!1;let s=t[n.id];return s!=="pending"&&s!=="accepted"})}var _e={exceptions:!1,denyGit:["commit","push"],maxFollowups:2},Wt=8;function hs(e){let t=e.slice(0,Wt).map(n=>{let s=n.refs[0],r=s?` (${s.path}${s.line?`:${s.line}`:""})`:"";return`- ${n.title}${r}. ${n.fix}`});return e.length>Wt&&t.push(`- and ${e.length-Wt} more; run \`gruum check\`.`),t.join(`
6
+ `)}var Gt="You asked for a design element that is not in the spec. 1. Use an existing spec style for it. 2. Add it as it is and request review.";function bs(e){let t="If that tool is not available, read .gruum/baseline.json. Do not run npx or search the computer for a gruum program.",n=`Ask the user before you do anything else: "${Gt}" If they choose 1, restyle it to a spec look (call gruum_button_spec).`;return e.exceptions?`${n} If they choose 2, keep it and call gruum_request_exception with a reason. Do not request a review until they choose 2. ${t}`:`${n} If they choose 2, stop and tell the developer which review you need. Do not invent a style. ${t}`}function ys(e,t,n=_e,s={}){let r=ze(e.items,s),o=t.conversation_id??"",i=typeof t.loop_count=="number"?t.loop_count:e.followups[o]??0;return r.length===0||t.status==="aborted"?{output:{},ledger:e}:i>=n.maxFollowups?{output:{},ledger:e}:{output:{followup_message:`Gruum found ${r.length} button${r.length===1?"":"s"} that drift from the published spec:
7
+ ${hs(r)}
8
8
 
9
- ${ds(n)}`},ledger:{...e,followups:{...e.followups,[o]:i+1}}}}function Gt(e){let t=[];for(let n of e.split(/&&|\|\||[;|\n]/)){let s=n.trim().split(/\s+/).filter(Boolean),r=0;for(;r<s.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(s[r]);)r++;if((s[r]==="command"||s[r]==="exec")&&r++,!!/(^|\/)git$/.test(s[r]??"")){for(r++;r<s.length&&s[r].startsWith("-");){let o=s[r];r+=/^(-C|-c|--git-dir|--work-tree|--namespace)$/.test(o)?2:1}s[r]&&t.push(s[r])}}return t}function ms(e,t,n=_e,s={}){let r=Gt(t.command??"").filter(i=>n.denyGit.includes(i));if(r.length===0)return{permission:"allow"};let o=ze(e.items,s);return o.length===0?{permission:"allow"}:{permission:"deny",user_message:`Gruum blocked git ${r[0]}: ${o.length} button drift item${o.length===1?"":"s"} against the spec. Run \`gruum check\` for details.`,agent_message:`git ${r[0]} is blocked until button drift is resolved:
10
- ${fs(o)}
9
+ ${bs(n)}`},ledger:{...e,followups:{...e.followups,[o]:i+1}}}}function Ht(e){let t=[];for(let n of e.split(/&&|\|\||[;|\n]/)){let s=n.trim().split(/\s+/).filter(Boolean),r=0;for(;r<s.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(s[r]);)r++;if((s[r]==="command"||s[r]==="exec")&&r++,!!/(^|\/)git$/.test(s[r]??"")){for(r++;r<s.length&&s[r].startsWith("-");){let o=s[r];r+=/^(-C|-c|--git-dir|--work-tree|--namespace)$/.test(o)?2:1}s[r]&&t.push(s[r])}}return t}function xs(e,t,n=_e,s={}){let r=Ht(t.command??"").filter(i=>n.denyGit.includes(i));if(r.length===0)return{permission:"allow"};let o=ze(e.items,s);return o.length===0?{permission:"allow"}:{permission:"deny",user_message:`Gruum blocked git ${r[0]}: ${o.length} button drift item${o.length===1?"":"s"} against the spec. Run \`gruum check\` for details.`,agent_message:`git ${r[0]} is blocked until button drift is resolved:
10
+ ${hs(o)}
11
11
 
12
- ${ds(n)}`}}var We="npx --no-install @gruum/cli",hs={afterFileEdit:"after-file-edit",stop:"stop",beforeShellExecution:"before-shell"},$i=/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+hook\s+(after-file-edit|stop|before-shell)\s*$/;function Ht(e){return typeof e=="string"&&$i.test(e)}function st(e,t){if(e===null||e.trim()==="")return{ok:!0,value:{}};try{let n=JSON.parse(e);return!n||typeof n!="object"||Array.isArray(n)?{ok:!1,error:`${t} is not a JSON object; fix it or move it aside, then run init again.`}:{ok:!0,value:n}}catch{return{ok:!1,error:`${t} is not valid JSON; fix it or move it aside, then run init again.`}}}function rt(e){return`${JSON.stringify(e,null,2)}
13
- `}function bs(e,t){let n=Kt(e),s=Jt(t);return!n.ok||!s.ok?!1:n.changed||s.changed}function Kt(e,t=We){let n=".cursor/hooks.json",s=st(e,n);if(!s.ok)return s;let r=s.value;if(r.hooks!==void 0&&(typeof r.hooks!="object"||Array.isArray(r.hooks)||r.hooks===null))return{ok:!1,error:`${n} has a "hooks" value that is not an object.`};let o={...r.hooks??{}},i=e===null||e.trim()==="";for(let a of Object.keys(hs)){let l=o[a]??[];if(!Array.isArray(l))return{ok:!1,error:`${n} has a "${a}" value that is not an array.`};let c=`${t} hook ${hs[a]}`,u=l.filter(f=>Ht(f?.command));u.length===1&&u[0].command===c||(o[a]=[...l.filter(f=>!Ht(f?.command)),{command:c}],i=!0)}return i?{ok:!0,text:rt({version:r.version??1,...r,hooks:o}),changed:!0}:{ok:!0,text:e,changed:!1}}function ys(e){let t=".cursor/hooks.json";if(e===null)return{ok:!0,text:"",changed:!1};let n=st(e,t);if(!n.ok)return n;let s=n.value,r={...s.hooks??{}},o=!1;for(let a of Object.keys(r)){let l=r[a];if(!Array.isArray(l))continue;let c=l.filter(u=>!Ht(u?.command));c.length!==l.length&&(o=!0,c.length?r[a]=c:delete r[a])}if(!o)return{ok:!0,text:e,changed:!1};let i=Object.keys(s).every(a=>a==="version"||a==="hooks");return Object.keys(r).length===0&&i?{ok:!0,text:"",changed:!0}:{ok:!0,text:rt({...s,hooks:r}),changed:!0}}function Ci(e){let[t,...n]=e.trim().split(/\s+/);return{command:t,args:[...n,"mcp"]}}function Jt(e,t=We){let n=".cursor/mcp.json",s=st(e,n);if(!s.ok)return s;let r=s.value,o=r.mcpServers??{};if(typeof o!="object"||Array.isArray(o)||o===null)return{ok:!1,error:`${n} has an "mcpServers" value that is not an object.`};let i=Ci(t),a=o.gruum;return JSON.stringify(a)===JSON.stringify(i)?{ok:!0,text:e,changed:!1}:{ok:!0,text:rt({...r,mcpServers:{...o,gruum:i}}),changed:!0}}function xs(e){let t=".cursor/mcp.json";if(e===null)return{ok:!0,text:"",changed:!1};let n=st(e,t);if(!n.ok)return n;let s=n.value,r={...s.mcpServers??{}};return"gruum"in r?(delete r.gruum,Object.keys(r).length===0&&Object.keys(s).every(o=>o==="mcpServers")?{ok:!0,text:"",changed:!0}:{ok:!0,text:rt({...s,mcpServers:r}),changed:!0}):{ok:!0,text:e,changed:!1}}var me=".cursor/rules/gruum-buttons.mdc",ws="<!-- written by gruum init cursor -->",Si=20,Ri=["**/*.css","**/*.scss","**/*.tsx","**/*.jsx"];function ks(e){let t=(e?.findings??[]).filter(s=>s.role==="implements"||s.role==="styles").map(s=>s.path).filter(s=>!/[,"\n]/.test(s)),n=[...new Set(t)].sort().slice(0,Si);return n.length?n:Ri}function vs(e){return["---","description: Buttons in this repository follow a spec published in Gruum.",`globs: ${e.join(",")}`,"alwaysApply: false","---",ws,"","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(`
14
- `)}function $s(e){return e.includes(ws)}function Ai(e){let t=e.trim();if(!t||t.startsWith("#")||t.startsWith("!"))return!1;let n=t.replace(/\s+#.*$/,"").trim();return/^(?:\/|\*\*\/)?\.gruum(?:\/|\*\*|\/\*\*|\/\*)?$/.test(n)}function ot(e){let t=e??"";if(t.split(/\r?\n/).some(Ai))return{text:t,changed:!1};let n=t===""||t.endsWith(`
12
+ ${bs(n)}`}}var nt="npx --no-install @gruum/cli",Jt="npx --yes @gruum/cli",ws={afterFileEdit:"after-file-edit",stop:"stop",beforeShellExecution:"before-shell"},Ai=/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+hook\s+(after-file-edit|stop|before-shell)\s*$/;function Kt(e){return typeof e=="string"&&Ai.test(e)}function st(e,t){if(e===null||e.trim()==="")return{ok:!0,value:{}};try{let n=JSON.parse(e);return!n||typeof n!="object"||Array.isArray(n)?{ok:!1,error:`${t} is not a JSON object; fix it or move it aside, then run init again.`}:{ok:!0,value:n}}catch{return{ok:!1,error:`${t} is not valid JSON; fix it or move it aside, then run init again.`}}}function rt(e){return`${JSON.stringify(e,null,2)}
13
+ `}function ks(e,t){let n=Zt(e),s=Xt(t);return!n.ok||!s.ok?!1:n.changed||s.changed}function Zt(e,t=nt){let n=".cursor/hooks.json",s=st(e,n);if(!s.ok)return s;let r=s.value;if(r.hooks!==void 0&&(typeof r.hooks!="object"||Array.isArray(r.hooks)||r.hooks===null))return{ok:!1,error:`${n} has a "hooks" value that is not an object.`};let o={...r.hooks??{}},i=e===null||e.trim()==="";for(let a of Object.keys(ws)){let l=o[a]??[];if(!Array.isArray(l))return{ok:!1,error:`${n} has a "${a}" value that is not an array.`};let c=`${t} hook ${ws[a]}`,p=l.filter(f=>Kt(f?.command));p.length===1&&p[0].command===c||(o[a]=[...l.filter(f=>!Kt(f?.command)),{command:c}],i=!0)}return i?{ok:!0,text:rt({version:r.version??1,...r,hooks:o}),changed:!0}:{ok:!0,text:e,changed:!1}}function vs(e){let t=".cursor/hooks.json";if(e===null)return{ok:!0,text:"",changed:!1};let n=st(e,t);if(!n.ok)return n;let s=n.value,r={...s.hooks??{}},o=!1;for(let a of Object.keys(r)){let l=r[a];if(!Array.isArray(l))continue;let c=l.filter(p=>!Kt(p?.command));c.length!==l.length&&(o=!0,c.length?r[a]=c:delete r[a])}if(!o)return{ok:!0,text:e,changed:!1};let i=Object.keys(s).every(a=>a==="version"||a==="hooks");return Object.keys(r).length===0&&i?{ok:!0,text:"",changed:!0}:{ok:!0,text:rt({...s,hooks:r}),changed:!0}}function _i(e){let[t,...n]=e.trim().split(/\s+/);return{command:t,args:[...n,"mcp"]}}function Xt(e,t=Jt){let n=".cursor/mcp.json",s=st(e,n);if(!s.ok)return s;let r=s.value,o=r.mcpServers??{};if(typeof o!="object"||Array.isArray(o)||o===null)return{ok:!1,error:`${n} has an "mcpServers" value that is not an object.`};let i=_i(t),a=o.gruum;return JSON.stringify(a)===JSON.stringify(i)?{ok:!0,text:e,changed:!1}:{ok:!0,text:rt({...r,mcpServers:{...o,gruum:i}}),changed:!0}}function $s(e){let t=".cursor/mcp.json";if(e===null)return{ok:!0,text:"",changed:!1};let n=st(e,t);if(!n.ok)return n;let s=n.value,r={...s.mcpServers??{}};return"gruum"in r?(delete r.gruum,Object.keys(r).length===0&&Object.keys(s).every(o=>o==="mcpServers")?{ok:!0,text:"",changed:!0}:{ok:!0,text:rt({...s,mcpServers:r}),changed:!0}):{ok:!0,text:e,changed:!1}}var q=".cursor/rules/gruum-buttons.mdc",Cs="<!-- written by gruum init cursor -->",Ei=20,Ss=["**/*.css","**/*.scss","**/*.tsx","**/*.jsx"];function Rs(e){let t=(e?.findings??[]).filter(s=>s.role==="implements"||s.role==="styles").map(s=>s.path).filter(s=>!/[,"\n]/.test(s)),n=[...new Set(t)].sort().slice(0,Ei);return n.length?n:Ss}var Ii=["The button spec for this repository lives in Gruum. Before writing or restyling a button, call the Cursor tool `gruum_button_spec`.","Before you stop, call the Cursor tool `gruum_check_buttons` and fix every drift item it reports to the spec.","If those tools are not available, read `.gruum/baseline.json` and follow that spec. Do not run npx, and do not search the computer for a gruum program.",`When the request needs a button the spec does not have, stop and ask the user exactly: "${Gt}" Do not write that look, and do not request a review, until they answer. Never edit Gruum's generated files to make a check pass.`];function qt(e){return["---","description: Buttons in this repository follow a spec published in Gruum.",`globs: ${e.join(",")}`,"alwaysApply: false","---",Cs,"",...Ii,""].join(`
14
+ `)}function As(e){let n=(e.match(/^globs: (.*)$/m)?.[1]??"").split(",").map(r=>r.trim()).filter(Boolean),s=qt(n.length?n:Ss);return{text:s,changed:s!==e}}function Yt(e){return e.includes(Cs)}function ji(e){let t=e.trim();if(!t||t.startsWith("#")||t.startsWith("!"))return!1;let n=t.replace(/\s+#.*$/,"").trim();return/^(?:\/|\*\*\/)?\.gruum(?:\/|\*\*|\/\*\*|\/\*)?$/.test(n)}function ot(e){let t=e??"";if(t.split(/\r?\n/).some(ji))return{text:t,changed:!1};let n=t===""||t.endsWith(`
15
15
  `)?"":`
16
16
  `;return{text:`${t}${n}# Gruum local state
17
17
  .gruum/
18
- `,changed:!0}}function Cs(e){if(e===null)return{text:"",changed:!1};let t=e.replace(/(^|\n)# Gruum local state\n\.gruum\/\n/,"$1");return{text:t,changed:t!==e}}var _i=e=>`${e} check --staged`;function Ss(e,t=We){let n=_i(t);if(e.lefthook)return{kind:"print",reason:"lefthook config found; add this to the pre-commit commands",snippet:`pre-commit:
18
+ `,changed:!0}}function _s(e){if(e===null)return{text:"",changed:!1};let t=e.replace(/(^|\n)# Gruum local state\n\.gruum\/\n/,"$1");return{text:t,changed:t!==e}}var Pi=e=>`${e} check --staged`;function Es(e,t=nt){let n=Pi(t);if(e.lefthook)return{kind:"print",reason:"lefthook config found; add this to the pre-commit commands",snippet:`pre-commit:
19
19
  commands:
20
20
  gruum:
21
21
  run: ${n}
22
22
  `};let s=e.husky?"husky":e.gitHooksDir?"git":null;if(!s)return{kind:"print",reason:"no hook directory found; add this to your pre-commit hook",snippet:`${n}
23
- `};let r=e.husky?".husky/pre-commit":`${e.gitHooksDir}/pre-commit`,o=e.hookText;if(o!==null&&o.split(/\r?\n/).some(l=>Rs(l)))return{kind:s,path:r,text:o,changed:!1};let i=o===null?s==="git"?`#!/bin/sh
23
+ `};let r=e.husky?".husky/pre-commit":`${e.gitHooksDir}/pre-commit`,o=e.hookText;if(o!==null&&o.split(/\r?\n/).some(l=>Is(l)))return{kind:s,path:r,text:o,changed:!1};let i=o===null?s==="git"?`#!/bin/sh
24
24
  `:"":o,a=i===""||i.endsWith(`
25
25
  `)?"":`
26
26
  `;return{kind:s,path:r,text:`${i}${a}${n}
27
- `,changed:!0}}function Rs(e){return/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+check\s+--staged\s*$/.test(e.trim())}function As(e){let t=e.split(`
28
- `),n=t.filter(o=>!Rs(o)),s=n.length!==t.length,r=n.join(`
29
- `);return s&&/^(#!\/bin\/sh)?\s*$/.test(r)?{text:"",changed:s}:{text:r,changed:s}}var Ee=[{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 spec from this checkout and publish it",usage:"npx @gruum/cli baseline --write"}];function _s(e){let t=Ee.map((n,s)=>` ${s+1} ${n.name.padEnd(10)} ${n.blurb}`);return`gruum ${e}
27
+ `,changed:!0}}function Is(e){return/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+check\s+--staged\s*$/.test(e.trim())}function js(e){let t=e.split(`
28
+ `),n=t.filter(o=>!Is(o)),s=n.length!==t.length,r=n.join(`
29
+ `);return s&&/^(#!\/bin\/sh)?\s*$/.test(r)?{text:"",changed:s}:{text:r,changed:s}}var Ee=[{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 spec from this checkout and publish it",usage:"npx @gruum/cli baseline --write"}];function Ps(e){let t=Ee.map((n,s)=>` ${s+1} ${n.name.padEnd(10)} ${n.blurb}`);return`gruum ${e}
30
30
 
31
31
  ${t.join(`
32
32
  `)}
33
- `}var Es=`
34
- Choose 1\u20133, or press Enter to quit: `,Is=`
35
- Would you like to run a (c) check, (b) baseline, or (q) quit? `,js=`
36
- You have no baseline. Would you like to run it? (b) baseline, (q) quit: `;function Ps(e){return`
33
+ `}var Ls=`
34
+ Choose 1\u20133, or press Enter to quit: `,Os=`
35
+ Would you like to run a (c) check, (b) baseline, or (q) quit? `,Ms=`
36
+ You have no baseline. Would you like to run it? (b) baseline, (q) quit: `;function Ns(e){return`
37
37
  ${e?"This repo uses Cursor and Claude. Gruum can set up Cursor.":"This repo uses Cursor."}
38
38
 
39
- Set up Gruum in Cursor so checks run while you edit and before a commit? (y) yes, (n) no: `}function Ls(e){let t=e.trim().toLowerCase();return!t||t==="n"||t==="no"||t==="q"||t==="quit"?"no":t==="y"||t==="yes"?"yes":null}function Os(e){let t=e.trim().toLowerCase();return!t||t==="q"||t==="quit"?"quit":t==="c"||t==="check"?"check":t==="b"||t==="baseline"?"baseline":null}function Ms(e){let t=e.trim().toLowerCase();return!t||t==="q"||t==="quit"||t==="n"||t==="no"?"quit":t==="b"||t==="baseline"||t==="y"||t==="yes"?"baseline":null}function Ns(e){let t=e.trim().toLowerCase();if(!t)return"quit";let n=Number(t);return Number.isInteger(n)&&n>=1&&n<=Ee.length?Ee[n-1]:Ee.find(s=>s.name===t)??null}var Ei="2025-06-18",it="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.",at={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. ${it}`,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. ${it}`,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. ${it}`,gruum_exception_status:`Pending, accepted, or rejected for this branch's exception requests. Pass an id to read one. ${it}`};function Ts(e){return[{name:"gruum_button_spec",description:at.gruum_button_spec,inputSchema:{type:"object",properties:{},additionalProperties:!1},run:()=>e.spec()},{name:"gruum_check_buttons",description:at.gruum_check_buttons,inputSchema:{type:"object",properties:{paths:{type:"array",items:{type:"string"},description:"Only report drift in these files (relative to the repository root). Omit to check everything."}},additionalProperties:!1},run:t=>{let n=Array.isArray(t.paths)?t.paths.filter(s=>typeof s=="string"):[];return e.check(n)}},{name:"gruum_request_exception",description:at.gruum_request_exception,inputSchema:{type:"object",properties:{driftId:{type:"string",description:"The drift item id from gruum_check_buttons."},reason:{type:"string",description:"Why the spec has no button for this job."}},required:["driftId","reason"],additionalProperties:!1},run:t=>e.request(typeof t.driftId=="string"?t.driftId:"",typeof t.reason=="string"?t.reason:"")},{name:"gruum_exception_status",description:at.gruum_exception_status,inputSchema:{type:"object",properties:{id:{type:"string",description:"One request id. Omit to list this branch."}},additionalProperties:!1},run:t=>e.status(typeof t.id=="string"?t.id:void 0)}]}function Ge(e,t){return{jsonrpc:"2.0",id:e,result:t}}function lt(e,t,n){return{jsonrpc:"2.0",id:e,error:{code:t,message:n}}}async function Ds(e,t,n){if(!e||typeof e!="object")return lt(null,-32600,"Invalid request");let s=e,r=!("id"in s),o=s.id??null;if(typeof s.method!="string")return r?null:lt(o,-32600,"Invalid request");let i=s.params??{};switch(s.method){case"initialize":{let a=i.protocolVersion;return Ge(o,{protocolVersion:typeof a=="string"?a:Ei,capabilities:{tools:{listChanged:!1}},serverInfo:n})}case"ping":return Ge(o,{});case"tools/list":return Ge(o,{tools:t.map(({name:a,description:l,inputSchema:c})=>({name:a,description:l,inputSchema:c}))});case"tools/call":{let a=t.find(c=>c.name===i.name);if(!a)return lt(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 Ge(o,{content:[{type:"text",text:c.text}],isError:c.isError??!1})}catch(c){return Ge(o,{content:[{type:"text",text:c instanceof Error?c.message:String(c)}],isError:!0})}}default:return r?null:lt(o,-32601,`Method not found: ${s.method}`)}}var Ii=/(^|\/)(node_modules|\.git|\.next|dist|build|out|coverage|vendor|\.turbo|\.cache|__pycache__|target|\.venv|venv)\//,ji=/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb|Cargo\.lock|poetry\.lock|composer\.lock|Gemfile\.lock)$/,Pi=/\.(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,Li=/(^|\/)\.gruum\//;function Zt(e){return!Ii.test(`${e}/`)&&!Li.test(`${e}/`)}function Xt(e,t){return ji.test(e)||Pi.test(e)?!1:t<=3e5}function Vs(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}var Oi=/\.(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 Bs(e){return Oi.test(e)}function qt(e){return e.replace(/\\/g,"/").replace(/^\.\/?/,"").replace(/^\/+|\/+$/g,"")}function Yt(e,t){let n=qt(t),s=e.replace(/\\/g,"/");return n?s.startsWith(`${n}/`)?s.slice(n.length+1):null:s}function Fs(e,t,n){let s=new Map(e);for(let r of t){let o=Yt(r.path,n);o===null||!Zt(o.split("/").slice(0,-1).join("/")||".")||(r.content===null?s.delete(o):Xt(o,r.content.length)&&s.set(o,r.content))}return s}function Us(e){let t=e.split("\0").filter(Boolean),n=[];for(let s=0;s<t.length;s++){let r=t[s];if(/^[RC]/.test(r)){let i=t[++s],a=t[++s];r.startsWith("R")&&i&&n.push({path:i,deleted:!0}),a&&n.push({path:a,deleted:!1});continue}let o=t[++s];o&&n.push({path:o,deleted:r.startsWith("D")})}return n}function ct(e){let t=/^(?:git@|ssh:\/\/git@|https?:\/\/(?:[^@/]+@)?)github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(e.trim());return t?`${t[1]}/${t[2]}`:null}var zs=e=>e.replace(/\\(.)/g,"$1");function Mi(e){let t=e;for(;;){let n=/:(?:global|local)\(/i.exec(t);if(!n)break;let s=0,r=-1;for(let i=n.index+n[0].length-1;i<t.length;i++){let a=t[i];if(a==="(")s++;else if(a===")"&&--s===0){r=i;break}}if(r<0)break;let o=t.slice(n.index+n[0].length,r).trim();t=`${t.slice(0,n.index)}${o}${t.slice(r+1)}`}return t.replace(/:(?:global|local)(?=\s|$)/gi,"").trim()}var Qt=/\*|[a-z][\w-]*|\.((?:\\.|[\w-])+)|#((?:\\.|[\w-])+)|\[\s*([\w-]+)\s*(?:([~|^$*]?=)\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*[is]?\s*\]|::([\w-]+)|:([\w-]+)(\((?:[^()]|\([^()]*\))*\))?/giy;function Hs(e){let t=[];Qt.lastIndex=0;let n=0;for(;n<e.length;){Qt.lastIndex=n;let s=Qt.exec(e);if(!s||s.index!==n)return null;let r=s[0];if(n+=r.length,r==="*")t.push({kind:"universal",raw:r});else if(s[1]!==void 0)t.push({kind:"class",raw:r,name:zs(s[1])});else if(s[2]!==void 0)t.push({kind:"id",raw:r,name:zs(s[2])});else if(s[3]!==void 0)t.push({kind:"attr",raw:r,name:s[3],op:s[4]??null,value:s[4]?s[5]??s[6]??s[7]??"":null});else if(s[8]!==void 0)t.push({kind:"pseudoElement",raw:r,name:s[8].toLowerCase()});else if(s[9]!==void 0){let o=s[9].toLowerCase();/^(?:before|after|first-line|first-letter)$/.test(o)?t.push({kind:"pseudoElement",raw:r,name:o}):t.push({kind:"pseudo",raw:r,name:o,args:s[10]?s[10].slice(1,-1).trim():null})}else if(t.length===0)t.push({kind:"tag",raw:r,name:r.toLowerCase()});else return null}return t.length?t:null}function q(e){let t=Mi(e),n=[],s=0,r=0,o=null,i=!0,a=l=>{let c=t.slice(r,l).trim();if(!c)return!0;let u=Hs(c);return u?(n.push({combinator:i?null:o??" ",simples:u}),i=!1,o=null,!0):!1};for(let l=0;l<t.length;l++){let c=t[l];if(c==="("||c==="[")s++;else if(c===")"||c==="]")s=Math.max(0,s-1);else if(s===0&&(c===">"||c==="+"||c==="~")){if(!a(l)||o)return null;o=c,r=l+1}else if(s===0&&/\s/.test(c)){if(!a(l))return null;r=l+1}}return!a(t.length)||o?null:n.length?n:null}function He(e){return e.map(t=>t.raw).join("")}function Ke(e){return e.map((t,n)=>{let s=He(t.simples);return n===0?s:t.combinator===" "?` ${s}`:` ${t.combinator} ${s}`}).join("")}function z(e){let t=[],n=0,s=0;for(let r=0;r<e.length;r++){let o=e[r];o==="("||o==="["?n++:o===")"||o==="]"?n=Math.max(0,n-1):o===","&&n===0&&(t.push(e.slice(s,r).trim()),s=r+1)}return t.push(e.slice(s).trim()),t.filter(Boolean)}var Ks=e=>e.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(t=>t.toLowerCase());function Ws(e,t){let n=e.toLowerCase();return t.some(s=>n.includes(s.toLowerCase()))}function en(e,t){let n=t.excludeClassKeywords;if(!n?.length)return!1;let s=new Set(n.flatMap(r=>[r.toLowerCase(),`${r.toLowerCase()}s`]));return e.some(r=>r.kind==="class"&&Ks(r.name).some(o=>s.has(o)))}var Ni=new Set(["html","body"]),Ti=new Set(["svg","path","use","img","picture","video","i","em","strong","b","small","kbd","sup","sub"]);function pt(e,t){for(let n of e)switch(n.kind){case"tag":if(t.elements.includes(n.name))return!0;break;case"class":if(Ws(n.name,t.classKeywords))return!0;break;case"attr":if(n.name==="role"&&n.value!==null&&t.roles.includes(n.value.toLowerCase())||n.name==="data-component"&&n.value!==null&&Ws(n.value,t.classKeywords))return!0;break;case"pseudo":if((n.name==="is"||n.name==="where")&&n.args){let s=z(n.args).map(q);if(s.length>0&&s.every(r=>r!==null&&pt(r[r.length-1].simples,t)))return!0}break;default:break}return!1}function Js(e){return e.some(n=>n.kind==="universal")?e.length===1:e.some(n=>n.kind==="tag"&&Ni.has(n.name))?!0:!e.some(n=>n.kind==="tag"||n.kind==="class"||n.kind==="attr"||n.kind==="id"||n.kind==="pseudo"&&(n.name==="is"||n.name==="where"))}function Zs(e){return e.some(t=>t.kind==="tag"&&Ti.has(t.name))}var ut=["hover","focus","active","selected","current","loading","disabled"],Di={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"},Vi={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",checked:"selected",disabled:"disabled"},Bi={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"},Fi=new Set(["active","selected","pressed","checked","loading","busy","disabled","open","current","hover","focus","show","expanded","collapsed"]),Gs=e=>Di[e.toLowerCase()]??e.toLowerCase(),le={hover:"__gs-hover",focus:"__gs-focus",active:"__gs-active"};function Xs(e){if(e.kind==="pseudo"){let t=Vi[e.name];if(!t)return null;let n=le[t];return{state:t,marker:n?{classes:[n],attrs:{}}:{classes:[],attrs:{[e.name==="checked"?"checked":"disabled"]:""}}}}if(e.kind==="attr"){if(e.name==="data-state"&&e.value!==null)return{state:Gs(e.value),marker:{classes:[],attrs:{"data-state":e.value}}};let t=Bi[e.name];if(!t||e.value!==null&&/^(?:false|off|0)$/i.test(e.value))return null;let n=e.value??(e.name.startsWith("aria-")?"true":"");return{state:t,marker:{classes:[],attrs:{[e.name]:n}}}}if(e.kind==="class"){let t=/^(?:is|has)-(.+)$/i.exec(e.name),n=t?t[1]:Fi.has(e.name.toLowerCase())?e.name:null;return n?{state:Gs(n),marker:{classes:[e.name],attrs:{}}}:null}return null}function Ui(e){return e.kind!=="pseudo"||e.name!=="not"||!e.args?!1:z(e.args).every(t=>{let n=Hs(t);return n!==null&&n.every(s=>Xs(s)!==null)})}function ft(e){let t=[],n=new Map;for(let o of e){if(Ui(o))continue;let i=Xs(o);if(!i){t.push(o);continue}let a=n.get(i.state)??{classes:[],attrs:{}};for(let l of i.marker.classes)a.classes.includes(l)||a.classes.push(l);Object.assign(a.attrs,i.marker.attrs),n.set(i.state,a)}let s=[...n.keys()].sort((o,i)=>H(o)-H(i)||o.localeCompare(i)),r={classes:[],attrs:{}};for(let o of s){let i=n.get(o);r.classes.push(...i.classes),Object.assign(r.attrs,i.attrs)}return{identity:t,states:s,marker:r}}function H(e){if(e==="default")return-1;let t=ut.indexOf(e);return t===-1?ut.length:t}function he(e){return e.length?e.join(" + "):"default"}function tn(e){return e.replace(/:hover\b/g,`.${le.hover}`).replace(/:focus(?:-visible|-within)?\b/g,`.${le.focus}`).replace(/:active\b/g,`.${le.active}`)}var zi=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"]),Wi=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"]),Gi=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 Je(e){let t=e.toLowerCase();return zi.has(t)?"paint":Wi.has(t)?"layout":Gi.has(t)?"hint":"box"}var Hi={shadow:/^box-shadow$/,cursor:/^cursor$/,rounded:/^border(?:-[a-z]+)*-radius$/,radius:/^border(?:-[a-z]+)*-radius$/};function qs(e,t){let n=e.filter(o=>o.kind==="class");if(n.length!==1||e.length!==1)return!1;let s=Ks(n[0].name)[0],r=s?Hi[s]:void 0;return r?t.length>0&&t.every(o=>r.test(o.property.toLowerCase())):!1}var Au={hover:{classes:[le.hover],attrs:{}},focus:{classes:[le.focus],attrs:{}},active:{classes:[le.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 Ki="data-gs-sheet";function Qs(e){return`[${Ki}="${e.replace(/["\\]/g,"")}"]`}function Ys(e){return/\.module\.[a-z]+$/i.test(e)}var Ji=new Set(["button","a","div","span","input","summary","label"]);function be(e){let t=0,n=0;for(let s=0;s<e.length;s++){let r=e[s];r==="("||r==="["?t++:r===")"||r==="]"?t=Math.max(0,t-1):t===0&&/[\s>+~]/.test(r)&&(n=s+1)}return n}function Zi(e){let t={tag:"",classes:[],attrs:{}};for(let n of e)switch(n.kind){case"pseudoElement":return null;case"tag":t.tag=n.name;break;case"class":t.classes.push(n.name);break;case"attr":t.attrs[n.name]=n.value??"";break;default:break}return t}function dt(e,t){let n=q(e);if(!n||n.some(c=>c.combinator==="+"||c.combinator==="~"))return null;let s=n.map(c=>Zi(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(!Ji.has(i)||o.classes.length===0&&Object.keys(o.attrs).length===0&&!o.tag)return null;let a=[...new Set([...t,...o.classes])],l=r.slice(0,-1).filter(c=>c.tag||c.classes.length||Object.keys(c.attrs).length).map(c=>({...c,tag:c.tag&&c.tag!=="*"?c.tag:"div"}));return{tag:i,classes:a,attrs:o.attrs,ancestors:l}}function nn(e,t){let n="";for(let s of e)s.property.toLowerCase()===t&&(n=s.value.replace(/!important\s*$/i,"").trim());return n}function gt(e){let t=nn(e,"display");if(/^none\b/i.test(t))return"display: none";let n=nn(e,"visibility");if(/^(hidden|collapse)\b/i.test(n))return`visibility: ${n.split(/\s+/)[0].toLowerCase()}`;let s=nn(e,"opacity");return/^(0|0\.0+)$/.test(s)?"opacity: 0":null}function er(e,t){return e===t||!Ys(e)&&!Ys(t)}function ne(e,t){if(/[<>]|@import|expression\(|javascript:|behavior\s*:/i.test(t))return!1;for(let n of t.matchAll(/url\(\s*(['"]?)([^'")]*)\1\s*\)/gi))if(!/^data:image\//i.test(n[2]))return!1;return/^-{0,2}[a-z][\w-]*$/i.test(e)}var Xi=40,Y=(e,t)=>({path:e,line:t});function Q(e,t,n,s){return{...e,status:t.length===0?"ok":"attention",summary:t.length===0?n:s(t.length),findings:t.slice(0,Xi)}}function ye(e,t){return{...e,status:"na",summary:t,findings:[]}}var sn=e=>e.state.split(" + ");function or(e,t){if(!e.element||!t.element||e!==t&&!er(e.path,t.path)||e.element.ancestors.length>0||e.element.tag!==t.element.tag)return!1;let n=new Set(t.element.classes);return e.element.classes.every(s=>n.has(s))?Object.entries(e.element.attrs).every(([s,r])=>t.element.attrs[s]===r):!1}function ir(e,t){return t.filter(n=>or(n,e)).flatMap(n=>n.states)}function qi(e,t,n){return ir(e,t).some(s=>sn(s).includes(n))||t.filter(s=>or(s,e)).some(s=>(s.parts??[]).some(r=>r.state.split(" + ").includes(n)))}var Yi=[{state:"hover",severity:"issue"},{state:"focus",severity:"issue"},{state:"disabled",severity:"issue"},{state:"active",severity:"note"}];function Qi(e){let t={id:"states",title:"Missing states",description:"Styles with no hover, focus, disabled, or active rule, counting rules they inherit from a shared base class."},n=e.variants.filter(r=>r.element&&r.element.ancestors.length===0);if(n.length===0)return ye(t,"No styles that can be drawn on their own.");let s=[];for(let{state:r,severity:o}of Yi){let i=n.filter(a=>!qi(a,e.variants,r));i.length!==0&&s.push({severity:o,message:i.length===n.length?`No style defines a ${r} state.`:`${i.length} of ${n.length} styles have no ${r} state.`,styles:i.length===n.length?void 0:i.map(a=>a.title),refs:i.slice(0,6).map(a=>Y(a.path,a.line))})}return Q(t,s,"Every style has hover, focus, disabled, and active rules.",r=>`${r} state${r===1?"":"s"} missing on some styles.`)}var tr=new Set(["outline","outline-style","outline-width"]),nr=/^(?:none|0|0px)(?:\s+(?:none|0|0px))*$/i,ea=/^(?:outline(?:-color|-width|-style)?|box-shadow|border(?:-[a-z]+)*|background(?:-color)?|text-decoration(?:-[a-z]+)?|color)$/;function ta(e){let t={id:"focus",title:"Focus indicator removed",description:"Styles that remove the outline and give keyboard focus nothing in its place."},n=e.variants.filter(r=>r.element&&r.element.ancestors.length===0);if(n.length===0)return ye(t,"No styles that can be drawn on their own.");let s=[];for(let r of n){let o=ir(r,e.variants),i=o.filter(l=>{let c=sn(l);return c.includes("default")||c.includes("focus")}).flatMap(l=>l.declarations.map(c=>({s:l,d:c}))).find(({d:l})=>tr.has(l.property)&&nr.test(l.value.replace(/\s*!important/i,"")));!i||o.filter(l=>sn(l).includes("focus")).some(l=>l.declarations.some(c=>ea.test(c.property)&&!(tr.has(c.property)&&nr.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(t,s,"No style removes the outline without a focus replacement.",r=>`${r} style${r===1?"":"s"} lose the focus indicator.`)}function na(e){let t={id:"tokens",title:"Undefined tokens",description:`Custom properties the ${e.noun} styles read that no scanned stylesheet defines.`};if(e.tokens.length===0)return ye(t,`The ${e.noun} styles read no custom properties.`);let s=e.tokens.filter(r=>r.definedIn.length===0&&!r.name.startsWith("--tw-")).map(r=>{let o=e.variants.filter(i=>i.states.some(a=>a.declarations.some(l=>l.value.includes(`var(${r.name}`)||new RegExp(`var\\(\\s*${r.name}\\b`).test(l.value))));return{severity:"note",message:`${r.name} is read but never defined here. It may be set outside the scanned files (a framework, a theme provider).`,styles:o.slice(0,8).map(i=>i.title),refs:o.slice(0,3).map(i=>Y(i.path,i.line))}});return Q(t,s,`All ${e.tokens.length} tokens read are defined.`,r=>`${r} token${r===1?"":"s"} with no definition.`)}var sa=/var\((?:[^()]|\([^()]*\))*\)/g,sr=/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?)\([^)]*\)/gi,ra=/^(?:padding|margin|gap|row-gap|column-gap|height|min-height|max-height|border-radius|font-size|letter-spacing)(?:-[a-z]+)*$/,oa=/(?<![\w.-])(\d+(?:\.\d+)?)px\b/g;function rr(e){let t=e.trim().toLowerCase().replace(/\s+/g,""),n=/^#([0-9a-f]{3})$/.exec(t);return n?`#${[...n[1]].map(s=>s+s).join("")}`:t}function rn(e,t,n=0){return n>6?e:e.replace(/var\(\s*(--[\w-]+)\s*(?:,\s*([^)]*))?\)/g,(s,r,o)=>{let i=t.get(r);return i!==void 0?rn(i,t,n+1):o!==void 0?rn(o.trim(),t,n+1):s})}var ia=[[/^(?: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 aa(e,t){if(!t)return null;let n=ia.find(([s])=>s.test(e))?.[1];return t.find(s=>!n||n.test(s))??null}function la(e){let t={id:"hardcoded",title:"Hard-coded values",description:`Raw colors, and pixel sizes that exactly match a token, written into ${e.noun} styles instead of using the token.`},n=new Map,s=new Map;for(let[o,i]of e.tokenValues){let a=rn(i,e.tokenValues).trim();if(new RegExp(`^(?:${sr.source})$`,"i").test(a)){let l=rr(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 ye(t,"No color or size tokens were found to compare against.");let r=[];for(let o of e.variants){let i=[],a=null;for(let c of o.states)for(let u of c.declarations){if(u.via)continue;let f=u.value.replace(sa," ");for(let m of f.matchAll(sr)){let h=n.get(rr(m[0]));i.push(h?`${m[0]} in ${u.property} is the value of ${h[0]}`:`${m[0]} in ${u.property} is not a token`),a??=c}if(ra.test(u.property))for(let m of f.matchAll(oa)){let h=aa(u.property,s.get(`${m[1]}px`));!h||Number(m[1])<=1||(i.push(`${m[1]}px in ${u.property} is the value of ${h}`),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(t,r,`No ${e.noun} style hard-codes a value a token already has.`,o=>`${o} style${o===1?"":"s"} hard-code values.`)}function ca(e){let t={id:"unused",title:"Unused styles",description:"Styles defined in CSS that no component, page, or template references."},n=e.variants.filter(r=>r.element&&r.usage.status!=="unknown");if(n.length===0)return ye(t,"No styles with a class name to look for.");let s=[];for(let r of n)r.usage.status==="unreferenced"?s.push({severity:"issue",message:`${r.title} (${r.selector}) is defined but no reference to it was found.`,styles:[r.title],refs:[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(t,s,`All ${n.length} styles are referenced.`,r=>`${r} style${r===1?"":"s"} unreferenced or unconfirmed.`)}function ua(e){let t={id:"duplicates",title:"Duplicate styles",description:"Different styles whose default declarations are identical."},n=new Map;for(let r of e.variants){if(!r.element)continue;let o=r.states.filter(a=>a.state==="default"&&a.context==="").flatMap(a=>a.declarations).map(a=>`${a.property}:${a.value.replace(/\s+/g," ").trim()}`);if(o.length<2)continue;let i=[...new Set(o)].sort().join(";");n.set(i,[...n.get(i)??[],r])}let s=[...n.values()].filter(r=>r.length>1).map(r=>({severity:"issue",message:`${r.map(o=>o.title).join(", ")} declare the same default styles (${r.map(o=>o.selector).join(", ")}).`,styles:r.map(o=>o.title),refs:r.map(o=>Y(o.path,o.line))}));return Q(t,s,"No two styles share the same default declarations.",r=>`${r} group${r===1?"":"s"} of identical styles.`)}function pa(e){let t={id:"native",title:`Native <${e.element}> instead of the component`,description:`Files that render a raw <${e.element}> although the repository has a shared ${e.element} component.`};if(!e.hasComponent)return ye(t,`No shared ${e.element} component was found, so native elements are expected.`);let n=e.nativeUses.map(s=>({severity:"issue",message:`${s.count} native <${e.element}> element${s.count===1?"":"s"} in ${s.path}.`,refs:[Y(s.path,s.line)]}));return Q(t,n,`Every <${e.element}> goes through the component.`,s=>`${s} file${s===1?"":"s"} bypass the component.`)}function fa(e){let t={id:"props",title:"Prop values with no look",description:`Calls to a ${e.element} component with a literal prop value the component has no style for.`};if(!e.hasComponent)return ye(t,`No shared ${e.element} component was found.`);let n=(e.unknownProps??[]).map(s=>({severity:"issue",message:`<${s.component} ${s.prop}="${s.value}"> in ${s.path}: ${s.component} has no ${s.prop} "${s.value}" (it has ${s.known.join(", ")}).`,refs:[Y(s.path,s.line)]}));return Q(t,n,"Every literal prop value picks a look the component has.",s=>`${s} call${s===1?"":"s"} ask for a look the component does not have.`)}function da(e){let t={id:"undocumented",title:"Styles without written guidance",description:"Styles that no instruction file or doc names, so nothing written says how they should be used."},{guidance:n}=e;if(n.files.length===0)return{...t,status:"attention",summary:`Nothing in the repository mentions ${e.noun}.`,findings:[{severity:"note",message:`No instruction file or doc says how ${e.noun} should look or be built.`,refs:[]}]};if(n.undocumented.length===0)return Q(t,[],"Every style is named in written guidance.",()=>"");let s=e.variants.filter(r=>r.element&&n.undocumented.includes(r.title));return Q(t,[{severity:"note",message:`${n.undocumented.length} of ${n.documented.length+n.undocumented.length} styles are named in no guidance.`,styles:n.undocumented,refs:s.slice(0,6).map(r=>Y(r.path,r.line))}],"",r=>`${r} finding${r===1?"":"s"}.`)}function ar(e){return[Qi(e),ta(e),ca(e),ua(e),na(e),la(e),pa(e),fa(e),da(e)]}var ga=/\.(erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,lr=/^<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/,ma=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),ha=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),ba=new Set(["classNames","classnames","clsx","cn","cx"]),ya=/^(?:ref|key|style|dangerouslySetInnerHTML)$/i;function pr(e,t){let n=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
40
- `&&n++;return n}function cr(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function fr(e){let t=e.filter(s=>s.trim()).map(s=>/^ */.exec(s)?.[0].length??0),n=t.length?Math.min(...t):0;return e.map(s=>{let r=s.slice(n);return r.length>200?`${r.slice(0,200)}\u2026`:r}).join(`
41
- `)}function xa(e,t,n){let s=Math.max(0,Math.min(t,e.length)),r=Math.max(s,Math.min(n,e.length)),o=pr(e,s),i=e.slice(s,r).split(`
39
+ Set up Gruum in Cursor so checks run while you edit and before a commit? (y) yes, (n) no: `}function Ts(e){let t=e.trim().toLowerCase();return!t||t==="n"||t==="no"||t==="q"||t==="quit"?"no":t==="y"||t==="yes"?"yes":null}function Ds(e){let t=e.trim().toLowerCase();return!t||t==="q"||t==="quit"?"quit":t==="c"||t==="check"?"check":t==="b"||t==="baseline"?"baseline":null}function Fs(e){let t=e.trim().toLowerCase();return!t||t==="q"||t==="quit"||t==="n"||t==="no"?"quit":t==="b"||t==="baseline"||t==="y"||t==="yes"?"baseline":null}function Bs(e){let t=e.trim().toLowerCase();if(!t)return"quit";let n=Number(t);return Number.isInteger(n)&&n>=1&&n<=Ee.length?Ee[n-1]:Ee.find(s=>s.name===t)??null}var Li="2025-06-18",it=`Check before you finish. If the request needs a button the spec does not have, ask the user: "You asked for a design element that is not in the spec. 1. Use an existing spec style for it. 2. Add it as it is and request review." Do not request a review until they choose 2. Never edit Gruum's generated files to make a check pass.`,at={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. ${it}`,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. ${it}`,gruum_request_exception:`Ask a designer to review one drift item. Call this only after the user chooses to add the element as it is and request review. Send the drift id from gruum_check_buttons and a reason. ${it}`,gruum_exception_status:`Pending, accepted, or rejected for this branch's exception requests. Pass an id to read one. ${it}`};function Vs(e){return[{name:"gruum_button_spec",description:at.gruum_button_spec,inputSchema:{type:"object",properties:{},additionalProperties:!1},run:()=>e.spec()},{name:"gruum_check_buttons",description:at.gruum_check_buttons,inputSchema:{type:"object",properties:{paths:{type:"array",items:{type:"string"},description:"Only report drift in these files (relative to the repository root). Omit to check everything."}},additionalProperties:!1},run:t=>{let n=Array.isArray(t.paths)?t.paths.filter(s=>typeof s=="string"):[];return e.check(n)}},{name:"gruum_request_exception",description:at.gruum_request_exception,inputSchema:{type:"object",properties:{driftId:{type:"string",description:"The drift item id from gruum_check_buttons."},reason:{type:"string",description:"Why the spec has no button for this job."}},required:["driftId","reason"],additionalProperties:!1},run:t=>e.request(typeof t.driftId=="string"?t.driftId:"",typeof t.reason=="string"?t.reason:"")},{name:"gruum_exception_status",description:at.gruum_exception_status,inputSchema:{type:"object",properties:{id:{type:"string",description:"One request id. Omit to list this branch."}},additionalProperties:!1},run:t=>e.status(typeof t.id=="string"?t.id:void 0)}]}function We(e,t){return{jsonrpc:"2.0",id:e,result:t}}function lt(e,t,n){return{jsonrpc:"2.0",id:e,error:{code:t,message:n}}}async function Us(e,t,n){if(!e||typeof e!="object")return lt(null,-32600,"Invalid request");let s=e,r=!("id"in s),o=s.id??null;if(typeof s.method!="string")return r?null:lt(o,-32600,"Invalid request");let i=s.params??{};switch(s.method){case"initialize":{let a=i.protocolVersion;return We(o,{protocolVersion:typeof a=="string"?a:Li,capabilities:{tools:{listChanged:!1}},serverInfo:n})}case"ping":return We(o,{});case"tools/list":return We(o,{tools:t.map(({name:a,description:l,inputSchema:c})=>({name:a,description:l,inputSchema:c}))});case"tools/call":{let a=t.find(c=>c.name===i.name);if(!a)return lt(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 We(o,{content:[{type:"text",text:c.text}],isError:c.isError??!1})}catch(c){return We(o,{content:[{type:"text",text:c instanceof Error?c.message:String(c)}],isError:!0})}}default:return r?null:lt(o,-32601,`Method not found: ${s.method}`)}}var Oi=/(^|\/)(node_modules|\.git|\.next|dist|build|out|coverage|vendor|\.turbo|\.cache|__pycache__|target|\.venv|venv)\//,Mi=/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb|Cargo\.lock|poetry\.lock|composer\.lock|Gemfile\.lock)$/,Ni=/\.(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,Ti=/(^|\/)\.gruum\//;function Qt(e){return!Oi.test(`${e}/`)&&!Ti.test(`${e}/`)}function en(e,t){return Mi.test(e)||Ni.test(e)?!1:t<=3e5}function zs(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}var Di=/\.(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 Ws(e){return Di.test(e)}function tn(e){return e.replace(/\\/g,"/").replace(/^\.\/?/,"").replace(/^\/+|\/+$/g,"")}function nn(e,t){let n=tn(t),s=e.replace(/\\/g,"/");return n?s.startsWith(`${n}/`)?s.slice(n.length+1):null:s}function Gs(e,t,n){let s=new Map(e);for(let r of t){let o=nn(r.path,n);o===null||!Qt(o.split("/").slice(0,-1).join("/")||".")||(r.content===null?s.delete(o):en(o,r.content.length)&&s.set(o,r.content))}return s}function Hs(e){let t=e.split("\0").filter(Boolean),n=[];for(let s=0;s<t.length;s++){let r=t[s];if(/^[RC]/.test(r)){let i=t[++s],a=t[++s];r.startsWith("R")&&i&&n.push({path:i,deleted:!0}),a&&n.push({path:a,deleted:!1});continue}let o=t[++s];o&&n.push({path:o,deleted:r.startsWith("D")})}return n}function ct(e){let t=/^(?:git@|ssh:\/\/git@|https?:\/\/(?:[^@/]+@)?)github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(e.trim());return t?`${t[1]}/${t[2]}`:null}var Ks=e=>e.replace(/\\(.)/g,"$1");function Fi(e){let t=e;for(;;){let n=/:(?:global|local)\(/i.exec(t);if(!n)break;let s=0,r=-1;for(let i=n.index+n[0].length-1;i<t.length;i++){let a=t[i];if(a==="(")s++;else if(a===")"&&--s===0){r=i;break}}if(r<0)break;let o=t.slice(n.index+n[0].length,r).trim();t=`${t.slice(0,n.index)}${o}${t.slice(r+1)}`}return t.replace(/:(?:global|local)(?=\s|$)/gi,"").trim()}var sn=/\*|[a-z][\w-]*|\.((?:\\.|[\w-])+)|#((?:\\.|[\w-])+)|\[\s*([\w-]+)\s*(?:([~|^$*]?=)\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*[is]?\s*\]|::([\w-]+)|:([\w-]+)(\((?:[^()]|\([^()]*\))*\))?/giy;function Xs(e){let t=[];sn.lastIndex=0;let n=0;for(;n<e.length;){sn.lastIndex=n;let s=sn.exec(e);if(!s||s.index!==n)return null;let r=s[0];if(n+=r.length,r==="*")t.push({kind:"universal",raw:r});else if(s[1]!==void 0)t.push({kind:"class",raw:r,name:Ks(s[1])});else if(s[2]!==void 0)t.push({kind:"id",raw:r,name:Ks(s[2])});else if(s[3]!==void 0)t.push({kind:"attr",raw:r,name:s[3],op:s[4]??null,value:s[4]?s[5]??s[6]??s[7]??"":null});else if(s[8]!==void 0)t.push({kind:"pseudoElement",raw:r,name:s[8].toLowerCase()});else if(s[9]!==void 0){let o=s[9].toLowerCase();/^(?:before|after|first-line|first-letter)$/.test(o)?t.push({kind:"pseudoElement",raw:r,name:o}):t.push({kind:"pseudo",raw:r,name:o,args:s[10]?s[10].slice(1,-1).trim():null})}else if(t.length===0)t.push({kind:"tag",raw:r,name:r.toLowerCase()});else return null}return t.length?t:null}function Y(e){let t=Fi(e),n=[],s=0,r=0,o=null,i=!0,a=l=>{let c=t.slice(r,l).trim();if(!c)return!0;let p=Xs(c);return p?(n.push({combinator:i?null:o??" ",simples:p}),i=!1,o=null,!0):!1};for(let l=0;l<t.length;l++){let c=t[l];if(c==="("||c==="[")s++;else if(c===")"||c==="]")s=Math.max(0,s-1);else if(s===0&&(c===">"||c==="+"||c==="~")){if(!a(l)||o)return null;o=c,r=l+1}else if(s===0&&/\s/.test(c)){if(!a(l))return null;r=l+1}}return!a(t.length)||o?null:n.length?n:null}function Ge(e){return e.map(t=>t.raw).join("")}function He(e){return e.map((t,n)=>{let s=Ge(t.simples);return n===0?s:t.combinator===" "?` ${s}`:` ${t.combinator} ${s}`}).join("")}function z(e){let t=[],n=0,s=0;for(let r=0;r<e.length;r++){let o=e[r];o==="("||o==="["?n++:o===")"||o==="]"?n=Math.max(0,n-1):o===","&&n===0&&(t.push(e.slice(s,r).trim()),s=r+1)}return t.push(e.slice(s).trim()),t.filter(Boolean)}var qs=e=>e.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(t=>t.toLowerCase());function Js(e,t){let n=e.toLowerCase();return t.some(s=>n.includes(s.toLowerCase()))}function rn(e,t){let n=t.excludeClassKeywords;if(!n?.length)return!1;let s=new Set(n.flatMap(r=>[r.toLowerCase(),`${r.toLowerCase()}s`]));return e.some(r=>r.kind==="class"&&qs(r.name).some(o=>s.has(o)))}var Bi=new Set(["html","body"]),Vi=new Set(["svg","path","use","img","picture","video","i","em","strong","b","small","kbd","sup","sub"]);function pt(e,t){for(let n of e)switch(n.kind){case"tag":if(t.elements.includes(n.name))return!0;break;case"class":if(Js(n.name,t.classKeywords))return!0;break;case"attr":if(n.name==="role"&&n.value!==null&&t.roles.includes(n.value.toLowerCase())||n.name==="data-component"&&n.value!==null&&Js(n.value,t.classKeywords))return!0;break;case"pseudo":if((n.name==="is"||n.name==="where")&&n.args){let s=z(n.args).map(Y);if(s.length>0&&s.every(r=>r!==null&&pt(r[r.length-1].simples,t)))return!0}break;default:break}return!1}function Ys(e){return e.some(n=>n.kind==="universal")?e.length===1:e.some(n=>n.kind==="tag"&&Bi.has(n.name))?!0:!e.some(n=>n.kind==="tag"||n.kind==="class"||n.kind==="attr"||n.kind==="id"||n.kind==="pseudo"&&(n.name==="is"||n.name==="where"))}function Qs(e){return e.some(t=>t.kind==="tag"&&Vi.has(t.name))}var ut=["hover","focus","active","selected","current","loading","disabled"],Ui={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"},zi={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",checked:"selected",disabled:"disabled"},Wi={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"},Gi=new Set(["active","selected","pressed","checked","loading","busy","disabled","open","current","hover","focus","show","expanded","collapsed"]),Zs=e=>Ui[e.toLowerCase()]??e.toLowerCase(),ce={hover:"__gs-hover",focus:"__gs-focus",active:"__gs-active"};function er(e){if(e.kind==="pseudo"){let t=zi[e.name];if(!t)return null;let n=ce[t];return{state:t,marker:n?{classes:[n],attrs:{}}:{classes:[],attrs:{[e.name==="checked"?"checked":"disabled"]:""}}}}if(e.kind==="attr"){if(e.name==="data-state"&&e.value!==null)return{state:Zs(e.value),marker:{classes:[],attrs:{"data-state":e.value}}};let t=Wi[e.name];if(!t||e.value!==null&&/^(?:false|off|0)$/i.test(e.value))return null;let n=e.value??(e.name.startsWith("aria-")?"true":"");return{state:t,marker:{classes:[],attrs:{[e.name]:n}}}}if(e.kind==="class"){let t=/^(?:is|has)-(.+)$/i.exec(e.name),n=t?t[1]:Gi.has(e.name.toLowerCase())?e.name:null;return n?{state:Zs(n),marker:{classes:[e.name],attrs:{}}}:null}return null}function Hi(e){return e.kind!=="pseudo"||e.name!=="not"||!e.args?!1:z(e.args).every(t=>{let n=Xs(t);return n!==null&&n.every(s=>er(s)!==null)})}function ft(e){let t=[],n=new Map;for(let o of e){if(Hi(o))continue;let i=er(o);if(!i){t.push(o);continue}let a=n.get(i.state)??{classes:[],attrs:{}};for(let l of i.marker.classes)a.classes.includes(l)||a.classes.push(l);Object.assign(a.attrs,i.marker.attrs),n.set(i.state,a)}let s=[...n.keys()].sort((o,i)=>H(o)-H(i)||o.localeCompare(i)),r={classes:[],attrs:{}};for(let o of s){let i=n.get(o);r.classes.push(...i.classes),Object.assign(r.attrs,i.attrs)}return{identity:t,states:s,marker:r}}function H(e){if(e==="default")return-1;let t=ut.indexOf(e);return t===-1?ut.length:t}function be(e){return e.length?e.join(" + "):"default"}function on(e){return e.replace(/:hover\b/g,`.${ce.hover}`).replace(/:focus(?:-visible|-within)?\b/g,`.${ce.focus}`).replace(/:active\b/g,`.${ce.active}`)}var Ki=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"]),Ji=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"]),Zi=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 Ke(e){let t=e.toLowerCase();return Ki.has(t)?"paint":Ji.has(t)?"layout":Zi.has(t)?"hint":"box"}var Xi={shadow:/^box-shadow$/,cursor:/^cursor$/,rounded:/^border(?:-[a-z]+)*-radius$/,radius:/^border(?:-[a-z]+)*-radius$/};function tr(e,t){let n=e.filter(o=>o.kind==="class");if(n.length!==1||e.length!==1)return!1;let s=qs(n[0].name)[0],r=s?Xi[s]:void 0;return r?t.length>0&&t.every(o=>r.test(o.property.toLowerCase())):!1}var Pu={hover:{classes:[ce.hover],attrs:{}},focus:{classes:[ce.focus],attrs:{}},active:{classes:[ce.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 qi="data-gs-sheet";function sr(e){return`[${qi}="${e.replace(/["\\]/g,"")}"]`}function nr(e){return/\.module\.[a-z]+$/i.test(e)}var Yi=new Set(["button","a","div","span","input","summary","label"]);function ye(e){let t=0,n=0;for(let s=0;s<e.length;s++){let r=e[s];r==="("||r==="["?t++:r===")"||r==="]"?t=Math.max(0,t-1):t===0&&/[\s>+~]/.test(r)&&(n=s+1)}return n}function Qi(e){let t={tag:"",classes:[],attrs:{}};for(let n of e)switch(n.kind){case"pseudoElement":return null;case"tag":t.tag=n.name;break;case"class":t.classes.push(n.name);break;case"attr":t.attrs[n.name]=n.value??"";break;default:break}return t}function dt(e,t){let n=Y(e);if(!n||n.some(c=>c.combinator==="+"||c.combinator==="~"))return null;let s=n.map(c=>Qi(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(!Yi.has(i)||o.classes.length===0&&Object.keys(o.attrs).length===0&&!o.tag)return null;let a=[...new Set([...t,...o.classes])],l=r.slice(0,-1).filter(c=>c.tag||c.classes.length||Object.keys(c.attrs).length).map(c=>({...c,tag:c.tag&&c.tag!=="*"?c.tag:"div"}));return{tag:i,classes:a,attrs:o.attrs,ancestors:l}}function an(e,t){let n="";for(let s of e)s.property.toLowerCase()===t&&(n=s.value.replace(/!important\s*$/i,"").trim());return n}function gt(e){let t=an(e,"display");if(/^none\b/i.test(t))return"display: none";let n=an(e,"visibility");if(/^(hidden|collapse)\b/i.test(n))return`visibility: ${n.split(/\s+/)[0].toLowerCase()}`;let s=an(e,"opacity");return/^(0|0\.0+)$/.test(s)?"opacity: 0":null}function rr(e,t){return e===t||!nr(e)&&!nr(t)}function se(e,t){if(/[<>]|@import|expression\(|javascript:|behavior\s*:/i.test(t))return!1;for(let n of t.matchAll(/url\(\s*(['"]?)([^'")]*)\1\s*\)/gi))if(!/^data:image\//i.test(n[2]))return!1;return/^-{0,2}[a-z][\w-]*$/i.test(e)}var ea=40,Q=(e,t)=>({path:e,line:t});function ee(e,t,n,s){return{...e,status:t.length===0?"ok":"attention",summary:t.length===0?n:s(t.length),findings:t.slice(0,ea)}}function xe(e,t){return{...e,status:"na",summary:t,findings:[]}}var ln=e=>e.state.split(" + ");function cr(e,t){if(!e.element||!t.element||e!==t&&!rr(e.path,t.path)||e.element.ancestors.length>0||e.element.tag!==t.element.tag)return!1;let n=new Set(t.element.classes);return e.element.classes.every(s=>n.has(s))?Object.entries(e.element.attrs).every(([s,r])=>t.element.attrs[s]===r):!1}function ur(e,t){return t.filter(n=>cr(n,e)).flatMap(n=>n.states)}function ta(e,t,n){return ur(e,t).some(s=>ln(s).includes(n))||t.filter(s=>cr(s,e)).some(s=>(s.parts??[]).some(r=>r.state.split(" + ").includes(n)))}var na=[{state:"hover",severity:"issue"},{state:"focus",severity:"issue"},{state:"disabled",severity:"issue"},{state:"active",severity:"note"}];function sa(e){let t={id:"states",title:"Missing states",description:"Styles with no hover, focus, disabled, or active rule, counting rules they inherit from a shared base class."},n=e.variants.filter(r=>r.element&&r.element.ancestors.length===0);if(n.length===0)return xe(t,"No styles that can be drawn on their own.");let s=[];for(let{state:r,severity:o}of na){let i=n.filter(a=>!ta(a,e.variants,r));i.length!==0&&s.push({severity:o,message:i.length===n.length?`No style defines a ${r} state.`:`${i.length} of ${n.length} styles have no ${r} state.`,styles:i.length===n.length?void 0:i.map(a=>a.title),refs:i.slice(0,6).map(a=>Q(a.path,a.line))})}return ee(t,s,"Every style has hover, focus, disabled, and active rules.",r=>`${r} state${r===1?"":"s"} missing on some styles.`)}var or=new Set(["outline","outline-style","outline-width"]),ir=/^(?:none|0|0px)(?:\s+(?:none|0|0px))*$/i,ra=/^(?:outline(?:-color|-width|-style)?|box-shadow|border(?:-[a-z]+)*|background(?:-color)?|text-decoration(?:-[a-z]+)?|color)$/;function oa(e){let t={id:"focus",title:"Focus indicator removed",description:"Styles that remove the outline and give keyboard focus nothing in its place."},n=e.variants.filter(r=>r.element&&r.element.ancestors.length===0);if(n.length===0)return xe(t,"No styles that can be drawn on their own.");let s=[];for(let r of n){let o=ur(r,e.variants),i=o.filter(l=>{let c=ln(l);return c.includes("default")||c.includes("focus")}).flatMap(l=>l.declarations.map(c=>({s:l,d:c}))).find(({d:l})=>or.has(l.property)&&ir.test(l.value.replace(/\s*!important/i,"")));!i||o.filter(l=>ln(l).includes("focus")).some(l=>l.declarations.some(c=>ra.test(c.property)&&!(or.has(c.property)&&ir.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 ee(t,s,"No style removes the outline without a focus replacement.",r=>`${r} style${r===1?"":"s"} lose the focus indicator.`)}function ia(e){let t={id:"tokens",title:"Undefined tokens",description:`Custom properties the ${e.noun} styles read that no scanned stylesheet defines.`};if(e.tokens.length===0)return xe(t,`The ${e.noun} styles read no custom properties.`);let s=e.tokens.filter(r=>r.definedIn.length===0&&!r.name.startsWith("--tw-")).map(r=>{let o=e.variants.filter(i=>i.states.some(a=>a.declarations.some(l=>l.value.includes(`var(${r.name}`)||new RegExp(`var\\(\\s*${r.name}\\b`).test(l.value))));return{severity:"note",message:`${r.name} is read but never defined here. It may be set outside the scanned files (a framework, a theme provider).`,styles:o.slice(0,8).map(i=>i.title),refs:o.slice(0,3).map(i=>Q(i.path,i.line))}});return ee(t,s,`All ${e.tokens.length} tokens read are defined.`,r=>`${r} token${r===1?"":"s"} with no definition.`)}var aa=/var\((?:[^()]|\([^()]*\))*\)/g,ar=/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?)\([^)]*\)/gi,la=/^(?:padding|margin|gap|row-gap|column-gap|height|min-height|max-height|border-radius|font-size|letter-spacing)(?:-[a-z]+)*$/,ca=/(?<![\w.-])(\d+(?:\.\d+)?)px\b/g;function lr(e){let t=e.trim().toLowerCase().replace(/\s+/g,""),n=/^#([0-9a-f]{3})$/.exec(t);return n?`#${[...n[1]].map(s=>s+s).join("")}`:t}function cn(e,t,n=0){return n>6?e:e.replace(/var\(\s*(--[\w-]+)\s*(?:,\s*([^)]*))?\)/g,(s,r,o)=>{let i=t.get(r);return i!==void 0?cn(i,t,n+1):o!==void 0?cn(o.trim(),t,n+1):s})}var ua=[[/^(?: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 pa(e,t){if(!t)return null;let n=ua.find(([s])=>s.test(e))?.[1];return t.find(s=>!n||n.test(s))??null}function fa(e){let t={id:"hardcoded",title:"Hard-coded values",description:`Raw colors, and pixel sizes that exactly match a token, written into ${e.noun} styles instead of using the token.`},n=new Map,s=new Map;for(let[o,i]of e.tokenValues){let a=cn(i,e.tokenValues).trim();if(new RegExp(`^(?:${ar.source})$`,"i").test(a)){let l=lr(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 xe(t,"No color or size tokens were found to compare against.");let r=[];for(let o of e.variants){let i=[],a=null;for(let c of o.states)for(let p of c.declarations){if(p.via)continue;let f=p.value.replace(aa," ");for(let m of f.matchAll(ar)){let h=n.get(lr(m[0]));i.push(h?`${m[0]} in ${p.property} is the value of ${h[0]}`:`${m[0]} in ${p.property} is not a token`),a??=c}if(la.test(p.property))for(let m of f.matchAll(ca)){let h=pa(p.property,s.get(`${m[1]}px`));!h||Number(m[1])<=1||(i.push(`${m[1]}px in ${p.property} is the value of ${h}`),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 ee(t,r,`No ${e.noun} style hard-codes a value a token already has.`,o=>`${o} style${o===1?"":"s"} hard-code values.`)}function da(e){let t={id:"unused",title:"Unused styles",description:"Styles defined in CSS that no component, page, or template references."},n=e.variants.filter(r=>r.element&&r.usage.status!=="unknown");if(n.length===0)return xe(t,"No styles with a class name to look for.");let s=[];for(let r of n)r.usage.status==="unreferenced"?s.push({severity:"issue",message:`${r.title} (${r.selector}) is defined but no reference to it was found.`,styles:[r.title],refs:[Q(r.path,r.line)]}):r.usage.status==="dynamic"&&s.push({severity:"note",message:`${r.title} (${r.selector}) is built at runtime and nothing selects it by value.`,styles:[r.title],refs:[Q(r.path,r.line),...r.usage.files.slice(0,2)]});return s.sort((r,o)=>+(o.severity==="issue")-+(r.severity==="issue")),ee(t,s,`All ${n.length} styles are referenced.`,r=>`${r} style${r===1?"":"s"} unreferenced or unconfirmed.`)}function ga(e){let t={id:"duplicates",title:"Duplicate styles",description:"Different styles whose default declarations are identical."},n=new Map;for(let r of e.variants){if(!r.element)continue;let o=r.states.filter(a=>a.state==="default"&&a.context==="").flatMap(a=>a.declarations).map(a=>`${a.property}:${a.value.replace(/\s+/g," ").trim()}`);if(o.length<2)continue;let i=[...new Set(o)].sort().join(";");n.set(i,[...n.get(i)??[],r])}let s=[...n.values()].filter(r=>r.length>1).map(r=>({severity:"issue",message:`${r.map(o=>o.title).join(", ")} declare the same default styles (${r.map(o=>o.selector).join(", ")}).`,styles:r.map(o=>o.title),refs:r.map(o=>Q(o.path,o.line))}));return ee(t,s,"No two styles share the same default declarations.",r=>`${r} group${r===1?"":"s"} of identical styles.`)}function ma(e){let t={id:"native",title:`Native <${e.element}> instead of the component`,description:`Files that render a raw <${e.element}> although the repository has a shared ${e.element} component.`};if(!e.hasComponent)return xe(t,`No shared ${e.element} component was found, so native elements are expected.`);let n=e.nativeUses.map(s=>({severity:"issue",message:`${s.count} native <${e.element}> element${s.count===1?"":"s"} in ${s.path}.`,refs:[Q(s.path,s.line)]}));return ee(t,n,`Every <${e.element}> goes through the component.`,s=>`${s} file${s===1?"":"s"} bypass the component.`)}function ha(e){let t={id:"props",title:"Prop values with no look",description:`Calls to a ${e.element} component with a literal prop value the component has no style for.`};if(!e.hasComponent)return xe(t,`No shared ${e.element} component was found.`);let n=(e.unknownProps??[]).map(s=>({severity:"issue",message:`<${s.component} ${s.prop}="${s.value}"> in ${s.path}: ${s.component} has no ${s.prop} "${s.value}" (it has ${s.known.join(", ")}).`,refs:[Q(s.path,s.line)]}));return ee(t,n,"Every literal prop value picks a look the component has.",s=>`${s} call${s===1?"":"s"} ask for a look the component does not have.`)}function ba(e){let t={id:"undocumented",title:"Styles without written guidance",description:"Styles that no instruction file or doc names, so nothing written says how they should be used."},{guidance:n}=e;if(n.files.length===0)return{...t,status:"attention",summary:`Nothing in the repository mentions ${e.noun}.`,findings:[{severity:"note",message:`No instruction file or doc says how ${e.noun} should look or be built.`,refs:[]}]};if(n.undocumented.length===0)return ee(t,[],"Every style is named in written guidance.",()=>"");let s=e.variants.filter(r=>r.element&&n.undocumented.includes(r.title));return ee(t,[{severity:"note",message:`${n.undocumented.length} of ${n.documented.length+n.undocumented.length} styles are named in no guidance.`,styles:n.undocumented,refs:s.slice(0,6).map(r=>Q(r.path,r.line))}],"",r=>`${r} finding${r===1?"":"s"}.`)}function pr(e){return[sa(e),oa(e),da(e),ga(e),ia(e),fa(e),ma(e),ha(e),ba(e)]}var ya=/\.(erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,fr=/^<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/,xa=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),wa=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),ka=new Set(["classNames","classnames","clsx","cn","cx"]),va=/^(?:ref|key|style|dangerouslySetInnerHTML)$/i;function mr(e,t){let n=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
40
+ `&&n++;return n}function dr(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function hr(e){let t=e.filter(s=>s.trim()).map(s=>/^ */.exec(s)?.[0].length??0),n=t.length?Math.min(...t):0;return e.map(s=>{let r=s.slice(n);return r.length>200?`${r.slice(0,200)}\u2026`:r}).join(`
41
+ `)}function $a(e,t,n){let s=Math.max(0,Math.min(t,e.length)),r=Math.max(s,Math.min(n,e.length)),o=mr(e,s),i=e.slice(s,r).split(`
42
42
  `).slice(0,12),a=e.slice(s,r).split(`
43
- `).length>12;return{source:fr(i)+(a?`
44
- \u2026`:""),startLine:o}}function wa(e,t){let n=pr(e,Math.max(0,t)),s=e.split(`
45
- `),r=Math.max(0,n-1);return{source:fr(s.slice(r,r+12)),startLine:r+1}}function ur(e,t){return{kind:"other",...wa(e,t)}}function yt(e,t){let n=lr.exec(e.slice(t));if(!n)return null;let s=n[1],r=n[2]??"",o=t+n[0].length;if(/\/\s*$/.test(r)||ma.has(s.toLowerCase()))return{tag:s,attrs:r,openStart:t,openEnd:o,closeEnd:o,body:""};let a=1,l=o,c=Math.min(e.length,t+4e3);for(;l<c;){if(e[l]!=="<"){l++;continue}if(e.startsWith("</",l)){let f=/^<\/([A-Za-z][\w.-]*)\s*>/.exec(e.slice(l));if(f&&f[1].toLowerCase()===s.toLowerCase()){if(a--,a===0){let m=l+f[0].length;return{tag:s,attrs:r,openStart:t,openEnd:o,closeEnd:m,body:e.slice(o,l)}}l+=f?f[0].length:2;continue}l+=f?f[0].length:2;continue}let u=lr.exec(e.slice(l));if(u&&u[1].toLowerCase()===s.toLowerCase()&&!/\/\s*$/.test(u[2]??"")&&(a++,a>6))return"too-big";l+=u?u[0].length:1}return l>=c&&o+(c-t)>=4e3?"too-big":null}function an(e,t){let n=Math.max(0,t-8e3),s=Math.min(t,e.length-1);for(;s>=n;){let r=e.lastIndexOf("<",s);if(r<n)return null;if(e[r+1]==="/"||e[r+1]==="!"||e[r+1]==="?"){s=r-1;continue}let o=yt(e,r);if(o==="too-big")return"too-big";if(o&&t>=o.openStart&&t<o.closeEnd)return o;s=r-1}return null}function dr(e){return e.replace(/([a-z\d])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function je(e){return e.split(/\s+/).filter(Boolean)}function ce(e,t){let n=e[t];if(n!=='"'&&n!=="'"&&n!=="`")return null;let s="";for(let r=t+1;r<e.length;r++){let o=e[r];if(o==="\\"){s+=e[r+1]??"",r++;continue}if(n==="`"&&o==="$"&&e[r+1]==="{")return null;if(o===n)return{value:s,end:r+1};s+=o}return null}function gr(e){let t=[],n="",s=0,r=null;for(let o=0;o<e.length;o++){let i=e[o];if(r){if(n+=i,i==="\\"){n+=e[o+1]??"",o++;continue}i===r&&(r=null);continue}if(i==='"'||i==="'"||i==="`"){r=i,n+=i;continue}if(i==="("||i==="["||i==="{")s++;else if(i===")"||i==="]"||i==="}")s=Math.max(0,s-1);else if(i===","&&s===0){n.trim()&&t.push(n.trim()),n="";continue}n+=i}return n.trim()&&t.push(n.trim()),t}function ht(e=new Map,t=new Map){return{values:e,aliases:t,flags:new Set,strings:new Set,prefixes:new Map}}var on=/^[A-Za-z_$][\w$]*$/;function ln(e,t){let n=0,s=null;for(let r=0;r<e.length;r++){let o=e[r];if(s){o==="\\"?r++:o===s&&(s=null);continue}if(o==='"'||o==="'"||o==="`"){s=o;continue}if(o==="("||o==="["||o==="{")n++;else if(o===")"||o==="]"||o==="}")n--;else if(n===0&&e.startsWith(t,r))return r}return-1}function cn(e){let t=e.trim();for(;t.startsWith("(")&&t.endsWith(")");){let n=0,s=!0;for(let r=0;r<t.length-1&&s;r++)t[r]==="("?n++:t[r]===")"&&n--,n===0&&(s=!1);if(!s)break;t=t.slice(1,-1).trim()}return t}function mr(e,t,n){if(e==="true")return!0;if(e==="false"||e==="undefined"||e==="null")return!1;let s=t.aliases.get(e);return s!==void 0&&!t.values.has(e)?Pe(s,t,n+1):(t.flags.add(e),!!t.values.get(e))}function Pe(e,t,n=0){if(n>4)return null;let s=cn(e);for(let c of["||","&&"]){let u=ln(s,c);if(u<0)continue;let f=Pe(s.slice(0,u),t,n+1),m=Pe(s.slice(u+2),t,n+1);return f===null||m===null?null:c==="||"?f||m:f&&m}let r=/^(!\s*)?([A-Za-z_$][\w$]*)$/.exec(s);if(r){let c=mr(r[2],t,n);return c===null?null:r[1]?!c:c}let o=/^([A-Za-z_$][\w$]*)\s*(===|==|!==|!=)\s*(["'])(.*?)\3$/.exec(s);if(!o)return null;let i=t.values.get(o[1]);typeof i=="string"&&t.strings.add(o[1]);let a=typeof i=="string"?i:"";return o[2]==="==="||o[2]==="=="?a===o[4]:a!==o[4]}function hr(e){let t=0,n=null,s=-1;for(let r=0;r<e.length;r++){let o=e[r];if(n){o==="\\"?r++:o===n&&(n=null);continue}if(o==='"'||o==="'"||o==="`"){n=o;continue}if(o==="("||o==="["||o==="{")t++;else if(o===")"||o==="]"||o==="}")t--;else if(o==="?"&&t===0){s=r;break}}if(s<0)return null;t=0,n=null;for(let r=s+1;r<e.length;r++){let o=e[r];if(n){o==="\\"?r++:o===n&&(n=null);continue}if(o==='"'||o==="'"||o==="`"){n=o;continue}if(o==="("||o==="["||o==="{")t++;else if(o===")"||o==="]"||o==="}")t--;else if(o===":"&&t===0)return{condition:e.slice(0,s),yes:e.slice(s+1,r),no:e.slice(r+1)}}return null}function Ie(e,t=ht()){let n=cn(e);if(!n)return{classes:[],dynamic:!1};let s=hr(n);if(s){let c=Pe(s.condition,t);return c===null?{classes:[],dynamic:!0}:Ie(c?s.yes:s.no,t)}let r=ln(n,"&&");if(r>=0){let c=Pe(n.slice(0,r),t);return c===null?{classes:[],dynamic:!0}:c?Ie(n.slice(r+2),t):{classes:[],dynamic:!1}}if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))return{classes:je(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 h=c.indexOf("}",m+2);if(h<0)return{classes:[],dynamic:!0};let $=c.slice(m+2,h).trim();if(on.test($)){let k=t.values.get($);if(typeof k!="string")return{classes:[],dynamic:!0};t.strings.add($);let w=/[\w-]*$/.exec(u)?.[0];w&&t.prefixes.set($,w),u+=k}else{let k=Ie($,t);if(k.dynamic)return{classes:[],dynamic:!0};u+=k.classes.join(" ")}f=h+1}return{classes:je(u),dynamic:!1}}if(on.test(n)&&t.values.has(n)){let c=t.values.get(n);return typeof c!="string"?{classes:[],dynamic:!1}:(t.strings.add(n),{classes:je(c),dynamic:!1})}let o=/^(?:styles?|classes|css|cls)\.([A-Za-z_]\w*)$/.exec(n);if(o)return{classes:[dr(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=Ie(a[1],t);return c.dynamic||c.classes.length!==1?{classes:[],dynamic:!0}:c}let l=/^([A-Za-z_][\w]*)\s*\(([\s\S]*)\)$/.exec(n);if(l&&ba.has(l[1])){let c=[];for(let u of gr(l[2])){let f=Ie(u,t);if(f.dynamic)return{classes:[],dynamic:!0};c.push(...f.classes)}return{classes:c,dynamic:!1}}return{classes:[],dynamic:!0}}function xt(e){let t=[],n=!1,s=0;for(;s<e.length;){if(/\s/.test(e[s])){s++;continue}if(e[s]==="{"){let i=0,a=s;for(let l=s;l<e.length;l++)if(e[l]==="{")i++;else if(e[l]==="}"&&(i--,i===0)){s=l+1;break}s===a&&(s=e.length),/^\{\s*\.\.\./.test(e.slice(a))&&(n=!0);continue}let r=/^([A-Za-z_:][\w:.-]*)/.exec(e.slice(s));if(!r){s++;continue}for(s+=r[0].length;s<e.length&&/\s/.test(e[s]);)s++;if(e[s]!=="="){t.push({name:r[1]});continue}for(s++;s<e.length&&/\s/.test(e[s]);)s++;let o=ce(e,s);if(o){t.push({name:r[1],value:o.value}),s=o.end;continue}if(e[s]==="{"){let i=0,a=s;for(let u=s;u<e.length;u++)if(e[u]==="{")i++;else if(e[u]==="}"&&(i--,i===0)){s=u+1;break}s===a&&(s=e.length);let l=e.slice(a+1,s-1).trim(),c=ce(l,0);c&&c.end===l.length?t.push({name:r[1],value:c.value}):t.push({name:r[1],expr:l});continue}s++}return{list:t,spread:n}}function un(e,t){let n=xt(e).list.find(s=>s.name==="class"||s.name==="className");return n?n.value!==void 0?{classes:je(n.value),dynamic:!1}:n.expr===void 0?{classes:[],dynamic:!0}:Ie(n.expr,t):null}function br(e,t){return/[<>]/.test(t)?!1:e==="href"||e==="src"||e==="action"?/^(?:https?:|mailto:|\/|#)/i.test(t):!0}function ka(e){return e==="class"||e==="className"?!1:!ya.test(e)&&!/^on/i.test(e)}function yr(e){let t={};for(let n of xt(e).list){if(!ka(n.name)||n.expr!==void 0)continue;let s=n.value??"";br(n.name,s)&&(t[n.name]=s)}return t}var va=/^(?:data-[\w-]+|aria-[\w-]+|disabled|hidden)$/,$a=new Set(["disabled","hidden"]);function mt(e,t,n=0){if(n>4)return null;let s=cn(e),r=ce(s,0);if(r&&r.end===s.length)return r.value;let o=hr(s);if(o){let l=Pe(o.condition,t);return l===null?null:mt(l?o.yes:o.no,t,n+1)}let i=ln(s,"||");if(i>=0){let l=mt(s.slice(0,i),t,n+1);return l===null?null:l!==void 0?l:mt(s.slice(i+2),t,n+1)}if(s==="undefined"||s==="null"||s==="false")return;if(s==="true")return"true";if(!on.test(s))return null;let a=t.values.get(s);if(typeof a=="string")return t.strings.add(s),a;if(typeof a=="boolean"||t.aliases.has(s)){let l=mr(s,t,n);return l===null?null:l?"true":void 0}return t.values.has(s)?void 0:null}function Ca(e,t){let n={};for(let s of xt(e).list){if(s.expr===void 0||!va.test(s.name))continue;let r=mt(s.expr,t);if(r!=null){if($a.has(s.name)){r!=="false"&&(n[s.name]="");continue}br(s.name,r)&&(n[s.name]=r)}}return n}function Sa(e,t){let n=/([A-Za-z_][\w-]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*["']([^"']*)["']\s*\})/g;for(let s of e.matchAll(n)){let r=s.index??0;if(t>=r&&t<r+s[0].length){let o=s[1];return o==="class"||o==="className"?{}:{prop:o,value:s[2]??s[3]??s[4]}}}return{}}function bt(e,t=0){if(t>6)return"";let n="",s=0;for(;s<e.length;){if(e[s]==="{"){let i=0,a=s;for(let u=s;u<e.length;u++)if(e[u]==="{")i++;else if(e[u]==="}"&&(i--,i===0)){a=u+1;break}if(a===s)break;let l=e.slice(s+1,a-1).trim();/^[A-Za-z_$][\w$]*$/.exec(l)?.[0]&&(n+='<span class="__gs-slot">Text</span>'),s=a;continue}if(e[s]==="<"){if(e.startsWith("<!--",s)){let l=e.indexOf("-->",s);s=l===-1?e.length:l+3;continue}if(e.startsWith("</",s)){let l=/^<\/[A-Za-z][\w.-]*\s*>/.exec(e.slice(s));s+=l?l[0].length:1;continue}let i=yt(e,s);if(!i||i==="too-big"){s++;continue}let a=i.tag.toLowerCase();if(/^[A-Z]/.test(i.tag))n+=bt(i.body,t+1);else if(ha.has(a)){let l=un(i.attrs),c=l&&!l.dynamic&&l.classes.length?` class="${cr(l.classes.join(" "))}"`:"",u=bt(i.body,t+1);n+=`<${a}${c}>${u}</${a}>`}s=i.closeEnd;continue}let r=e.slice(s).search(/[<{}]/),o=r===-1?e.length:s+r;n+=cr(e.slice(s,o)),s=o}return n}function Ra(e){let t=un(e.attrs);return!t||t.dynamic||t.classes.length===0?null:{tag:e.tag.toLowerCase(),classes:t.classes,attrs:yr(e.attrs)}}function xr(e,t){let n=[],s=t-1;for(;n.length<3&&s>=0;){let r=an(e,s);if(!r||r==="too-big"||/^[A-Z]/.test(r.tag))break;let o=Ra(r);if(!o)break;n.push(o),s=r.openStart-1}return n.reverse()}var Aa=8;function _a(e){let t=e.trim(),n=ce(t,0);return n&&n.end===t.length?n.value:t==="true"?!0:t==="false"?!1:/^-?\d+(?:\.\d+)?$/.test(t)?t:null}function Ea(e,t){let n=0,s=-1;for(let i=t;i<e.length&&i<t+2e3;i++){let a=e[i];if(a==='"'||a==="'"||a==="`"){let l=ce(e,i);if(!l)return null;i=l.end-1;continue}if(a==="{")n++;else if(a==="}"&&(n--,n===0)){s=i;break}}if(s<0)return null;let r=e.slice(s+1).trimStart()[0];if(r!==")"&&r!==":")return null;let o=new Map;for(let i of gr(e.slice(t+1,s))){if(i.startsWith("..."))continue;let a=/^([A-Za-z_$][\w$]*)(?:\s*:\s*([A-Za-z_$][\w$]*))?(?:\s*=\s*([\s\S]+))?$/.exec(i);if(!a)continue;let l=a[2]??a[1];if(a[3]===void 0){o.set(l,void 0);continue}let c=_a(a[3]);c!==null&&o.set(l,c)}return{values:o,end:s}}function Ia(e,t){let n=new Set(t.attrs.match(/[A-Za-z_$][\w$]*/g)??[]),s=Math.max(0,t.openStart-8e3),o=[...e.slice(s,t.openStart).matchAll(/\(\s*\{/g)].reverse();for(let i of o){let a=s+(i.index??0)+i[0].length-1,l=Ea(e,a);if(!l||![...l.values.keys()].some(f=>n.has(f)))continue;let c=new Map,u=e.slice(l.end,t.openStart);for(let f of u.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*([^;\n]+);/g))n.has(f[1])&&c.set(f[1],f[2].trim());return ht(l.values,c)}return ht()}function ja(e,t){let n=new Map;for(let s of e.matchAll(/([\w-]+)\$\{\s*([A-Za-z_$][\w$]*)\s*\}/g)){let r=s[1],o=t.find(i=>i.startsWith(r)&&i.length>r.length);o&&n.set(s[2],o.slice(r.length))}return n}function Pa(e,t,n,s){let r=xa(e,t.openStart,t.closeEnd);if(/^[A-Z]/.test(t.tag)){let m=Sa(e.slice(t.openStart,t.openEnd),n-t.openStart);return{kind:"component",...r,component:{tag:t.tag,...m}}}let o=Ia(e,t);for(let[m,h]of ja(t.attrs,s))o.values.set(m,h);let i={};for(let[m,h]of o.values)i[m]=h??null;let a={attrs:t.attrs,values:i,aliases:Object.fromEntries(o.aliases)},l=ht(new Map(o.values),o.aliases),c=La(a.attrs,l);if(!c)return{kind:"dynamic",...r};let u={tag:t.tag.toLowerCase(),...c,ancestors:xr(e,t.openStart),bodyHtml:bt(t.body)},f=[...[...l.strings].filter(m=>typeof o.values.get(m)=="string").map(m=>({name:m,kind:"text",...l.prefixes.has(m)?{prefix:l.prefixes.get(m)}:{}})),...[...l.flags].slice(0,Aa).map(m=>({name:m,kind:"flag"}))];return f.length===0?{kind:"markup",...r,element:u}:{kind:"markup",...r,element:u,params:f,redraw:a}}function La(e,t){let n=un(e,t);return n?.dynamic?null:{classes:n?.classes??[],attrs:{...yr(e),...Ca(e,t)}}}function pn(e,t,n,s){if(ga.test(s))return ur(e,t);let r=an(e,t);return r==="too-big"||!r?ur(e,t):Pa(e,r,t,n)}function Oa(e){let t={},n=new Set,{list:s,spread:r}=xt(e);for(let o of s)o.expr===void 0?t[o.name]=o.value??"true":o.expr==="true"||o.expr==="false"?t[o.name]=o.expr:n.add(o.name);return{literals:t,dynamic:n,spread:r}}function wr(e,t){let n=Oa(t),s=new Map,r=[],o=[],i=[],a=n.spread;for(let l of e.axes){if(l.opaque){a=!0;continue}if(!l.locked&&n.dynamic.has(l.prop)){a=!0;continue}let c=l.locked?l.defaultValue:n.literals[l.prop]??(n.spread?void 0:l.defaultValue);if(c===void 0)continue;s.set(l.prop,c);let u=!l.locked&&n.literals[l.prop]===c;if(l.prefix){o.push(`${l.prefix}${c}`),u&&c!==l.defaultValue&&i.push({prop:l.prop,value:c,known:l.defaultValue?[l.defaultValue]:[],cls:`${l.prefix}${c}`});continue}let f=l.values.find(m=>m.value===c);if(!f){a=!0,u&&l.values.length>0&&i.push({prop:l.prop,value:c,known:l.values.map(m=>m.value)});continue}for(let m of f.classes)m.startsWith("__gs-recipe-")&&r.push(m),o.push(m)}if(!a){for(let l of e.compounds)if(l.when.every(u=>s.get(u.prop)===u.value))for(let u of l.classes)u.startsWith("__gs-recipe-")&&r.push(u),o.push(u)}return e.classNameProp&&(n.dynamic.has("className")?a=!0:n.literals.className&&o.push(...je(n.literals.className))),{draw:a?null:[...e.staticClasses,...o],selects:r,unknown:i}}function fn(e){let t=[],n=/import\s*\{([^}]+)\}\s*from\s*["']([^"']+)["']/g;for(let s of e.matchAll(n)){let r=s[2];for(let o of s[1].split(",")){let i=o.trim().split(/\s+as\s+/),a=i[0]?.trim(),l=(i[1]??i[0])?.trim();a&&l&&t.push({local:l,imported:a,spec:r})}}return t}function Ma(e,t,n,s,r){for(let o of fn(t)){if(o.local!==n)continue;let i=r(e,o.spec),a=s.find(l=>l.path===i&&l.component===o.imported);if(a)return a}return s.find(o=>o.path===e&&o.component===n)}function kr(e,t,n,s,r,o){if(e.kind!=="component"||!e.component||r.length===0)return e;let i=Ma(s,t,e.component.tag,r,o);if(!i)return e;let a=an(t,n),l=e.component.tag;if(!a||a==="too-big"||a.tag!==l&&a.tag!==i.component)return e;let c=wr(i,a.attrs);return c.draw?{kind:"markup",source:e.source,startLine:e.startLine,component:e.component,element:{tag:i.rootTag,classes:c.draw,attrs:{},ancestors:xr(t,a.openStart),bodyHtml:bt(a.body)}}:e}function wt(e,t,n,s){let r=[],o=new Set,i=(l,c)=>{let u=`${l}\0${c.path}`;o.has(u)||(o.add(u),r.push({local:l,binding:c}))};for(let l of fn(t)){let c=s(e,l.spec),u=n.find(f=>f.path===c&&f.component===l.imported);u&&i(l.local,u)}for(let l of n)l.path===e&&i(l.component,l);let a=[];for(let{local:l,binding:c}of r){let u=0,f=`<${l}`;for(;u<t.length;){let m=t.indexOf(f,u);if(m<0)break;let h=t[m+f.length];if(h&&/[\w.]/.test(h)){u=m+f.length;continue}let $=yt(t,m);if(!$||$==="too-big"){u=m+f.length;continue}let k=wr(c,$.attrs);(k.selects.length||k.unknown.length)&&a.push({offset:m,component:l,selects:k.selects,unknown:k.unknown}),u=Math.max($.closeEnd,m+f.length)}}return a}function Na(e,t){let n=e.slice(t,t+700),s=n.indexOf("{");if(s<0)return{};let r=n.indexOf("}",s),o=n.slice(s,r<0?s+400:r+1),i={};for(let a of o.matchAll(/([A-Za-z_$][\w$]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))i[a[1]]=a[2]??a[3]??"";return i}function Ta(e){let t=/\bclassName\s*=\s*/.exec(e);if(!t)return null;let n=t.index+t[0].length,s=ce(e,n);if(s)return s.value;if(e[n]!=="{")return null;let r=0;for(let o=n;o<e.length;o++)if(e[o]==="{")r++;else if(e[o]==="}"&&(r--,r===0))return e.slice(n+1,o);return null}function Da(e,t){let n=t+1;for(;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]===")")return{rename:{},fixed:{},opaque:[]};if(e[n]!=="{")return null;let s={rename:{},fixed:{},opaque:[]};for(n++;n<e.length;){for(;n<e.length&&/[\s,]/.test(e[n]);)n++;if(e[n]==="}")return s;if(e.startsWith("...",n))return null;let r=/^[A-Za-z_$][\w$]*/.exec(e.slice(n));if(!r)return null;for(n+=r[0].length;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]===","||e[n]==="}"){s.rename[r[0]]=r[0];continue}if(e[n]!==":")return null;for(n++;n<e.length&&/\s/.test(e[n]);)n++;let o=ce(e,n);if(o){s.fixed[r[0]]=o.value,n=o.end;continue}let i=/^[A-Za-z_$][\w$]*/.exec(e.slice(n));if(i){s.rename[r[0]]=i[0],n+=i[0].length;continue}s.opaque.push(r[0]);let a=0;for(;n<e.length;){let l=e[n];if(l==='"'||l==="'"||l==="`"){let c=ce(e,n);if(!c)return null;n=c.end;continue}if(l==="("||l==="["||l==="{")a++;else if(l===")"||l==="]"||l==="}"){if(a===0)break;a--}else if(l===","&&a===0)break;n++}}return null}function Va(e,t,n,s){let r=[];for(let o of fn(e)){let i=s(t,o.spec),a=n.find(l=>l.path===i&&l.name===o.imported);a&&r.push({local:o.local,recipe:a})}for(let o of n)o.path===t&&o.name&&r.push({local:o.name,recipe:o});return r}function Ba(e){let t=[],n=/(?:styles?|classes|css|cls)\s*\.\s*([A-Za-z_]\w*)/g;for(let c of e.matchAll(n))t.push({at:c.index??0,kind:"static",text:dr(c[1])});let s=/(?:styles?|classes|css|cls)\s*\[\s*["']([^"']+)["']\s*\]/g;for(let c of e.matchAll(s))t.push({at:c.index??0,kind:"static",text:c[1]});let r=/(?:styles?|classes|css|cls)\s*\[\s*`([^`$]*)\$\{\s*([A-Za-z_$][\w$]*)\s*\}`\s*\]/g;for(let c of e.matchAll(r))t.push({at:c.index??0,kind:"prefix",text:c[1],prop:c[2]});let o=/(?:styles?|classes|css|cls)\s*\[\s*["']([^"']+)["']\s*\+\s*([A-Za-z_$][\w$]*)\s*\]/g;for(let c of e.matchAll(o))t.push({at:c.index??0,kind:"prefix",text:c[1],prop:c[2]});/[[{(]/.test(e)||t.push({at:0,kind:"static",text:e.trim()}),t.sort((c,u)=>c.at-u.at);let i=[],a=[];for(let c of t)c.kind==="prefix"&&c.prop?a.push({prop:c.prop,prefix:c.text}):i.push(...je(c.text));let l=/(?:^|[(,\s])className\s*(?:[,)]|$)/.test(e);return{staticClasses:i,prefixes:a,classNameProp:l}}function Fa(e,t,n,s,r){let o=l=>t.rename[l]??l,i=e.axes.map(l=>{let c=t.fixed[l.prop],u=o(l.prop);return{prop:u,values:c?l.values.filter(f=>f.value===c):l.values,defaultValue:c??n[u]??l.defaultValue,opaque:t.opaque.includes(l.prop),locked:!!c}}),a=e.compounds.map(l=>({classes:l.classes,when:l.when.map(c=>({prop:o(c.prop),value:t.fixed[c.prop]??c.value}))}));return{staticClasses:[...e.staticClasses,...s],axes:i,compounds:a,classNameProp:r}}function vr(e,t,n){let s=[];for(let r of e){let o=Va(r.source,r.path,t,n);for(let i of r.names){let a=new RegExp(`(?:function\\s+${i}\\b|(?:const|let|var)\\s+${i}\\b)`,"g"),l=[...r.source.matchAll(a)],c=null;for(let u of l){let f=u.index??0,h=r.source.slice(f+u[0].length).search(/\nexport\s/),$=r.source.slice(f,f+u[0].length+(h<0?8e3:h)),k=Na(r.source,f),w=0;for(;w<$.length;){if($[w]!=="<"||$[w+1]==="/"||$[w+1]==="!"){w++;continue}let g=yt($,w);if(!g||g==="too-big"){w++;continue}if(w=g.openEnd,/^[A-Z]/.test(g.tag))continue;let p=Ta(g.attrs);if(!p)continue;let d=Ba(p),y=d.prefixes.length?2:d.staticClasses.length?1:0,v=null,x=o.find(C=>new RegExp(`(?:^|[^\\w$])${C.local}\\s*\\(`).test(p));if(x){let C=p.search(new RegExp(`(?:^|[^\\w$])${x.local}\\s*\\(`)),j=p.indexOf("(",C),I=j<0?null:Da(p,j);if(I){y=3,v=Fa(x.recipe,I,k,d.staticClasses,d.classNameProp);for(let A of d.prefixes)v.axes.push({prop:A.prop,values:[],prefix:A.prefix,defaultValue:k[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:k[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,za=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,Wa=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),Ga=new Set(["icon","glyph","svg"]),Ha=new Set(["label","text","title","caption"]),Ka=e=>e.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(t=>t.toLowerCase());function Cr(e){let t=e.flatMap(Ka);return t.some(n=>Ga.has(n))?"icon":t.some(n=>Ha.has(n))?"label":null}function Ja(e){let t=e.replace(/\{\s*\/\*[\s\S]*?\*\/\s*\}/g," "),n=[];for(let s of t.matchAll(Ua)){let r=s[1];if(!Wa.has(r.toLowerCase())||r!==r.toLowerCase())continue;let o=[...s[2].matchAll(za)].map(a=>a[1]??a[2]),i=Cr(o);i&&n.push({index:s.index??0,role:i,tag:r.toLowerCase(),classes:o})}return n}function Za(e,t,n){if(!t.some(r=>r.property.toLowerCase()==="display"&&/^none\b/i.test(r.value.trim()))||n.size===0)return null;for(let r of z(e)){let o=q(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 Xa=["text","icon-start","icon-end","icon"],$r={text:"Text","icon-start":"Icon left","icon-end":"Icon right",icon:"Icon"};function qa(e,t){let n=null,s=null;for(let i of t)i.index<e.index?n=i:s||(s=i);if(!n&&!s)return null;let r=n?e.index-n.index:1/0;return(s?s.index-e.index:1/0)<=r?"start":"end"}function Le(e){return{role:e.role,tag:e.tag,classes:e.classes}}function Sr(e){let t=new Map,n=(s,r)=>{let o=t.get(s)??[];o.some(i=>i.path===r.path)||o.push(r),t.set(s,o)};for(let s of e){let r=s.sources.flatMap(Ja),o=r.filter(h=>h.role==="label"),i=r.filter(h=>h.role==="icon"),a=o[0];a&&n("text",{path:s.sheet,slots:[Le(a)],classes:[],attrs:{}});let l=new Set(o.flatMap(h=>h.classes.filter($=>Cr([$])==="label"))),c=null,u=null;for(let h of i){let $=qa(h,o),k=o.reduce((w,g)=>{let p=Math.abs(g.index-h.index);return!w||p<w.dist?{hit:g,dist:p}:w},null);$==="start"&&k&&!c&&(c={icon:h,label:k.hit}),$==="end"&&k&&!u&&(u={icon:h,label:k.hit})}c&&n("icon-start",{path:s.sheet,slots:[Le(c.icon),Le(c.label)],classes:[],attrs:{}}),u&&n("icon-end",{path:s.sheet,slots:[Le(u.label),Le(u.icon)],classes:[],attrs:{}});let f=null;for(let h of s.rules)if(f=Za(h.selector,h.declarations,l),f)break;let m=c?.icon??u?.icon??i[0]??null;f&&m&&n("icon",{path:s.sheet,slots:[Le(m)],classes:f.classes,attrs:f.attrs})}return[{id:"text",label:$r.text,sheets:t.get("text")??[]},...Xa.filter(s=>s!=="text"&&t.has(s)).map(s=>({id:s,label:$r[s],sheets:t.get(s)??[]}))]}function Ya(e,t){if(!e)return t;let n=z(e);return z(t).flatMap(s=>n.map(r=>s.includes("&")?s.replaceAll("&",r):`${r} ${s}`)).join(", ")}var Qa=/^@(?:-\w+-)?(?:keyframes|font-face|property)\b/i;function xe(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,i=>i.replace(/[^\n]/g," ")),n=[],s=[],r=0,o=1;for(let i=0;i<t.length;i++){let a=t[i];if(a===`
46
- `&&o++,a==="{"){let l=t.slice(r,i).trim(),c=s[s.length-1];c&&(c.own+=t.slice(c.segStart,r));let u=/^@theme\b/i.test(l),f=l.startsWith("@")&&!u,m=[...s].reverse().find(h=>!h.isAt)??null;s.push({selector:l,resolved:f?l:u?":root":Ya(m?.resolved??null,l),isAt:f,skip:(c?.skip??!1)||f&&Qa.test(l),start:i+1,line:o,own:"",segStart:i+1}),r=i+1}else if(a==="}"){let l=s.pop();if(l){l.own+=t.slice(l.segStart,i),!l.isAt&&!l.skip&&n.push({selector:l.resolved,body:t.slice(l.start,i),ownBody:l.own,line:l.line,context:s.filter(u=>u.isAt).map(u=>u.selector.replace(/\s+/g," ")).join(" \xB7 ")});let c=s[s.length-1];c&&(c.segStart=i+1)}r=i+1}else a===";"&&(r=i+1)}return n}function ue(e){let t=[],n=0,s=0,r=o=>{let i=o.indexOf(":");if(i<=0)return;let a=o.slice(0,i).trim(),l=o.slice(i+1).replace(/\s+/g," ").trim();/^-{0,2}[a-z][\w-]*$/i.test(a)&&l&&a!=="composes"&&t.push({property:a,value:l})};for(let o=0;o<e.length;o++){let i=e[o];i==="("?n++:i===")"?n=Math.max(0,n-1):i===";"&&n===0&&(r(e.slice(s,o)),s=o+1)}return r(e.slice(s)),t}var el=25,tl=12,Rr=700,nl=/\b(?:must(?: not)?|never|always|should(?: not|n't)?|do not|don't|avoid|prefer|forbidden|not allowed|no more than)\b/i,se=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function sl(e){let t=e.split(`
47
- `),n=[],s=[],r=null,o=null,i=0;if(t[0]?.trim()==="---"){let l=t.findIndex((c,u)=>u>0&&c.trim()==="---");l>0&&(i=l+1)}let a=l=>{r&&(n.push({start:r.start,end:l,text:r.lines.join(`
48
- `).trimEnd(),headings:r.headings}),r=null)};for(;i<t.length;i++){let l=t[i],c=i+1,u=/^\s*(```|~~~)/.exec(l)?.[1];if(o){r.lines.push(l),u===o&&(o=null,a(c));continue}if(u){a(c-1),o=u,r={start:c,lines:[l],headings:[...s]};continue}let f=/^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(l);if(f){a(c-1),s=[...s.slice(0,f[1].length-1),f[2]];continue}if(l.trim()===""){a(c-1);continue}r??={start:c,lines:[],headings:[...s]},r.lines.push(l)}return a(t.length),n}function rl(e,t){let n=e.map(se).join("|"),s=e.map(r=>se(r.charAt(0).toUpperCase()+r.slice(1))).join("|");return new RegExp(`${t.source}|\\b(?:${n})s?\\b|[a-z](?:${s})s?\\b|\\b(?:${n})[-_]|[-_](?:${n})\\b`,"i")}function ol(e,t){let n=t.map(se).join("|"),s=new Map;for(let r of e){if(r.base||r.title==="Unnamed"||r.title.startsWith("In ")||!r.element)continue;let i=s.get(r.title)??{title:r.title,tests:[],heading:null},a=r.selector.slice(be(r.selector));for(let l of a.matchAll(/\.((?:\\.|[\w-])+)/g)){let c=l[1].replace(/\\(.)/g,"$1");if(t.includes(c.toLowerCase()))continue;let u=/[-_]|[a-z][A-Z]/.test(c);i.tests.push(new RegExp(u?`(?<![\\w-])${se(c)}(?![\\w-])`:`(?:\\.|["'\`])${se(c)}(?![\\w-])`))}if(!r.title.includes(" + ")){let l=r.title.toLowerCase().split(/\s+/).map(se).join("[\\s_-]+");i.tests.push(new RegExp(`\\b${l}[\\s_-]+(?:${n})s?\\b|\\b(?:${n})s?[_-]+${l}\\b`,"i")),r.axis&&/^[a-z]+$/i.test(r.title)&&i.tests.push(new RegExp(`\\b${se(r.axis)}\\s*[=:]\\s*\\{?\\s*["'\`]${se(r.title.toLowerCase())}["'\`]`,"i")),i.heading=r.title.toLowerCase()}s.set(r.title,i)}return[...s.values()]}function il(e,t){return e.toLowerCase().replace(new RegExp(`\\b(?:${t.map(se).join("|")})s?\\b`,"g")," ").replace(/[^a-z0-9]+/g," ").trim()}function al(e){return e.length>Rr?`${e.slice(0,Rr).trimEnd()}\u2026`:e}function Ar(e,t,n,s){let r=rl(n.classKeywords,n.prose),o=ol(s,n.classKeywords),i=new Set,a=[];for(let u of t){let f=e.get(u.path);if(f===void 0)continue;let m=[];for(let h of sl(f)){if(!r.test(h.text)&&!h.headings.some(w=>r.test(w)))continue;let $=h.headings.length?il(h.headings[h.headings.length-1],n.classKeywords):"",k=o.filter(w=>w.tests.some(g=>g.test(h.text))||$!==""&&w.heading===$).map(w=>w.title);for(let w of k)i.add(w);m.push({path:u.path,line:h.start,endLine:h.end,headings:h.headings,text:al(h.text),rule:nl.test(h.text),styles:k})}m.length!==0&&a.push({path:u.path,kind:u.kind,passages:m.slice(0,tl),total:m.length,rules:m.filter(h=>h.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,el).map(({rules:u,...f})=>f),documented:[...i].sort(),undocumented:[...c.keys()].filter(u=>!i.has(u))}}var _r=new Set(["tone","size","variant","kind","type","style","theme","color","colour","appearance","intent","emphasis","shape","level"]),ll=new Set(["is","has","js","c","component","comp","el","ui","the","root"]),cl={xs:["extra","small"],sm:["small"],md:["medium"],lg:["large"],xl:["extra","large"],xxl:["extra","extra","large"]},ul=new Set(["cta","ui","ux","faq","cms","api","url","ios"]);function gn(e){return e.replace(/\\(.)/g,"$1").replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(t=>t.toLowerCase())}function pl(e){return new Set(e.flatMap(t=>[t,`${t}s`]))}function dn(e){let t=e.map(n=>ul.has(n)?n.toUpperCase():n).join(" ");return t.charAt(0).toUpperCase()+t.slice(1)}function Oe(e,t){let n=gn(e).filter(r=>!t.has(r)&&!ll.has(r)),s=null;return n.length>1&&_r.has(n[0])&&(s=n[0],n=n.slice(1)),{words:n.flatMap(r=>cl[r]??[r]),axis:s}}var Er=/\.((?:\\.|[\w-])+)/g,fl=/\[\s*([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*))\s*\]/g;function dl(e,t){let n=e.split("/"),s=(n.pop()??"").replace(/(\.module)?\.[a-z]+$/i,""),r=n.pop()??"";return gn(s).some(a=>t.has(a))||gn(r).some(a=>t.has(a))?Oe(s,t).words:[]}function gl(e,t){let n=[];for(let s of e.split(/[\s>+~]+/).filter(Boolean)){let r=[...s.matchAll(Er)].map(o=>o[1]);if(r.length)for(let o of r)n.push(...Oe(o,t).words);else{let o=/^[a-z][\w-]*/i.exec(s)?.[0]?.toLowerCase();o&&!["div","span","html","body"].includes(o)&&n.push(...Oe(o,t).words)}}return n}function Me(e,t){let n=pl(t),s=be(e.selector),r=e.selector.slice(0,s),o=e.selector.slice(s),i=[...o.matchAll(Er)].map(u=>Oe(u[1],n));for(let u of o.matchAll(fl)){let f=u[1].replace(/^data-/,"").toLowerCase();if(!_r.has(f))continue;let m=u[2]??u[3]??u[4]??"",h=Oe(m,n);i.push({words:h.words,axis:f})}let a=i.filter(u=>u.words.length>0);if(a.length>0)return{title:a.map(u=>dn(u.words)).join(" + "),axis:a.length===1?a[0].axis:null};let l=gl(r,n);if(l.length>0)return{title:`In ${l.join(" ")}`,axis:null};let c=dl(e.path,n);if(c.length>0)return{title:dn(c),axis:null};if(e.base){let u=ml(e.path,n);return u.length>0?{title:`${dn(u)} Base`,axis:null}:{title:"Base",axis:null}}return{title:"Unnamed",axis:null}}function ml(e,t){let n=e.split("/").pop()??"";if(!/\.module\.[a-z]+$/i.test(n))return[];let s=n.replace(/\.module\.[a-z]+$/i,"");return Oe(s,t).words}var hl=60;function Ze(e,t,n){let s=q(e);if(!s)return null;let r=s.length-1,o=s[r].simples;if(Js(o)||en(o,t))return null;if(pt(o,t))return{compounds:s,at:r};for(let i=r-1;i>=0;i--){let a=s[i].simples;if(pt(a,t)&&!en(a,t))return{compounds:s,at:i}}return!n||r===0&&Zs(o)?null:{compounds:s,at:0}}function Ir(e,t,n){return Ke([...e,{combinator:e.length?t.combinator:null,simples:n}])}function jr(e,t){return e.kind!==t.kind?!1:e.kind==="attr"&&t.kind==="attr"?e.name===t.name&&e.op===t.op&&e.value===t.value:e.raw===t.raw}function bl(e,t){return e.length>=t.length?!1:e.every(n=>t.some(s=>jr(n,s)))}function yl(e,t){if(e.length!==1)return!1;let n=e[0];return n.kind==="tag"?t.elements.includes(n.name):n.kind==="class"?t.classKeywords.some(s=>s.toLowerCase()===n.name.toLowerCase()):!1}function xl(e,t){for(let n of t.classes)e.classes.includes(n)||e.classes.push(n);Object.assign(e.attrs,t.attrs)}function Pr(e){let t=new Set(e.map(n=>Je(n.property)).filter(n=>n!=="hint"));return t.size===0||t.size===1&&t.has("layout")?"placement":t.size===1&&t.has("paint")?"effect":"override"}function wl(e){let t=e.filter(o=>o.context===""),n=t.length?t:e;if(n.some(o=>o.state==="default"))return null;let r=[...n.map(o=>new Set(o.state.split(" + "))).reduce((o,i)=>o?new Set([...o].filter(a=>i.has(a))):i,null)??[]].filter(o=>H(o)===ut.length);return r.length===1?r[0]:null}function mn(e){return e.sort((t,n)=>+(t.context!=="")-+(n.context!=="")||H(t.state.split(" + ")[0])-H(n.state.split(" + ")[0])||t.state.localeCompare(n.state))}function Lr(e,t,n,s,r={parts:new Set,controls:new Set}){let o=new Map,i=[];for(let g of t)if(g.declarations.length!==0)for(let p of z(g.selector)){let d=Ze(p,n,s);if(!d)continue;let{compounds:y,at:v}=d,x=y[v],C=ft(x.simples);if(C.identity.length===0)continue;let j=y.slice(0,v),I=Ir(j,x,C.identity),A=he(C.states);if(v<y.length-1){i.push({hostKey:I,part:{selector:Ke(y),path:e,line:g.line,state:A}});continue}if(qs(C.identity,g.declarations))continue;let R=o.get(I);if(!R){if(o.size>=hl)continue;R={key:I,prefix:j,identity:C.identity,line:g.line,states:[],modifiers:[],contexts:[],parts:[],movedInto:null},o.set(I,R)}let P=R.states.find(T=>T.state===A&&T.context===g.context);P||(P={state:A,context:g.context,line:g.line,declarations:[]},C.states.length&&(P.marker={classes:[],attrs:{}}),R.states.push(P)),P.marker&&xl(P.marker,C.marker),P.declarations.push(...g.declarations)}for(let[g,p]of o){let d=p.states.flatMap(x=>x.declarations),y=p.states.every(x=>gt(x.declarations)),v=d.every(x=>Je(x.property)==="hint");(y||v)&&o.delete(g)}let a=new Map;for(let g of o.values()){let p=He(g.identity);a.set(p,[...a.get(p)??[],g])}for(let g of a.values()){let p=g.map(x=>wl(x.states)),d=p[0];if(!d||p.some(x=>x!==d))continue;let y=g.flatMap(x=>x.states).find(x=>x.marker&&x.state.split(" + ").includes(d))?.marker;if(!y)continue;let v=[...y.classes.map(x=>({kind:"class",raw:`.${x}`,name:x})),...Object.entries(y.attrs).map(([x,C])=>({kind:"attr",raw:`[${x}="${C}"]`,name:x,op:"=",value:C}))];for(let x of g){let C=[...x.identity,...v],j={combinator:x.prefix.length?" ":null,simples:C},I=Ir(x.prefix,j,C);for(let A of x.states){let R=A.state.split(" + ").filter(P=>P!==d);if(A.state=he(R),R.length===0)delete A.marker;else if(A.marker){A.marker.classes=A.marker.classes.filter(P=>!y.classes.includes(P));for(let P of Object.keys(y.attrs))delete A.marker.attrs[P]}}o.delete(x.key),o.set(I,{...x,key:I,identity:C})}}let l=()=>[...o.values()].filter(g=>g.prefix.length===0),c=g=>g.states.filter(p=>p.state==="default").reduce((p,d)=>p+d.declarations.length,0),u=l().find(g=>yl(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)},h=[...o.values()],$=g=>{let p=h.find(d=>d.key===g)??null;for(;p?.movedInto;)p=p.movedInto;return p};for(let g of l()){let p=g.identity.length===1?g.identity[0]:null;if(!(p?.kind!=="class"||!r.parts.has(p.name))&&(o.delete(g.key),u&&g!==u)){g.movedInto=u;for(let d of g.states)u.parts.push({selector:g.key,path:e,line:d.line,state:d.state})}}let k=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 k){let p=h.filter(y=>y!==g&&y!==u&&y.prefix.length===0&&bl(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=$(p[0].key);d&&d!==g&&m(g,d,"modifiers")}for(let{hostKey:g,part:p}of i){let d=$(g)??(s?u:null);d&&o.has(d.key)&&d.parts.push(p)}let w=g=>{let p=g===u,d=dt(g.key,f);return{...Me({selector:g.key,path:e,base:p},n.classKeywords),element:d,usage:{status:"unknown",files:[],fileCount:0},selector:g.key,path:e,line:g.line,base:p,states:mn(g.states),modifiers:g.modifiers.length?g.modifiers.map(y=>{let v=y.identity.filter(x=>!g.identity.some(C=>jr(C,x)));return{title:Me({selector:v.map(x=>x.raw).join(""),path:e,base:!1},n.classKeywords).title,selector:y.key,path:e,line:y.line,element:dt(y.key,f),usage:{status:"unknown",files:[],fileCount:0},states:mn(y.states)}}):void 0,contexts:g.contexts.length?g.contexts.map(y=>{let v=Pr(y.states.flatMap(x=>x.declarations));return{selector:y.key,path:e,line:y.line,role:v,element:v==="override"?dt(y.key,f):null,states:mn(y.states)}}):void 0,parts:g.parts.length?g.parts:void 0}};return[...o.values()].map(w)}function Or(e){let t=new Map;for(let i of e){let a=i.base?/^\.([\w-]+)$/.exec(i.selector):null;a&&t.set(i.path,[...t.get(i.path)??[],a[1]])}let n=i=>{let a=q(i.selector);if(!a)return null;let l=a[a.length-1].simples,c=t.get(i.path)??[],u=l.filter(f=>!(f.kind==="class"&&c.includes(f.name)));return{depth:a.length-1,subject:He(l),bareTag:!l.some(f=>f.kind==="class"||f.kind==="attr"||f.kind==="id"),bare:u.length&&u.length<l.length?He(u):null}},s=new Map(e.map(i=>[i,n(i)])),r=new Set,o=i=>{let a=s.get(i);if(!a||a.depth===0)return null;let l=e.filter(c=>{if(c===i||r.has(c))return!1;let u=s.get(c);return u!=null&&u.depth<a.depth&&(!a.bareTag||u.depth===0)&&(u.subject===a.subject||a.bare!==null&&u.subject===a.bare)});return l.sort((c,u)=>+(u.path===i.path)-+(c.path===i.path)||s.get(c).depth-s.get(u).depth),l[0]??null};for(let i of[...e].sort((a,l)=>(s.get(l)?.depth??0)-(s.get(a)?.depth??0))){let a=o(i);if(!a)continue;for(;r.has(a);)a=o(a)??a;let l=Pr(i.states.flatMap(c=>c.declarations));a.contexts=[...a.contexts??[],{selector:i.selector,path:i.path,line:i.line,role:l,element:l==="override"?i.element:null,states:i.states}],i.parts?.length&&(a.parts=[...a.parts??[],...i.parts]),i.modifiers?.length&&(a.modifiers=[...a.modifiers??[],...i.modifiers]),r.add(i)}return e.filter(i=>!r.has(i))}var kl={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(e){let t=e.lastIndexOf("-");return t<=0?null:kl[e.slice(0,t)]?.[e.slice(t+1)]??null}var E=(e,t)=>({property:e,value:t});function wn(e){if(!e.startsWith("[")||!e.endsWith("]"))return null;let t=e.slice(1,-1).replace(/_/g," ").trim();return/^-?[\d.]+(?:px|rem|em|%|vh|vw)$/.test(t)||/^var\(\s*--[\w-]+\s*\)$/.test(t)?t.replace(/\s+/g,""):null}function xn(e){let t=wn(e);if(t)return t;if(e==="px")return"1px";if(!/^\d+(?:\.\d+)?$/.test(e))return null;let n=Number(e);if(n>96)return null;let s=Math.round(n*2);if(Math.abs(n*2-s)>1e-6)return null;if(s===0)return"0";let r=Math.floor(s/8),o=["",".125",".25",".375",".5",".625",".75",".875"][s%8];return r===0?`0${o}rem`:`${r}${o}rem`}function vl(e){let t=/^(\d+)\/(\d+)$/.exec(e);if(!t)return null;let n=Number(t[1])/Number(t[2])*100;return Number.isFinite(n)?`${Number(n.toFixed(4))}%`:null}function Nr(e,t){return{full:"100%",screen:t==="w"?"100vw":"100vh",auto:"auto",fit:"fit-content",min:"min-content",max:"max-content"}[e]??vl(e)??wn(e)??xn(e)}var $l={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"}},Cl={thin:"100",extralight:"200",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"},Sl={none:"1",tight:"1.25",snug:"1.375",normal:"1.5",relaxed:"1.625",loose:"2"},Rl={none:"0",sm:"0.125rem","":"0.25rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem","3xl":"1.5rem",full:"9999px"},Al={sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)","":"0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",xl:"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)","2xl":"0 25px 50px -12px rgb(0 0 0 / 0.25)",inner:"inset 0 2px 4px 0 rgb(0 0 0 / 0.05)",none:"none"},_l={"":"3px",0:"0px",1:"1px",2:"2px",4:"4px",8:"8px"};function hn(e,t){let n=null;if(e.startsWith("[")&&e.endsWith("]")){let r=e.slice(1,-1).replace(/_/g," ").trim();if(r.startsWith("--"))n=`var(${r})`;else if(/^var\(\s*--[\w-]+\s*\)$/.test(r))n=r.replace(/\s+/g,"");else if(/^#[0-9a-f]{3,8}$/i.test(r)||/^(?:rgb|hsl|oklch|oklab|color)\(/i.test(r))n=r;else return null}else e==="white"?n="#fff":e==="black"?n="#000":e==="transparent"?n="transparent":e==="current"?n="currentColor":e==="inherit"?n="inherit":n=Mr(e)??(/^[a-z][\w-]*$/i.test(e)?`var(--${e}, var(--color-${e}))`:null);if(!n)return null;if(!t)return n;if(!/^\d+(?:\.\d+)?$/.test(t))return null;let s=Number(t)<=1?Number(t)*100:Number(t);return s<0||s>100?null:s===100?n:`color-mix(in srgb, ${n} ${s}%, transparent)`}function El(e){let t=0,n=-1;for(let s=0;s<e.length;s++){let r=e[s];r==="["?t++:r==="]"?t=Math.max(0,t-1):r==="/"&&t===0&&(n=s)}return n<0?{body:e,opacity:null}:{body:e.slice(0,n),opacity:e.slice(n+1)}}function bn(){return E("box-shadow","0 0 0 var(--gs-ring-w, 3px) var(--gs-ring-c, currentColor)")}var Il={flex:"flex","inline-flex":"inline-flex",block:"block","inline-block":"inline-block",inline:"inline",grid:"grid","inline-grid":"inline-grid",hidden:"none",contents:"contents"},yn={start:"flex-start",end:"flex-end",center:"center",baseline:"baseline",stretch:"stretch",between:"space-between",around:"space-around",evenly:"space-evenly"};function Tr(e){let t=e.startsWith("-"),n=t?e.slice(1):e,{body:s,opacity:r}=El(n),o=Il[s];if(o&&!t&&!r)return[E("display",o)];let i=/^flex-(row|col|row-reverse|col-reverse)$/.exec(s);if(i&&!t&&!r){let R=i[1]==="col"?"column":i[1]==="col-reverse"?"column-reverse":i[1];return[E("flex-direction",R)]}if(s==="flex-wrap"&&!t)return[E("flex-wrap","wrap")];if(s==="flex-nowrap"&&!t)return[E("flex-wrap","nowrap")];if(s==="flex-1"&&!t)return[E("flex","1 1 0%")];if(s==="shrink-0"&&!t)return[E("flex-shrink","0")];if(s==="grow-0"&&!t)return[E("flex-grow","0")];if(s==="grow"&&!t)return[E("flex-grow","1")];let a=/^items-(start|end|center|baseline|stretch)$/.exec(s);if(a&&!t)return[E("align-items",yn[a[1]])];let l=/^justify-(start|end|center|between|around|evenly)$/.exec(s);if(l&&!t)return[E("justify-content",yn[l[1]])];let c=/^self-(start|end|center|stretch|auto)$/.exec(s);if(c&&!t)return[E("align-self",c[1]==="auto"?"auto":yn[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=$l[s.replace(/^text-/,"")];if(s.startsWith("text-")&&m&&!r&&!t)return[E("font-size",m.size),E("line-height",m.leading)];let h=Cl[s.replace(/^font-/,"")];if(s.startsWith("font-")&&h&&!r)return[E("font-weight",h)];if(s.startsWith("leading-")&&!r){let R=s.slice(8),T=Sl[R]??xn(R);if(T)return[E("line-height",T)]}let $=/^cursor-(pointer|default|not-allowed|wait|text|move)$/.exec(s);if($)return[E("cursor",$[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 k=/^opacity-(\d+)$/.exec(s);if(k&&!t)return[E("opacity",String(Number(k[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 w=/^duration-(\d+)$/.exec(s);if(w)return[E("transition-duration",`${w[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),P=Al[R];if(P)return[E("box-shadow",P)]}if(s==="ring"||/^ring(?:-(?:0|1|2|4|8))?$/.test(s)){let R=s==="ring"?"":s.slice(5),P=_l[R];if(P)return[E("--gs-ring-w",P),bn()]}if(s.startsWith("ring-")&&r===null){let R=hn(s.slice(5),null);if(R)return[E("--gs-ring-c",R),bn()]}if(s.startsWith("ring-")&&r){let R=hn(s.slice(5),r);if(R)return[E("--gs-ring-c",R),bn()]}let d=s==="rounded"?"":s.startsWith("rounded-")?s.slice(8):null;if(d!==null&&!t){let R=/^(t|r|b|l|s|e|tl|tr|bl|br|ss|se)(?:-(.+))?$/.exec(d),P=R?R[2]??"":d,T=Rl[P];if(!T)return null;if(!R)return[E("border-radius",T)];let X={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 X?X.map(tt=>E(tt,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],j=x?.[2];if(C&&j&&!r){let R=C==="w"||C==="min-w"||C==="max-w"?Nr(j,"w"):C==="h"||C==="min-h"||C==="max-h"?Nr(j,"h"):xn(j);if(!R)return null;let P=t?R==="0"?"0":`-${R}`:R,G={p:["padding"],px:["padding-inline"],py:["padding-block"],pt:["padding-top"],pr:["padding-right"],pb:["padding-bottom"],pl:["padding-left"],ps:["padding-inline-start"],pe:["padding-inline-end"],m:["margin"],mx:["margin-inline"],my:["margin-block"],mt:["margin-top"],mr:["margin-right"],mb:["margin-bottom"],ml:["margin-left"],ms:["margin-inline-start"],me:["margin-inline-end"],gap:["gap"],"gap-x":["column-gap"],"gap-y":["row-gap"],w:["width"],h:["height"],"min-w":["min-width"],"min-h":["min-height"],"max-w":["max-width"],"max-h":["max-height"],size:["width","height"],inset:["inset"],top:["top"],right:["right"],bottom:["bottom"],left:["left"]}[C];return G?G.map(X=>E(X,P)):null}let I={bg:"background-color",text:"color",border:"border-color",outline:"outline-color",decoration:"text-decoration-color",accent:"accent-color",caret:"caret-color",fill:"fill",stroke:"stroke"};for(let[R,P]of Object.entries(I))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"&&!t){let X=wn(T);if(X)return[E("font-size",X)]}let G=hn(T,r);return!G||t?null:[E(P,G)]}let A=/^\[([a-z-]+):(.+)\]$/i.exec(s);if(A&&!t&&!r){let R=A[1].toLowerCase(),P=A[2].replace(/_/g," ").trim();if(/^[a-z][\w-]*$/.test(R)&&P&&!/[<>]/.test(P))return[E(R,P)]}return null}var jl=48,Pl={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",disabled:"disabled"},Ll=new Set(["cn","clsx","classNames","classnames","cx","twMerge"]);function pe(e,t){let n=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
49
- `&&n++;return n}function Ol(e){let t=n=>n.replace(/[^\n]/g," ");return e.replace(/\/\*[\s\S]*?\*\//g,t).replace(/(^|\s)\/\/[^\n]*/g,(n,s)=>s+t(n.slice(s.length)))}function W(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;return t}function kt(e,t){let n=e[t];if(n!=='"'&&n!=="'"&&n!=="`")return null;let s="",r=!1;for(let o=t+1;o<e.length;o++){let i=e[o];if(i==="\\"){let a=e[o+1];if(a===void 0)return null;s+=a==="n"?`
50
- `:a,o++;continue}if(n==="`"&&i==="$"&&e[o+1]==="{"){r=!0;let a=1;for(o+=2;o<e.length&&a>0;o++)e[o]==="{"?a++:e[o]==="}"&&a--;o--;continue}if(i===n)return{v:r?null:s,end:o+1};s+=i}return null}function $n(e,t,n,s){let r=0;for(let o=t;o<e.length;o++){let i=e[o];if(i==='"'||i==="'"||i==="`"){let a=kt(e,o);if(!a)return e.length;o=a.end-1;continue}if(i===n)r++;else if(i===s&&(r--,r===0))return o+1}return e.length}function Ml(e,t){let n=0;for(let s=t;s<e.length;s++){let r=e[s];if(r==='"'||r==="'"||r==="`"){let o=kt(e,s);if(!o)return e.length;s=o.end-1;continue}if(r==="("||r==="["||r==="{")n++;else if(r===")"||r==="]"||r==="}"){if(n===0)return s;n--}else if(r===","&&n===0)return s}return e.length}function Dr(e){if(e.t==="str")return e.v;if(e.t==="arr"){let t=[];for(let n of e.items){let s=Dr(n);s&&t.push(s)}return t.join(" ")||null}return e.t==="obj"&&e.entries.filter(n=>n.value.t==="bool"&&n.value.v).map(n=>n.key).join(" ")||null}function Nl(e,t){let n=t+1,s=[];for(;n<e.length;){if(n=W(e,n),e[n]===")")return{v:s.join(" ").replace(/\s+/g," ").trim()||null,end:n+1};if(e[n]===","){n++;continue}let r=ee(e,n);if(!r)return null;let o=W(e,r.end);if(e[o]===","||e[o]===")"){let i=Dr(r.val);i&&s.push(i),n=r.end;continue}n=Ml(e,n)}return null}function ee(e,t){if(t=W(e,t),t>=e.length)return null;let n=e[t];if(n==='"'||n==="'"||n==="`"){let r=kt(e,t);return r?{val:{t:"str",v:r.v,at:t},end:r.end}:null}if(n==="["){let r=t+1,o=[];for(;r<e.length;){if(r=W(e,r),e[r]==="]")return{val:{t:"arr",items:o,at:t},end:r+1};if(e[r]===","){r++;continue}let i=ee(e,r);if(!i)return null;o.push(i.val),r=i.end}return null}if(n==="{"){let r=t+1,o=[];for(;r<e.length;){if(r=W(e,r),e[r]==="}")return{val:{t:"obj",entries:o,at:t},end:r+1};if(e[r]===","){r++;continue}if(e.slice(r,r+3)==="..."){let c=ee(e,r+3);if(!c)return null;r=c.end;continue}let i="",a=r;if(e[r]==='"'||e[r]==="'"||e[r]==="`"){let c=kt(e,r);if(!c||c.v===null)return null;i=c.v,r=c.end}else if(/[\w$]/.test(e[r])){for(a=r;r<e.length&&/[\w$]/.test(e[r]);)r++;i=e.slice(a,r)}else return null;if(r=W(e,r),e[r]!==":"){e[r]==="("&&(r=$n(e,r,"(",")"));continue}let l=ee(e,r+1);if(!l)return null;o.push({key:i,at:a,value:l.val}),r=l.end}return null}let s=t;if(n==="."||n==="-"||/\d/.test(n)){let r=t+1;for(;r<e.length&&/[\d.]/.test(e[r]);)r++;let o=e.slice(t,r);if(/^-?\d+(?:\.\d+)?$/.test(o))return{val:{t:"num",v:Number(o),at:s},end:r};for(;r<e.length&&/[\w$.+-]/.test(e[r]);)r++;return{val:{t:"other",at:s},end:r}}if(/[\w$]/.test(n)){let r=t;for(;r<e.length&&/[\w$]/.test(e[r]);)r++;let o=e.slice(t,r),i=W(e,r);if(e[i]==="("){if(Ll.has(o)){let a=Nl(e,i);return a?{val:{t:"str",v:a.v,at:s},end:a.end}:null}return{val:{t:"other",at:s},end:$n(e,i,"(",")")}}return o==="true"||o==="false"?{val:{t:"bool",v:o==="true",at:s},end:r}:{val:{t:"other",at:s},end:i}}return null}function vt(e){if(e.t==="str")return e.v;if(e.t==="arr"){let t=[];for(let n of e.items){if(n.t!=="str"||n.v===null)return null;t.push(n.v)}return t.join(" ")}return null}function Vr(e){let t=[],n="",s=0;for(let r of e)r==="["?s++:r==="]"&&(s=Math.max(0,s-1)),/\s/.test(r)&&s===0?(n&&t.push(n),n=""):(!/\s/.test(r)||s>0)&&(n+=r);return n&&t.push(n),t}var kn={sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"};function Tl(e,t,n,s){let r=Pl[e];if(r)return t.includes(r)||t.push(r),!0;if(e==="dark")return s.on=!0,!0;if(kn[e])return n.min.push(kn[e]),!0;let o=/^max-(sm|md|lg|xl|2xl)$/.exec(e);if(o)return n.below.push(kn[o[1]]),!0;let i=/^min-\[([\d.]+(?:px|rem|em))\]$/.exec(e);if(i)return n.min.push(i[1]),!0;let a=/^max-\[([\d.]+(?:px|rem|em))\]$/.exec(e);return a?(n.max.push(a[1]),!0):!1}function Dl(e,t){let n=[];for(let s of e.min)n.push(`(min-width: ${s})`);for(let s of e.max)n.push(`(max-width: ${s})`);for(let s of e.below)n.push(`not all and (min-width: ${s})`);return t&&n.push("(prefers-color-scheme: dark)"),n.length?`@media ${n.join(" and ")}`:""}function Br(e){let t=e.trim();if(!t)return null;let n=!1;t.startsWith("!")&&(n=!0,t=t.slice(1)),t.endsWith("!")&&(n=!0,t=t.slice(0,-1));let s=[],r="",o=0;for(let f of t)f==="["?o++:f==="]"&&(o=Math.max(0,o-1)),f===":"&&o===0?(s.push(r),r=""):r+=f;s.push(r);let i=s.pop()??"";if(!i)return null;let a=[],l={min:[],max:[],below:[]},c={on:!1};for(let f of s)if(!f||!Tl(f,a,l,c))return null;a.sort((f,m)=>H(f)-H(m));let u=/^[\w-]+$/.test(i)?i:null;return{token:e,state:he(a),context:Dl(l,c.on),utility:i,important:n,stem:u}}function Fr(e){let t=Tr(e.utility);return t?t.map(n=>({property:n.property,value:e.important?`${n.value} !important`:n.value,via:e.token})):[]}function Vl(e){return e.some(t=>Je(t.property)!=="hint")}function $t(e){let t=[];for(let n of e.matchAll(/@apply\s+([^;{}]+)/g))for(let s of Vr(n[1])){let r=Br(s);if(!r)continue;let o=Fr(r).filter(i=>ne(i.property,i.value));o.length!==0&&t.push({state:r.state,context:r.context,declarations:o})}return t}function Ur(e){return e==="default"?"":e.split(" + ").map(t=>t==="hover"?":hover":t==="focus"?":focus":t==="active"?":active":t==="disabled"?":disabled":"").join("")}function Rn(e,t,n){let s=t.map(f=>`${f.property}:${f.value}`).join(";");if(!s)return[];let r=tn(e),o=`${r}{${s}}`,i=n.split(" \xB7 ").map(f=>f.trim()).filter(f=>f&&!/^@layer\b/i.test(f));if(i.length===0)return[o];if(i.length!==1||!i[0].startsWith("@media"))return[];let a=i[0],l=[`${a}{${o}}`];if(!a.includes("prefers-color-scheme: dark"))return l;let c=a.replace(/^@media\s+/,"").split(/\s+and\s+/).filter(f=>!f.includes("prefers-color-scheme")).join(" and "),u=`html[data-theme="dark"] ${r}{${s}}`;return l.push(c?`@media ${c}{${u}}`:u),l}function Bl(e,t){let n=e.slice(Math.max(0,t-160),t);return/(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(?:await\s+)?$/.exec(n)?.[1]??null}function Fl(e){if(e.t!=="obj")return{};let t=e.entries.find(s=>s.key==="defaultVariants")?.value;if(!t||t.t!=="obj")return{};let n={};for(let s of t.entries)s.value.t==="str"&&s.value.v?n[s.key]=s.value.v:s.value.t==="bool"&&(n[s.key]=s.value.v?"true":"false");return n}function Ul(e,t,n,s,r){let o=ee(e,t),i={slots:[],defaults:{}};if(!o)return i;let a=vt(o.val)??"",l=W(e,o.end);if(e[l]!==",")return a.trim()?{slots:[vn(a,pe(e,t),r)],defaults:{}}:i;let c=ee(e,l+1);if(!c||c.val.t!=="obj")return a.trim()?{slots:[vn(a,pe(e,t),r)],defaults:{}}:i;let u=c.val.entries.find(h=>h.key==="variants")?.value,f=[],m=new Map;if(a.trim()&&f.push(vn(a,pe(e,t),r)),u&&u.t==="obj"){for(let h of u.entries)if(h.value.t==="obj")for(let $ of h.value.entries){let k=vt($.value);if(!k||!k.trim()||$.key==="false")continue;m.set(`${h.key}\0${$.key}`,k);let w=$.key==="true"?`.${h.key}`:`.${h.key}-${$.key}`,g=Me({selector:w,path:s,base:!1},n.classKeywords);f.push({title:g.title,axis:$.key==="true"?h.key:g.axis??h.key,base:!1,classes:`${a} ${k}`.trim(),line:pe(e,$.at),group:r,prop:h.key,value:$.key})}}return f.push(...zl(c.val,a,m,n,s,e,r)),{slots:f,defaults:Fl(c.val)}}function zr(e){if(e.t==="str"&&e.v)return[e.v];if(e.t==="bool")return[e.v?"true":"false"];if(e.t==="arr"){let t=[];for(let n of e.items){let s=zr(n);if(!s||s.length!==1)return null;t.push(s[0])}return t.length?t:null}return null}function zl(e,t,n,s,r,o,i){let a=e.entries.find(c=>c.key==="compoundVariants")?.value;if(!a||a.t!=="arr")return[];let l=[];for(let c of a.items){if(c.t!=="obj")continue;let u=[],f="",m=c.at,h=!1;for(let k of c.entries){if(k.key==="class"||k.key==="className"){f=vt(k.value)??"",m=k.at,k.value.t!=="str"&&k.value.t!=="arr"&&f===""&&(h=!0);continue}let w=zr(k.value);if(!w){h=!0;break}u.push({axis:k.key,values:w})}if(h)continue;let $=[[]];for(let k of u){let w=[];for(let g of $){for(let p of k.values)if(w.push([...g,{axis:k.axis,value:p}]),w.length>=8)break;if(w.length>=8)break}$=w}for(let k of $){if(k.length<2&&!f.trim())continue;let w=[t],g=[];for(let y of k){let v=n.get(`${y.axis}\0${y.value}`);v&&w.push(v),g.push(y.value==="true"?y.axis:y.value)}f.trim()&&w.push(f);let p=w.join(" ").replace(/\s+/g," ").trim();if(!p)continue;let d=Me({selector:`.${g.join("-")}`,path:r,base:!1},s.classKeywords);l.push({title:d.title,axis:d.axis,base:!1,classes:p,line:pe(o,m),group:i,when:k.map(y=>({prop:y.axis,value:y.value}))})}}return l}function vn(e,t,n){return{title:"Base",axis:null,base:!0,classes:e,line:t,group:n}}function Wr(e,t){return t.elements.includes(e.toLowerCase())?!0:t.identifier.test(e)}function Wl(e){let t=e.match(/\bclassName\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*"([^"]*)"\s*\}|\{\s*'([^']*)'\s*\})/);return t?.[1]??t?.[2]??t?.[3]??t?.[4]??null}var Gl=new Set(["opacity","z-index","font-weight","line-height","flex","flex-grow","flex-shrink","order","zoom"]);function Hl(e){return e.replace(/^[A-Z]/,t=>`-${t.toLowerCase()}`).replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Kl(e,t){return t.t==="str"?t.v:t.t==="num"?Gl.has(e)?String(t.v):`${t.v}px`:null}function Ct(e,t){if(e.t!=="obj")return[];let n=[],s=[];for(let o of e.entries){if(o.value.t==="obj"){let l=o.key.replace(/^&/,""),c=l===":hover"?"hover":l===":focus"||l===":focus-visible"?"focus":l===":active"?"active":l===":disabled"?"disabled":null;c&&s.push(...Ct(o.value,c));continue}let i=Hl(o.key),a=Kl(i,o.value);!a||!ne(i,a)||n.push({property:i,value:a,via:"style"})}return[...n.length?[{state:t,context:"",declarations:n}]:[],...s]}function Cn(e,t){if(e[t]!=="`")return null;let n="";for(let s=t+1;s<e.length;s++){let r=e[s];if(r==="\\"){let o=e[s+1];if(o===void 0)return null;n+=o==="n"?`
51
- `:o,s++;continue}if(r==="$"&&e[s+1]==="{"){let o=1;for(s+=2;s<e.length&&o>0;s++)e[s]==="{"?o++:e[s]==="}"&&o--;s--,n+=" ";continue}if(r==="`")return{css:n,end:s+1};n+=r}return null}function Jl(e,t){if(e==="default")return t;if(t==="default")return e;let n=[...new Set([...e.split(" + "),...t.split(" + ")])];return n.sort((s,r)=>H(s)-H(r)||s.localeCompare(r)),he(n)}function Sn(e){let t=[];for(let n of xe(`.__gs {
43
+ `).length>12;return{source:hr(i)+(a?`
44
+ \u2026`:""),startLine:o}}function Ca(e,t){let n=mr(e,Math.max(0,t)),s=e.split(`
45
+ `),r=Math.max(0,n-1);return{source:hr(s.slice(r,r+12)),startLine:r+1}}function gr(e,t){return{kind:"other",...Ca(e,t)}}function yt(e,t){let n=fr.exec(e.slice(t));if(!n)return null;let s=n[1],r=n[2]??"",o=t+n[0].length;if(/\/\s*$/.test(r)||xa.has(s.toLowerCase()))return{tag:s,attrs:r,openStart:t,openEnd:o,closeEnd:o,body:""};let a=1,l=o,c=Math.min(e.length,t+4e3);for(;l<c;){if(e[l]!=="<"){l++;continue}if(e.startsWith("</",l)){let f=/^<\/([A-Za-z][\w.-]*)\s*>/.exec(e.slice(l));if(f&&f[1].toLowerCase()===s.toLowerCase()){if(a--,a===0){let m=l+f[0].length;return{tag:s,attrs:r,openStart:t,openEnd:o,closeEnd:m,body:e.slice(o,l)}}l+=f?f[0].length:2;continue}l+=f?f[0].length:2;continue}let p=fr.exec(e.slice(l));if(p&&p[1].toLowerCase()===s.toLowerCase()&&!/\/\s*$/.test(p[2]??"")&&(a++,a>6))return"too-big";l+=p?p[0].length:1}return l>=c&&o+(c-t)>=4e3?"too-big":null}function pn(e,t){let n=Math.max(0,t-8e3),s=Math.min(t,e.length-1);for(;s>=n;){let r=e.lastIndexOf("<",s);if(r<n)return null;if(e[r+1]==="/"||e[r+1]==="!"||e[r+1]==="?"){s=r-1;continue}let o=yt(e,r);if(o==="too-big")return"too-big";if(o&&t>=o.openStart&&t<o.closeEnd)return o;s=r-1}return null}function br(e){return e.replace(/([a-z\d])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function je(e){return e.split(/\s+/).filter(Boolean)}function ue(e,t){let n=e[t];if(n!=='"'&&n!=="'"&&n!=="`")return null;let s="";for(let r=t+1;r<e.length;r++){let o=e[r];if(o==="\\"){s+=e[r+1]??"",r++;continue}if(n==="`"&&o==="$"&&e[r+1]==="{")return null;if(o===n)return{value:s,end:r+1};s+=o}return null}function yr(e){let t=[],n="",s=0,r=null;for(let o=0;o<e.length;o++){let i=e[o];if(r){if(n+=i,i==="\\"){n+=e[o+1]??"",o++;continue}i===r&&(r=null);continue}if(i==='"'||i==="'"||i==="`"){r=i,n+=i;continue}if(i==="("||i==="["||i==="{")s++;else if(i===")"||i==="]"||i==="}")s=Math.max(0,s-1);else if(i===","&&s===0){n.trim()&&t.push(n.trim()),n="";continue}n+=i}return n.trim()&&t.push(n.trim()),t}function ht(e=new Map,t=new Map){return{values:e,aliases:t,flags:new Set,strings:new Set,prefixes:new Map}}var un=/^[A-Za-z_$][\w$]*$/;function fn(e,t){let n=0,s=null;for(let r=0;r<e.length;r++){let o=e[r];if(s){o==="\\"?r++:o===s&&(s=null);continue}if(o==='"'||o==="'"||o==="`"){s=o;continue}if(o==="("||o==="["||o==="{")n++;else if(o===")"||o==="]"||o==="}")n--;else if(n===0&&e.startsWith(t,r))return r}return-1}function dn(e){let t=e.trim();for(;t.startsWith("(")&&t.endsWith(")");){let n=0,s=!0;for(let r=0;r<t.length-1&&s;r++)t[r]==="("?n++:t[r]===")"&&n--,n===0&&(s=!1);if(!s)break;t=t.slice(1,-1).trim()}return t}function xr(e,t,n){if(e==="true")return!0;if(e==="false"||e==="undefined"||e==="null")return!1;let s=t.aliases.get(e);return s!==void 0&&!t.values.has(e)?Pe(s,t,n+1):(t.flags.add(e),!!t.values.get(e))}function Pe(e,t,n=0){if(n>4)return null;let s=dn(e);for(let c of["||","&&"]){let p=fn(s,c);if(p<0)continue;let f=Pe(s.slice(0,p),t,n+1),m=Pe(s.slice(p+2),t,n+1);return f===null||m===null?null:c==="||"?f||m:f&&m}let r=/^(!\s*)?([A-Za-z_$][\w$]*)$/.exec(s);if(r){let c=xr(r[2],t,n);return c===null?null:r[1]?!c:c}let o=/^([A-Za-z_$][\w$]*)\s*(===|==|!==|!=)\s*(["'])(.*?)\3$/.exec(s);if(!o)return null;let i=t.values.get(o[1]);typeof i=="string"&&t.strings.add(o[1]);let a=typeof i=="string"?i:"";return o[2]==="==="||o[2]==="=="?a===o[4]:a!==o[4]}function wr(e){let t=0,n=null,s=-1;for(let r=0;r<e.length;r++){let o=e[r];if(n){o==="\\"?r++:o===n&&(n=null);continue}if(o==='"'||o==="'"||o==="`"){n=o;continue}if(o==="("||o==="["||o==="{")t++;else if(o===")"||o==="]"||o==="}")t--;else if(o==="?"&&t===0){s=r;break}}if(s<0)return null;t=0,n=null;for(let r=s+1;r<e.length;r++){let o=e[r];if(n){o==="\\"?r++:o===n&&(n=null);continue}if(o==='"'||o==="'"||o==="`"){n=o;continue}if(o==="("||o==="["||o==="{")t++;else if(o===")"||o==="]"||o==="}")t--;else if(o===":"&&t===0)return{condition:e.slice(0,s),yes:e.slice(s+1,r),no:e.slice(r+1)}}return null}function Ie(e,t=ht()){let n=dn(e);if(!n)return{classes:[],dynamic:!1};let s=wr(n);if(s){let c=Pe(s.condition,t);return c===null?{classes:[],dynamic:!0}:Ie(c?s.yes:s.no,t)}let r=fn(n,"&&");if(r>=0){let c=Pe(n.slice(0,r),t);return c===null?{classes:[],dynamic:!0}:c?Ie(n.slice(r+2),t):{classes:[],dynamic:!1}}if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))return{classes:je(n.slice(1,-1)),dynamic:!1};if(n.startsWith("`")&&n.endsWith("`")){let c=n.slice(1,-1),p="",f=0;for(;f<c.length;){let m=c.indexOf("${",f);if(m<0){p+=c.slice(f);break}p+=c.slice(f,m);let h=c.indexOf("}",m+2);if(h<0)return{classes:[],dynamic:!0};let C=c.slice(m+2,h).trim();if(un.test(C)){let w=t.values.get(C);if(typeof w!="string")return{classes:[],dynamic:!0};t.strings.add(C);let v=/[\w-]*$/.exec(p)?.[0];v&&t.prefixes.set(C,v),p+=w}else{let w=Ie(C,t);if(w.dynamic)return{classes:[],dynamic:!0};p+=w.classes.join(" ")}f=h+1}return{classes:je(p),dynamic:!1}}if(un.test(n)&&t.values.has(n)){let c=t.values.get(n);return typeof c!="string"?{classes:[],dynamic:!1}:(t.strings.add(n),{classes:je(c),dynamic:!1})}let o=/^(?:styles?|classes|css|cls)\.([A-Za-z_]\w*)$/.exec(n);if(o)return{classes:[br(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=Ie(a[1],t);return c.dynamic||c.classes.length!==1?{classes:[],dynamic:!0}:c}let l=/^([A-Za-z_][\w]*)\s*\(([\s\S]*)\)$/.exec(n);if(l&&ka.has(l[1])){let c=[];for(let p of yr(l[2])){let f=Ie(p,t);if(f.dynamic)return{classes:[],dynamic:!0};c.push(...f.classes)}return{classes:c,dynamic:!1}}return{classes:[],dynamic:!0}}function xt(e){let t=[],n=!1,s=0;for(;s<e.length;){if(/\s/.test(e[s])){s++;continue}if(e[s]==="{"){let i=0,a=s;for(let l=s;l<e.length;l++)if(e[l]==="{")i++;else if(e[l]==="}"&&(i--,i===0)){s=l+1;break}s===a&&(s=e.length),/^\{\s*\.\.\./.test(e.slice(a))&&(n=!0);continue}let r=/^([A-Za-z_:][\w:.-]*)/.exec(e.slice(s));if(!r){s++;continue}for(s+=r[0].length;s<e.length&&/\s/.test(e[s]);)s++;if(e[s]!=="="){t.push({name:r[1]});continue}for(s++;s<e.length&&/\s/.test(e[s]);)s++;let o=ue(e,s);if(o){t.push({name:r[1],value:o.value}),s=o.end;continue}if(e[s]==="{"){let i=0,a=s;for(let p=s;p<e.length;p++)if(e[p]==="{")i++;else if(e[p]==="}"&&(i--,i===0)){s=p+1;break}s===a&&(s=e.length);let l=e.slice(a+1,s-1).trim(),c=ue(l,0);c&&c.end===l.length?t.push({name:r[1],value:c.value}):t.push({name:r[1],expr:l});continue}s++}return{list:t,spread:n}}function gn(e,t){let n=xt(e).list.find(s=>s.name==="class"||s.name==="className");return n?n.value!==void 0?{classes:je(n.value),dynamic:!1}:n.expr===void 0?{classes:[],dynamic:!0}:Ie(n.expr,t):null}function kr(e,t){return/[<>]/.test(t)?!1:e==="href"||e==="src"||e==="action"?/^(?:https?:|mailto:|\/|#)/i.test(t):!0}function Sa(e){return e==="class"||e==="className"?!1:!va.test(e)&&!/^on/i.test(e)}function vr(e){let t={};for(let n of xt(e).list){if(!Sa(n.name)||n.expr!==void 0)continue;let s=n.value??"";kr(n.name,s)&&(t[n.name]=s)}return t}var Ra=/^(?:data-[\w-]+|aria-[\w-]+|disabled|hidden)$/,Aa=new Set(["disabled","hidden"]);function mt(e,t,n=0){if(n>4)return null;let s=dn(e),r=ue(s,0);if(r&&r.end===s.length)return r.value;let o=wr(s);if(o){let l=Pe(o.condition,t);return l===null?null:mt(l?o.yes:o.no,t,n+1)}let i=fn(s,"||");if(i>=0){let l=mt(s.slice(0,i),t,n+1);return l===null?null:l!==void 0?l:mt(s.slice(i+2),t,n+1)}if(s==="undefined"||s==="null"||s==="false")return;if(s==="true")return"true";if(!un.test(s))return null;let a=t.values.get(s);if(typeof a=="string")return t.strings.add(s),a;if(typeof a=="boolean"||t.aliases.has(s)){let l=xr(s,t,n);return l===null?null:l?"true":void 0}return t.values.has(s)?void 0:null}function _a(e,t){let n={};for(let s of xt(e).list){if(s.expr===void 0||!Ra.test(s.name))continue;let r=mt(s.expr,t);if(r!=null){if(Aa.has(s.name)){r!=="false"&&(n[s.name]="");continue}kr(s.name,r)&&(n[s.name]=r)}}return n}function Ea(e,t){let n=/([A-Za-z_][\w-]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*["']([^"']*)["']\s*\})/g;for(let s of e.matchAll(n)){let r=s.index??0;if(t>=r&&t<r+s[0].length){let o=s[1];return o==="class"||o==="className"?{}:{prop:o,value:s[2]??s[3]??s[4]}}}return{}}function bt(e,t=0){if(t>6)return"";let n="",s=0;for(;s<e.length;){if(e[s]==="{"){let i=0,a=s;for(let p=s;p<e.length;p++)if(e[p]==="{")i++;else if(e[p]==="}"&&(i--,i===0)){a=p+1;break}if(a===s)break;let l=e.slice(s+1,a-1).trim();/^[A-Za-z_$][\w$]*$/.exec(l)?.[0]&&(n+='<span class="__gs-slot">Text</span>'),s=a;continue}if(e[s]==="<"){if(e.startsWith("<!--",s)){let l=e.indexOf("-->",s);s=l===-1?e.length:l+3;continue}if(e.startsWith("</",s)){let l=/^<\/[A-Za-z][\w.-]*\s*>/.exec(e.slice(s));s+=l?l[0].length:1;continue}let i=yt(e,s);if(!i||i==="too-big"){s++;continue}let a=i.tag.toLowerCase();if(/^[A-Z]/.test(i.tag))n+=bt(i.body,t+1);else if(wa.has(a)){let l=gn(i.attrs),c=l&&!l.dynamic&&l.classes.length?` class="${dr(l.classes.join(" "))}"`:"",p=bt(i.body,t+1);n+=`<${a}${c}>${p}</${a}>`}s=i.closeEnd;continue}let r=e.slice(s).search(/[<{}]/),o=r===-1?e.length:s+r;n+=dr(e.slice(s,o)),s=o}return n}function Ia(e){let t=gn(e.attrs);return!t||t.dynamic||t.classes.length===0?null:{tag:e.tag.toLowerCase(),classes:t.classes,attrs:vr(e.attrs)}}function $r(e,t){let n=[],s=t-1;for(;n.length<3&&s>=0;){let r=pn(e,s);if(!r||r==="too-big"||/^[A-Z]/.test(r.tag))break;let o=Ia(r);if(!o)break;n.push(o),s=r.openStart-1}return n.reverse()}var ja=8;function Pa(e){let t=e.trim(),n=ue(t,0);return n&&n.end===t.length?n.value:t==="true"?!0:t==="false"?!1:/^-?\d+(?:\.\d+)?$/.test(t)?t:null}function La(e,t){let n=0,s=-1;for(let i=t;i<e.length&&i<t+2e3;i++){let a=e[i];if(a==='"'||a==="'"||a==="`"){let l=ue(e,i);if(!l)return null;i=l.end-1;continue}if(a==="{")n++;else if(a==="}"&&(n--,n===0)){s=i;break}}if(s<0)return null;let r=e.slice(s+1).trimStart()[0];if(r!==")"&&r!==":")return null;let o=new Map;for(let i of yr(e.slice(t+1,s))){if(i.startsWith("..."))continue;let a=/^([A-Za-z_$][\w$]*)(?:\s*:\s*([A-Za-z_$][\w$]*))?(?:\s*=\s*([\s\S]+))?$/.exec(i);if(!a)continue;let l=a[2]??a[1];if(a[3]===void 0){o.set(l,void 0);continue}let c=Pa(a[3]);c!==null&&o.set(l,c)}return{values:o,end:s}}function Oa(e,t){let n=new Set(t.attrs.match(/[A-Za-z_$][\w$]*/g)??[]),s=Math.max(0,t.openStart-8e3),o=[...e.slice(s,t.openStart).matchAll(/\(\s*\{/g)].reverse();for(let i of o){let a=s+(i.index??0)+i[0].length-1,l=La(e,a);if(!l||![...l.values.keys()].some(f=>n.has(f)))continue;let c=new Map,p=e.slice(l.end,t.openStart);for(let f of p.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*([^;\n]+);/g))n.has(f[1])&&c.set(f[1],f[2].trim());return ht(l.values,c)}return ht()}function Ma(e,t){let n=new Map;for(let s of e.matchAll(/([\w-]+)\$\{\s*([A-Za-z_$][\w$]*)\s*\}/g)){let r=s[1],o=t.find(i=>i.startsWith(r)&&i.length>r.length);o&&n.set(s[2],o.slice(r.length))}return n}function Na(e,t,n,s){let r=$a(e,t.openStart,t.closeEnd);if(/^[A-Z]/.test(t.tag)){let m=Ea(e.slice(t.openStart,t.openEnd),n-t.openStart);return{kind:"component",...r,component:{tag:t.tag,...m}}}let o=Oa(e,t);for(let[m,h]of Ma(t.attrs,s))o.values.set(m,h);let i={};for(let[m,h]of o.values)i[m]=h??null;let a={attrs:t.attrs,values:i,aliases:Object.fromEntries(o.aliases)},l=ht(new Map(o.values),o.aliases),c=Ta(a.attrs,l);if(!c)return{kind:"dynamic",...r};let p={tag:t.tag.toLowerCase(),...c,ancestors:$r(e,t.openStart),bodyHtml:bt(t.body)},f=[...[...l.strings].filter(m=>typeof o.values.get(m)=="string").map(m=>({name:m,kind:"text",...l.prefixes.has(m)?{prefix:l.prefixes.get(m)}:{}})),...[...l.flags].slice(0,ja).map(m=>({name:m,kind:"flag"}))];return f.length===0?{kind:"markup",...r,element:p}:{kind:"markup",...r,element:p,params:f,redraw:a}}function Ta(e,t){let n=gn(e,t);return n?.dynamic?null:{classes:n?.classes??[],attrs:{...vr(e),..._a(e,t)}}}function mn(e,t,n,s){if(ya.test(s))return gr(e,t);let r=pn(e,t);return r==="too-big"||!r?gr(e,t):Na(e,r,t,n)}function Da(e){let t={},n=new Set,{list:s,spread:r}=xt(e);for(let o of s)o.expr===void 0?t[o.name]=o.value??"true":o.expr==="true"||o.expr==="false"?t[o.name]=o.expr:n.add(o.name);return{literals:t,dynamic:n,spread:r}}function Cr(e,t){let n=Da(t),s=new Map,r=[],o=[],i=[],a=n.spread;for(let l of e.axes){if(l.opaque){a=!0;continue}if(!l.locked&&n.dynamic.has(l.prop)){a=!0;continue}let c=l.locked?l.defaultValue:n.literals[l.prop]??(n.spread?void 0:l.defaultValue);if(c===void 0)continue;s.set(l.prop,c);let p=!l.locked&&n.literals[l.prop]===c;if(l.prefix){o.push(`${l.prefix}${c}`),p&&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,p&&l.values.length>0&&i.push({prop:l.prop,value:c,known:l.values.map(m=>m.value)});continue}for(let m of f.classes)m.startsWith("__gs-recipe-")&&r.push(m),o.push(m)}if(!a){for(let l of e.compounds)if(l.when.every(p=>s.get(p.prop)===p.value))for(let p of l.classes)p.startsWith("__gs-recipe-")&&r.push(p),o.push(p)}return e.classNameProp&&(n.dynamic.has("className")?a=!0:n.literals.className&&o.push(...je(n.literals.className))),{draw:a?null:[...e.staticClasses,...o],selects:r,unknown:i}}function hn(e){let t=[],n=/import\s*\{([^}]+)\}\s*from\s*["']([^"']+)["']/g;for(let s of e.matchAll(n)){let r=s[2];for(let o of s[1].split(",")){let i=o.trim().split(/\s+as\s+/),a=i[0]?.trim(),l=(i[1]??i[0])?.trim();a&&l&&t.push({local:l,imported:a,spec:r})}}return t}function Fa(e,t,n,s,r){for(let o of hn(t)){if(o.local!==n)continue;let i=r(e,o.spec),a=s.find(l=>l.path===i&&l.component===o.imported);if(a)return a}return s.find(o=>o.path===e&&o.component===n)}function Sr(e,t,n,s,r,o){if(e.kind!=="component"||!e.component||r.length===0)return e;let i=Fa(s,t,e.component.tag,r,o);if(!i)return e;let a=pn(t,n),l=e.component.tag;if(!a||a==="too-big"||a.tag!==l&&a.tag!==i.component)return e;let c=Cr(i,a.attrs);return c.draw?{kind:"markup",source:e.source,startLine:e.startLine,component:e.component,element:{tag:i.rootTag,classes:c.draw,attrs:{},ancestors:$r(t,a.openStart),bodyHtml:bt(a.body)}}:e}function wt(e,t,n,s){let r=[],o=new Set,i=(l,c)=>{let p=`${l}\0${c.path}`;o.has(p)||(o.add(p),r.push({local:l,binding:c}))};for(let l of hn(t)){let c=s(e,l.spec),p=n.find(f=>f.path===c&&f.component===l.imported);p&&i(l.local,p)}for(let l of n)l.path===e&&i(l.component,l);let a=[];for(let{local:l,binding:c}of r){let p=0,f=`<${l}`;for(;p<t.length;){let m=t.indexOf(f,p);if(m<0)break;let h=t[m+f.length];if(h&&/[\w.]/.test(h)){p=m+f.length;continue}let C=yt(t,m);if(!C||C==="too-big"){p=m+f.length;continue}let w=Cr(c,C.attrs);(w.selects.length||w.unknown.length)&&a.push({offset:m,component:l,selects:w.selects,unknown:w.unknown}),p=Math.max(C.closeEnd,m+f.length)}}return a}function Ba(e,t){let n=e.slice(t,t+700),s=n.indexOf("{");if(s<0)return{};let r=n.indexOf("}",s),o=n.slice(s,r<0?s+400:r+1),i={};for(let a of o.matchAll(/([A-Za-z_$][\w$]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))i[a[1]]=a[2]??a[3]??"";return i}function Va(e){let t=/\bclassName\s*=\s*/.exec(e);if(!t)return null;let n=t.index+t[0].length,s=ue(e,n);if(s)return s.value;if(e[n]!=="{")return null;let r=0;for(let o=n;o<e.length;o++)if(e[o]==="{")r++;else if(e[o]==="}"&&(r--,r===0))return e.slice(n+1,o);return null}function Ua(e,t){let n=t+1;for(;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]===")")return{rename:{},fixed:{},opaque:[]};if(e[n]!=="{")return null;let s={rename:{},fixed:{},opaque:[]};for(n++;n<e.length;){for(;n<e.length&&/[\s,]/.test(e[n]);)n++;if(e[n]==="}")return s;if(e.startsWith("...",n))return null;let r=/^[A-Za-z_$][\w$]*/.exec(e.slice(n));if(!r)return null;for(n+=r[0].length;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]===","||e[n]==="}"){s.rename[r[0]]=r[0];continue}if(e[n]!==":")return null;for(n++;n<e.length&&/\s/.test(e[n]);)n++;let o=ue(e,n);if(o){s.fixed[r[0]]=o.value,n=o.end;continue}let i=/^[A-Za-z_$][\w$]*/.exec(e.slice(n));if(i){s.rename[r[0]]=i[0],n+=i[0].length;continue}s.opaque.push(r[0]);let a=0;for(;n<e.length;){let l=e[n];if(l==='"'||l==="'"||l==="`"){let c=ue(e,n);if(!c)return null;n=c.end;continue}if(l==="("||l==="["||l==="{")a++;else if(l===")"||l==="]"||l==="}"){if(a===0)break;a--}else if(l===","&&a===0)break;n++}}return null}function za(e,t,n,s){let r=[];for(let o of hn(e)){let i=s(t,o.spec),a=n.find(l=>l.path===i&&l.name===o.imported);a&&r.push({local:o.local,recipe:a})}for(let o of n)o.path===t&&o.name&&r.push({local:o.name,recipe:o});return r}function Wa(e){let t=[],n=/(?:styles?|classes|css|cls)\s*\.\s*([A-Za-z_]\w*)/g;for(let c of e.matchAll(n))t.push({at:c.index??0,kind:"static",text:br(c[1])});let s=/(?:styles?|classes|css|cls)\s*\[\s*["']([^"']+)["']\s*\]/g;for(let c of e.matchAll(s))t.push({at:c.index??0,kind:"static",text:c[1]});let r=/(?:styles?|classes|css|cls)\s*\[\s*`([^`$]*)\$\{\s*([A-Za-z_$][\w$]*)\s*\}`\s*\]/g;for(let c of e.matchAll(r))t.push({at:c.index??0,kind:"prefix",text:c[1],prop:c[2]});let o=/(?:styles?|classes|css|cls)\s*\[\s*["']([^"']+)["']\s*\+\s*([A-Za-z_$][\w$]*)\s*\]/g;for(let c of e.matchAll(o))t.push({at:c.index??0,kind:"prefix",text:c[1],prop:c[2]});/[[{(]/.test(e)||t.push({at:0,kind:"static",text:e.trim()}),t.sort((c,p)=>c.at-p.at);let i=[],a=[];for(let c of t)c.kind==="prefix"&&c.prop?a.push({prop:c.prop,prefix:c.text}):i.push(...je(c.text));let l=/(?:^|[(,\s])className\s*(?:[,)]|$)/.test(e);return{staticClasses:i,prefixes:a,classNameProp:l}}function Ga(e,t,n,s,r){let o=l=>t.rename[l]??l,i=e.axes.map(l=>{let c=t.fixed[l.prop],p=o(l.prop);return{prop:p,values:c?l.values.filter(f=>f.value===c):l.values,defaultValue:c??n[p]??l.defaultValue,opaque:t.opaque.includes(l.prop),locked:!!c}}),a=e.compounds.map(l=>({classes:l.classes,when:l.when.map(c=>({prop:o(c.prop),value:t.fixed[c.prop]??c.value}))}));return{staticClasses:[...e.staticClasses,...s],axes:i,compounds:a,classNameProp:r}}function Rr(e,t,n){let s=[];for(let r of e){let o=za(r.source,r.path,t,n);for(let i of r.names){let a=new RegExp(`(?:function\\s+${i}\\b|(?:const|let|var)\\s+${i}\\b)`,"g"),l=[...r.source.matchAll(a)],c=null;for(let p of l){let f=p.index??0,h=r.source.slice(f+p[0].length).search(/\nexport\s/),C=r.source.slice(f,f+p[0].length+(h<0?8e3:h)),w=Ba(r.source,f),v=0;for(;v<C.length;){if(C[v]!=="<"||C[v+1]==="/"||C[v+1]==="!"){v++;continue}let d=yt(C,v);if(!d||d==="too-big"){v++;continue}if(v=d.openEnd,/^[A-Z]/.test(d.tag))continue;let u=Va(d.attrs);if(!u)continue;let g=Wa(u),y=g.prefixes.length?2:g.staticClasses.length?1:0,k=null,x=o.find($=>new RegExp(`(?:^|[^\\w$])${$.local}\\s*\\(`).test(u));if(x){let $=u.search(new RegExp(`(?:^|[^\\w$])${x.local}\\s*\\(`)),j=u.indexOf("(",$),I=j<0?null:Ua(u,j);if(I){y=3,k=Ga(x.recipe,I,w,g.staticClasses,g.classNameProp);for(let A of g.prefixes)k.axes.push({prop:A.prop,values:[],prefix:A.prefix,defaultValue:w[A.prop]})}}!k&&(g.prefixes.length||g.staticClasses.length)&&(k={staticClasses:g.staticClasses,axes:g.prefixes.map($=>({prop:$.prop,values:[],prefix:$.prefix,defaultValue:w[$.prop]})),compounds:[],classNameProp:g.classNameProp}),k&&(!c||y>c.score)&&(c={score:y,tag:d.tag.toLowerCase(),body:k})}}c&&s.push({component:i,path:r.path,rootTag:c.tag,...c.body})}}return s}var Ha=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,Ka=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,Ja=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),Za=new Set(["icon","glyph","svg"]),Xa=new Set(["label","text","title","caption"]),qa=e=>e.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(t=>t.toLowerCase());function _r(e){let t=e.flatMap(qa);return t.some(n=>Za.has(n))?"icon":t.some(n=>Xa.has(n))?"label":null}function Ya(e){let t=e.replace(/\{\s*\/\*[\s\S]*?\*\/\s*\}/g," "),n=[];for(let s of t.matchAll(Ha)){let r=s[1];if(!Ja.has(r.toLowerCase())||r!==r.toLowerCase())continue;let o=[...s[2].matchAll(Ka)].map(a=>a[1]??a[2]),i=_r(o);i&&n.push({index:s.index??0,role:i,tag:r.toLowerCase(),classes:o})}return n}function Qa(e,t,n){if(!t.some(r=>r.property.toLowerCase()==="display"&&/^none\b/i.test(r.value.trim()))||n.size===0)return null;for(let r of z(e)){let o=Y(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 p=l.simples.filter(m=>m.kind==="class"),f=l.simples.filter(m=>m.kind==="attr");if(p.length===1&&f.length===0&&p[0].kind==="class"&&!/^(?:is|has)-/.test(p[0].name))return{classes:[p[0].name],attrs:{}};if(p.length===0&&f.length===1&&f[0].kind==="attr"&&f[0].value)return{classes:[],attrs:{[f[0].name]:f[0].value}}}return null}var el=["text","icon-start","icon-end","icon"],Ar={text:"Text","icon-start":"Icon left","icon-end":"Icon right",icon:"Icon"};function tl(e,t){let n=null,s=null;for(let i of t)i.index<e.index?n=i:s||(s=i);if(!n&&!s)return null;let r=n?e.index-n.index:1/0;return(s?s.index-e.index:1/0)<=r?"start":"end"}function Le(e){return{role:e.role,tag:e.tag,classes:e.classes}}function Er(e){let t=new Map,n=(s,r)=>{let o=t.get(s)??[];o.some(i=>i.path===r.path)||o.push(r),t.set(s,o)};for(let s of e){let r=s.sources.flatMap(Ya),o=r.filter(h=>h.role==="label"),i=r.filter(h=>h.role==="icon"),a=o[0];a&&n("text",{path:s.sheet,slots:[Le(a)],classes:[],attrs:{}});let l=new Set(o.flatMap(h=>h.classes.filter(C=>_r([C])==="label"))),c=null,p=null;for(let h of i){let C=tl(h,o),w=o.reduce((v,d)=>{let u=Math.abs(d.index-h.index);return!v||u<v.dist?{hit:d,dist:u}:v},null);C==="start"&&w&&!c&&(c={icon:h,label:w.hit}),C==="end"&&w&&!p&&(p={icon:h,label:w.hit})}c&&n("icon-start",{path:s.sheet,slots:[Le(c.icon),Le(c.label)],classes:[],attrs:{}}),p&&n("icon-end",{path:s.sheet,slots:[Le(p.label),Le(p.icon)],classes:[],attrs:{}});let f=null;for(let h of s.rules)if(f=Qa(h.selector,h.declarations,l),f)break;let m=c?.icon??p?.icon??i[0]??null;f&&m&&n("icon",{path:s.sheet,slots:[Le(m)],classes:f.classes,attrs:f.attrs})}return[{id:"text",label:Ar.text,sheets:t.get("text")??[]},...el.filter(s=>s!=="text"&&t.has(s)).map(s=>({id:s,label:Ar[s],sheets:t.get(s)??[]}))]}function nl(e,t){if(!e)return t;let n=z(e);return z(t).flatMap(s=>n.map(r=>s.includes("&")?s.replaceAll("&",r):`${r} ${s}`)).join(", ")}var sl=/^@(?:-\w+-)?(?:keyframes|font-face|property)\b/i;function we(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,i=>i.replace(/[^\n]/g," ")),n=[],s=[],r=0,o=1;for(let i=0;i<t.length;i++){let a=t[i];if(a===`
46
+ `&&o++,a==="{"){let l=t.slice(r,i).trim(),c=s[s.length-1];c&&(c.own+=t.slice(c.segStart,r));let p=/^@theme\b/i.test(l),f=l.startsWith("@")&&!p,m=[...s].reverse().find(h=>!h.isAt)??null;s.push({selector:l,resolved:f?l:p?":root":nl(m?.resolved??null,l),isAt:f,skip:(c?.skip??!1)||f&&sl.test(l),start:i+1,line:o,own:"",segStart:i+1}),r=i+1}else if(a==="}"){let l=s.pop();if(l){l.own+=t.slice(l.segStart,i),!l.isAt&&!l.skip&&n.push({selector:l.resolved,body:t.slice(l.start,i),ownBody:l.own,line:l.line,context:s.filter(p=>p.isAt).map(p=>p.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 pe(e){let t=[],n=0,s=0,r=o=>{let i=o.indexOf(":");if(i<=0)return;let a=o.slice(0,i).trim(),l=o.slice(i+1).replace(/\s+/g," ").trim();/^-{0,2}[a-z][\w-]*$/i.test(a)&&l&&a!=="composes"&&t.push({property:a,value:l})};for(let o=0;o<e.length;o++){let i=e[o];i==="("?n++:i===")"?n=Math.max(0,n-1):i===";"&&n===0&&(r(e.slice(s,o)),s=o+1)}return r(e.slice(s)),t}var rl=25,ol=12,Ir=700,il=/\b(?:must(?: not)?|never|always|should(?: not|n't)?|do not|don't|avoid|prefer|forbidden|not allowed|no more than)\b/i,re=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function al(e){let t=e.split(`
47
+ `),n=[],s=[],r=null,o=null,i=0;if(t[0]?.trim()==="---"){let l=t.findIndex((c,p)=>p>0&&c.trim()==="---");l>0&&(i=l+1)}let a=l=>{r&&(n.push({start:r.start,end:l,text:r.lines.join(`
48
+ `).trimEnd(),headings:r.headings}),r=null)};for(;i<t.length;i++){let l=t[i],c=i+1,p=/^\s*(```|~~~)/.exec(l)?.[1];if(o){r.lines.push(l),p===o&&(o=null,a(c));continue}if(p){a(c-1),o=p,r={start:c,lines:[l],headings:[...s]};continue}let f=/^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(l);if(f){a(c-1),s=[...s.slice(0,f[1].length-1),f[2]];continue}if(l.trim()===""){a(c-1);continue}r??={start:c,lines:[],headings:[...s]},r.lines.push(l)}return a(t.length),n}function ll(e,t){let n=e.map(re).join("|"),s=e.map(r=>re(r.charAt(0).toUpperCase()+r.slice(1))).join("|");return new RegExp(`${t.source}|\\b(?:${n})s?\\b|[a-z](?:${s})s?\\b|\\b(?:${n})[-_]|[-_](?:${n})\\b`,"i")}function cl(e,t){let n=t.map(re).join("|"),s=new Map;for(let r of e){if(r.base||r.title==="Unnamed"||r.title.startsWith("In ")||!r.element)continue;let i=s.get(r.title)??{title:r.title,tests:[],heading:null},a=r.selector.slice(ye(r.selector));for(let l of a.matchAll(/\.((?:\\.|[\w-])+)/g)){let c=l[1].replace(/\\(.)/g,"$1");if(t.includes(c.toLowerCase()))continue;let p=/[-_]|[a-z][A-Z]/.test(c);i.tests.push(new RegExp(p?`(?<![\\w-])${re(c)}(?![\\w-])`:`(?:\\.|["'\`])${re(c)}(?![\\w-])`))}if(!r.title.includes(" + ")){let l=r.title.toLowerCase().split(/\s+/).map(re).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${re(r.axis)}\\s*[=:]\\s*\\{?\\s*["'\`]${re(r.title.toLowerCase())}["'\`]`,"i")),i.heading=r.title.toLowerCase()}s.set(r.title,i)}return[...s.values()]}function ul(e,t){return e.toLowerCase().replace(new RegExp(`\\b(?:${t.map(re).join("|")})s?\\b`,"g")," ").replace(/[^a-z0-9]+/g," ").trim()}function pl(e){return e.length>Ir?`${e.slice(0,Ir).trimEnd()}\u2026`:e}function jr(e,t,n,s){let r=ll(n.classKeywords,n.prose),o=cl(s,n.classKeywords),i=new Set,a=[];for(let p of t){let f=e.get(p.path);if(f===void 0)continue;let m=[];for(let h of al(f)){if(!r.test(h.text)&&!h.headings.some(v=>r.test(v)))continue;let C=h.headings.length?ul(h.headings[h.headings.length-1],n.classKeywords):"",w=o.filter(v=>v.tests.some(d=>d.test(h.text))||C!==""&&v.heading===C).map(v=>v.title);for(let v of w)i.add(v);m.push({path:p.path,line:h.start,endLine:h.end,headings:h.headings,text:pl(h.text),rule:il.test(h.text),styles:w})}m.length!==0&&a.push({path:p.path,kind:p.kind,passages:m.slice(0,ol),total:m.length,rules:m.filter(h=>h.rule).length})}let l={instruction:0,documentation:1,record:2};a.sort((p,f)=>l[p.kind]-l[f.kind]||f.rules-p.rules||f.total-p.total||p.path.localeCompare(f.path));let c=new Map;for(let p of s)p.element&&!p.base&&p.title!=="Unnamed"&&!p.title.startsWith("In ")&&c.set(p.title,!0);return{files:a.slice(0,rl).map(({rules:p,...f})=>f),documented:[...i].sort(),undocumented:[...c.keys()].filter(p=>!i.has(p))}}var Pr=new Set(["tone","size","variant","kind","type","style","theme","color","colour","appearance","intent","emphasis","shape","level"]),fl=new Set(["is","has","js","c","component","comp","el","ui","the","root"]),dl={xs:["extra","small"],sm:["small"],md:["medium"],lg:["large"],xl:["extra","large"],xxl:["extra","extra","large"]},gl=new Set(["cta","ui","ux","faq","cms","api","url","ios"]);function yn(e){return e.replace(/\\(.)/g,"$1").replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map(t=>t.toLowerCase())}function ml(e){return new Set(e.flatMap(t=>[t,`${t}s`]))}function bn(e){let t=e.map(n=>gl.has(n)?n.toUpperCase():n).join(" ");return t.charAt(0).toUpperCase()+t.slice(1)}function Oe(e,t){let n=yn(e).filter(r=>!t.has(r)&&!fl.has(r)),s=null;return n.length>1&&Pr.has(n[0])&&(s=n[0],n=n.slice(1)),{words:n.flatMap(r=>dl[r]??[r]),axis:s}}var Lr=/\.((?:\\.|[\w-])+)/g,hl=/\[\s*([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*))\s*\]/g;function bl(e,t){let n=e.split("/"),s=(n.pop()??"").replace(/(\.module)?\.[a-z]+$/i,""),r=n.pop()??"";return yn(s).some(a=>t.has(a))||yn(r).some(a=>t.has(a))?Oe(s,t).words:[]}function yl(e,t){let n=[];for(let s of e.split(/[\s>+~]+/).filter(Boolean)){let r=[...s.matchAll(Lr)].map(o=>o[1]);if(r.length)for(let o of r)n.push(...Oe(o,t).words);else{let o=/^[a-z][\w-]*/i.exec(s)?.[0]?.toLowerCase();o&&!["div","span","html","body"].includes(o)&&n.push(...Oe(o,t).words)}}return n}function Me(e,t){let n=ml(t),s=ye(e.selector),r=e.selector.slice(0,s),o=e.selector.slice(s),i=[...o.matchAll(Lr)].map(p=>Oe(p[1],n));for(let p of o.matchAll(hl)){let f=p[1].replace(/^data-/,"").toLowerCase();if(!Pr.has(f))continue;let m=p[2]??p[3]??p[4]??"",h=Oe(m,n);i.push({words:h.words,axis:f})}let a=i.filter(p=>p.words.length>0);if(a.length>0)return{title:a.map(p=>bn(p.words)).join(" + "),axis:a.length===1?a[0].axis:null};let l=yl(r,n);if(l.length>0)return{title:`In ${l.join(" ")}`,axis:null};let c=bl(e.path,n);if(c.length>0)return{title:bn(c),axis:null};if(e.base){let p=xl(e.path,n);return p.length>0?{title:`${bn(p)} Base`,axis:null}:{title:"Base",axis:null}}return{title:"Unnamed",axis:null}}function xl(e,t){let n=e.split("/").pop()??"";if(!/\.module\.[a-z]+$/i.test(n))return[];let s=n.replace(/\.module\.[a-z]+$/i,"");return Oe(s,t).words}var wl=60;function Je(e,t,n){let s=Y(e);if(!s)return null;let r=s.length-1,o=s[r].simples;if(Ys(o)||rn(o,t))return null;if(pt(o,t))return{compounds:s,at:r};for(let i=r-1;i>=0;i--){let a=s[i].simples;if(pt(a,t)&&!rn(a,t))return{compounds:s,at:i}}return!n||r===0&&Qs(o)?null:{compounds:s,at:0}}function Or(e,t,n){return He([...e,{combinator:e.length?t.combinator:null,simples:n}])}function Mr(e,t){return e.kind!==t.kind?!1:e.kind==="attr"&&t.kind==="attr"?e.name===t.name&&e.op===t.op&&e.value===t.value:e.raw===t.raw}function kl(e,t){return e.length>=t.length?!1:e.every(n=>t.some(s=>Mr(n,s)))}function vl(e,t){if(e.length!==1)return!1;let n=e[0];return n.kind==="tag"?t.elements.includes(n.name):n.kind==="class"?t.classKeywords.some(s=>s.toLowerCase()===n.name.toLowerCase()):!1}function $l(e,t){for(let n of t.classes)e.classes.includes(n)||e.classes.push(n);Object.assign(e.attrs,t.attrs)}function Nr(e){let t=new Set(e.map(n=>Ke(n.property)).filter(n=>n!=="hint"));return t.size===0||t.size===1&&t.has("layout")?"placement":t.size===1&&t.has("paint")?"effect":"override"}function Cl(e){let t=e.filter(o=>o.context===""),n=t.length?t:e;if(n.some(o=>o.state==="default"))return null;let r=[...n.map(o=>new Set(o.state.split(" + "))).reduce((o,i)=>o?new Set([...o].filter(a=>i.has(a))):i,null)??[]].filter(o=>H(o)===ut.length);return r.length===1?r[0]:null}function xn(e){return e.sort((t,n)=>+(t.context!=="")-+(n.context!=="")||H(t.state.split(" + ")[0])-H(n.state.split(" + ")[0])||t.state.localeCompare(n.state))}function Tr(e,t,n,s,r={parts:new Set,controls:new Set}){let o=new Map,i=[];for(let d of t)if(d.declarations.length!==0)for(let u of z(d.selector)){let g=Je(u,n,s);if(!g)continue;let{compounds:y,at:k}=g,x=y[k],$=ft(x.simples);if($.identity.length===0)continue;let j=y.slice(0,k),I=Or(j,x,$.identity),A=be($.states);if(k<y.length-1){i.push({hostKey:I,part:{selector:He(y),path:e,line:d.line,state:A}});continue}if(tr($.identity,d.declarations))continue;let R=o.get(I);if(!R){if(o.size>=wl)continue;R={key:I,prefix:j,identity:$.identity,line:d.line,states:[],modifiers:[],contexts:[],parts:[],movedInto:null},o.set(I,R)}let P=R.states.find(D=>D.state===A&&D.context===d.context);P||(P={state:A,context:d.context,line:d.line,declarations:[]},$.states.length&&(P.marker={classes:[],attrs:{}}),R.states.push(P)),P.marker&&$l(P.marker,$.marker),P.declarations.push(...d.declarations)}for(let[d,u]of o){let g=u.states.flatMap(x=>x.declarations),y=u.states.every(x=>gt(x.declarations)),k=g.every(x=>Ke(x.property)==="hint");(y||k)&&o.delete(d)}let a=new Map;for(let d of o.values()){let u=Ge(d.identity);a.set(u,[...a.get(u)??[],d])}for(let d of a.values()){let u=d.map(x=>Cl(x.states)),g=u[0];if(!g||u.some(x=>x!==g))continue;let y=d.flatMap(x=>x.states).find(x=>x.marker&&x.state.split(" + ").includes(g))?.marker;if(!y)continue;let k=[...y.classes.map(x=>({kind:"class",raw:`.${x}`,name:x})),...Object.entries(y.attrs).map(([x,$])=>({kind:"attr",raw:`[${x}="${$}"]`,name:x,op:"=",value:$}))];for(let x of d){let $=[...x.identity,...k],j={combinator:x.prefix.length?" ":null,simples:$},I=Or(x.prefix,j,$);for(let A of x.states){let R=A.state.split(" + ").filter(P=>P!==g);if(A.state=be(R),R.length===0)delete A.marker;else if(A.marker){A.marker.classes=A.marker.classes.filter(P=>!y.classes.includes(P));for(let P of Object.keys(y.attrs))delete A.marker.attrs[P]}}o.delete(x.key),o.set(I,{...x,key:I,identity:$})}}let l=()=>[...o.values()].filter(d=>d.prefix.length===0),c=d=>d.states.filter(u=>u.state==="default").reduce((u,g)=>u+g.declarations.length,0),p=l().find(d=>vl(d.identity,n))??(s?l().filter(d=>{let u=d.identity.length===1?d.identity[0]:null;return u?.kind==="class"&&r.controls.has(u.name)}).sort((d,u)=>c(u)-c(d)||d.line-u.line)[0]??null:null),f=p&&p.identity[0].kind==="class"?[p.identity[0].name]:[],m=(d,u,g)=>{u[g].push(d),d.movedInto=u,o.delete(d.key)},h=[...o.values()],C=d=>{let u=h.find(g=>g.key===d)??null;for(;u?.movedInto;)u=u.movedInto;return u};for(let d of l()){let u=d.identity.length===1?d.identity[0]:null;if(!(u?.kind!=="class"||!r.parts.has(u.name))&&(o.delete(d.key),p&&d!==p)){d.movedInto=p;for(let g of d.states)p.parts.push({selector:d.key,path:e,line:g.line,state:g.state})}}let w=l().filter(d=>d.identity.filter(u=>u.kind!=="tag"&&u.kind!=="universal").length>=2).sort((d,u)=>d.identity.length-u.identity.length);for(let d of w){let u=h.filter(y=>y!==d&&y!==p&&y.prefix.length===0&&kl(y.identity,d.identity));if(u.length===0)continue;u.sort((y,k)=>k.identity.length-y.identity.length||c(k)-c(y)||y.line-k.line);let g=C(u[0].key);g&&g!==d&&m(d,g,"modifiers")}for(let{hostKey:d,part:u}of i){let g=C(d)??(s?p:null);g&&o.has(g.key)&&g.parts.push(u)}let v=d=>{let u=d===p,g=dt(d.key,f);return{...Me({selector:d.key,path:e,base:u},n.classKeywords),element:g,usage:{status:"unknown",files:[],fileCount:0},selector:d.key,path:e,line:d.line,base:u,states:xn(d.states),modifiers:d.modifiers.length?d.modifiers.map(y=>{let k=y.identity.filter(x=>!d.identity.some($=>Mr($,x)));return{title:Me({selector:k.map(x=>x.raw).join(""),path:e,base:!1},n.classKeywords).title,selector:y.key,path:e,line:y.line,element:dt(y.key,f),usage:{status:"unknown",files:[],fileCount:0},states:xn(y.states)}}):void 0,contexts:d.contexts.length?d.contexts.map(y=>{let k=Nr(y.states.flatMap(x=>x.declarations));return{selector:y.key,path:e,line:y.line,role:k,element:k==="override"?dt(y.key,f):null,states:xn(y.states)}}):void 0,parts:d.parts.length?d.parts:void 0}};return[...o.values()].map(v)}function Dr(e){let t=new Map;for(let i of e){let a=i.base?/^\.([\w-]+)$/.exec(i.selector):null;a&&t.set(i.path,[...t.get(i.path)??[],a[1]])}let n=i=>{let a=Y(i.selector);if(!a)return null;let l=a[a.length-1].simples,c=t.get(i.path)??[],p=l.filter(f=>!(f.kind==="class"&&c.includes(f.name)));return{depth:a.length-1,subject:Ge(l),bareTag:!l.some(f=>f.kind==="class"||f.kind==="attr"||f.kind==="id"),bare:p.length&&p.length<l.length?Ge(p):null}},s=new Map(e.map(i=>[i,n(i)])),r=new Set,o=i=>{let a=s.get(i);if(!a||a.depth===0)return null;let l=e.filter(c=>{if(c===i||r.has(c))return!1;let p=s.get(c);return p!=null&&p.depth<a.depth&&(!a.bareTag||p.depth===0)&&(p.subject===a.subject||a.bare!==null&&p.subject===a.bare)});return l.sort((c,p)=>+(p.path===i.path)-+(c.path===i.path)||s.get(c).depth-s.get(p).depth),l[0]??null};for(let i of[...e].sort((a,l)=>(s.get(l)?.depth??0)-(s.get(a)?.depth??0))){let a=o(i);if(!a)continue;for(;r.has(a);)a=o(a)??a;let l=Nr(i.states.flatMap(c=>c.declarations));a.contexts=[...a.contexts??[],{selector:i.selector,path:i.path,line:i.line,role:l,element:l==="override"?i.element:null,states:i.states}],i.parts?.length&&(a.parts=[...a.parts??[],...i.parts]),i.modifiers?.length&&(a.modifiers=[...a.modifiers??[],...i.modifiers]),r.add(i)}return e.filter(i=>!r.has(i))}var Sl={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 Fr(e){let t=e.lastIndexOf("-");return t<=0?null:Sl[e.slice(0,t)]?.[e.slice(t+1)]??null}var E=(e,t)=>({property:e,value:t});function Cn(e){if(!e.startsWith("[")||!e.endsWith("]"))return null;let t=e.slice(1,-1).replace(/_/g," ").trim();return/^-?[\d.]+(?:px|rem|em|%|vh|vw)$/.test(t)||/^var\(\s*--[\w-]+\s*\)$/.test(t)?t.replace(/\s+/g,""):null}function $n(e){let t=Cn(e);if(t)return t;if(e==="px")return"1px";if(!/^\d+(?:\.\d+)?$/.test(e))return null;let n=Number(e);if(n>96)return null;let s=Math.round(n*2);if(Math.abs(n*2-s)>1e-6)return null;if(s===0)return"0";let r=Math.floor(s/8),o=["",".125",".25",".375",".5",".625",".75",".875"][s%8];return r===0?`0${o}rem`:`${r}${o}rem`}function Rl(e){let t=/^(\d+)\/(\d+)$/.exec(e);if(!t)return null;let n=Number(t[1])/Number(t[2])*100;return Number.isFinite(n)?`${Number(n.toFixed(4))}%`:null}function Br(e,t){return{full:"100%",screen:t==="w"?"100vw":"100vh",auto:"auto",fit:"fit-content",min:"min-content",max:"max-content"}[e]??Rl(e)??Cn(e)??$n(e)}var Al={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"}},_l={thin:"100",extralight:"200",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"},El={none:"1",tight:"1.25",snug:"1.375",normal:"1.5",relaxed:"1.625",loose:"2"},Il={none:"0",sm:"0.125rem","":"0.25rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem","3xl":"1.5rem",full:"9999px"},jl={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"},Pl={"":"3px",0:"0px",1:"1px",2:"2px",4:"4px",8:"8px"};function wn(e,t){let n=null;if(e.startsWith("[")&&e.endsWith("]")){let r=e.slice(1,-1).replace(/_/g," ").trim();if(r.startsWith("--"))n=`var(${r})`;else if(/^var\(\s*--[\w-]+\s*\)$/.test(r))n=r.replace(/\s+/g,"");else if(/^#[0-9a-f]{3,8}$/i.test(r)||/^(?:rgb|hsl|oklch|oklab|color)\(/i.test(r))n=r;else return null}else e==="white"?n="#fff":e==="black"?n="#000":e==="transparent"?n="transparent":e==="current"?n="currentColor":e==="inherit"?n="inherit":n=Fr(e)??(/^[a-z][\w-]*$/i.test(e)?`var(--${e}, var(--color-${e}))`:null);if(!n)return null;if(!t)return n;if(!/^\d+(?:\.\d+)?$/.test(t))return null;let s=Number(t)<=1?Number(t)*100:Number(t);return s<0||s>100?null:s===100?n:`color-mix(in srgb, ${n} ${s}%, transparent)`}function Ll(e){let t=0,n=-1;for(let s=0;s<e.length;s++){let r=e[s];r==="["?t++:r==="]"?t=Math.max(0,t-1):r==="/"&&t===0&&(n=s)}return n<0?{body:e,opacity:null}:{body:e.slice(0,n),opacity:e.slice(n+1)}}function kn(){return E("box-shadow","0 0 0 var(--gs-ring-w, 3px) var(--gs-ring-c, currentColor)")}var Ol={flex:"flex","inline-flex":"inline-flex",block:"block","inline-block":"inline-block",inline:"inline",grid:"grid","inline-grid":"inline-grid",hidden:"none",contents:"contents"},vn={start:"flex-start",end:"flex-end",center:"center",baseline:"baseline",stretch:"stretch",between:"space-between",around:"space-around",evenly:"space-evenly"};function Vr(e){let t=e.startsWith("-"),n=t?e.slice(1):e,{body:s,opacity:r}=Ll(n),o=Ol[s];if(o&&!t&&!r)return[E("display",o)];let i=/^flex-(row|col|row-reverse|col-reverse)$/.exec(s);if(i&&!t&&!r){let R=i[1]==="col"?"column":i[1]==="col-reverse"?"column-reverse":i[1];return[E("flex-direction",R)]}if(s==="flex-wrap"&&!t)return[E("flex-wrap","wrap")];if(s==="flex-nowrap"&&!t)return[E("flex-wrap","nowrap")];if(s==="flex-1"&&!t)return[E("flex","1 1 0%")];if(s==="shrink-0"&&!t)return[E("flex-shrink","0")];if(s==="grow-0"&&!t)return[E("flex-grow","0")];if(s==="grow"&&!t)return[E("flex-grow","1")];let a=/^items-(start|end|center|baseline|stretch)$/.exec(s);if(a&&!t)return[E("align-items",vn[a[1]])];let l=/^justify-(start|end|center|between|around|evenly)$/.exec(s);if(l&&!t)return[E("justify-content",vn[l[1]])];let c=/^self-(start|end|center|stretch|auto)$/.exec(s);if(c&&!t)return[E("align-self",c[1]==="auto"?"auto":vn[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 p=/^(uppercase|lowercase|capitalize|normal-case)$/.exec(s);if(p)return[E("text-transform",p[1]==="normal-case"?"none":p[1])];let f=/^text-(left|center|right|justify|start|end)$/.exec(s);if(f&&!r)return[E("text-align",f[1])];let m=Al[s.replace(/^text-/,"")];if(s.startsWith("text-")&&m&&!r&&!t)return[E("font-size",m.size),E("line-height",m.leading)];let h=_l[s.replace(/^font-/,"")];if(s.startsWith("font-")&&h&&!r)return[E("font-weight",h)];if(s.startsWith("leading-")&&!r){let R=s.slice(8),D=El[R]??$n(R);if(D)return[E("line-height",D)]}let C=/^cursor-(pointer|default|not-allowed|wait|text|move)$/.exec(s);if(C)return[E("cursor",C[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&&!t)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 v=/^duration-(\d+)$/.exec(s);if(v)return[E("transition-duration",`${v[1]}ms`)];let d={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-")&&d[s.slice(4)])return[E("transition-timing-function",d[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 u=/^outline-(\d+)$/.exec(s);if(u)return[E("outline-width",`${u[1]}px`)];if(s==="shadow"||s.startsWith("shadow-")){let R=s==="shadow"?"":s.slice(7),P=jl[R];if(P)return[E("box-shadow",P)]}if(s==="ring"||/^ring(?:-(?:0|1|2|4|8))?$/.test(s)){let R=s==="ring"?"":s.slice(5),P=Pl[R];if(P)return[E("--gs-ring-w",P),kn()]}if(s.startsWith("ring-")&&r===null){let R=wn(s.slice(5),null);if(R)return[E("--gs-ring-c",R),kn()]}if(s.startsWith("ring-")&&r){let R=wn(s.slice(5),r);if(R)return[E("--gs-ring-c",R),kn()]}let g=s==="rounded"?"":s.startsWith("rounded-")?s.slice(8):null;if(g!==null&&!t){let R=/^(t|r|b|l|s|e|tl|tr|bl|br|ss|se)(?:-(.+))?$/.exec(g),P=R?R[2]??"":g,D=Il[P];if(!D)return null;if(!R)return[E("border-radius",D)];let X={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 X?X.map(et=>E(et,D)):null}if(/^border(?:-[trblxy])?$/.test(s)&&!r)return[E("border-width","1px"),E("border-style","solid")];let y=/^border-(\d+)$/.exec(s);if(y&&!r)return[E("border-width",`${y[1]}px`),E("border-style","solid")];let k=/^border-(solid|dashed|dotted|double|none|hidden)$/.exec(s);if(k)return[E("border-style",k[1])];let x=/^(p|px|py|pt|pr|pb|pl|ps|pe|m|mx|my|mt|mr|mb|ml|ms|me|gap|gap-x|gap-y|w|h|min-w|min-h|max-w|max-h|size|inset|top|right|bottom|left)-(.+)$/.exec(s),$=x?.[1],j=x?.[2];if($&&j&&!r){let R=$==="w"||$==="min-w"||$==="max-w"?Br(j,"w"):$==="h"||$==="min-h"||$==="max-h"?Br(j,"h"):$n(j);if(!R)return null;let P=t?R==="0"?"0":`-${R}`:R,G={p:["padding"],px:["padding-inline"],py:["padding-block"],pt:["padding-top"],pr:["padding-right"],pb:["padding-bottom"],pl:["padding-left"],ps:["padding-inline-start"],pe:["padding-inline-end"],m:["margin"],mx:["margin-inline"],my:["margin-block"],mt:["margin-top"],mr:["margin-right"],mb:["margin-bottom"],ml:["margin-left"],ms:["margin-inline-start"],me:["margin-inline-end"],gap:["gap"],"gap-x":["column-gap"],"gap-y":["row-gap"],w:["width"],h:["height"],"min-w":["min-width"],"min-h":["min-height"],"max-w":["max-width"],"max-h":["max-height"],size:["width","height"],inset:["inset"],top:["top"],right:["right"],bottom:["bottom"],left:["left"]}[$];return G?G.map(X=>E(X,P)):null}let I={bg:"background-color",text:"color",border:"border-color",outline:"outline-color",decoration:"text-decoration-color",accent:"accent-color",caret:"caret-color",fill:"fill",stroke:"stroke"};for(let[R,P]of Object.entries(I))if(s===R||s.startsWith(`${R}-`)){let D=s===R?"":s.slice(R.length+1);if(!D||/^(?:gradient|clip|ellipsis|wrap|nowrap|balance|pretty|opacity)/.test(D))return null;if(R==="text"&&!t){let X=Cn(D);if(X)return[E("font-size",X)]}let G=wn(D,r);return!G||t?null:[E(P,G)]}let A=/^\[([a-z-]+):(.+)\]$/i.exec(s);if(A&&!t&&!r){let R=A[1].toLowerCase(),P=A[2].replace(/_/g," ").trim();if(/^[a-z][\w-]*$/.test(R)&&P&&!/[<>]/.test(P))return[E(R,P)]}return null}var Ml=48,Nl={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",disabled:"disabled"},Tl=new Set(["cn","clsx","classNames","classnames","cx","twMerge"]);function fe(e,t){let n=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
49
+ `&&n++;return n}function Dl(e){let t=n=>n.replace(/[^\n]/g," ");return e.replace(/\/\*[\s\S]*?\*\//g,t).replace(/(^|\s)\/\/[^\n]*/g,(n,s)=>s+t(n.slice(s.length)))}function W(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;return t}function kt(e,t){let n=e[t];if(n!=='"'&&n!=="'"&&n!=="`")return null;let s="",r=!1;for(let o=t+1;o<e.length;o++){let i=e[o];if(i==="\\"){let a=e[o+1];if(a===void 0)return null;s+=a==="n"?`
50
+ `:a,o++;continue}if(n==="`"&&i==="$"&&e[o+1]==="{"){r=!0;let a=1;for(o+=2;o<e.length&&a>0;o++)e[o]==="{"?a++:e[o]==="}"&&a--;o--;continue}if(i===n)return{v:r?null:s,end:o+1};s+=i}return null}function An(e,t,n,s){let r=0;for(let o=t;o<e.length;o++){let i=e[o];if(i==='"'||i==="'"||i==="`"){let a=kt(e,o);if(!a)return e.length;o=a.end-1;continue}if(i===n)r++;else if(i===s&&(r--,r===0))return o+1}return e.length}function Fl(e,t){let n=0;for(let s=t;s<e.length;s++){let r=e[s];if(r==='"'||r==="'"||r==="`"){let o=kt(e,s);if(!o)return e.length;s=o.end-1;continue}if(r==="("||r==="["||r==="{")n++;else if(r===")"||r==="]"||r==="}"){if(n===0)return s;n--}else if(r===","&&n===0)return s}return e.length}function Ur(e){if(e.t==="str")return e.v;if(e.t==="arr"){let t=[];for(let n of e.items){let s=Ur(n);s&&t.push(s)}return t.join(" ")||null}return e.t==="obj"&&e.entries.filter(n=>n.value.t==="bool"&&n.value.v).map(n=>n.key).join(" ")||null}function Bl(e,t){let n=t+1,s=[];for(;n<e.length;){if(n=W(e,n),e[n]===")")return{v:s.join(" ").replace(/\s+/g," ").trim()||null,end:n+1};if(e[n]===","){n++;continue}let r=te(e,n);if(!r)return null;let o=W(e,r.end);if(e[o]===","||e[o]===")"){let i=Ur(r.val);i&&s.push(i),n=r.end;continue}n=Fl(e,n)}return null}function te(e,t){if(t=W(e,t),t>=e.length)return null;let n=e[t];if(n==='"'||n==="'"||n==="`"){let r=kt(e,t);return r?{val:{t:"str",v:r.v,at:t},end:r.end}:null}if(n==="["){let r=t+1,o=[];for(;r<e.length;){if(r=W(e,r),e[r]==="]")return{val:{t:"arr",items:o,at:t},end:r+1};if(e[r]===","){r++;continue}let i=te(e,r);if(!i)return null;o.push(i.val),r=i.end}return null}if(n==="{"){let r=t+1,o=[];for(;r<e.length;){if(r=W(e,r),e[r]==="}")return{val:{t:"obj",entries:o,at:t},end:r+1};if(e[r]===","){r++;continue}if(e.slice(r,r+3)==="..."){let c=te(e,r+3);if(!c)return null;r=c.end;continue}let i="",a=r;if(e[r]==='"'||e[r]==="'"||e[r]==="`"){let c=kt(e,r);if(!c||c.v===null)return null;i=c.v,r=c.end}else if(/[\w$]/.test(e[r])){for(a=r;r<e.length&&/[\w$]/.test(e[r]);)r++;i=e.slice(a,r)}else return null;if(r=W(e,r),e[r]!==":"){e[r]==="("&&(r=An(e,r,"(",")"));continue}let l=te(e,r+1);if(!l)return null;o.push({key:i,at:a,value:l.val}),r=l.end}return null}let s=t;if(n==="."||n==="-"||/\d/.test(n)){let r=t+1;for(;r<e.length&&/[\d.]/.test(e[r]);)r++;let o=e.slice(t,r);if(/^-?\d+(?:\.\d+)?$/.test(o))return{val:{t:"num",v:Number(o),at:s},end:r};for(;r<e.length&&/[\w$.+-]/.test(e[r]);)r++;return{val:{t:"other",at:s},end:r}}if(/[\w$]/.test(n)){let r=t;for(;r<e.length&&/[\w$]/.test(e[r]);)r++;let o=e.slice(t,r),i=W(e,r);if(e[i]==="("){if(Tl.has(o)){let a=Bl(e,i);return a?{val:{t:"str",v:a.v,at:s},end:a.end}:null}return{val:{t:"other",at:s},end:An(e,i,"(",")")}}return o==="true"||o==="false"?{val:{t:"bool",v:o==="true",at:s},end:r}:{val:{t:"other",at:s},end:i}}return null}function vt(e){if(e.t==="str")return e.v;if(e.t==="arr"){let t=[];for(let n of e.items){if(n.t!=="str"||n.v===null)return null;t.push(n.v)}return t.join(" ")}return null}function zr(e){let t=[],n="",s=0;for(let r of e)r==="["?s++:r==="]"&&(s=Math.max(0,s-1)),/\s/.test(r)&&s===0?(n&&t.push(n),n=""):(!/\s/.test(r)||s>0)&&(n+=r);return n&&t.push(n),t}var Sn={sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"};function Vl(e,t,n,s){let r=Nl[e];if(r)return t.includes(r)||t.push(r),!0;if(e==="dark")return s.on=!0,!0;if(Sn[e])return n.min.push(Sn[e]),!0;let o=/^max-(sm|md|lg|xl|2xl)$/.exec(e);if(o)return n.below.push(Sn[o[1]]),!0;let i=/^min-\[([\d.]+(?:px|rem|em))\]$/.exec(e);if(i)return n.min.push(i[1]),!0;let a=/^max-\[([\d.]+(?:px|rem|em))\]$/.exec(e);return a?(n.max.push(a[1]),!0):!1}function Ul(e,t){let n=[];for(let s of e.min)n.push(`(min-width: ${s})`);for(let s of e.max)n.push(`(max-width: ${s})`);for(let s of e.below)n.push(`not all and (min-width: ${s})`);return t&&n.push("(prefers-color-scheme: dark)"),n.length?`@media ${n.join(" and ")}`:""}function Wr(e){let t=e.trim();if(!t)return null;let n=!1;t.startsWith("!")&&(n=!0,t=t.slice(1)),t.endsWith("!")&&(n=!0,t=t.slice(0,-1));let s=[],r="",o=0;for(let f of t)f==="["?o++:f==="]"&&(o=Math.max(0,o-1)),f===":"&&o===0?(s.push(r),r=""):r+=f;s.push(r);let i=s.pop()??"";if(!i)return null;let a=[],l={min:[],max:[],below:[]},c={on:!1};for(let f of s)if(!f||!Vl(f,a,l,c))return null;a.sort((f,m)=>H(f)-H(m));let p=/^[\w-]+$/.test(i)?i:null;return{token:e,state:be(a),context:Ul(l,c.on),utility:i,important:n,stem:p}}function Gr(e){let t=Vr(e.utility);return t?t.map(n=>({property:n.property,value:e.important?`${n.value} !important`:n.value,via:e.token})):[]}function zl(e){return e.some(t=>Ke(t.property)!=="hint")}function $t(e){let t=[];for(let n of e.matchAll(/@apply\s+([^;{}]+)/g))for(let s of zr(n[1])){let r=Wr(s);if(!r)continue;let o=Gr(r).filter(i=>se(i.property,i.value));o.length!==0&&t.push({state:r.state,context:r.context,declarations:o})}return t}function Hr(e){return e==="default"?"":e.split(" + ").map(t=>t==="hover"?":hover":t==="focus"?":focus":t==="active"?":active":t==="disabled"?":disabled":"").join("")}function In(e,t,n){let s=t.map(f=>`${f.property}:${f.value}`).join(";");if(!s)return[];let r=on(e),o=`${r}{${s}}`,i=n.split(" \xB7 ").map(f=>f.trim()).filter(f=>f&&!/^@layer\b/i.test(f));if(i.length===0)return[o];if(i.length!==1||!i[0].startsWith("@media"))return[];let a=i[0],l=[`${a}{${o}}`];if(!a.includes("prefers-color-scheme: dark"))return l;let c=a.replace(/^@media\s+/,"").split(/\s+and\s+/).filter(f=>!f.includes("prefers-color-scheme")).join(" and "),p=`html[data-theme="dark"] ${r}{${s}}`;return l.push(c?`@media ${c}{${p}}`:p),l}function Wl(e,t){let n=e.slice(Math.max(0,t-160),t);return/(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(?:await\s+)?$/.exec(n)?.[1]??null}function Gl(e){if(e.t!=="obj")return{};let t=e.entries.find(s=>s.key==="defaultVariants")?.value;if(!t||t.t!=="obj")return{};let n={};for(let s of t.entries)s.value.t==="str"&&s.value.v?n[s.key]=s.value.v:s.value.t==="bool"&&(n[s.key]=s.value.v?"true":"false");return n}function Hl(e,t,n,s,r){let o=te(e,t),i={slots:[],defaults:{}};if(!o)return i;let a=vt(o.val)??"",l=W(e,o.end);if(e[l]!==",")return a.trim()?{slots:[Rn(a,fe(e,t),r)],defaults:{}}:i;let c=te(e,l+1);if(!c||c.val.t!=="obj")return a.trim()?{slots:[Rn(a,fe(e,t),r)],defaults:{}}:i;let p=c.val.entries.find(h=>h.key==="variants")?.value,f=[],m=new Map;if(a.trim()&&f.push(Rn(a,fe(e,t),r)),p&&p.t==="obj"){for(let h of p.entries)if(h.value.t==="obj")for(let C of h.value.entries){let w=vt(C.value);if(!w||!w.trim()||C.key==="false")continue;m.set(`${h.key}\0${C.key}`,w);let v=C.key==="true"?`.${h.key}`:`.${h.key}-${C.key}`,d=Me({selector:v,path:s,base:!1},n.classKeywords);f.push({title:d.title,axis:C.key==="true"?h.key:d.axis??h.key,base:!1,classes:`${a} ${w}`.trim(),line:fe(e,C.at),group:r,prop:h.key,value:C.key})}}return f.push(...Kl(c.val,a,m,n,s,e,r)),{slots:f,defaults:Gl(c.val)}}function Kr(e){if(e.t==="str"&&e.v)return[e.v];if(e.t==="bool")return[e.v?"true":"false"];if(e.t==="arr"){let t=[];for(let n of e.items){let s=Kr(n);if(!s||s.length!==1)return null;t.push(s[0])}return t.length?t:null}return null}function Kl(e,t,n,s,r,o,i){let a=e.entries.find(c=>c.key==="compoundVariants")?.value;if(!a||a.t!=="arr")return[];let l=[];for(let c of a.items){if(c.t!=="obj")continue;let p=[],f="",m=c.at,h=!1;for(let w of c.entries){if(w.key==="class"||w.key==="className"){f=vt(w.value)??"",m=w.at,w.value.t!=="str"&&w.value.t!=="arr"&&f===""&&(h=!0);continue}let v=Kr(w.value);if(!v){h=!0;break}p.push({axis:w.key,values:v})}if(h)continue;let C=[[]];for(let w of p){let v=[];for(let d of C){for(let u of w.values)if(v.push([...d,{axis:w.axis,value:u}]),v.length>=8)break;if(v.length>=8)break}C=v}for(let w of C){if(w.length<2&&!f.trim())continue;let v=[t],d=[];for(let y of w){let k=n.get(`${y.axis}\0${y.value}`);k&&v.push(k),d.push(y.value==="true"?y.axis:y.value)}f.trim()&&v.push(f);let u=v.join(" ").replace(/\s+/g," ").trim();if(!u)continue;let g=Me({selector:`.${d.join("-")}`,path:r,base:!1},s.classKeywords);l.push({title:g.title,axis:g.axis,base:!1,classes:u,line:fe(o,m),group:i,when:w.map(y=>({prop:y.axis,value:y.value}))})}}return l}function Rn(e,t,n){return{title:"Base",axis:null,base:!0,classes:e,line:t,group:n}}function Jr(e,t){return t.elements.includes(e.toLowerCase())?!0:t.identifier.test(e)}function Jl(e){let t=e.match(/\bclassName\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*"([^"]*)"\s*\}|\{\s*'([^']*)'\s*\})/);return t?.[1]??t?.[2]??t?.[3]??t?.[4]??null}var Zl=new Set(["opacity","z-index","font-weight","line-height","flex","flex-grow","flex-shrink","order","zoom"]);function Xl(e){return e.replace(/^[A-Z]/,t=>`-${t.toLowerCase()}`).replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function ql(e,t){return t.t==="str"?t.v:t.t==="num"?Zl.has(e)?String(t.v):`${t.v}px`:null}function Ct(e,t){if(e.t!=="obj")return[];let n=[],s=[];for(let o of e.entries){if(o.value.t==="obj"){let l=o.key.replace(/^&/,""),c=l===":hover"?"hover":l===":focus"||l===":focus-visible"?"focus":l===":active"?"active":l===":disabled"?"disabled":null;c&&s.push(...Ct(o.value,c));continue}let i=Xl(o.key),a=ql(i,o.value);!a||!se(i,a)||n.push({property:i,value:a,via:"style"})}return[...n.length?[{state:t,context:"",declarations:n}]:[],...s]}function _n(e,t){if(e[t]!=="`")return null;let n="";for(let s=t+1;s<e.length;s++){let r=e[s];if(r==="\\"){let o=e[s+1];if(o===void 0)return null;n+=o==="n"?`
51
+ `:o,s++;continue}if(r==="$"&&e[s+1]==="{"){let o=1;for(s+=2;s<e.length&&o>0;s++)e[s]==="{"?o++:e[s]==="}"&&o--;s--,n+=" ";continue}if(r==="`")return{css:n,end:s+1};n+=r}return null}function Yl(e,t){if(e==="default")return t;if(t==="default")return e;let n=[...new Set([...e.split(" + "),...t.split(" + ")])];return n.sort((s,r)=>H(s)-H(r)||s.localeCompare(r)),be(n)}function En(e){let t=[];for(let n of we(`.__gs {
52
52
  ${e}
53
- }`)){let s=q(n.selector),r=s?.[s.length-1];if(!r)continue;let o=ft(r.simples),i=he(o.states),a=ue(n.ownBody).filter(l=>ne(l.property,l.value));a.length&&t.push({state:i,context:n.context,declarations:a});for(let l of $t(n.ownBody))t.push({state:Jl(i,l.state),context:[n.context,l.context].filter(Boolean).join(" \xB7 "),declarations:l.declarations})}return t}function Zl(e){let t=e.match(/\bstyle\s*=\s*"([^"]*)"/);if(t){let i=ue(t[1]).filter(a=>ne(a.property,a.value));return i.length?[{state:"default",context:"",declarations:i}]:[]}let n=e.search(/\bstyle\s*=\s*\{/);if(n<0)return[];let s=e.indexOf("{",n),r=W(e,s+1);e[r]==="{"&&(s=r);let o=ee(e,s);return o?Ct(o.val,"default"):[]}function Xl(e){let t=Wl(e);if(t)return{classes:t,painted:[]};let n=e.search(/\bclassName\s*=\s*\{/);if(n<0)return{classes:"",painted:[]};let s=e.indexOf("{",n),r=W(e,s+1);if(e.startsWith("css",r)&&!/[\w$]/.test(e[r+3]??"")){let i=W(e,r+3);if(e[i]==="`"){let a=Cn(e,i);return{classes:"",painted:a?Sn(a.css):[]}}if(e[i]==="("){let a=ee(e,i+1);return{classes:"",painted:a?Ct(a.val,"default"):[]}}}let o=ee(e,r);return o?{classes:vt(o.val)??"",painted:[]}:{classes:"",painted:[]}}function ql(e,t){if(t.identifier.test(e))return!0;let n=e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);return t.classKeywords.some(s=>n.includes(s.toLowerCase()))}function Yl(e,t){let n=[],s=/(?:^|[^\w$])styled(?:\.([A-Za-z][\w]*)|\(\s*(?:["']([A-Za-z][\w]*)["']|([A-Za-z][\w]*))\s*\))/g;for(let o of e.matchAll(s)){let i=o[1]??o[2]??o[3]??"";if(!Wr(i,t))continue;let a=W(e,(o.index??0)+o[0].length);e.startsWith(".attrs",a)&&(a=W(e,a+6),e[a]==="("&&(a=$n(e,a,"(",")")),a=W(e,a));let l=[];if(e[a]==="`"){let c=Cn(e,a);c&&(l=Sn(c.css))}else if(e[a]==="("){let c=ee(e,a+1);c&&(l=Ct(c.val,"default"))}l.length!==0&&n.push({title:"Styled",axis:null,base:!0,classes:"",line:pe(e,o.index??0),painted:l})}let r=/(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*css\s*`/g;for(let o of e.matchAll(r)){let i=o[1]??"";if(!ql(i,t))continue;let a=e.indexOf("`",o.index??0),l=a<0?null:Cn(e,a);if(!l)continue;let c=Sn(l.css);c.length!==0&&n.push({title:"Css",axis:null,base:!0,classes:"",line:pe(e,o.index??0),painted:c})}return n}function Ql(e,t){if(t==="default")return`.${e}`;let n=`.${e}`;for(let s of t.split(" + "))s==="hover"?n+=":hover":s==="focus"?n+=":focus":s==="active"?n+=":active":s==="disabled"&&(n+=":disabled");return n}function ec(e,t,n,s,r){let o=Vr(e.classes).map(Br).filter(d=>d!==null),i=o.filter(d=>d.stem===null||!s.has(d.stem)),a=(e.painted??[]).filter(d=>d.declarations.length>0);if(i.length===0&&a.length===0)return null;let l=new Map,c=(d,y,v)=>{if(v.length===0)return;let x=`${d}\0${y}`,C=l.get(x)??{state:d,context:y,declarations:[]};C.declarations.push(...v),l.set(x,C)},u=[r];for(let d of o){let y=Fr(d).filter(v=>ne(v.property,v.value));c(d.state,d.context,y),d.state==="default"&&d.context===""&&d.stem&&u.push(d.stem)}for(let d of a)c(d.state,d.context,d.declarations);let f=[...l.values()].flatMap(d=>d.declarations);if(!Vl(f))return null;let m=l.get("default\0")?.declarations??[];if(gt(m))return null;let h=[...l.values()].map(d=>({state:d.state,context:d.context,line:e.line,declarations:d.declarations})).sort((d,y)=>d.state!==y.state?d.state==="default"?-1:y.state==="default"?1:H(d.state.split(" + ")[0])-H(y.state.split(" + ")[0])||d.state.localeCompare(y.state):d.context===""?-1:y.context===""?1:d.context.localeCompare(y.context)),$=[...new Set(o.map(d=>d.stem).filter(d=>d!==null))],k=$.length?$.map(d=>`.${d}`).join(""):n.elements[0]??"button",w=h.flatMap(d=>Rn(Ql(r,d.state),d.declarations,d.context)),g=n.elements[0]??"button";return{variant:{title:e.title,axis:e.axis,element:{tag:g,classes:u,attrs:{},ancestors:[]},usage:{status:"unknown",files:[],fileCount:0},selector:k,path:t,line:e.line,base:e.base,states:h},rules:w}}function Gr(e,t,n,s,r){let o=Ol(t),i=[],a=[],l=/(?:^|[^\w$])(cva|tv)\s*\(/g;for(let p of o.matchAll(l)){let d=(p.index??0)+Math.max(0,p[0].indexOf(p[1])),y=(p.index??0)+p[0].length,v=a.length,x=Ul(o,y,n,e,v);a.push({name:Bl(o,d),defaults:x.defaults}),i.push(...x.slots)}i.push(...Yl(o,n));let c=/<([A-Za-z][\w.]*)\b([^>]*?)>/g;for(let p of o.matchAll(c)){let d=p[1];if(!Wr(d,n))continue;let y=p[2]??"",v=Xl(y),x=[...v.painted,...Zl(y)],C=v.classes.trim();if(!C&&x.length===0)continue;let j=p.index??0,I=pe(o,j);i.push({title:C?"Base":v.painted.length?"Css":"Inline",axis:null,base:!0,classes:C,line:I,painted:x,...C&&x.length===0?{site:{path:e,line:I,offset:j}}:{}})}let u=[],f=[],m=new Map,h=[],$=new Map,k=new Map,w=r;for(let p=0;p<i.length;p++){let d=i[p];if(u.length+f.length>=jl)break;let y=(d.painted??[]).map(I=>`${I.state}|${I.context}|${I.declarations.map(A=>`${A.property}:${A.value}`).join(";")}`).join("||"),v=`${d.classes.replace(/\s+/g," ").trim()}##${y}`,x=$.get(v);if(x){d.group!==void 0&&k.set(p,x),d.site&&m.get(x)?.sites.push(d.site);continue}w+=1;let C=`__gs-recipe-${w}`,j=ec(d,e,n,s,C);if(j){if($.set(v,C),d.group!==void 0&&k.set(p,C),d.site){let I={variant:j.variant,sites:[d.site]};m.set(C,I),f.push(I)}else u.push(j.variant);h.push(...j.rules)}}let g=[];for(let p=0;p<a.length;p++){let d=a[p],y={path:e,name:d.name,staticClasses:[],axes:[],compounds:[]},v=new Map;for(let x=0;x<i.length;x++){let C=i[x];if(C.group!==p)continue;let j=k.get(x);if(!j)continue;if(!C.prop&&!C.when){y.staticClasses.push(j);continue}if(C.when){y.compounds.push({when:C.when,classes:[j]});continue}let I=v.get(C.prop)??[];I.push({value:C.value,classes:[j]}),v.set(C.prop,I)}for(let[x,C]of v)y.axes.push({prop:x,values:C,...d.defaults[x]?{defaultValue:d.defaults[x]}:{}});(y.staticClasses.length||y.axes.length||y.compounds.length)&&g.push(y)}return{variants:u,inline:f,previewRules:h,nextId:w,recipes:g}}function Hr(e,t){let s=(e.split("/").pop()??"").replace(/(\.module)?\.[^.]+$/i,"").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);return t.some(r=>{let o=r.toLowerCase();return s.includes(o)||s.includes(`${o}s`)})}var An=6,tc=/"([^"\\\n]{0,400})"|'([^'\\\n]{0,400})'|`([^`\\]{0,400})`/g,nc=/\bclass(?:Name)?\s*=\s*(?:"([^"]*)"|'([^']*)')/g,sc=/\b(?:styles?|classes|css|cls|s)\.([A-Za-z_]\w*)/g,Xe=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function rc(e){let t=n=>n.replace(/[^\n]/g," ");return e.replace(/\/\*[\s\S]*?\*\//g,t).replace(/<!--[\s\S]*?-->/g,t).replace(/(^|\s)\/\/[^\n]*/g,(n,s)=>s+t(n.slice(s.length)))}function oc(e,t){let n=rc(t),s=new Map,r=new Map,o=(a,l,c)=>{let u=a.get(l);u?u.push(c):a.set(l,[c])},i=(a,l)=>{for(let c of a.matchAll(/[\w-]+/g))o(s,c[0],l)};for(let a of n.matchAll(tc))i(a[1]??a[2]??a[3]??"",a.index);for(let a of n.matchAll(nc))i(a[1]??a[2]??"",a.index);for(let a of n.matchAll(sc))o(r,a[1],a.index);return{path:e,text:n,original:t,words:s,ids:r}}function Kr(e,t){let n=1;for(let s=e.indexOf(`
53
+ }`)){let s=Y(n.selector),r=s?.[s.length-1];if(!r)continue;let o=ft(r.simples),i=be(o.states),a=pe(n.ownBody).filter(l=>se(l.property,l.value));a.length&&t.push({state:i,context:n.context,declarations:a});for(let l of $t(n.ownBody))t.push({state:Yl(i,l.state),context:[n.context,l.context].filter(Boolean).join(" \xB7 "),declarations:l.declarations})}return t}function Ql(e){let t=e.match(/\bstyle\s*=\s*"([^"]*)"/);if(t){let i=pe(t[1]).filter(a=>se(a.property,a.value));return i.length?[{state:"default",context:"",declarations:i}]:[]}let n=e.search(/\bstyle\s*=\s*\{/);if(n<0)return[];let s=e.indexOf("{",n),r=W(e,s+1);e[r]==="{"&&(s=r);let o=te(e,s);return o?Ct(o.val,"default"):[]}function ec(e){let t=Jl(e);if(t)return{classes:t,painted:[]};let n=e.search(/\bclassName\s*=\s*\{/);if(n<0)return{classes:"",painted:[]};let s=e.indexOf("{",n),r=W(e,s+1);if(e.startsWith("css",r)&&!/[\w$]/.test(e[r+3]??"")){let i=W(e,r+3);if(e[i]==="`"){let a=_n(e,i);return{classes:"",painted:a?En(a.css):[]}}if(e[i]==="("){let a=te(e,i+1);return{classes:"",painted:a?Ct(a.val,"default"):[]}}}let o=te(e,r);return o?{classes:vt(o.val)??"",painted:[]}:{classes:"",painted:[]}}function tc(e,t){if(t.identifier.test(e))return!0;let n=e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);return t.classKeywords.some(s=>n.includes(s.toLowerCase()))}function nc(e,t){let n=[],s=/(?:^|[^\w$])styled(?:\.([A-Za-z][\w]*)|\(\s*(?:["']([A-Za-z][\w]*)["']|([A-Za-z][\w]*))\s*\))/g;for(let o of e.matchAll(s)){let i=o[1]??o[2]??o[3]??"";if(!Jr(i,t))continue;let a=W(e,(o.index??0)+o[0].length);e.startsWith(".attrs",a)&&(a=W(e,a+6),e[a]==="("&&(a=An(e,a,"(",")")),a=W(e,a));let l=[];if(e[a]==="`"){let c=_n(e,a);c&&(l=En(c.css))}else if(e[a]==="("){let c=te(e,a+1);c&&(l=Ct(c.val,"default"))}l.length!==0&&n.push({title:"Styled",axis:null,base:!0,classes:"",line:fe(e,o.index??0),painted:l})}let r=/(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*css\s*`/g;for(let o of e.matchAll(r)){let i=o[1]??"";if(!tc(i,t))continue;let a=e.indexOf("`",o.index??0),l=a<0?null:_n(e,a);if(!l)continue;let c=En(l.css);c.length!==0&&n.push({title:"Css",axis:null,base:!0,classes:"",line:fe(e,o.index??0),painted:c})}return n}function sc(e,t){if(t==="default")return`.${e}`;let n=`.${e}`;for(let s of t.split(" + "))s==="hover"?n+=":hover":s==="focus"?n+=":focus":s==="active"?n+=":active":s==="disabled"&&(n+=":disabled");return n}function rc(e,t,n,s,r){let o=zr(e.classes).map(Wr).filter(g=>g!==null),i=o.filter(g=>g.stem===null||!s.has(g.stem)),a=(e.painted??[]).filter(g=>g.declarations.length>0);if(i.length===0&&a.length===0)return null;let l=new Map,c=(g,y,k)=>{if(k.length===0)return;let x=`${g}\0${y}`,$=l.get(x)??{state:g,context:y,declarations:[]};$.declarations.push(...k),l.set(x,$)},p=[r];for(let g of o){let y=Gr(g).filter(k=>se(k.property,k.value));c(g.state,g.context,y),g.state==="default"&&g.context===""&&g.stem&&p.push(g.stem)}for(let g of a)c(g.state,g.context,g.declarations);let f=[...l.values()].flatMap(g=>g.declarations);if(!zl(f))return null;let m=l.get("default\0")?.declarations??[];if(gt(m))return null;let h=[...l.values()].map(g=>({state:g.state,context:g.context,line:e.line,declarations:g.declarations})).sort((g,y)=>g.state!==y.state?g.state==="default"?-1:y.state==="default"?1:H(g.state.split(" + ")[0])-H(y.state.split(" + ")[0])||g.state.localeCompare(y.state):g.context===""?-1:y.context===""?1:g.context.localeCompare(y.context)),C=[...new Set(o.map(g=>g.stem).filter(g=>g!==null))],w=C.length?C.map(g=>`.${g}`).join(""):n.elements[0]??"button",v=h.flatMap(g=>In(sc(r,g.state),g.declarations,g.context)),d=n.elements[0]??"button";return{variant:{title:e.title,axis:e.axis,element:{tag:d,classes:p,attrs:{},ancestors:[]},usage:{status:"unknown",files:[],fileCount:0},selector:w,path:t,line:e.line,base:e.base,states:h},rules:v}}function Zr(e,t,n,s,r){let o=Dl(t),i=[],a=[],l=/(?:^|[^\w$])(cva|tv)\s*\(/g;for(let u of o.matchAll(l)){let g=(u.index??0)+Math.max(0,u[0].indexOf(u[1])),y=(u.index??0)+u[0].length,k=a.length,x=Hl(o,y,n,e,k);a.push({name:Wl(o,g),defaults:x.defaults}),i.push(...x.slots)}i.push(...nc(o,n));let c=/<([A-Za-z][\w.]*)\b([^>]*?)>/g;for(let u of o.matchAll(c)){let g=u[1];if(!Jr(g,n))continue;let y=u[2]??"",k=ec(y),x=[...k.painted,...Ql(y)],$=k.classes.trim();if(!$&&x.length===0)continue;let j=u.index??0,I=fe(o,j);i.push({title:$?"Base":k.painted.length?"Css":"Inline",axis:null,base:!0,classes:$,line:I,painted:x,...$&&x.length===0?{site:{path:e,line:I,offset:j}}:{}})}let p=[],f=[],m=new Map,h=[],C=new Map,w=new Map,v=r;for(let u=0;u<i.length;u++){let g=i[u];if(p.length+f.length>=Ml)break;let y=(g.painted??[]).map(I=>`${I.state}|${I.context}|${I.declarations.map(A=>`${A.property}:${A.value}`).join(";")}`).join("||"),k=`${g.classes.replace(/\s+/g," ").trim()}##${y}`,x=C.get(k);if(x){g.group!==void 0&&w.set(u,x),g.site&&m.get(x)?.sites.push(g.site);continue}v+=1;let $=`__gs-recipe-${v}`,j=rc(g,e,n,s,$);if(j){if(C.set(k,$),g.group!==void 0&&w.set(u,$),g.site){let I={variant:j.variant,sites:[g.site]};m.set($,I),f.push(I)}else p.push(j.variant);h.push(...j.rules)}}let d=[];for(let u=0;u<a.length;u++){let g=a[u],y={path:e,name:g.name,staticClasses:[],axes:[],compounds:[]},k=new Map;for(let x=0;x<i.length;x++){let $=i[x];if($.group!==u)continue;let j=w.get(x);if(!j)continue;if(!$.prop&&!$.when){y.staticClasses.push(j);continue}if($.when){y.compounds.push({when:$.when,classes:[j]});continue}let I=k.get($.prop)??[];I.push({value:$.value,classes:[j]}),k.set($.prop,I)}for(let[x,$]of k)y.axes.push({prop:x,values:$,...g.defaults[x]?{defaultValue:g.defaults[x]}:{}});(y.staticClasses.length||y.axes.length||y.compounds.length)&&d.push(y)}return{variants:p,inline:f,previewRules:h,nextId:v,recipes:d}}function Xr(e,t){let s=(e.split("/").pop()??"").replace(/(\.module)?\.[^.]+$/i,"").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);return t.some(r=>{let o=r.toLowerCase();return s.includes(o)||s.includes(`${o}s`)})}var jn=6,oc=/"([^"\\\n]{0,400})"|'([^'\\\n]{0,400})'|`([^`\\]{0,400})`/g,ic=/\bclass(?:Name)?\s*=\s*(?:"([^"]*)"|'([^']*)')/g,ac=/\b(?:styles?|classes|css|cls|s)\.([A-Za-z_]\w*)/g,Ze=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function lc(e){let t=n=>n.replace(/[^\n]/g," ");return e.replace(/\/\*[\s\S]*?\*\//g,t).replace(/<!--[\s\S]*?-->/g,t).replace(/(^|\s)\/\/[^\n]*/g,(n,s)=>s+t(n.slice(s.length)))}function cc(e,t){let n=lc(t),s=new Map,r=new Map,o=(a,l,c)=>{let p=a.get(l);p?p.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(oc))i(a[1]??a[2]??a[3]??"",a.index);for(let a of n.matchAll(ic))i(a[1]??a[2]??"",a.index);for(let a of n.matchAll(ac))o(r,a[1],a.index);return{path:e,text:n,original:t,words:s,ids:r}}function qr(e,t){let n=1;for(let s=e.indexOf(`
54
54
  `);s!==-1&&s<t;)n++,s=e.indexOf(`
55
- `,s+1);return n}var ic=e=>e.replace(/[-_]+(\w)/g,(t,n)=>n.toUpperCase()),ac=/\[\s*([\w-]+)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*\]/g,lc=new Set(["data-component","data-slot","role"]);function cc(e,t){return[...e.slice(be(e)).matchAll(ac)].map(s=>({name:s[1],value:s[2]??s[3]??s[4]??null})).filter(s=>!lc.has(s.name)&&!(s.value!==null&&t.has(s.value.toLowerCase())))}function uc(e){return[...e.slice(be(e)).matchAll(/\.((?:\\.|[\w-])+)/g)].map(n=>n[1].replace(/\\(.)/g,"$1"))}function _n(e,t,n,s,r=!1,o=[],i=()=>null){let a=null,l=()=>a??=t.map(g=>oc(g,e.get(g)??"")),c=new Map,u=g=>{let p=c.get(g);if(!p){let d=new RegExp(`["'\`]${Xe(g)}["'\`]\\s*\\+`);p=l().filter(y=>y.text.includes(`${g}\${`)||d.test(y.text)),c.set(g,p)}return p},f=(g,p,d)=>kr(pn(g.original,p,d,g.path),g.original,p,g.path,o,i),m=(g,p)=>({files:g.slice(0,An).map(({file:d,offset:y,example:v})=>({path:d.path,line:Kr(d.text,y),...r?{example:v??f(d,y,p)}:{}})),fileCount:g.length}),h=(g,p)=>{let d=[],y=ic(g);for(let v of l()){let x=[...s.has(g)?[]:v.words.get(g)??[],...v.ids.get(y)??v.ids.get(g)??[]],C=x[0];if(C===void 0)continue;let j=C,I;if(r)for(let A of x){let R=f(v,A,p);if(R.kind!=="other"){j=A,I=R;break}}d.push({file:v,offset:j,example:I})}if(d.length)return{status:"used",...m(d,p)};for(let v=g.length-1;v>0;v--){if(g[v]!=="-"&&g[v]!=="_")continue;let x=g.slice(0,v+1),C=g.slice(v+1),j=u(x);if(j.length===0||!C)continue;let I=x.slice(0,-1),A=new RegExp(`\\b${Xe(I)}\\s*[=:]\\s*\\{?\\s*["'\`]${Xe(C)}["'\`]`),R=[];for(let P of l()){let T=A.exec(P.text);T&&R.push({file:P,offset:T.index})}return R.length?{status:"used",via:`via ${I} prop`,...m(R,p)}:{status:"dynamic",via:`built as ${x}\${\u2026}`,...m(j.map(P=>({file:P,offset:0})),p)}}return{status:"unreferenced",files:[],fileCount:0}},$=(g,p)=>{let d=Xe(g.name),y=g.value===null?new RegExp(`\\b${d}\\b`):new RegExp(`\\b${d}\\s*[=:]\\s*\\{?\\s*["'\`]${Xe(g.value)}["'\`]`),v=[];for(let j of l()){let I=y.exec(j.text);I&&v.push({file:j,offset:I.index})}if(v.length)return{status:"used",via:`via ${g.name} attribute`,...m(v,p)};let x=new RegExp(`\\b${d}\\s*=\\s*\\{(?!\\s*["'\`])`),C=[];for(let j of l()){let I=x.exec(j.text);I&&C.push({file:j,offset:I.index})}return C.length?{status:"dynamic",via:`${g.name} is set from a variable`,...m(C,p)}:{status:"unreferenced",files:[],fileCount:0}},k=new Map;if(r&&o.length>0)for(let g of l())for(let p of wt(g.path,g.text,o,i))for(let d of p.selects){let y=k.get(d)??[];y.push({file:g,offset:p.offset}),k.set(d,y)}let w={used:0,unknown:0,dynamic:1,unreferenced:2};for(let g of n){let p=uc(g.selector),d=cc(g.selector,s);if(p.length===0&&d.length===0){g.usage={status:"unknown",files:[],fileCount:0};continue}let y=[...p.map(A=>h(A,p)),...d.map(A=>$(A,p))];g.usage=y.reduce((A,R)=>w[R.status]>=w[A.status]?R:A);let v=g.element?.classes.find(A=>A.startsWith("__gs-recipe-")),x=v?k.get(v):void 0;if(!x||x.length===0)continue;let C=new Set(g.usage.files.map(A=>A.path)),j=g.usage.fileCount,I=[...g.usage.files];for(let A of x)C.has(A.file.path)||(C.add(A.file.path),j+=1,!(I.length>=An)&&I.push({path:A.file.path,line:Kr(A.file.text,A.offset),...r?{example:f(A.file,A.offset,[])}:{}}));g.usage={...g.usage,status:g.usage.status==="unknown"?"unknown":"used",files:I,fileCount:j}}}function Jr(e,t,n){let s=[],r=new Set;for(let o of t)r.has(o.path)||(r.add(o.path),!(s.length>=An)&&s.push({path:o.path,line:o.line,...n?{example:pn(e.get(o.path)??"",o.offset,[],o.path)}:{}}));return{status:"used",files:s,fileCount:r.size}}var pc={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},eo={button:pc},to=12,In=200,we=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro)$/i,Zr=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro|html?|mdx|erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,qe=/\.(css|scss|sass|less|styl)$/i,Xr=/\.(mdx?|markdown|txt|rst|adoc)$/i,qr=/(^|\/)(tokens?|design-tokens?|theme)[^/]*\.json$/i,Z=/(^|\/)(__tests__|tests?|spec|e2e|cypress|playwright)(\/|$)|\.(test|spec)\.[a-z]+$/i,fc=/(^|\/)(plans?|results?|changelogs?|history|archive)(\/|\.|$)|(^|\/)CHANGELOG/i;function dc(e){return St.test(e)&&!/(^|\/)README\.md$/i.test(e)?"instruction":fc.test(e)?"record":"documentation"}var St=/(^|\/)(AGENTS|CLAUDE|CONTRIBUTING|README|GUIDELINES?)\.md$|(^|\/)(eslint|stylelint|\.eslintrc|\.stylelintrc)[^/]*$|(^|\/)\.cursor\/|(^|\/)\.claude\//i;function fe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function gc(e){return(e.split("/").pop()??"").replace(/(\.module)?\.[^.]+$/i,"")}function Yr(e,t){let n=gc(e).toLowerCase();return t.some(s=>{let r=s.toLowerCase();return n===r||n===`${r}s`})}function mc(e,t){let n=1;for(let s=0;s<t;s++)e.charCodeAt(s)===10&&n++;return n}function de(e,t){let n=e.split(`
56
- `),s=0,r=[];for(let o=0;o<n.length;o++){let i=n[o];if(t.lastIndex=0,!!t.test(i)&&(s++,r.length<to)){let a=i.trim();r.push({line:o+1,text:a.length>In?`${a.slice(0,In)}\u2026`:a})}}return{count:s,lines:r}}function no(e){let t=e.lastIndexOf("/");return t<0?"":e.slice(0,t)}function so(e){let t=[];for(let n of e.split("/"))!n||n==="."||(n===".."?t.pop():t.push(n));return t.join("/")}var hc=["",".tsx",".ts",".jsx",".js",".mjs",".vue",".svelte",".css",".module.css",".scss","/index.tsx","/index.ts","/index.js"];function ke(e,t,n){let s;if(t.startsWith("."))s=so(`${no(e)}/${t}`);else if(t.startsWith("@/"))s=t.slice(2);else if(t.startsWith("~/"))s=t.slice(2);else if(t.startsWith("/"))s=t.slice(1);else return null;for(let r of hc)if(n(s+r))return s+r;return null}var bc=/import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]|require\(\s*['"]([^'"]+)['"]\s*\)|@import\s+(?:url\()?['"]([^'"]+)['"]/g;function En(e){let t=[];for(let n of e.matchAll(bc)){let s=n[1]??n[2]??n[3];s&&t.push(s)}return t}var yc=/export\s+(?:default\s+)?(?:async\s+)?(?:function|const|let|class|var)\s+([A-Za-z_$][\w$]*)|export\s*\{([^}]*)\}/g;function Qr(e){let t=new Set;for(let n of e.matchAll(yc))if(n[1]&&t.add(n[1]),n[2])for(let s of n[2].split(",")){let r=s.trim().split(/\s+as\s+/).pop()?.trim();r&&t.add(r)}return[...t]}var jn=/var\(\s*(--[\w-]+)/g;function Rt(e){return e.split(" \xB7 ").every(t=>t===""||/^@layer\b/i.test(t))}function ro(e){let t=[];for(let n of e.matchAll(/(?:^|[;{}])\s*composes\s*:\s*([^;]+)/g)){let s=n[1].trim(),r=/^(.*?)\s+from\s+(['"]?)([^'"]+)\2\s*$/.exec(s);r?t.push({names:r[1].split(/\s+/).filter(Boolean),from:r[3]}):t.push({names:s.split(/\s+/).filter(Boolean),from:null})}return t}function xc(e,t,n){let s=t.startsWith(".")?so(`${no(e)}/${t}`):t.startsWith("@/")?t.slice(2):t.startsWith("~/")||t.startsWith("/")?t.replace(/^~?\//,""):null;return s&&n(s)?s:ke(e,t.replace(/\.(?:module\.)?(?:css|scss|sass|less)$/i,""),n)}function wc(e){let t=new Map;for(let[n,s]of e)if(qe.test(n)){for(let r of xe(s))if(Rt(r.context))for(let o of z(r.selector)){let i=/^\.([\w-]+)$/.exec(o.trim())?.[1];if(!i)continue;let a=`${n}\0${i}`,l=t.get(a)??{decls:[],composes:[]};l.decls.push(...ue(r.ownBody));for(let c of $t(r.ownBody))c.state==="default"&&c.context===""&&l.decls.push(...c.declarations);l.composes.push(...ro(r.ownBody)),t.set(a,l)}}return t}function kc(e,t,n,s){let r=[],o=new Set,i=(l,c,u)=>{if(u>4)return;let f=`${l}\0${c}`;if(o.has(f))return;o.add(f);let m=n.get(f);if(m){for(let h of m.composes)a(l,h,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 h=m.indexOf("\0"),$=m.slice(0,h);m.slice(h+1)!==f||/\.module\./i.test($)||i($,f,u)}else if(c.from){let m=xc(l,c.from,s);m&&i(m,f,u)}else i(l,f,u)};for(let l of ro(t))a(e,l,0);return r}function vc(e,t){let n=Ur(t);return n?z(e).map(s=>{let r=Math.max(s.lastIndexOf(" "),s.lastIndexOf(">"),s.lastIndexOf("+"),s.lastIndexOf("~"));return r<0?`${s}${n}`:`${s.slice(0,r+1)}${s.slice(r+1)}${n}`}).join(", "):e}var $c=/^(?::root|html|body|\*)$/i,Cc=25e4,Sc=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,Rc=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,Ac=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]);function _c(e){let t=new Set,n=new Set;for(let s of e.matchAll(Sc)){let r=s[1],o=Ac.has(r.toLowerCase())&&r===r.toLowerCase()?t:n;for(let i of s[2].matchAll(Rc))o.add(i[1]??i[2])}return{parts:new Set([...t].filter(s=>!n.has(s))),controls:n}}function Ec(e,t){let n=new Map;for(let s of t)if(qe.test(s)){for(let r of xe(e.get(s)))if(Rt(r.context)&&z(r.selector).some(o=>$c.test(o)))for(let o of ue(r.ownBody))o.property.startsWith("--")&&!n.has(o.property)&&n.set(o.property,o.value)}return n}function Ic(e,t){let n=new Set,s=[],r=a=>{for(let l of a.matchAll(jn))n.has(l[1])||(n.add(l[1]),s.push(l[1]))};for(let a of t)r(a);let o=[];for(let a=s.shift();a;a=s.shift()){let l=e.get(a);l===void 0||!ne(a,l)||(o.push(`${a}:${l}`),r(l))}return`${o.length?`:root{${o.join(";")}}
55
+ `,s+1);return n}var uc=e=>e.replace(/[-_]+(\w)/g,(t,n)=>n.toUpperCase()),pc=/\[\s*([\w-]+)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*\]/g,fc=new Set(["data-component","data-slot","role"]);function dc(e,t){return[...e.slice(ye(e)).matchAll(pc)].map(s=>({name:s[1],value:s[2]??s[3]??s[4]??null})).filter(s=>!fc.has(s.name)&&!(s.value!==null&&t.has(s.value.toLowerCase())))}function gc(e){return[...e.slice(ye(e)).matchAll(/\.((?:\\.|[\w-])+)/g)].map(n=>n[1].replace(/\\(.)/g,"$1"))}function Pn(e,t,n,s,r=!1,o=[],i=()=>null){let a=null,l=()=>a??=t.map(d=>cc(d,e.get(d)??"")),c=new Map,p=d=>{let u=c.get(d);if(!u){let g=new RegExp(`["'\`]${Ze(d)}["'\`]\\s*\\+`);u=l().filter(y=>y.text.includes(`${d}\${`)||g.test(y.text)),c.set(d,u)}return u},f=(d,u,g)=>Sr(mn(d.original,u,g,d.path),d.original,u,d.path,o,i),m=(d,u)=>({files:d.slice(0,jn).map(({file:g,offset:y,example:k})=>({path:g.path,line:qr(g.text,y),...r?{example:k??f(g,y,u)}:{}})),fileCount:d.length}),h=(d,u)=>{let g=[],y=uc(d);for(let k of l()){let x=[...s.has(d)?[]:k.words.get(d)??[],...k.ids.get(y)??k.ids.get(d)??[]],$=x[0];if($===void 0)continue;let j=$,I;if(r)for(let A of x){let R=f(k,A,u);if(R.kind!=="other"){j=A,I=R;break}}g.push({file:k,offset:j,example:I})}if(g.length)return{status:"used",...m(g,u)};for(let k=d.length-1;k>0;k--){if(d[k]!=="-"&&d[k]!=="_")continue;let x=d.slice(0,k+1),$=d.slice(k+1),j=p(x);if(j.length===0||!$)continue;let I=x.slice(0,-1),A=new RegExp(`\\b${Ze(I)}\\s*[=:]\\s*\\{?\\s*["'\`]${Ze($)}["'\`]`),R=[];for(let P of l()){let D=A.exec(P.text);D&&R.push({file:P,offset:D.index})}return R.length?{status:"used",via:`via ${I} prop`,...m(R,u)}:{status:"dynamic",via:`built as ${x}\${\u2026}`,...m(j.map(P=>({file:P,offset:0})),u)}}return{status:"unreferenced",files:[],fileCount:0}},C=(d,u)=>{let g=Ze(d.name),y=d.value===null?new RegExp(`\\b${g}\\b`):new RegExp(`\\b${g}\\s*[=:]\\s*\\{?\\s*["'\`]${Ze(d.value)}["'\`]`),k=[];for(let j of l()){let I=y.exec(j.text);I&&k.push({file:j,offset:I.index})}if(k.length)return{status:"used",via:`via ${d.name} attribute`,...m(k,u)};let x=new RegExp(`\\b${g}\\s*=\\s*\\{(?!\\s*["'\`])`),$=[];for(let j of l()){let I=x.exec(j.text);I&&$.push({file:j,offset:I.index})}return $.length?{status:"dynamic",via:`${d.name} is set from a variable`,...m($,u)}:{status:"unreferenced",files:[],fileCount:0}},w=new Map;if(r&&o.length>0)for(let d of l())for(let u of wt(d.path,d.text,o,i))for(let g of u.selects){let y=w.get(g)??[];y.push({file:d,offset:u.offset}),w.set(g,y)}let v={used:0,unknown:0,dynamic:1,unreferenced:2};for(let d of n){let u=gc(d.selector),g=dc(d.selector,s);if(u.length===0&&g.length===0){d.usage={status:"unknown",files:[],fileCount:0};continue}let y=[...u.map(A=>h(A,u)),...g.map(A=>C(A,u))];d.usage=y.reduce((A,R)=>v[R.status]>=v[A.status]?R:A);let k=d.element?.classes.find(A=>A.startsWith("__gs-recipe-")),x=k?w.get(k):void 0;if(!x||x.length===0)continue;let $=new Set(d.usage.files.map(A=>A.path)),j=d.usage.fileCount,I=[...d.usage.files];for(let A of x)$.has(A.file.path)||($.add(A.file.path),j+=1,!(I.length>=jn)&&I.push({path:A.file.path,line:qr(A.file.text,A.offset),...r?{example:f(A.file,A.offset,[])}:{}}));d.usage={...d.usage,status:d.usage.status==="unknown"?"unknown":"used",files:I,fileCount:j}}}function Yr(e,t,n){let s=[],r=new Set;for(let o of t)r.has(o.path)||(r.add(o.path),!(s.length>=jn)&&s.push({path:o.path,line:o.line,...n?{example:mn(e.get(o.path)??"",o.offset,[],o.path)}:{}}));return{status:"used",files:s,fileCount:r.size}}var mc={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},ro={button:mc},oo=12,On=200,ke=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro)$/i,Qr=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro|html?|mdx|erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,Xe=/\.(css|scss|sass|less|styl)$/i,eo=/\.(mdx?|markdown|txt|rst|adoc)$/i,to=/(^|\/)(tokens?|design-tokens?|theme)[^/]*\.json$/i,Z=/(^|\/)(__tests__|tests?|spec|e2e|cypress|playwright)(\/|$)|\.(test|spec)\.[a-z]+$/i,hc=/(^|\/)(plans?|results?|changelogs?|history|archive)(\/|\.|$)|(^|\/)CHANGELOG/i;function bc(e){return St.test(e)&&!/(^|\/)README\.md$/i.test(e)?"instruction":hc.test(e)?"record":"documentation"}var St=/(^|\/)(AGENTS|CLAUDE|CONTRIBUTING|README|GUIDELINES?)\.md$|(^|\/)(eslint|stylelint|\.eslintrc|\.stylelintrc)[^/]*$|(^|\/)\.cursor\/|(^|\/)\.claude\//i;function de(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yc(e){return(e.split("/").pop()??"").replace(/(\.module)?\.[^.]+$/i,"")}function no(e,t){let n=yc(e).toLowerCase();return t.some(s=>{let r=s.toLowerCase();return n===r||n===`${r}s`})}function xc(e,t){let n=1;for(let s=0;s<t;s++)e.charCodeAt(s)===10&&n++;return n}function ge(e,t){let n=e.split(`
56
+ `),s=0,r=[];for(let o=0;o<n.length;o++){let i=n[o];if(t.lastIndex=0,!!t.test(i)&&(s++,r.length<oo)){let a=i.trim();r.push({line:o+1,text:a.length>On?`${a.slice(0,On)}\u2026`:a})}}return{count:s,lines:r}}function io(e){let t=e.lastIndexOf("/");return t<0?"":e.slice(0,t)}function ao(e){let t=[];for(let n of e.split("/"))!n||n==="."||(n===".."?t.pop():t.push(n));return t.join("/")}var wc=["",".tsx",".ts",".jsx",".js",".mjs",".vue",".svelte",".css",".module.css",".scss","/index.tsx","/index.ts","/index.js"];function ve(e,t,n){let s;if(t.startsWith("."))s=ao(`${io(e)}/${t}`);else if(t.startsWith("@/"))s=t.slice(2);else if(t.startsWith("~/"))s=t.slice(2);else if(t.startsWith("/"))s=t.slice(1);else return null;for(let r of wc)if(n(s+r))return s+r;return null}var kc=/import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]|require\(\s*['"]([^'"]+)['"]\s*\)|@import\s+(?:url\()?['"]([^'"]+)['"]/g;function Ln(e){let t=[];for(let n of e.matchAll(kc)){let s=n[1]??n[2]??n[3];s&&t.push(s)}return t}var vc=/export\s+(?:default\s+)?(?:async\s+)?(?:function|const|let|class|var)\s+([A-Za-z_$][\w$]*)|export\s*\{([^}]*)\}/g;function so(e){let t=new Set;for(let n of e.matchAll(vc))if(n[1]&&t.add(n[1]),n[2])for(let s of n[2].split(",")){let r=s.trim().split(/\s+as\s+/).pop()?.trim();r&&t.add(r)}return[...t]}var Mn=/var\(\s*(--[\w-]+)/g;function Rt(e){return e.split(" \xB7 ").every(t=>t===""||/^@layer\b/i.test(t))}function lo(e){let t=[];for(let n of e.matchAll(/(?:^|[;{}])\s*composes\s*:\s*([^;]+)/g)){let s=n[1].trim(),r=/^(.*?)\s+from\s+(['"]?)([^'"]+)\2\s*$/.exec(s);r?t.push({names:r[1].split(/\s+/).filter(Boolean),from:r[3]}):t.push({names:s.split(/\s+/).filter(Boolean),from:null})}return t}function $c(e,t,n){let s=t.startsWith(".")?ao(`${io(e)}/${t}`):t.startsWith("@/")?t.slice(2):t.startsWith("~/")||t.startsWith("/")?t.replace(/^~?\//,""):null;return s&&n(s)?s:ve(e,t.replace(/\.(?:module\.)?(?:css|scss|sass|less)$/i,""),n)}function Cc(e){let t=new Map;for(let[n,s]of e)if(Xe.test(n)){for(let r of we(s))if(Rt(r.context))for(let o of z(r.selector)){let i=/^\.([\w-]+)$/.exec(o.trim())?.[1];if(!i)continue;let a=`${n}\0${i}`,l=t.get(a)??{decls:[],composes:[]};l.decls.push(...pe(r.ownBody));for(let c of $t(r.ownBody))c.state==="default"&&c.context===""&&l.decls.push(...c.declarations);l.composes.push(...lo(r.ownBody)),t.set(a,l)}}return t}function Sc(e,t,n,s){let r=[],o=new Set,i=(l,c,p)=>{if(p>4)return;let f=`${l}\0${c}`;if(o.has(f))return;o.add(f);let m=n.get(f);if(m){for(let h of m.composes)a(l,h,p+1);r.push(...m.decls)}},a=(l,c,p)=>{for(let f of c.names)if(c.from==="global")for(let m of n.keys()){let h=m.indexOf("\0"),C=m.slice(0,h);m.slice(h+1)!==f||/\.module\./i.test(C)||i(C,f,p)}else if(c.from){let m=$c(l,c.from,s);m&&i(m,f,p)}else i(l,f,p)};for(let l of lo(t))a(e,l,0);return r}function Rc(e,t){let n=Hr(t);return n?z(e).map(s=>{let r=Math.max(s.lastIndexOf(" "),s.lastIndexOf(">"),s.lastIndexOf("+"),s.lastIndexOf("~"));return r<0?`${s}${n}`:`${s.slice(0,r+1)}${s.slice(r+1)}${n}`}).join(", "):e}var Ac=/^(?::root|html|body|\*)$/i,_c=25e4,Ec=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,Ic=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,jc=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]);function Pc(e){let t=new Set,n=new Set;for(let s of e.matchAll(Ec)){let r=s[1],o=jc.has(r.toLowerCase())&&r===r.toLowerCase()?t:n;for(let i of s[2].matchAll(Ic))o.add(i[1]??i[2])}return{parts:new Set([...t].filter(s=>!n.has(s))),controls:n}}function Lc(e,t){let n=new Map;for(let s of t)if(Xe.test(s)){for(let r of we(e.get(s)))if(Rt(r.context)&&z(r.selector).some(o=>Ac.test(o)))for(let o of pe(r.ownBody))o.property.startsWith("--")&&!n.has(o.property)&&n.set(o.property,o.value)}return n}function Oc(e,t){let n=new Set,s=[],r=a=>{for(let l of a.matchAll(Mn))n.has(l[1])||(n.add(l[1]),s.push(l[1]))};for(let a of t)r(a);let o=[];for(let a=s.shift();a;a=s.shift()){let l=e.get(a);l===void 0||!se(a,l)||(o.push(`${a}:${l}`),r(l))}return`${o.length?`:root{${o.join(";")}}
57
57
  `:""}${t.join(`
58
- `)}`.slice(0,Cc)}function oo(e,t){let n=[...e.keys()].sort(),s=b=>e.has(b),r=new Map,o=(b,S,_,L)=>{let M=`${S}:${b}`,B=r.get(M);if(B){B.note.includes(_)||(B.note+=`; ${_}`);return}r.set(M,{path:b,role:S,note:_,matches:L.count,lines:L.lines})},i=new Set,a=new Set;for(let b of n){if(!we.test(b)||Z.test(b))continue;let S=e.get(b),_=Qr(S).filter(O=>t.identifier.test(O)),L=b.split("/").pop()??"",M=new RegExp(t.classKeywords.join("|"),"i").test(L);if(_.length===0&&!M)continue;for(let O of _)i.add(O);a.add(b);let B=_.length?new RegExp(`\\b(?:${_.map(fe).join("|")})\\b`,"g"):t.prose;o(b,"implements",_.length?`exports ${_.join(", ")}`:"named for the concept",de(S,B))}let l=new Set,c=[],u=[],f=new Map,m=b=>Yr(b,t.classKeywords)||/\.module\.[a-z]+$/i.test(b)&&f.has(b),h=null,$=()=>h??=wc(e),k=b=>{let S=m(b),_=[],L=0;for(let O of xe(e.get(b))){let F=z(O.selector).filter(N=>Ze(N,t,S));if(F.length===0)continue;L+=1;for(let N of O.ownBody.matchAll(jn))l.add(N[1]);let U=$t(O.ownBody),ie=[...kc(b,O.ownBody,$(),s),...ue(O.ownBody),...U.filter(N=>N.state==="default"&&N.context==="").flatMap(N=>N.declarations)];for(let N of ie)for(let J of N.value.matchAll(jn))l.add(J[1]);_.push({block:O,parts:F,declarations:ie,previewContext:Rt(O.context)?"":null,listed:!0});for(let N of U){if(N.state==="default"&&N.context==="")continue;let J=vc(F.join(", "),N.state),Ve=z(J).filter(Qo=>Ze(Qo,t,S));if(Ve.length===0)continue;let Yo=[O.context,N.context].filter(Boolean).join(" \xB7 ");_.push({block:{...O,selector:J,context:Yo},parts:Ve,declarations:N.declarations,previewContext:Rt(O.context)?N.context:null,listed:!1})}}let M={parts:new Set,controls:new Set};for(let O of f.get(b)??[]){let F=_c(e.get(O)??"");for(let U of F.parts)M.parts.add(U);for(let U of F.controls)M.controls.add(U)}c.push(...Lr(b,_.map(({block:O,parts:F,declarations:U})=>({selector:F.join(", "),declarations:U,line:O.line,context:O.context})),t,S,M));let B=/\.module\.[a-z]+$/i.test(b)?`${Qs(b)} `:"";for(let{parts:O,declarations:F,previewContext:U}of _){if(U===null)continue;let ie=O.flatMap(J=>{let Ve=Ze(J,t,S);return Ve?[`${B}${Ke(Ve.compounds)}`]:[]}),N=F.filter(J=>ne(J.property,J.value));if(!(ie.length===0||N.length===0))for(let J of ie)u.push(...Rn(J,N,U))}return{count:L,lines:_.filter(O=>O.listed).slice(0,to).map(({block:O})=>({line:O.line,text:O.selector.replace(/\s+/g," ").slice(0,In)}))}},w=new Map;for(let b of a)for(let S of En(e.get(b))){let _=ke(b,S,s);if(_&&qe.test(_)){let L=w.get(_)??[];L.push(b.split("/").pop()??b),w.set(_,L),Yr(b,t.classKeywords)&&f.set(_,[...f.get(_)??[],b])}}for(let b of n){if(!qe.test(b))continue;let S=k(b),_=w.get(b);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(b,"styles",L.join("; "),S)}let g=new Set;for(let b of c)for(let S of b.selector.matchAll(/\.((?:\\.|[\w-])+)/g))g.add(S[1].replace(/\\(.)/g,"$1"));let p=new Set(a),d=new RegExp([...t.elements.map(b=>`<${fe(b)}\\b`),...t.roles.map(b=>`role=["']${fe(b)}["']`)].join("|"));for(let b of n)!we.test(b)||Z.test(b)||d.test(e.get(b)??"")&&p.add(b);for(let b of a)for(let S of En(e.get(b))){let _=ke(b,S,s);!_||!we.test(_)||Z.test(_)||Hr(_,t.classKeywords)&&p.add(_)}let y=0,v=[],x=[];for(let b of p){let S=Gr(b,e.get(b)??"",t,g,y);y=S.nextId,v.push(...S.recipes),c.push(...S.variants),x.push(...S.inline),u.push(...S.previewRules)}let C=es(x);c.push(...C.variants);let j=vr([...a].map(b=>({path:b,source:e.get(b)??"",names:Qr(e.get(b)??"").filter(S=>t.identifier.test(S))})),v,(b,S)=>ke(b,S,s)),I=[];if(l.size>0){let b=new RegExp(`(?:^|[\\s{;])(${[...l].map(fe).join("|")})\\s*:`),S=new Map;for(let _ of n){if(!qe.test(_)&&!qr.test(_))continue;let L=e.get(_),M=de(L,b);if(M.count!==0){for(let B of L.matchAll(new RegExp(b.source,"gm"))){let O=S.get(B[1])??[];O.includes(_)||O.push(_),S.set(B[1],O)}o(_,"tokens",`defines ${M.count} token${M.count===1?"":"s"} read by ${t.label.toLowerCase()} styles`,M)}}for(let _ of[...l].sort())I.push({name:_,definedIn:S.get(_)??[]})}for(let b of n){if(!qr.test(b))continue;let S=de(e.get(b),t.prose);S.count>0&&o(b,"tokens","token file mentions the concept",S)}let A=[...i],R=new RegExp([...A.length?[`<(?:${A.map(fe).join("|")})\\b`]:[],...t.elements.map(b=>`<${fe(b)}\\b`),...t.roles.map(b=>`role=["']${fe(b)}["']`)].join("|"));for(let b of n){if(!we.test(b)||a.has(b))continue;let S=e.get(b),_=Z.test(b),L=de(S,R),M=En(S).some(O=>{let F=ke(b,O,s);return F!=null&&a.has(F)});if(L.count===0&&!M)continue;let B=L.count>0?`${L.count} render${L.count===1?"":"s"}`:"imports a button component";o(b,_?"tests":"uses",B,L.count?L:de(S,t.prose))}for(let b of n){if(!(Xr.test(b)||St.test(b)))continue;let _=e.get(b),L=de(_,t.prose);L.count!==0&&o(b,Z.test(b)?"tests":"describes",St.test(b)?"repo rules / instructions":"documentation",L)}for(let b of n){if(!Z.test(b)||r.has(`tests:${b}`)||!we.test(b))continue;let S=de(e.get(b),t.prose);S.count>0&&o(b,"tests","mentions the concept",S)}let P=[...r.values()].sort((b,S)=>S.matches-b.matches||b.path.localeCompare(S.path)),T={implements:0,styles:0,tokens:0,uses:0,describes:0,tests:0};for(let b of P)T[b.role]++;let G=Or(c);_n(e,n.filter(b=>Zr.test(b)&&!Z.test(b)),G,new Set(t.elements),!0,j,(b,S)=>ke(b,S,s)),_n(e,n.filter(b=>Zr.test(b)&&!Z.test(b)),G.flatMap(b=>b.modifiers??[]),new Set(t.elements));for(let[b,S]of C.sites)b.usage=Jr(e,S,!("alike"in b));let X=Ec(e,n),tt=[];if(i.size>0){let b=new RegExp(t.elements.map(S=>`<${fe(S)}\\b`).join("|"),"g");for(let S of n){if(!we.test(S)||Z.test(S)||a.has(S))continue;let _=e.get(S),L=(_.match(b)??[]).length;if(L===0)continue;let M=de(_,new RegExp(b.source));tt.push({path:S,line:M.lines[0]?.line??1,count:L})}}let Zn=[],Xn=new Set;for(let b of n){if(!we.test(b)||Z.test(b))continue;let S=e.get(b),_=wt(b,S,j,(L,M)=>ke(L,M,s));for(let L of _)for(let M of L.unknown){let B=[...M.known].sort();if(M.cls!==void 0){if(g.has(M.cls))continue;let U=M.cls.slice(0,M.cls.length-M.value.length),ie=[...g].filter(N=>N.startsWith(U)&&N.length>U.length).map(N=>N.slice(U.length));if(ie.length===0)continue;B=[...new Set([...M.known,...ie])].sort()}if(B.length===0)continue;let O=mc(S,L.offset),F=`${b}\0${L.component}\0${M.prop}\0${M.value}`;Xn.has(F)||(Xn.add(F),Zn.push({path:b,line:O,component:L.component,prop:M.prop,value:M.value,known:B}))}}let Xo=n.filter(b=>(Xr.test(b)||St.test(b))&&!Z.test(b)).map(b=>({path:b,kind:dc(b)}));G.sort((b,S)=>Number(S.base)-Number(b.base)||b.path.localeCompare(S.path)||b.line-S.line);let qn=Ar(e,Xo,t,G),qo=Sr([...f.entries()].map(([b,S])=>({sheet:b,sources:S.map(_=>e.get(_)??""),rules:xe(e.get(b)??"").map(_=>({selector:_.selector,declarations:ue(_.ownBody)}))})));return{components:A.sort(),tokens:I,findings:P,variants:G,audit:ar({variants:G,tokens:I,tokenValues:X,hasComponent:i.size>0,nativeUses:tt,unknownProps:Zn,guidance:qn,noun:t.label.toLowerCase(),element:t.elements[0]??t.id}),guidance:qn,content:qo,previewCss:Ic(X,u),counts:T}}import{execFileSync as Pc}from"node:child_process";import{readdirSync as Lc,readFileSync as Oc,statSync as Mc}from"node:fs";import At from"node:path";function ve(e,t){try{return Pc("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:64*1024*1024})}catch{return null}}function Pn(e,t=""){let s=ve(e,["rev-parse","--show-toplevel"])?.trim()||e;return{repoDir:s,root:qt(t),stateDir:At.join(s,".gruum")}}function _t(e){let t=At.join(e.repoDir,e.root),n=new Map,s=new TextDecoder("utf-8",{fatal:!1}),r=0,o=0,i=!1,a=(l,c)=>{if(i)return;let u;try{u=Lc(l).sort()}catch{return}for(let f of u){let m=c?`${c}/${f}`:f,h=At.join(l,f),$;try{$=Mc(h)}catch{continue}if($.isDirectory()){Zt(m)&&a(h,m);continue}if(!$.isFile())continue;if(!Xt(m,$.size)){o++;continue}let k=Oc(h);if(Vs(k)){o++;continue}if(r+k.length>4e7){i=!0;return}r+=k.length,n.set(m,s.decode(k))}};return a(t,""),{files:n,truncated:i,skipped:o}}function io(e,t){let n=ve(e.repoDir,["diff","--cached","--name-status","-z"]);if(n===null)return t;let s=Us(n).map(({path:r,deleted:o})=>({path:r,content:o?null:ve(e.repoDir,["show",`:${r}`])}));return{...t,files:Fs(t.files,s,e.root)}}function ao(e){let t=ve(e.repoDir,["remote","get-url","origin"])?.trim()??"",n=ct(t)??At.basename(e.repoDir),s=ve(e.repoDir,["rev-parse","HEAD"])?.trim()||"working-tree";return{fullName:n,ref:s,rootPath:e.root,htmlUrl:n.includes("/")?`https://github.com/${n}`:""}}function lo(e){let t=ve(e.repoDir,["config","--get","core.hooksPath"])?.trim();return t||ve(e.repoDir,["rev-parse","--git-path","hooks"])?.trim()||null}function Et(e,t={}){let n=eo[t.concept??"button"],s=_t(e);return t.staged&&(s=io(e,s)),{concept:n.id,label:n.label,...oo(s.files,n),repo:ao(e),index:{files:s.files.size,truncated:s.truncated,skipped:s.skipped}}}function $e(e,t,n={}){let s=Et(e,{concept:t.concept,...n});return{result:s,baseline:t,items:ls(s,t)}}import{mkdirSync as Nc,readFileSync as Tc,writeFileSync as co}from"node:fs";import re from"node:path";function Ce(e){try{return Tc(e,"utf8")}catch{return null}}function It(e){let t=Ce(e);if(t===null)return null;try{return JSON.parse(t)}catch{return null}}function Se(e,t){Nc(re.dirname(e),{recursive:!0}),co(e,t)}function oe(e,t){Se(e,`${JSON.stringify(t,null,2)}
59
- `),Dc(e)}function Dc(e){let t=e.split(re.sep),n=t.lastIndexOf(".gruum");if(n<=0)return;let s=re.join(t.slice(0,n).join(re.sep),".gitignore"),r=ot(Ce(s));r.changed&&(co(s,r.text),process.stderr.write(`Added .gruum/ to .gitignore.
60
- `))}var Re=e=>re.join(e.stateDir,"baseline.json"),uo=e=>re.join(e.stateDir,"drift.json"),Ln=e=>re.join(e.stateDir,"exceptions.json"),Vc=e=>re.join(e.stateDir,"config.json");function ge(e,t){return Ue(It(t?re.resolve(t):Re(e)))}function jt(e){return ps(It(uo(e)),new Date().toISOString())}function On(e,t){oe(uo(e),t)}function Bc(e){if(!e||typeof e!="object")return{};let t={};for(let[n,s]of Object.entries(e))(s==="pending"||s==="accepted"||s==="rejected")&&(t[n]=s);return t}function Pt(e){return Bc(It(Ln(e)))}function Mn(e){let t=It(Vc(e)),n=Array.isArray(t?.denyGit)?t.denyGit.filter(r=>r==="commit"||r==="push"):_e.denyGit,s=typeof t?.maxFollowups=="number"&&t.maxFollowups>=0?Math.floor(t.maxFollowups):_e.maxFollowups;return{...typeof t?.root=="string"?{root:t.root}:{},hooks:{..._e,denyGit:n,maxFollowups:s}}}import{chmodSync as Gc,mkdirSync as Hc,readFileSync as jo,writeFileSync as Kc}from"node:fs";import{hostname as Jc,homedir as Zc}from"node:os";import Dn from"node:path";import{createInterface as Po}from"node:readline/promises";function po(e){return`/v2/projects/${encodeURIComponent(e)}`}function fo(e,t){if(e.length===0)return null;if(e.length===1)return e[0];let n=t.replace(/^\/+|\/+$/g,""),s=e.filter(r=>r.rootPath===n);if(s.length===1)return s[0];if(!n){let r=e.filter(o=>o.rootPath==="");if(r.length===1)return r[0]}return null}function go(e){if(typeof e!="string")return{error:"Send a URL."};let t=e.trim();if(!t)return{error:"Enter a live URL."};if(!/^https:\/\//i.test(t))return{error:"URL must start with https://"};let n;try{n=new URL(t)}catch{return{error:"That doesn\u2019t look like a URL."}}if(n.protocol!=="https:")return{error:"URL must start with https://"};if(n.username||n.password)return{error:"That doesn\u2019t look like a URL."};let s=n.hostname.toLowerCase().replace(/^www\./,"");return!s||!s.includes(".")?{error:"That doesn\u2019t look like a URL."}:s==="localhost"||s==="127.0.0.1"?{error:"Public hosts only for Live URL (localhost needs the extension later)."}:{value:s}}var Fc="http://localhost:3000",Uc=/(^|\.)(github\.com|githubusercontent\.com|gitlab\.com|bitbucket\.org|npmjs\.com|npmjs\.org|unpkg\.com|jsdelivr\.net|googleapis\.com|gstatic\.com|google\.com|schema\.org|w3\.org|mozilla\.org|wikipedia\.org|example\.com|example\.org|sentry\.io|vercel\.com|cloudflare\.com|amazonaws\.com)$/i;function mo(e){return`https://${(e.split("/").pop()||e).toLowerCase().replace(/\.git$/,"").replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"")||"example"}.com`}function ho(e){return`
58
+ `)}`.slice(0,_c)}function co(e,t){let n=[...e.keys()].sort(),s=b=>e.has(b),r=new Map,o=(b,S,_,L)=>{let M=`${S}:${b}`,B=r.get(M);if(B){B.note.includes(_)||(B.note+=`; ${_}`);return}r.set(M,{path:b,role:S,note:_,matches:L.count,lines:L.lines})},i=new Set,a=new Set;for(let b of n){if(!ke.test(b)||Z.test(b))continue;let S=e.get(b),_=so(S).filter(O=>t.identifier.test(O)),L=b.split("/").pop()??"",M=new RegExp(t.classKeywords.join("|"),"i").test(L);if(_.length===0&&!M)continue;for(let O of _)i.add(O);a.add(b);let B=_.length?new RegExp(`\\b(?:${_.map(de).join("|")})\\b`,"g"):t.prose;o(b,"implements",_.length?`exports ${_.join(", ")}`:"named for the concept",ge(S,B))}let l=new Set,c=[],p=[],f=new Map,m=b=>no(b,t.classKeywords)||/\.module\.[a-z]+$/i.test(b)&&f.has(b),h=null,C=()=>h??=Cc(e),w=b=>{let S=m(b),_=[],L=0;for(let O of we(e.get(b))){let V=z(O.selector).filter(N=>Je(N,t,S));if(V.length===0)continue;L+=1;for(let N of O.ownBody.matchAll(Mn))l.add(N[1]);let U=$t(O.ownBody),ae=[...Sc(b,O.ownBody,C(),s),...pe(O.ownBody),...U.filter(N=>N.state==="default"&&N.context==="").flatMap(N=>N.declarations)];for(let N of ae)for(let J of N.value.matchAll(Mn))l.add(J[1]);_.push({block:O,parts:V,declarations:ae,previewContext:Rt(O.context)?"":null,listed:!0});for(let N of U){if(N.state==="default"&&N.context==="")continue;let J=Rc(V.join(", "),N.state),Fe=z(J).filter(si=>Je(si,t,S));if(Fe.length===0)continue;let ni=[O.context,N.context].filter(Boolean).join(" \xB7 ");_.push({block:{...O,selector:J,context:ni},parts:Fe,declarations:N.declarations,previewContext:Rt(O.context)?N.context:null,listed:!1})}}let M={parts:new Set,controls:new Set};for(let O of f.get(b)??[]){let V=Pc(e.get(O)??"");for(let U of V.parts)M.parts.add(U);for(let U of V.controls)M.controls.add(U)}c.push(...Tr(b,_.map(({block:O,parts:V,declarations:U})=>({selector:V.join(", "),declarations:U,line:O.line,context:O.context})),t,S,M));let B=/\.module\.[a-z]+$/i.test(b)?`${sr(b)} `:"";for(let{parts:O,declarations:V,previewContext:U}of _){if(U===null)continue;let ae=O.flatMap(J=>{let Fe=Je(J,t,S);return Fe?[`${B}${He(Fe.compounds)}`]:[]}),N=V.filter(J=>se(J.property,J.value));if(!(ae.length===0||N.length===0))for(let J of ae)p.push(...In(J,N,U))}return{count:L,lines:_.filter(O=>O.listed).slice(0,oo).map(({block:O})=>({line:O.line,text:O.selector.replace(/\s+/g," ").slice(0,On)}))}},v=new Map;for(let b of a)for(let S of Ln(e.get(b))){let _=ve(b,S,s);if(_&&Xe.test(_)){let L=v.get(_)??[];L.push(b.split("/").pop()??b),v.set(_,L),no(b,t.classKeywords)&&f.set(_,[...f.get(_)??[],b])}}for(let b of n){if(!Xe.test(b))continue;let S=w(b),_=v.get(b);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(b,"styles",L.join("; "),S)}let d=new Set;for(let b of c)for(let S of b.selector.matchAll(/\.((?:\\.|[\w-])+)/g))d.add(S[1].replace(/\\(.)/g,"$1"));let u=new Set(a),g=new RegExp([...t.elements.map(b=>`<${de(b)}\\b`),...t.roles.map(b=>`role=["']${de(b)}["']`)].join("|"));for(let b of n)!ke.test(b)||Z.test(b)||g.test(e.get(b)??"")&&u.add(b);for(let b of a)for(let S of Ln(e.get(b))){let _=ve(b,S,s);!_||!ke.test(_)||Z.test(_)||Xr(_,t.classKeywords)&&u.add(_)}let y=0,k=[],x=[];for(let b of u){let S=Zr(b,e.get(b)??"",t,d,y);y=S.nextId,k.push(...S.recipes),c.push(...S.variants),x.push(...S.inline),p.push(...S.previewRules)}let $=rs(x);c.push(...$.variants);let j=Rr([...a].map(b=>({path:b,source:e.get(b)??"",names:so(e.get(b)??"").filter(S=>t.identifier.test(S))})),k,(b,S)=>ve(b,S,s)),I=[];if(l.size>0){let b=new RegExp(`(?:^|[\\s{;])(${[...l].map(de).join("|")})\\s*:`),S=new Map;for(let _ of n){if(!Xe.test(_)&&!to.test(_))continue;let L=e.get(_),M=ge(L,b);if(M.count!==0){for(let B of L.matchAll(new RegExp(b.source,"gm"))){let O=S.get(B[1])??[];O.includes(_)||O.push(_),S.set(B[1],O)}o(_,"tokens",`defines ${M.count} token${M.count===1?"":"s"} read by ${t.label.toLowerCase()} styles`,M)}}for(let _ of[...l].sort())I.push({name:_,definedIn:S.get(_)??[]})}for(let b of n){if(!to.test(b))continue;let S=ge(e.get(b),t.prose);S.count>0&&o(b,"tokens","token file mentions the concept",S)}let A=[...i],R=new RegExp([...A.length?[`<(?:${A.map(de).join("|")})\\b`]:[],...t.elements.map(b=>`<${de(b)}\\b`),...t.roles.map(b=>`role=["']${de(b)}["']`)].join("|"));for(let b of n){if(!ke.test(b)||a.has(b))continue;let S=e.get(b),_=Z.test(b),L=ge(S,R),M=Ln(S).some(O=>{let V=ve(b,O,s);return V!=null&&a.has(V)});if(L.count===0&&!M)continue;let B=L.count>0?`${L.count} render${L.count===1?"":"s"}`:"imports a button component";o(b,_?"tests":"uses",B,L.count?L:ge(S,t.prose))}for(let b of n){if(!(eo.test(b)||St.test(b)))continue;let _=e.get(b),L=ge(_,t.prose);L.count!==0&&o(b,Z.test(b)?"tests":"describes",St.test(b)?"repo rules / instructions":"documentation",L)}for(let b of n){if(!Z.test(b)||r.has(`tests:${b}`)||!ke.test(b))continue;let S=ge(e.get(b),t.prose);S.count>0&&o(b,"tests","mentions the concept",S)}let P=[...r.values()].sort((b,S)=>S.matches-b.matches||b.path.localeCompare(S.path)),D={implements:0,styles:0,tokens:0,uses:0,describes:0,tests:0};for(let b of P)D[b.role]++;let G=Dr(c);Pn(e,n.filter(b=>Qr.test(b)&&!Z.test(b)),G,new Set(t.elements),!0,j,(b,S)=>ve(b,S,s)),Pn(e,n.filter(b=>Qr.test(b)&&!Z.test(b)),G.flatMap(b=>b.modifiers??[]),new Set(t.elements));for(let[b,S]of $.sites)b.usage=Yr(e,S,!("alike"in b));let X=Lc(e,n),et=[];if(i.size>0){let b=new RegExp(t.elements.map(S=>`<${de(S)}\\b`).join("|"),"g");for(let S of n){if(!ke.test(S)||Z.test(S)||a.has(S))continue;let _=e.get(S),L=(_.match(b)??[]).length;if(L===0)continue;let M=ge(_,new RegExp(b.source));et.push({path:S,line:M.lines[0]?.line??1,count:L})}}let Qn=[],es=new Set;for(let b of n){if(!ke.test(b)||Z.test(b))continue;let S=e.get(b),_=wt(b,S,j,(L,M)=>ve(L,M,s));for(let L of _)for(let M of L.unknown){let B=[...M.known].sort();if(M.cls!==void 0){if(d.has(M.cls))continue;let U=M.cls.slice(0,M.cls.length-M.value.length),ae=[...d].filter(N=>N.startsWith(U)&&N.length>U.length).map(N=>N.slice(U.length));if(ae.length===0)continue;B=[...new Set([...M.known,...ae])].sort()}if(B.length===0)continue;let O=xc(S,L.offset),V=`${b}\0${L.component}\0${M.prop}\0${M.value}`;es.has(V)||(es.add(V),Qn.push({path:b,line:O,component:L.component,prop:M.prop,value:M.value,known:B}))}}let ei=n.filter(b=>(eo.test(b)||St.test(b))&&!Z.test(b)).map(b=>({path:b,kind:bc(b)}));G.sort((b,S)=>Number(S.base)-Number(b.base)||b.path.localeCompare(S.path)||b.line-S.line);let ts=jr(e,ei,t,G),ti=Er([...f.entries()].map(([b,S])=>({sheet:b,sources:S.map(_=>e.get(_)??""),rules:we(e.get(b)??"").map(_=>({selector:_.selector,declarations:pe(_.ownBody)}))})));return{components:A.sort(),tokens:I,findings:P,variants:G,audit:pr({variants:G,tokens:I,tokenValues:X,hasComponent:i.size>0,nativeUses:et,unknownProps:Qn,guidance:ts,noun:t.label.toLowerCase(),element:t.elements[0]??t.id}),guidance:ts,content:ti,previewCss:Oc(X,p),counts:D}}import{execFileSync as Nc}from"node:child_process";import{readdirSync as Tc,readFileSync as Dc,statSync as Fc}from"node:fs";import At from"node:path";function $e(e,t){try{return Nc("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:64*1024*1024})}catch{return null}}function Nn(e,t=""){let s=$e(e,["rev-parse","--show-toplevel"])?.trim()||e;return{repoDir:s,root:tn(t),stateDir:At.join(s,".gruum")}}function _t(e){let t=At.join(e.repoDir,e.root),n=new Map,s=new TextDecoder("utf-8",{fatal:!1}),r=0,o=0,i=!1,a=(l,c)=>{if(i)return;let p;try{p=Tc(l).sort()}catch{return}for(let f of p){let m=c?`${c}/${f}`:f,h=At.join(l,f),C;try{C=Fc(h)}catch{continue}if(C.isDirectory()){Qt(m)&&a(h,m);continue}if(!C.isFile())continue;if(!en(m,C.size)){o++;continue}let w=Dc(h);if(zs(w)){o++;continue}if(r+w.length>4e7){i=!0;return}r+=w.length,n.set(m,s.decode(w))}};return a(t,""),{files:n,truncated:i,skipped:o}}function uo(e,t){let n=$e(e.repoDir,["diff","--cached","--name-status","-z"]);if(n===null)return t;let s=Hs(n).map(({path:r,deleted:o})=>({path:r,content:o?null:$e(e.repoDir,["show",`:${r}`])}));return{...t,files:Gs(t.files,s,e.root)}}function po(e){let t=$e(e.repoDir,["remote","get-url","origin"])?.trim()??"",n=ct(t)??At.basename(e.repoDir),s=$e(e.repoDir,["rev-parse","HEAD"])?.trim()||"working-tree";return{fullName:n,ref:s,rootPath:e.root,htmlUrl:n.includes("/")?`https://github.com/${n}`:""}}function fo(e){let t=$e(e.repoDir,["config","--get","core.hooksPath"])?.trim();return t||$e(e.repoDir,["rev-parse","--git-path","hooks"])?.trim()||null}function Et(e,t={}){let n=ro[t.concept??"button"],s=_t(e);return t.staged&&(s=uo(e,s)),{concept:n.id,label:n.label,...co(s.files,n),repo:po(e),index:{files:s.files.size,truncated:s.truncated,skipped:s.skipped}}}function Ce(e,t,n={}){let s=Et(e,{concept:t.concept,...n});return{result:s,baseline:t,items:fs(s,t)}}import{mkdirSync as Bc,readFileSync as Vc,writeFileSync as go}from"node:fs";import oe from"node:path";function Se(e){try{return Vc(e,"utf8")}catch{return null}}function It(e){let t=Se(e);if(t===null)return null;try{return JSON.parse(t)}catch{return null}}function me(e,t){Bc(oe.dirname(e),{recursive:!0}),go(e,t)}function ie(e,t){me(e,`${JSON.stringify(t,null,2)}
59
+ `),Uc(e)}function Uc(e){let t=e.split(oe.sep),n=t.lastIndexOf(".gruum");if(n<=0)return;let s=oe.join(t.slice(0,n).join(oe.sep),".gitignore"),r=ot(Se(s));r.changed&&(go(s,r.text),process.stderr.write(`Added .gruum/ to .gitignore.
60
+ `))}var Re=e=>oe.join(e.stateDir,"baseline.json"),mo=e=>oe.join(e.stateDir,"drift.json"),Tn=e=>oe.join(e.stateDir,"exceptions.json"),zc=e=>oe.join(e.stateDir,"config.json");function he(e,t){return Ue(It(t?oe.resolve(t):Re(e)))}function jt(e){return ms(It(mo(e)),new Date().toISOString())}function Dn(e,t){ie(mo(e),t)}function Wc(e){if(!e||typeof e!="object")return{};let t={};for(let[n,s]of Object.entries(e))(s==="pending"||s==="accepted"||s==="rejected")&&(t[n]=s);return t}function Pt(e){return Wc(It(Tn(e)))}function Fn(e){let t=It(zc(e)),n=Array.isArray(t?.denyGit)?t.denyGit.filter(r=>r==="commit"||r==="push"):_e.denyGit,s=typeof t?.maxFollowups=="number"&&t.maxFollowups>=0?Math.floor(t.maxFollowups):_e.maxFollowups;return{...typeof t?.root=="string"?{root:t.root}:{},hooks:{..._e,denyGit:n,maxFollowups:s}}}import{chmodSync as Zc,mkdirSync as Xc,readFileSync as Mo,writeFileSync as qc}from"node:fs";import{hostname as Yc,homedir as Qc}from"node:os";import Un from"node:path";import{createInterface as No}from"node:readline/promises";function ho(e){return`/v2/projects/${encodeURIComponent(e)}`}function bo(e,t){if(e.length===0)return null;if(e.length===1)return e[0];let n=t.replace(/^\/+|\/+$/g,""),s=e.filter(r=>r.rootPath===n);if(s.length===1)return s[0];if(!n){let r=e.filter(o=>o.rootPath==="");if(r.length===1)return r[0]}return null}function yo(e){if(typeof e!="string")return{error:"Send a URL."};let t=e.trim();if(!t)return{error:"Enter a live URL."};if(!/^https:\/\//i.test(t))return{error:"URL must start with https://"};let n;try{n=new URL(t)}catch{return{error:"That doesn\u2019t look like a URL."}}if(n.protocol!=="https:")return{error:"URL must start with https://"};if(n.username||n.password)return{error:"That doesn\u2019t look like a URL."};let s=n.hostname.toLowerCase().replace(/^www\./,"");return!s||!s.includes(".")?{error:"That doesn\u2019t look like a URL."}:s==="localhost"||s==="127.0.0.1"?{error:"Public hosts only for Live URL (localhost needs the extension later)."}:{value:s}}var Gc="http://localhost:3000",Hc=/(^|\.)(github\.com|githubusercontent\.com|gitlab\.com|bitbucket\.org|npmjs\.com|npmjs\.org|unpkg\.com|jsdelivr\.net|googleapis\.com|gstatic\.com|google\.com|schema\.org|w3\.org|mozilla\.org|wikipedia\.org|example\.com|example\.org|sentry\.io|vercel\.com|cloudflare\.com|amazonaws\.com)$/i;function xo(e){return`https://${(e.split("/").pop()||e).toLowerCase().replace(/\.git$/,"").replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"")||"example"}.com`}function wo(e){return`
61
61
  Live URL for this repo.
62
- For example: ${Fc} or ${e}.
62
+ For example: ${Gc} or ${e}.
63
63
  You may not use wildcards.
64
64
 
65
- URL: `}function bo(e){let t=/https:\/\/[^\s"'<>)\]]+/gi;for(let n of e.matchAll(t)){let s;try{s=new URL(n[0])}catch{continue}let r=s.hostname.toLowerCase();if(!(!r.includes(".")||r.includes("*"))&&!(r==="localhost"||r==="127.0.0.1")&&!Uc.test(r))return`https://${r}`}return null}function zc(e){let t=e.toLowerCase().replace(/:\d+$/,"");return t==="localhost"||t==="127.0.0.1"}function yo(e){if(typeof e!="string")return{error:"Enter a live URL."};let t=e.trim();if(!t)return{error:"Enter a live URL."};if(t.includes("*"))return{error:"You may not use wildcards."};let n=Wc(t);if(n)return n;let s=/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:`https://${t}`;return go(s)}function Wc(e){let t=/^https?:\/\//i.test(e)?e:`http://${e}`,n;try{n=new URL(t)}catch{return null}let s=n.hostname.toLowerCase();if(s!=="localhost"&&s!=="127.0.0.1")return null;if(n.username||n.password)return{error:"That doesn\u2019t look like a URL."};let r=n.port;return{value:r&&r!=="80"&&r!=="443"?`${s}:${r}`:s}}function xo(e){return zc(e)?`http://${e}`:`https://${e}`}function wo(e,t){let n=e.filter(r=>r.workspaces.length>0);if(n.length===0)return{step:"none"};if(t){let r=n.find(o=>o.id===t);if(!r)return{step:"none"};if(r.workspaces.length===1){let o=r.workspaces[0];return{step:"use",workspaceId:o.id,orgName:r.name,workspaceName:o.name}}return{step:"workspace",orgId:r.id,orgName:r.name,workspaces:r.workspaces}}if(n.reduce((r,o)=>r+o.workspaces.length,0)===1){let r=n[0],o=r.workspaces[0];return{step:"use",workspaceId:o.id,orgName:r.name,workspaceName:o.name}}if(n.length===1){let r=n[0];return{step:"workspace",orgId:r.id,orgName:r.name,workspaces:r.workspaces}}return{step:"org",orgs:n.map(r=>({id:r.id,name:r.name}))}}var ko="No project for this repo found. Creating\u2026";function vo(e,t){let n=t.workspaceId;if(n)for(let s of e){let r=s.workspaces.find(o=>o.id===n);if(r)return`${s.name} / ${r.name} / ${t.name}`}return t.name}function $o(e){let t=e.length===1?`Use ${e[0]}, or create a new one.`:"This repo is already in more than one project. Use one, or create a new one.",s=[...e,"Create a new one"].map((r,o)=>` ${o+1} ${r}`);return`
65
+ URL: `}function ko(e){let t=/https:\/\/[^\s"'<>)\]]+/gi;for(let n of e.matchAll(t)){let s;try{s=new URL(n[0])}catch{continue}let r=s.hostname.toLowerCase();if(!(!r.includes(".")||r.includes("*"))&&!(r==="localhost"||r==="127.0.0.1")&&!Hc.test(r))return`https://${r}`}return null}function Kc(e){let t=e.toLowerCase().replace(/:\d+$/,"");return t==="localhost"||t==="127.0.0.1"}function vo(e){if(typeof e!="string")return{error:"Enter a live URL."};let t=e.trim();if(!t)return{error:"Enter a live URL."};if(t.includes("*"))return{error:"You may not use wildcards."};let n=Jc(t);if(n)return n;let s=/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:`https://${t}`;return yo(s)}function Jc(e){let t=/^https?:\/\//i.test(e)?e:`http://${e}`,n;try{n=new URL(t)}catch{return null}let s=n.hostname.toLowerCase();if(s!=="localhost"&&s!=="127.0.0.1")return null;if(n.username||n.password)return{error:"That doesn\u2019t look like a URL."};let r=n.port;return{value:r&&r!=="80"&&r!=="443"?`${s}:${r}`:s}}function $o(e){return Kc(e)?`http://${e}`:`https://${e}`}function Co(e,t){let n=e.filter(r=>r.workspaces.length>0);if(n.length===0)return{step:"none"};if(t){let r=n.find(o=>o.id===t);if(!r)return{step:"none"};if(r.workspaces.length===1){let o=r.workspaces[0];return{step:"use",workspaceId:o.id,orgName:r.name,workspaceName:o.name}}return{step:"workspace",orgId:r.id,orgName:r.name,workspaces:r.workspaces}}if(n.reduce((r,o)=>r+o.workspaces.length,0)===1){let r=n[0],o=r.workspaces[0];return{step:"use",workspaceId:o.id,orgName:r.name,workspaceName:o.name}}if(n.length===1){let r=n[0];return{step:"workspace",orgId:r.id,orgName:r.name,workspaces:r.workspaces}}return{step:"org",orgs:n.map(r=>({id:r.id,name:r.name}))}}var So="No project for this repo found. Creating\u2026";function Ro(e,t){let n=t.workspaceId;if(n)for(let s of e){let r=s.workspaces.find(o=>o.id===n);if(r)return`${s.name} / ${r.name} / ${t.name}`}return t.name}function Ao(e){let t=e.length===1?`Use ${e[0]}, or create a new one.`:"This repo is already in more than one project. Use one, or create a new one.",s=[...e,"Create a new one"].map((r,o)=>` ${o+1} ${r}`);return`
66
66
  ${t}
67
67
  ${s.join(`
68
68
  `)}
69
69
 
70
- Which project should this checkout use? `}function Nn(e){return((e.split("/").pop()||e).replace(/\.git$/i,"").replace(/[^a-zA-Z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(" ")||"New workspace").slice(0,80)}function Co(e,t){let n=t.trim().toLowerCase();if(!n)return null;let s=e.filter(r=>r.name.trim().toLowerCase()===n);return s.length===1?s[0]:null}function So(e,t,n){let s=[` C Create ${n}`,...t.map((r,o)=>` ${o+1} ${r.name}`)];return`
70
+ Which project should this checkout use? `}function Bn(e){return((e.split("/").pop()||e).replace(/\.git$/i,"").replace(/[^a-zA-Z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(" ")||"New workspace").slice(0,80)}function _o(e,t){let n=t.trim().toLowerCase();if(!n)return null;let s=e.filter(r=>r.name.trim().toLowerCase()===n);return s.length===1?s[0]:null}function Eo(e,t,n){let s=[` C Create ${n}`,...t.map((r,o)=>` ${o+1} ${r.name}`)];return`
71
71
  Select a workspace in ${e}, or create one.
72
72
  ${s.join(`
73
73
  `)}
74
74
 
75
- Which workspace should this project live in? `}function Ro(e,t){let n=e.trim().toLowerCase();if(!n)return null;if(n==="c")return"create";let s=Number(n);if(Number.isInteger(s)&&s>=1&&s<=t.length)return s-1;let r=t.flatMap((o,i)=>o.name.trim().toLowerCase()===n?[i]:[]);return r.length===1?r[0]:null}function Ao(e,t,n){let s=t.map((r,o)=>` ${o+1} ${r.name}`);return`
75
+ Which workspace should this project live in? `}function Io(e,t){let n=e.trim().toLowerCase();if(!n)return null;if(n==="c")return"create";let s=Number(n);if(Number.isInteger(s)&&s>=1&&s<=t.length)return s-1;let r=t.flatMap((o,i)=>o.name.trim().toLowerCase()===n?[i]:[]);return r.length===1?r[0]:null}function jo(e,t,n){let s=t.map((r,o)=>` ${o+1} ${r.name}`);return`
76
76
  ${e}
77
77
  ${s.join(`
78
78
  `)}
79
79
 
80
- Which ${n} should this project live in? `}function _o(e,t){let n=e.trim().toLowerCase();if(!n)return null;let s=Number(n);if(Number.isInteger(s)&&s>=1&&s<=t.length)return s-1;let r=t.flatMap((o,i)=>o.name.trim().toLowerCase()===n?[i]:[]);return r.length===1?r[0]:null}function Eo(e){return`/workspace/${encodeURIComponent(e)}`}import{spawnSync as Xc}from"node:child_process";var Ne="https://app.getgruum.com",Lo=()=>Dn.join(Zc(),".config","gruum","credentials.json");function Vn(){let e=process.env.GRUUM_TOKEN?.trim();if(e)return{token:e,apiOrigin:process.env.GRUUM_API_ORIGIN?.trim()||Ne};try{let t=JSON.parse(jo(Lo(),"utf8"));return typeof t.token!="string"||!t.token?null:{token:t.token,apiOrigin:typeof t.apiOrigin=="string"&&t.apiOrigin?t.apiOrigin:Ne}}catch{return null}}function qc(e){let t=Lo();Hc(Dn.dirname(t),{recursive:!0}),Kc(t,`${JSON.stringify(e,null,2)}
81
- `,{mode:384}),Gc(t,384)}function Lt(e){return(e?.apiOrigin||Ne).replace(/\/$/,"")}async function K(e,t,n={}){let s=new Headers(n.headers);return e&&s.set("Authorization",`Bearer ${e.token}`),n.body&&!s.has("Content-Type")&&s.set("Content-Type","application/json"),fetch(`${Lt(e)}${t}`,{...n,headers:s})}function Bn(e,t){let n=Xc("git",t,{cwd:e,encoding:"utf8"});return n.status!==0?null:n.stdout.trim()||null}function Yc(e){let t=Bn(e,["remote","get-url","origin"]);return t?ct(t):null}function Ot(e){let t=Bn(e,["rev-parse","--abbrev-ref","HEAD"]);return t&&t!=="HEAD"?t:""}function Oo(e){return Bn(e,["rev-parse","HEAD"])}function Mo(e){return Dn.join(e.stateDir,"project.json")}function Qc(e){try{let t=JSON.parse(jo(Mo(e),"utf8"));return typeof t.id!="string"||typeof t.repo!="string"||!("host"in t)?null:{id:t.id,name:typeof t.name=="string"?t.name:t.repo,repo:t.repo,rootPath:typeof t.rootPath=="string"?t.rootPath:"",host:typeof t.host=="string"&&t.host?t.host:null,workspaceId:typeof t.workspaceId=="string"&&t.workspaceId?t.workspaceId:null,hostDeclined:t.hostDeclined===!0}}catch{return null}}function Fn(e,t){return`${e}${po(t)}`}function Io(e,t,n,s){let r=Fn(e,t.id),o=s?` in ${s}`:"",i=t.workspaceId?`${e}${Eo(t.workspaceId)}
80
+ Which ${n} should this project live in? `}function Po(e,t){let n=e.trim().toLowerCase();if(!n)return null;let s=Number(n);if(Number.isInteger(s)&&s>=1&&s<=t.length)return s-1;let r=t.flatMap((o,i)=>o.name.trim().toLowerCase()===n?[i]:[]);return r.length===1?r[0]:null}function Lo(e){return`/workspace/${encodeURIComponent(e)}`}import{spawnSync as eu}from"node:child_process";var Ne="https://app.getgruum.com",To=()=>Un.join(Qc(),".config","gruum","credentials.json");function zn(){let e=process.env.GRUUM_TOKEN?.trim();if(e)return{token:e,apiOrigin:process.env.GRUUM_API_ORIGIN?.trim()||Ne};try{let t=JSON.parse(Mo(To(),"utf8"));return typeof t.token!="string"||!t.token?null:{token:t.token,apiOrigin:typeof t.apiOrigin=="string"&&t.apiOrigin?t.apiOrigin:Ne}}catch{return null}}function tu(e){let t=To();Xc(Un.dirname(t),{recursive:!0}),qc(t,`${JSON.stringify(e,null,2)}
81
+ `,{mode:384}),Zc(t,384)}function Lt(e){return(e?.apiOrigin||Ne).replace(/\/$/,"")}async function K(e,t,n={}){let s=new Headers(n.headers);return e&&s.set("Authorization",`Bearer ${e.token}`),n.body&&!s.has("Content-Type")&&s.set("Content-Type","application/json"),fetch(`${Lt(e)}${t}`,{...n,headers:s})}function Wn(e,t){let n=eu("git",t,{cwd:e,encoding:"utf8"});return n.status!==0?null:n.stdout.trim()||null}function nu(e){let t=Wn(e,["remote","get-url","origin"]);return t?ct(t):null}function Ot(e){let t=Wn(e,["rev-parse","--abbrev-ref","HEAD"]);return t&&t!=="HEAD"?t:""}function Do(e){return Wn(e,["rev-parse","HEAD"])}function Fo(e){return Un.join(e.stateDir,"project.json")}function su(e){try{let t=JSON.parse(Mo(Fo(e),"utf8"));return typeof t.id!="string"||typeof t.repo!="string"||!("host"in t)?null:{id:t.id,name:typeof t.name=="string"?t.name:t.repo,repo:t.repo,rootPath:typeof t.rootPath=="string"?t.rootPath:"",host:typeof t.host=="string"&&t.host?t.host:null,workspaceId:typeof t.workspaceId=="string"&&t.workspaceId?t.workspaceId:null,hostDeclined:t.hostDeclined===!0}}catch{return null}}function Gn(e,t){return`${e}${ho(t)}`}function Oo(e,t,n,s){let r=Gn(e,t.id),o=s?` in ${s}`:"",i=t.workspaceId?`${e}${Lo(t.workspaceId)}
82
82
  `:"";process.stderr.write(n?`Created a Gruum project for ${t.repo}${o}.
83
83
  ${i}${r}
84
84
  `:`Gruum project: ${r}
85
- ${i}`)}function eu(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!="object")continue;let s=n;if(typeof s.id!="string"||typeof s.name!="string")continue;let r=Array.isArray(s.workspaces)?s.workspaces.flatMap(o=>{if(!o||typeof o!="object")return[];let i=o;return typeof i.id!="string"||typeof i.name!="string"?[]:[{id:i.id,name:i.name}]}):[];t.push({id:s.id,name:s.name,workspaces:r})}return t}async function No(e,t,n){let s=Po({input:process.stdin,output:process.stderr});Ae(s);try{for(;;){let r=t(await s.question(e));if(r!=null)return r;process.stderr.write(n)}}finally{s.close()}}async function To(e,t){return No(e,n=>_o(n,t),`gruum: enter one of the numbers.
86
- `)}async function Do(e){let t=await K(e,"/api/v2/cli/workspaces");if(t.status===401)return process.stderr.write("gruum: sign-in expired. Run `npx @gruum/cli login` again.\n"),null;if(!t.ok)return process.stderr.write(`gruum: couldn't list workspaces (${t.status}).
87
- `),null;let n=await t.json();return eu(n.orgs)}async function tu(e,t,n,s){let r=s??await Do(e);if(!r)return null;let o=null;for(;;){let i=wo(r,o);if(i.step==="none")return{workspaceId:"",label:""};if(i.step==="use")return{workspaceId:i.workspaceId,label:`${i.orgName} / ${i.workspaceName}`};if(i.step==="workspace"){let h=Co(i.workspaces,Nn(n));if(h)return{workspaceId:h.id,label:`${i.orgName} / ${h.name}`}}if(!t)return process.stderr.write("gruum: this account has more than one workspace. Run `npx @gruum/cli check` in a terminal and choose where the project should live.\n"),null;if(i.step==="org"){let h=await To(Ao("This account has more than one organization.",i.orgs,"organization"),i.orgs);o=i.orgs[h].id;continue}let a=Nn(n),l=await No(So(i.orgName,i.workspaces,a),h=>Ro(h,i.workspaces),`gruum: enter C, or one of the numbers.
88
- `);if(l!=="create"){let h=i.workspaces[l];return{workspaceId:h.id,label:`${i.orgName} / ${h.name}`}}let c=await K(e,"/api/v2/cli/workspaces",{method:"POST",body:JSON.stringify({orgId:i.orgId,name:a})}),u=await c.json().catch(()=>({})),f=u.workspace?.id,m=typeof u.workspace?.name=="string"?u.workspace.name:a;if(!c.ok||typeof f!="string"){process.stderr.write(`gruum: ${u.error||`couldn't create that workspace (${c.status})`}
89
- `);continue}return{workspaceId:f,label:`${i.orgName} / ${m}`}}}function nu(e,t){let n=_t(e);for(let s of n.files.values()){let r=bo(s);if(r)return r}return mo(t)}async function su(e,t){let n=ho(nu(e,t)),s=Po({input:process.stdin,output:process.stderr});Ae(s);try{for(;;){let r=(await s.question(n)).trim(),o=yo(r);if("error"in o){process.stderr.write(`gruum: ${o.error}
90
- `);continue}return r}}finally{s.close()}}async function Vo(){let e=`Cursor on ${Jc()}`,t=await K(null,"/api/cli/pair/start",{method:"POST",body:JSON.stringify({label:e})});if(!t.ok)return process.stderr.write(`gruum: couldn't start sign-in (${t.status}). Is Gruum running at ${Ne}?
85
+ ${i}`)}function ru(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!="object")continue;let s=n;if(typeof s.id!="string"||typeof s.name!="string")continue;let r=Array.isArray(s.workspaces)?s.workspaces.flatMap(o=>{if(!o||typeof o!="object")return[];let i=o;return typeof i.id!="string"||typeof i.name!="string"?[]:[{id:i.id,name:i.name}]}):[];t.push({id:s.id,name:s.name,workspaces:r})}return t}async function Bo(e,t,n){let s=No({input:process.stdin,output:process.stderr});Ae(s);try{for(;;){let r=t(await s.question(e));if(r!=null)return r;process.stderr.write(n)}}finally{s.close()}}async function Vo(e,t){return Bo(e,n=>Po(n,t),`gruum: enter one of the numbers.
86
+ `)}async function Uo(e){let t=await K(e,"/api/v2/cli/workspaces");if(t.status===401)return process.stderr.write("gruum: sign-in expired. Run `npx @gruum/cli login` again.\n"),null;if(!t.ok)return process.stderr.write(`gruum: couldn't list workspaces (${t.status}).
87
+ `),null;let n=await t.json();return ru(n.orgs)}async function ou(e,t,n,s){let r=s??await Uo(e);if(!r)return null;let o=null;for(;;){let i=Co(r,o);if(i.step==="none")return{workspaceId:"",label:""};if(i.step==="use")return{workspaceId:i.workspaceId,label:`${i.orgName} / ${i.workspaceName}`};if(i.step==="workspace"){let h=_o(i.workspaces,Bn(n));if(h)return{workspaceId:h.id,label:`${i.orgName} / ${h.name}`}}if(!t)return process.stderr.write("gruum: this account has more than one workspace. Run `npx @gruum/cli check` in a terminal and choose where the project should live.\n"),null;if(i.step==="org"){let h=await Vo(jo("This account has more than one organization.",i.orgs,"organization"),i.orgs);o=i.orgs[h].id;continue}let a=Bn(n),l=await Bo(Eo(i.orgName,i.workspaces,a),h=>Io(h,i.workspaces),`gruum: enter C, or one of the numbers.
88
+ `);if(l!=="create"){let h=i.workspaces[l];return{workspaceId:h.id,label:`${i.orgName} / ${h.name}`}}let c=await K(e,"/api/v2/cli/workspaces",{method:"POST",body:JSON.stringify({orgId:i.orgId,name:a})}),p=await c.json().catch(()=>({})),f=p.workspace?.id,m=typeof p.workspace?.name=="string"?p.workspace.name:a;if(!c.ok||typeof f!="string"){process.stderr.write(`gruum: ${p.error||`couldn't create that workspace (${c.status})`}
89
+ `);continue}return{workspaceId:f,label:`${i.orgName} / ${m}`}}}function iu(e,t){let n=_t(e);for(let s of n.files.values()){let r=ko(s);if(r)return r}return xo(t)}async function au(e,t){let n=wo(iu(e,t)),s=No({input:process.stdin,output:process.stderr});Ae(s);try{for(;;){let r=(await s.question(n)).trim(),o=vo(r);if("error"in o){process.stderr.write(`gruum: ${o.error}
90
+ `);continue}return r}}finally{s.close()}}async function zo(){let e=`Cursor on ${Yc()}`,t=await K(null,"/api/cli/pair/start",{method:"POST",body:JSON.stringify({label:e})});if(!t.ok)return process.stderr.write(`gruum: couldn't start sign-in (${t.status}). Is Gruum running at ${Ne}?
91
91
  `),1;let n=await t.json(),s=`${Ne}/extension/connect?code=${encodeURIComponent(n.userCode)}`;process.stdout.write(`Sign in to Gruum to connect this CLI.
92
92
 
93
93
  Code: ${n.userCode}
94
94
  ${s}
95
95
 
96
96
  Waiting for confirmation\u2026
97
- `);let r=Date.now()+600*1e3;for(;Date.now()<r;){await new Promise(a=>setTimeout(a,2e3));let o=await K(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 qc({token:i.token,apiOrigin:Ne}),process.stdout.write(`Signed in. This CLI can read specs for your projects.
98
- `),0}return process.stderr.write("gruum: sign-in timed out. Run `npx @gruum/cli login` again.\n"),1}function Tn(e){if(!e||typeof e!="object")return null;let t=e;return typeof t.id!="string"||typeof t.repo!="string"?null:{id:t.id,name:typeof t.name=="string"?t.name:t.repo,repo:t.repo,rootPath:typeof t.rootPath=="string"?t.rootPath:"",host:typeof t.host=="string"&&t.host?t.host:null,workspaceId:typeof t.workspaceId=="string"&&t.workspaceId?t.workspaceId:null}}async function Un(e,t){let n=Yc(e.repoDir);if(!n)return process.stderr.write(`gruum: this folder has no GitHub origin, so it can't be matched to a Gruum project.
99
- `),null;let s=!!process.stdin.isTTY,r=Qc(e);if(r&&r.repo===n&&r.workspaceId&&(r.host||!s))return r;let o=Lt(t),i=await K(t,`/api/v2/cli/projects?repo=${encodeURIComponent(n)}`);if(i.status===401)return process.stderr.write("gruum: sign-in expired. Run `npx @gruum/cli login` again.\n"),null;if(!i.ok)return null;let a=await i.json(),l=Array.isArray(a.projects)?a.projects.map(Tn).filter(k=>k!==null):[],c=!1,u="",f;if(l.length>0&&s){let k=await Do(t);if(!k)return null;f=k;let w=l.map(d=>vo(k,d)),g=[...w.map(d=>({name:d})),{name:"Create a new one"}],p=await To($o(w),g);p===w.length?(l=[],process.stderr.write(`Creating\u2026
100
- `)):l=[l[p]]}if(l.length===0){f||process.stderr.write(`${ko}
101
- `);let k=await tu(t,s,n,f);if(!k)return null;let w=await K(t,"/api/v2/cli/projects",{method:"POST",body:JSON.stringify({repo:n,rootPath:e.root,...k.workspaceId?{workspaceId:k.workspaceId}:{}})}),g=await w.json().catch(()=>({}));typeof g.place?.org=="string"&&typeof g.place.workspace=="string"?u=`${g.place.org} / ${g.place.workspace}`:u=k.label;let p=Tn(g.project);if(c=g.created!==!1,!w.ok||!p){let d=typeof g.path=="string"?g.path:"";return process.stderr.write(`gruum: ${g.error||`couldn't create a project (${w.status})`}
102
- `),d&&process.stderr.write(`${o}${d}
103
- `),null}l=[p]}let m=fo(l,e.root);if(!m){let k=l.map(w=>` ${w.name}${w.rootPath?` #${w.rootPath}`:""}
104
- ${Fn(o,w.id)}`).join(`
97
+ `);let r=Date.now()+600*1e3;for(;Date.now()<r;){await new Promise(a=>setTimeout(a,2e3));let o=await K(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 tu({token:i.token,apiOrigin:Ne}),process.stdout.write(`Signed in. This CLI can read specs for your projects.
98
+ `),0}return process.stderr.write("gruum: sign-in timed out. Run `npx @gruum/cli login` again.\n"),1}function Vn(e){if(!e||typeof e!="object")return null;let t=e;return typeof t.id!="string"||typeof t.repo!="string"?null:{id:t.id,name:typeof t.name=="string"?t.name:t.repo,repo:t.repo,rootPath:typeof t.rootPath=="string"?t.rootPath:"",host:typeof t.host=="string"&&t.host?t.host:null,workspaceId:typeof t.workspaceId=="string"&&t.workspaceId?t.workspaceId:null}}async function Hn(e,t){let n=nu(e.repoDir);if(!n)return process.stderr.write(`gruum: this folder has no GitHub origin, so it can't be matched to a Gruum project.
99
+ `),null;let s=!!process.stdin.isTTY,r=su(e);if(r&&r.repo===n&&r.workspaceId&&(r.host||!s))return r;let o=Lt(t),i=await K(t,`/api/v2/cli/projects?repo=${encodeURIComponent(n)}`);if(i.status===401)return process.stderr.write("gruum: sign-in expired. Run `npx @gruum/cli login` again.\n"),null;if(!i.ok)return null;let a=await i.json(),l=Array.isArray(a.projects)?a.projects.map(Vn).filter(w=>w!==null):[],c=!1,p="",f;if(l.length>0&&s){let w=await Uo(t);if(!w)return null;f=w;let v=l.map(g=>Ro(w,g)),d=[...v.map(g=>({name:g})),{name:"Create a new one"}],u=await Vo(Ao(v),d);u===v.length?(l=[],process.stderr.write(`Creating\u2026
100
+ `)):l=[l[u]]}if(l.length===0){f||process.stderr.write(`${So}
101
+ `);let w=await ou(t,s,n,f);if(!w)return null;let v=await K(t,"/api/v2/cli/projects",{method:"POST",body:JSON.stringify({repo:n,rootPath:e.root,...w.workspaceId?{workspaceId:w.workspaceId}:{}})}),d=await v.json().catch(()=>({}));typeof d.place?.org=="string"&&typeof d.place.workspace=="string"?p=`${d.place.org} / ${d.place.workspace}`:p=w.label;let u=Vn(d.project);if(c=d.created!==!1,!v.ok||!u){let g=typeof d.path=="string"?d.path:"";return process.stderr.write(`gruum: ${d.error||`couldn't create a project (${v.status})`}
102
+ `),g&&process.stderr.write(`${o}${g}
103
+ `),null}l=[u]}let m=bo(l,e.root);if(!m){let w=l.map(v=>` ${v.name}${v.rootPath?` #${v.rootPath}`:""}
104
+ ${Gn(o,v.id)}`).join(`
105
105
  `);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.
106
- ${k}
107
- `),null}let h=m.host??null;if(!h&&s)for(Io(o,{...m,host:h},c,u);!h;){let k=await su(e,n),w=await K(t,`/api/v2/cli/projects/${encodeURIComponent(m.id)}/url`,{method:"POST",body:JSON.stringify({url:k})}),g=await w.json().catch(()=>({})),p=Tn(g.project);if(!w.ok||!p?.host){process.stderr.write(`gruum: ${g.error||`couldn't save that URL (${w.status})`}
108
- `);continue}h=p.host,process.stderr.write(`Live URL set to ${xo(h)}.
109
- `)}else Io(o,{...m,host:h},c,u),!h&&!s&&process.stderr.write(`No live URL yet. Add one on that page.
110
- `);let $={...m,host:h,workspaceId:m.workspaceId??null,hostDeclined:!1};return oe(Mo(e),$),$}async function zn(e,t,n={}){if(!t)return null;let s=Vn();if(!s)return n.announceLocal!==!1&&process.stderr.write("This spec is only on this computer. Sign in with `npx @gruum/cli login` to publish it.\n"),null;try{let r=await Un(e,s);if(!r)return process.stderr.write(`This spec is only on this computer. It was not published.
106
+ ${w}
107
+ `),null}let h=m.host??null;if(!h&&s)for(Oo(o,{...m,host:h},c,p);!h;){let w=await au(e,n),v=await K(t,`/api/v2/cli/projects/${encodeURIComponent(m.id)}/url`,{method:"POST",body:JSON.stringify({url:w})}),d=await v.json().catch(()=>({})),u=Vn(d.project);if(!v.ok||!u?.host){process.stderr.write(`gruum: ${d.error||`couldn't save that URL (${v.status})`}
108
+ `);continue}h=u.host,process.stderr.write(`Live URL set to ${$o(h)}.
109
+ `)}else Oo(o,{...m,host:h},c,p),!h&&!s&&process.stderr.write(`No live URL yet. Add one on that page.
110
+ `);let C={...m,host:h,workspaceId:m.workspaceId??null,hostDeclined:!1};return ie(Fo(e),C),C}async function Kn(e,t,n={}){if(!t)return null;let s=zn();if(!s)return n.announceLocal!==!1&&process.stderr.write("This spec is only on this computer. Sign in with `npx @gruum/cli login` to publish it.\n"),null;try{let r=await Hn(e,s);if(!r)return process.stderr.write(`This spec is only on this computer. It was not published.
111
111
  `),null;let o=await K(s,`/api/v2/cli/projects/${encodeURIComponent(r.id)}/baseline`,{method:"POST",body:JSON.stringify({concept:"button",baseline:t})}),i=await o.json().catch(()=>({}));if(o.status===409)return process.stderr.write(`Gruum already has a published spec, so this draft was not published over it.
112
- `),await Ye(e,!1),null;let a=Ue(i.baseline);return!o.ok||!a?(process.stderr.write(`gruum: ${i.error||`couldn't publish that spec (${o.status})`}. It is only on this computer.
113
- `),null):(oe(Re(e),a),process.stdout.write(`Published it as v${a.version}.
114
- ${Fn(Lt(s),r.id)}
112
+ `),await qe(e,!1),null;let a=Ue(i.baseline);return!o.ok||!a?(process.stderr.write(`gruum: ${i.error||`couldn't publish that spec (${o.status})`}. It is only on this computer.
113
+ `),null):(ie(Re(e),a),process.stdout.write(`Published it as v${a.version}.
114
+ ${Gn(Lt(s),r.id)}
115
115
  `),a)}catch(r){if(Be(r))throw r;return process.stderr.write(`gruum: couldn't reach Gruum to publish that spec. It is only on this computer.
116
- `),null}}async function Ye(e,t){if(t)return"local";let n=Vn();if(!n)return"local";try{let s=await Un(e,n);if(!s)return"local";let r=Ot(e.repoDir),o=await K(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=Ue(i.baseline);return a?(oe(Re(e),a),oe(Ln(e),i.exceptions??{}),"remote"):"local"}catch(s){if(Be(s))throw s;return process.stderr.write(`gruum: couldn't reach Gruum. Checking the spec cached in .gruum/baseline.json.
117
- `),"local"}}async function Wn(e){let t=Vn();if(!t)return null;let n=await Un(e,t);return n?{credentials:t,project:n}:null}async function Bo(e,t,n,s){let r=await Wn(e);if(!r)return;let o=Ot(e.repoDir);if(o)try{let i=await K(r.credentials,`/api/v2/cli/projects/${encodeURIComponent(r.project.id)}/drift`,{method:"POST",body:JSON.stringify({action:"observe",concept:"button",branch:o,commit:Oo(e.repoDir),baselineVersion:n,source:s,items:t})});i.ok||process.stderr.write(`gruum: couldn't report this check (${i.status}). The local result still stands.
116
+ `),null}}async function qe(e,t){if(t)return"local";let n=zn();if(!n)return"local";try{let s=await Hn(e,n);if(!s)return"local";let r=Ot(e.repoDir),o=await K(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=Ue(i.baseline);return a?(ie(Re(e),a),ie(Tn(e),i.exceptions??{}),"remote"):"local"}catch(s){if(Be(s))throw s;return process.stderr.write(`gruum: couldn't reach Gruum. Checking the spec cached in .gruum/baseline.json.
117
+ `),"local"}}async function Jn(e){let t=zn();if(!t)return null;let n=await Hn(e,t);return n?{credentials:t,project:n}:null}async function Wo(e,t,n,s){let r=await Jn(e);if(!r)return;let o=Ot(e.repoDir);if(o)try{let i=await K(r.credentials,`/api/v2/cli/projects/${encodeURIComponent(r.project.id)}/drift`,{method:"POST",body:JSON.stringify({action:"observe",concept:"button",branch:o,commit:Do(e.repoDir),baselineVersion:n,source:s,items:t})});i.ok||process.stderr.write(`gruum: couldn't report this check (${i.status}). The local result still stands.
118
118
  `)}catch{process.stderr.write(`gruum: couldn't reach Gruum to report this check. The local result still stands.
119
- `)}}async function Fo(e,t,n){let s=await Wn(e);if(!s)return{ok:!1,text:"Sign in with gruum login before requesting an exception."};let r=Ot(e.repoDir);if(!r)return{ok:!1,text:"This folder is not on a named git branch."};try{let o=await K(s.credentials,`/api/v2/cli/projects/${encodeURIComponent(s.project.id)}/drift`,{method:"POST",body:JSON.stringify({action:"request",concept:"button",branch:r,commit:Oo(e.repoDir),reason:n,item:t})}),i=await o.json().catch(()=>({}));if(!o.ok)return{ok:!1,text:i.error||`Request failed (${o.status}).`};let a=i.reviewUrl?`${Lt(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}
120
- ${a}`:l}}catch{return{ok:!1,text:"Couldn't reach Gruum to request an exception."}}}async function Uo(e,t){let n=await Wn(e);if(!n)return{ok:!1,text:"Sign in with gruum login to see exception status."};let s=Ot(e.repoDir);try{let r=await K(n.credentials,`/api/v2/cli/projects/${encodeURIComponent(n.project.id)}/drift?concept=button&branch=${encodeURIComponent(s)}`);if(!r.ok)return{ok:!1,text:`Couldn't load exceptions (${r.status}).`};let o=await r.json(),i=Array.isArray(o.requests)?o.requests:[],a=t?i.filter(l=>l.id===t):i;return a.length===0?{ok:!0,text:t?`No exception request ${t} on ${s||"this branch"}.`:`No exception requests on ${s||"this branch"}.`}:{ok:!0,text:a.map(l=>`${l.id} ${l.status} ${l.title} (${l.branch})`).join(`
121
- `)}}catch{return{ok:!1,text:"Couldn't reach Gruum to read exception status."}}}var Nt="0.1.19",zo=`gruum ${Nt}: keep buttons on the Gruum spec
119
+ `)}}async function Go(e,t,n){let s=await Jn(e);if(!s)return{ok:!1,text:"Sign in with gruum login before requesting an exception."};let r=Ot(e.repoDir);if(!r)return{ok:!1,text:"This folder is not on a named git branch."};try{let o=await K(s.credentials,`/api/v2/cli/projects/${encodeURIComponent(s.project.id)}/drift`,{method:"POST",body:JSON.stringify({action:"request",concept:"button",branch:r,commit:Do(e.repoDir),reason:n,item:t})}),i=await o.json().catch(()=>({}));if(!o.ok)return{ok:!1,text:i.error||`Request failed (${o.status}).`};let a=i.reviewUrl?`${Lt(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}
120
+ ${a}`:l}}catch{return{ok:!1,text:"Couldn't reach Gruum to request an exception."}}}async function Ho(e,t){let n=await Jn(e);if(!n)return{ok:!1,text:"Sign in with gruum login to see exception status."};let s=Ot(e.repoDir);try{let r=await K(n.credentials,`/api/v2/cli/projects/${encodeURIComponent(n.project.id)}/drift?concept=button&branch=${encodeURIComponent(s)}`);if(!r.ok)return{ok:!1,text:`Couldn't load exceptions (${r.status}).`};let o=await r.json(),i=Array.isArray(o.requests)?o.requests:[],a=t?i.filter(l=>l.id===t):i;return a.length===0?{ok:!0,text:t?`No exception request ${t} on ${s||"this branch"}.`:`No exception requests on ${s||"this branch"}.`}:{ok:!0,text:a.map(l=>`${l.id} ${l.status} ${l.title} (${l.branch})`).join(`
121
+ `)}}catch{return{ok:!1,text:"Couldn't reach Gruum to read exception status."}}}var Nt="0.1.20",Ko=`gruum ${Nt}: keep buttons on the Gruum spec
122
122
 
123
123
  Run it as \`npx @gruum/cli <command>\`.
124
124
 
@@ -147,36 +147,36 @@ Usage:
147
147
  gruum mcp
148
148
  Stdio MCP server: gruum_button_spec, gruum_check_buttons,
149
149
  gruum_request_exception, and gruum_exception_status.
150
- `,ou=new Set(["--baseline","--root","--out","--cli","--files"]);function Kn(e){let t=[],n=new Map;for(let s=0;s<e.length;s++){let r=e[s];if(!r.startsWith("--")){t.push(r);continue}let o=r.indexOf("="),i=o===-1?r:r.slice(0,o),a=o===-1?void 0:r.slice(o+1),l=n.get(i)??[];if(a!==void 0)l.push(a);else if(i==="--files")for(;e[s+1]&&!e[s+1].startsWith("--");)l.push(e[++s]);else ou.has(i)&&e[s+1]!==void 0&&l.push(e[++s]);n.set(i,l)}return{positional:t,flags:n}}var V=(e,t)=>e.flags.has(t),te=(e,t)=>e.flags.get(t)?.[0];function De(e,t=process.cwd()){let n=Pn(t),s=te(e,"--root")??Mn(n).root??"";return Pn(t,s)}var Qe="No spec found. Publish one from Gruum, or draft one locally with `npx @gruum/cli baseline --write`.";function iu(e,t){let n=ge(e,te(t,"--baseline"));return n||process.stderr.write(`gruum: ${Qe}
151
- `),n}function et(e,t,n){let s={...t,checkedAt:new Date().toISOString(),baselineVersion:n.baseline.version,items:n.items};return On(e,s),s}async function Jn(e,t){let n=Hn({input:process.stdin,output:process.stdout});Ae(n);try{for(;;){let s=await new Promise(o=>{n.question(e,o)}),r=t(s);if(r)return r;process.stdout.write(`Enter one of the letters in the question.
152
- `)}}finally{n.close()}}function Wo(e){return!!process.stdin.isTTY&&!V(e,"--ci")&&!V(e,"--json")&&!V(e,"--staged")}async function Ho(e){if(!process.stdin.isTTY||!Te(D.join(e.repoDir,".cursor")))return;let t=Ce(D.join(e.repoDir,".cursor/hooks.json")),n=Ce(D.join(e.repoDir,".cursor/mcp.json"));if(!bs(t,n))return;let s=Te(D.join(e.repoDir,".claude"));await Jn(Ps(s),Ls)==="yes"&&Zo(Kn(["init","cursor"]))}async function Ko(e,t=!1){let n=De(e);await Ye(n,V(e,"--baseline"));let s=ge(n,te(e,"--baseline"));if(s?.version===0&&!t&&!V(e,"--baseline")){let u=await zn(n,s,{announceLocal:!1});u&&(s=u)}if(!s){if(!t&&Wo(e)){if(await Jn(js,Ms)!=="baseline")return 0;let f=["baseline","--write"],m=te(e,"--root");m&&f.push("--root",m);let h=await Jo(Kn(f),!1);return h!==0?h:Ko(e,!0)}return process.stderr.write(`gruum: ${Qe}
153
- `),0}let r=$e(n,s,{staged:V(e,"--staged")});V(e,"--staged")||et(n,jt(n),r);let o=(e.flags.get("--files")??[]).map(u=>D.relative(D.join(n.repoDir,n.root),D.resolve(u)).split(D.sep).join("/")),i=zt(r.items,o),a=Pt(n);(V(e,"--ci")||V(e,"--report"))&&await Bo(n,i,s.version,V(e,"--ci")?"ci":"local"),V(e,"--json")?process.stdout.write(`${JSON.stringify({baselineVersion:s.version,items:i,exceptions:a},null,2)}
154
- `):process.stdout.write(`${cs(i,{baselineVersion:s.version,files:r.result.index.files,skipped:r.result.index.skipped},a)}
155
- `);let l=ze(i,a),c=l.length>0?1:0;if(V(e,"--strict")){let u=i.some(f=>f.severity==="block"&&a[f.id]==="pending");c=l.length>0||u?1:0}else if(V(e,"--ci")&&l.length===0){let u=i.filter(f=>a[f.id]==="pending");u.length>0&&process.stdout.write(`${u.length} pending exception${u.length===1?"":"s"}; this run does not fail on them.
156
- `)}return Wo(e)&&await Ho(n),c}async function au(e){let t=De(e);await Ye(t,V(e,"--baseline"));let n=iu(t,e);return n?(process.stdout.write(`${JSON.stringify(Ut(n),null,2)}
157
- `),0):1}async function Jo(e,t=!0){if(!V(e,"--write"))return process.stderr.write(`gruum: pass --write to draft a spec from the working tree.
158
- `),2;let n=De(e),s=Et(n),r=as(s,{version:0}),o=te(e,"--out")?D.resolve(te(e,"--out")):Re(n);oe(o,r);let i=D.relative(process.cwd(),o)||o;process.stdout.write(`Drafted a spec from ${s.index.files} files: ${r.styles.length} styles, ${r.tokens.length} tokens, ${r.rules.length} rules, ${r.acceptedFindings.length} accepted findings.
150
+ `,cu=new Set(["--baseline","--root","--out","--cli","--files"]);function qn(e){let t=[],n=new Map;for(let s=0;s<e.length;s++){let r=e[s];if(!r.startsWith("--")){t.push(r);continue}let o=r.indexOf("="),i=o===-1?r:r.slice(0,o),a=o===-1?void 0:r.slice(o+1),l=n.get(i)??[];if(a!==void 0)l.push(a);else if(i==="--files")for(;e[s+1]&&!e[s+1].startsWith("--");)l.push(e[++s]);else cu.has(i)&&e[s+1]!==void 0&&l.push(e[++s]);n.set(i,l)}return{positional:t,flags:n}}var F=(e,t)=>e.flags.has(t),ne=(e,t)=>e.flags.get(t)?.[0];function De(e,t=process.cwd()){let n=Nn(t),s=ne(e,"--root")??Fn(n).root??"";return Nn(t,s)}var Ye="No spec found. Publish one from Gruum, or draft one locally with `npx @gruum/cli baseline --write`.";function uu(e,t){let n=he(e,ne(t,"--baseline"));return n||process.stderr.write(`gruum: ${Ye}
151
+ `),n}function Qe(e,t,n){let s={...t,checkedAt:new Date().toISOString(),baselineVersion:n.baseline.version,items:n.items};return Dn(e,s),s}async function Yn(e,t){let n=Xn({input:process.stdin,output:process.stdout});Ae(n);try{for(;;){let s=await new Promise(o=>{n.question(e,o)}),r=t(s);if(r)return r;process.stdout.write(`Enter one of the letters in the question.
152
+ `)}}finally{n.close()}}function Jo(e){return!!process.stdin.isTTY&&!F(e,"--ci")&&!F(e,"--json")&&!F(e,"--staged")}async function Xo(e){if(!process.stdin.isTTY||!Te(T.join(e.repoDir,".cursor")))return;let t=Se(T.join(e.repoDir,".cursor/hooks.json")),n=Se(T.join(e.repoDir,".cursor/mcp.json"));if(!ks(t,n))return;let s=Te(T.join(e.repoDir,".claude"));await Yn(Ns(s),Ts)==="yes"&&Qo(qn(["init","cursor"]))}async function qo(e,t=!1){let n=De(e);await qe(n,F(e,"--baseline"));let s=he(n,ne(e,"--baseline"));if(s?.version===0&&!t&&!F(e,"--baseline")){let p=await Kn(n,s,{announceLocal:!1});p&&(s=p)}if(!s){if(!t&&Jo(e)){if(await Yn(Ms,Fs)!=="baseline")return 0;let f=["baseline","--write"],m=ne(e,"--root");m&&f.push("--root",m);let h=await Yo(qn(f),!1);return h!==0?h:qo(e,!0)}return process.stderr.write(`gruum: ${Ye}
153
+ `),0}let r=Ce(n,s,{staged:F(e,"--staged")});F(e,"--staged")||Qe(n,jt(n),r);let o=(e.flags.get("--files")??[]).map(p=>T.relative(T.join(n.repoDir,n.root),T.resolve(p)).split(T.sep).join("/")),i=zt(r.items,o),a=Pt(n);(F(e,"--ci")||F(e,"--report"))&&await Wo(n,i,s.version,F(e,"--ci")?"ci":"local"),F(e,"--json")?process.stdout.write(`${JSON.stringify({baselineVersion:s.version,items:i,exceptions:a},null,2)}
154
+ `):process.stdout.write(`${ds(i,{baselineVersion:s.version,files:r.result.index.files,skipped:r.result.index.skipped},a)}
155
+ `);let l=ze(i,a),c=l.length>0?1:0;if(F(e,"--strict")){let p=i.some(f=>f.severity==="block"&&a[f.id]==="pending");c=l.length>0||p?1:0}else if(F(e,"--ci")&&l.length===0){let p=i.filter(f=>a[f.id]==="pending");p.length>0&&process.stdout.write(`${p.length} pending exception${p.length===1?"":"s"}; this run does not fail on them.
156
+ `)}return Jo(e)&&await Xo(n),c}async function pu(e){let t=De(e);await qe(t,F(e,"--baseline"));let n=uu(t,e);return n?(process.stdout.write(`${JSON.stringify(Ut(n),null,2)}
157
+ `),0):1}async function Yo(e,t=!0){if(!F(e,"--write"))return process.stderr.write(`gruum: pass --write to draft a spec from the working tree.
158
+ `),2;let n=De(e),s=Et(n),r=ps(s,{version:0}),o=ne(e,"--out")?T.resolve(ne(e,"--out")):Re(n);ie(o,r);let i=T.relative(process.cwd(),o)||o;process.stdout.write(`Drafted a spec from ${s.index.files} files: ${r.styles.length} styles, ${r.tokens.length} tokens, ${r.rules.length} rules, ${r.acceptedFindings.length} accepted findings.
159
159
  Wrote ${i}.
160
- `);let a=await zn(n,r);return a&&o!==Re(n)&&oe(o,a),a&&t&&await Ho(n),0}function Go(e,t,n,s){if(!n.ok)return process.stderr.write(`gruum: ${n.error}
161
- `),!1;if(!n.changed)return s.push(`unchanged ${t}`),!0;let r=D.join(e.repoDir,t);return n.text===""?(Gn(r,{force:!0}),s.push(`removed ${t}`)):(Se(r,n.text),s.push(`wrote ${t}`)),!0}function Zo(e){if(e.positional[1]!=="cursor")return process.stderr.write(`gruum: usage: gruum init cursor [--remove] [--force] [--cli "<command>"]
162
- `),2;let t=De(e),n=te(e,"--cli")??We,s=V(e,"--remove"),r=w=>Ce(D.join(t.repoDir,w)),o=[],i=s?ys(r(".cursor/hooks.json")):Kt(r(".cursor/hooks.json"),n),a=s?xs(r(".cursor/mcp.json")):Jt(r(".cursor/mcp.json"),n);for(let w of[i,a])if(!w.ok)return process.stderr.write(`gruum: ${w.error}
163
- `),1;Go(t,".cursor/hooks.json",i,o),Go(t,".cursor/mcp.json",a,o);let l=r(me);if(s)l!==null&&$s(l)&&(Gn(D.join(t.repoDir,me)),o.push(`removed ${me}`));else if(l===null||V(e,"--force")){let w=ge(t,te(e,"--baseline")),g=ks(w?null:lu(t)),p=w?[...new Set(w.styles.map(d=>d.path))].sort():[];Se(D.join(t.repoDir,me),vs(p.length?p:g)),o.push(`wrote ${me}`)}else o.push(`kept ${me} (exists; --force replaces it)`);let c=s?Cs(r(".gitignore")):ot(r(".gitignore"));c.changed&&(Se(D.join(t.repoDir,".gitignore"),c.text),o.push("wrote .gitignore"));let u=Te(D.join(t.repoDir,".husky")),f=["lefthook.yml","lefthook.yaml",".lefthook.yml"].some(w=>Te(D.join(t.repoDir,w))),m=lo(t),h=u?".husky/pre-commit":m?`${m}/pre-commit`:null,$=h?D.resolve(t.repoDir,h):null,k=$?Ce($):null;if(s){if($&&k!==null){let w=As(k);w.changed&&w.text===""?(Gn($,{force:!0}),o.push(`removed ${h}`)):w.changed&&(Se($,w.text),o.push(`edited ${h}`))}}else{let w=Ss({husky:u,lefthook:f,hookText:k,gitHooksDir:m},n);if(w.kind==="print")o.push(`pre-commit ${w.reason}:
164
- ${w.snippet}`);else if(w.changed&&$){if(Se($,w.text),w.kind==="git")try{ru($,493)}catch{}o.push(`wrote ${h}${w.kind==="git"?" (local only; not shared through git)":""}`)}else o.push(`unchanged ${h}`)}return process.stdout.write(`${o.join(`
160
+ `);let a=await Kn(n,r);return a&&o!==Re(n)&&ie(o,a),a&&t&&await Xo(n),0}function Zo(e,t,n,s){if(!n.ok)return process.stderr.write(`gruum: ${n.error}
161
+ `),!1;if(!n.changed)return s.push(`unchanged ${t}`),!0;let r=T.join(e.repoDir,t);return n.text===""?(Zn(r,{force:!0}),s.push(`removed ${t}`)):(me(r,n.text),s.push(`wrote ${t}`)),!0}function Qo(e){if(e.positional[1]!=="cursor")return process.stderr.write(`gruum: usage: gruum init cursor [--remove] [--force] [--cli "<command>"]
162
+ `),2;let t=De(e),n=ne(e,"--cli"),s=n??nt,r=n??Jt,o=F(e,"--remove"),i=u=>Se(T.join(t.repoDir,u)),a=[],l=o?vs(i(".cursor/hooks.json")):Zt(i(".cursor/hooks.json"),s),c=o?$s(i(".cursor/mcp.json")):Xt(i(".cursor/mcp.json"),r);for(let u of[l,c])if(!u.ok)return process.stderr.write(`gruum: ${u.error}
163
+ `),1;Zo(t,".cursor/hooks.json",l,a),Zo(t,".cursor/mcp.json",c,a);let p=i(q);if(o)p!==null&&Yt(p)&&(Zn(T.join(t.repoDir,q)),a.push(`removed ${q}`));else if(p===null||F(e,"--force")){let u=he(t,ne(e,"--baseline")),g=Rs(u?null:fu(t)),y=u?[...new Set(u.styles.map(k=>k.path))].sort():[];me(T.join(t.repoDir,q),qt(y.length?y:g)),a.push(`wrote ${q}`)}else if(Yt(p)){let u=As(p);u.changed?(me(T.join(t.repoDir,q),u.text),a.push(`wrote ${q}`)):a.push(`unchanged ${q}`)}else a.push(`kept ${q} (exists; --force replaces it)`);let f=o?_s(i(".gitignore")):ot(i(".gitignore"));f.changed&&(me(T.join(t.repoDir,".gitignore"),f.text),a.push("wrote .gitignore"));let m=Te(T.join(t.repoDir,".husky")),h=["lefthook.yml","lefthook.yaml",".lefthook.yml"].some(u=>Te(T.join(t.repoDir,u))),C=fo(t),w=m?".husky/pre-commit":C?`${C}/pre-commit`:null,v=w?T.resolve(t.repoDir,w):null,d=v?Se(v):null;if(o){if(v&&d!==null){let u=js(d);u.changed&&u.text===""?(Zn(v,{force:!0}),a.push(`removed ${w}`)):u.changed&&(me(v,u.text),a.push(`edited ${w}`))}}else{let u=Es({husky:m,lefthook:h,hookText:d,gitHooksDir:C},s);if(u.kind==="print")a.push(`pre-commit ${u.reason}:
164
+ ${u.snippet}`);else if(u.changed&&v){if(me(v,u.text),u.kind==="git")try{lu(v,493)}catch{}a.push(`wrote ${w}${u.kind==="git"?" (local only; not shared through git)":""}`)}else a.push(`unchanged ${w}`)}return process.stdout.write(`${a.join(`
165
165
  `)}
166
- `),s||process.stdout.write(`
166
+ `),o||process.stdout.write(`
167
167
  Commit the .cursor/ files so teammates get the same guardrails. Tokens never go in the repository.
168
- `),0}function lu(e){try{return Et(e)}catch{return null}}async function cu(){if(process.stdin.isTTY)return{};let e=[];for await(let t of process.stdin)e.push(t);try{let t=JSON.parse(Buffer.concat(e).toString("utf8")||"{}");return t&&typeof t=="object"?t:{}}catch{return{}}}function uu(e){let t=e.workspace_roots,n=Array.isArray(t)&&typeof t[0]=="string"&&Te(t[0])?t[0]:typeof e.cwd=="string"&&Te(e.cwd)?e.cwd:process.cwd();return De({positional:[],flags:new Map},n)}async function pu(e){let t=e.positional[1],n=await cu(),s=t==="before-shell"?{permission:"allow"}:{};try{let r=uu(n),o=Mn(r),i={...o.hooks,exceptions:!0},a=ge(r),l=jt(r),c=Pt(r),u=s;if(t==="after-file-edit"){let f=typeof n.file_path=="string"?n.file_path:"",m=Yt(D.relative(r.repoDir,D.resolve(r.repoDir,f)).split(D.sep).join("/"),r.root);a&&m!==null&&Bs(m)&&et(r,l,$e(r,a))}else if(t==="stop"){if(a){let f=et(r,l,$e(r,a)),m=gs(f,n,i,c);On(r,m.ledger),u=m.output}}else if(t==="before-shell"){let f=typeof n.command=="string"?n.command:"",m=Gt(f).some(h=>o.hooks.denyGit.includes(h));if(a&&m){let h=et(r,l,$e(r,a));u=ms(h,n,i,c)}}else return process.stderr.write(`gruum: unknown hook ${String(t)}
169
- `),2;process.stdout.write(`${JSON.stringify(u)}
168
+ `),0}function fu(e){try{return Et(e)}catch{return null}}async function du(){if(process.stdin.isTTY)return{};let e=[];for await(let t of process.stdin)e.push(t);try{let t=JSON.parse(Buffer.concat(e).toString("utf8")||"{}");return t&&typeof t=="object"?t:{}}catch{return{}}}function gu(e){let t=e.workspace_roots,n=Array.isArray(t)&&typeof t[0]=="string"&&Te(t[0])?t[0]:typeof e.cwd=="string"&&Te(e.cwd)?e.cwd:process.cwd();return De({positional:[],flags:new Map},n)}async function mu(e){let t=e.positional[1],n=await du(),s=t==="before-shell"?{permission:"allow"}:{};try{let r=gu(n),o=Fn(r),i={...o.hooks,exceptions:!0},a=he(r),l=jt(r),c=Pt(r),p=s;if(t==="after-file-edit"){let f=typeof n.file_path=="string"?n.file_path:"",m=nn(T.relative(r.repoDir,T.resolve(r.repoDir,f)).split(T.sep).join("/"),r.root);a&&m!==null&&Ws(m)&&Qe(r,l,Ce(r,a))}else if(t==="stop"){if(a){let f=Qe(r,l,Ce(r,a)),m=ys(f,n,i,c);Dn(r,m.ledger),p=m.output}}else if(t==="before-shell"){let f=typeof n.command=="string"?n.command:"",m=Ht(f).some(h=>o.hooks.denyGit.includes(h));if(a&&m){let h=Qe(r,l,Ce(r,a));p=xs(h,n,i,c)}}else return process.stderr.write(`gruum: unknown hook ${String(t)}
169
+ `),2;process.stdout.write(`${JSON.stringify(p)}
170
170
  `)}catch(r){process.stderr.write(`gruum hook ${t}: ${r instanceof Error?r.message:String(r)}
171
171
  `),process.stdout.write(`${JSON.stringify(s)}
172
- `)}return 0}async function fu(e){let t=De(e),n=Ts({spec:async()=>{let o=ge(t,te(e,"--baseline"));return o?{text:JSON.stringify(Ut(o),null,2)}:{text:Qe,isError:!0}},check:async o=>{let i=ge(t,te(e,"--baseline"));if(!i)return{text:Qe,isError:!0};let a=$e(t,i);et(t,jt(t),a);let l=zt(a.items,o);return{text:JSON.stringify({baselineVersion:i.version,blocking:ze(l,Pt(t)).length,items:l},null,2)}},request:async(o,i)=>{await Ye(t,!1);let a=ge(t);if(!a)return{text:Qe,isError:!0};let c=$e(t,a).items.find(f=>f.id===o);if(!c)return{text:`No drift item ${o}. Run gruum_check_buttons and use an id from that list.`,isError:!0};let u=await Fo(t,c,i);return{text:u.text,isError:!u.ok}},status:async o=>{let i=await Uo(t,o);return{text:i.text,isError:!i.ok}}}),s={name:"gruum",version:Nt},r=Hn({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"}})}
173
- `);continue}let a=await Ds(i,n,s);a&&process.stdout.write(`${JSON.stringify(a)}
174
- `)}return 0}async function du(){if(process.stdout.write(_s(Nt)),!process.stdin.isTTY)return process.stdout.write(`
172
+ `)}return 0}async function hu(e){let t=De(e),n=Vs({spec:async()=>{let o=he(t,ne(e,"--baseline"));return o?{text:JSON.stringify(Ut(o),null,2)}:{text:Ye,isError:!0}},check:async o=>{let i=he(t,ne(e,"--baseline"));if(!i)return{text:Ye,isError:!0};let a=Ce(t,i);Qe(t,jt(t),a);let l=zt(a.items,o);return{text:JSON.stringify({baselineVersion:i.version,blocking:ze(l,Pt(t)).length,items:l},null,2)}},request:async(o,i)=>{await qe(t,!1);let a=he(t);if(!a)return{text:Ye,isError:!0};let c=Ce(t,a).items.find(f=>f.id===o);if(!c)return{text:`No drift item ${o}. Run gruum_check_buttons and use an id from that list.`,isError:!0};let p=await Go(t,c,i);return{text:p.text,isError:!p.ok}},status:async o=>{let i=await Ho(t,o);return{text:i.text,isError:!i.ok}}}),s={name:"gruum",version:Nt},r=Xn({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"}})}
173
+ `);continue}let a=await Us(i,n,s);a&&process.stdout.write(`${JSON.stringify(a)}
174
+ `)}return 0}async function bu(){if(process.stdout.write(Ps(Nt)),!process.stdin.isTTY)return process.stdout.write(`
175
175
  ${Ee.map(n=>n.usage).join(`
176
176
  `)}
177
- `),0;let e=Hn({input:process.stdin,output:process.stdout});Ae(e);let t=null;try{for(;;){let n=await new Promise(s=>{e.question(Es,s)});if(t=Ns(n),t==="quit"||t)break;process.stdout.write(`Enter 1, 2, or 3.
178
- `)}}finally{e.close()}return!t||t==="quit"?0:Mt([t.name,...t.args])}async function Mt(e){let t=Kn(e),n=t.positional[0];if(V(t,"--version"))return process.stdout.write(`${Nt}
179
- `),0;if(V(t,"--help")||n==="help")return process.stdout.write(zo),0;switch(n){case"login":{let s=await Vo();if(s!==0||!process.stdin.isTTY)return s;let r=await Jn(Is,Os);return r==="check"?Mt(["check"]):r==="baseline"?Mt(["baseline","--write"]):0}case"check":return Ko(t);case"spec":return au(t);case"baseline":return Jo(t);case"init":return Zo(t);case"hook":return pu(t);case"mcp":return fu(t);case void 0:return du();default:return process.stderr.write(`gruum: unknown command ${n}
177
+ `),0;let e=Xn({input:process.stdin,output:process.stdout});Ae(e);let t=null;try{for(;;){let n=await new Promise(s=>{e.question(Ls,s)});if(t=Bs(n),t==="quit"||t)break;process.stdout.write(`Enter 1, 2, or 3.
178
+ `)}}finally{e.close()}return!t||t==="quit"?0:Mt([t.name,...t.args])}async function Mt(e){let t=qn(e),n=t.positional[0];if(F(t,"--version"))return process.stdout.write(`${Nt}
179
+ `),0;if(F(t,"--help")||n==="help")return process.stdout.write(Ko),0;switch(n){case"login":{let s=await zo();if(s!==0||!process.stdin.isTTY)return s;let r=await Yn(Os,Ds);return r==="check"?Mt(["check"]):r==="baseline"?Mt(["baseline","--write"]):0}case"check":return qo(t);case"spec":return pu(t);case"baseline":return Yo(t);case"init":return Qo(t);case"hook":return mu(t);case"mcp":return hu(t);case void 0:return bu();default:return process.stderr.write(`gruum: unknown command ${n}
180
180
 
181
- ${zo}`),2}}Mt(process.argv.slice(2)).then(e=>{process.exitCode=e},e=>{Be(e)&&process.exit(130),process.stderr.write(`gruum: ${e instanceof Error?e.message:String(e)}
181
+ ${Ko}`),2}}Mt(process.argv.slice(2)).then(e=>{process.exitCode=e},e=>{Be(e)&&process.exit(130),process.stderr.write(`gruum: ${e instanceof Error?e.message:String(e)}
182
182
  `),process.exitCode=1});