@gruum/cli 0.2.5 → 0.2.7

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 +254 -101
  2. package/package.json +1 -1
package/gruum.mjs CHANGED
@@ -1,128 +1,275 @@
1
1
  #!/usr/bin/env node
2
- import{chmodSync as gu,existsSync as De,rmSync as Xn}from"node:fs";import T from"node:path";import{createInterface as Yn}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 _e(e){e.on("SIGINT",()=>{process.stderr.write(`
3
- `),process.exit(130)})}var ui=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"]),pi=new Set(["page","index","layout","route","default"]);function fi(e){return ui.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=>!fi(n)).map(n=>`${t.state}|${t.context}|${n.property}:${n.value}`)).sort().join(";")}function di(e){return Fe(e.states)}function gi(e){return e.states.filter(t=>t.state==="default"&&t.context==="").flatMap(t=>t.declarations)}function rs(e){return e.charAt(0).toUpperCase()+e.slice(1)}function mi(e){let t=e.via?/^bg-([\w-]+?)(?:\/(\d+))?$/.exec(e.via):null;if(t){let s=t[1].replace(/-/g," ");return rs(t[2]?`${s} ${t[2]}%`:s)}let n=/var\(\s*--(?:color-)?([\w-]+)/.exec(e.value)?.[1];return rs((n??e.value).replace(/-/g," "))}function hi(e){let t=gi(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?`${mi(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 bi(e){let t=e.split("/"),n=(t.pop()??e).replace(/\.[^.]+$/,""),s=t.pop();return pi.has(n)&&s?`${s}/${n}`:n}function yi(e){let t=[...new Set(e.map(s=>bi(s.path)))],n=t.slice(0,2).join(", ");return t.length>2?`${n} +${t.length-2}`:n}var os=(e,t)=>e.path.localeCompare(t.path)||e.line-t.line;function is(e){let t=new Map;for(let r of e){let o=hi(r.variant),i=t.get(o)??new Map,a=di(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(os);i.sort((h,w)=>w.sites.length-h.sites.length||os(h.sites[0],w.sites[0]));let[a,...l]=i,c=a.looks[0],u=l.map(h=>yi(h.sites)),f=l.map((h,w)=>{let C=h.looks[0],g={title:u.filter(p=>p===u[w]).length>1?`${u[w]} \xB7 line ${h.sites[0].line}`:u[w],selector:C.selector,path:h.sites[0].path,line:h.sites[0].line,element:C.element,usage:C.usage,states:C.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,places:a.sites.map(h=>({path:h.path,line:h.line})),...f.length?{modifiers:f}:{}};s.set(m,a.sites),n.push(m)}return{variants:n,sites:s}}var ls=1,cs=["style.new","state.changed","state.missing","token.unknown","value.hardcoded","native.element","prop.unknown","style.removed","guidance.rule"],Vt={"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 zt(e){let t=0;for(let n=0;n<e.length;n++)t=t*33+e.charCodeAt(n)>>>0;return t.toString(36)}function as(e){let t=`${e.path}::${e.selector}`;return`v2-style-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48)}-${zt(t)}`}function le(e){return e.context?`${e.state} @ ${e.context}`:e.state}var xi=/var\(\s*(--[\w-]+)/g;function ki(e){let t=new Set;for(let n of e)for(let s of n.declarations)for(let r of s.value.matchAll(xi))t.add(r[1]);return[...t].sort()}function wi(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 vi(e){let t=new Map;for(let n of e){let s=le(n),r=t.get(s),o=wi([...r?.declarations??[],...n.declarations]);t.set(s,{state:n.state,context:n.context,declarations:o})}return[...t.values()]}function $i(e){let t=[{path:e.path,line:e.line},...e.places??[]],n=new Set;return t.filter(s=>{let r=`${s.path}:${s.line}`;return n.has(r)?!1:(n.add(r),!0)})}function us(e){let t=new Map,n=(s,r,o)=>{let i=as(s),a=t.get(i),l=vi([...a?Ci(a.states):[],...r]),c=a?.stateLines??new Map;for(let u of r)c.has(le(u))||c.set(le(u),u.line);t.set(i,{...a??s,id:i,states:l,tokens:ki(l),line:a?.line??o,stateLines:c})};for(let s of e){let r=as(s);if(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),s.places?.length){let o=t.get(r);o&&(o.places=s.places)}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 Ci(e){return e.map(t=>({state:t.state,context:t.context,line:0,declarations:t.declarations}))}function Si(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 Ft=/^(\d+) native /;function Ri(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"},Ai=new Set(Object.values(nt));function ps(e){let t=e.find(n=>n.toLowerCase()==="button");return t||(e.length===1?e[0]:null)}var _i={"value.hardcoded":()=>"Replace each literal with the spec token named, or with a spec token for that property.","native.element":e=>{let t=ps(e.components);return t?`Render ${t} instead of a raw <button>, or ask for an exception.`:"Use a spec button 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 fs(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:Ri(n.id,s)});return t}function Tt(e){return`${e.path}#${zt(e.text.replace(/\s+/g," ").trim())}`}function ds(e,t={}){let n=Si(e.previewCss),s=[...us(e.variants).values()].map(({line:i,stateLines:a,places:l,...c})=>c),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:ls,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:fs(e).filter(({check:i})=>i in nt).map(({check:i,finding:a,key:l})=>({check:i,key:l,message:a.message})),settings:{severity:{...Vt,...t.settings?.severity??{}}}}}function Ei(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 Ut(e){return e.map(t=>`${t.property}: ${t.value}`).join("; ")}function Bt(e,t){return e.length>t?`${e.slice(0,t).join(", ")}, and ${e.length-t} more`:e.join(", ")}function Ii(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 gs(e,t){let n={...Vt,...t.settings.severity},s=[],r=(p,d="")=>{s.push({id:`${p.kind}:${zt(`${p.styleId??""}|${p.state??""}|${d}`)}`,severity:n[p.kind],...p})},o=us(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(R=>R.markup):a,k=y.filter(R=>R.path===p.path),x=(k.length?k:y).map(h),v=p.markup?`This one-off ${p.element??"button"} (${Bt((p.states[0]?.declarations??[]).map(R=>`${R.property}: ${R.value}`),3)})`:p.selector,I=ps(t.components),j=p.markup?I?`render ${I} with a spec look,`:x.length?`copy ${Bt(x,3)},`:"use a spec style,":d?`restyle ${d.selector} only through spec modifiers`:x.length?`use ${Bt(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:$i(p),fix:`${v} 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(k=>[le(k),k]));for(let k of p.states){let x=le(k),v=y.get(x),I=Ei(v?.declarations??[],k.declarations);I.length!==0&&r({kind:"state.changed",styleId:p.id,title:v?`${p.title}: ${x} changed`:`${p.title}: new ${x} state`,state:x,baseline:v?{declarations:v.declarations}:null,observed:{declarations:k.declarations},refs:[{path:p.path,line:p.stateLines.get(x)??p.line}],fix:v?`Restore ${p.selector} ${x} to the spec (${I.slice(0,3).join("; ")}), or ask for an exception.`:`${x} is not a spec state of ${p.selector}; remove it, or ask for an exception.`},Ut(k.declarations))}}for(let p of o.values()){let d=i.get(p.id);if(!d)continue;let y=new Set(p.states.map(le));for(let k of d.states){let x=le(k);y.has(x)||r({kind:"state.missing",styleId:p.id,title:`${p.title}: ${x} state is missing`,state:x,baseline:{declarations:k.declarations},observed:null,refs:[{path:p.path,line:p.line}],fix:`Define ${p.selector} ${x} again: ${Ut(k.declarations)||"as in the spec"}.`})}}for(let p of o.values())for(let d of p.tokens){if(l.has(d))continue;let y=Ii(d,c);r({kind:"token.unknown",styleId:p.id,title:`${p.title} reads ${d}, which is not a spec token`,baseline:null,observed:{token:d},refs:[{path:p.path,line:p.line}],fix:y.length?`Use a spec token such as ${y.join(", ")} instead of ${d}, or ask for an exception.`:`${d} is not a spec token; ask for an exception to add it.`},d)}let w=new Map;for(let p of t.acceptedFindings)w.set(p.key,[...w.get(p.key)??[],p]);let C=fs(e).filter(({check:p})=>p in nt);for(let p of cs)if(Ai.has(p))for(let{check:d,finding:y,key:k}of C){if(nt[d]!==p)continue;let x=w.get(k)??[];if(x.some(R=>!ji(d,R.message,y.message)))continue;let v=x[0],I=y.styles?.[0],j=I?[...o.values()].find(R=>R.title===I):void 0;if(p==="native.element"){let R=y.refs[0]?.path??"",A=Number(Ft.exec(y.message)?.[1]??"1");if(s.filter(N=>N.kind==="style.new"&&N.observed?.markup===!0&&N.refs.some(V=>V.path===R)).length>=A)continue}r({kind:p,styleId:j?.id??null,title:y.message,baseline:v?{message:v.message}:null,observed:{message:y.message,...p==="native.element"?{element:"button"}:{}},waiverKey:k,refs:y.refs.map(({path:R,line:A})=>({path:R,line:A})),fix:_i[p](t)},k)}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 $=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=$.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 ji(e,t,n){if(t===n)return!1;if(e==="native"){let s=Ft.exec(t)?.[1],r=Ft.exec(n)?.[1];if(s&&r)return Number(r)>Number(s)}return!0}var Pi={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. After they choose review, call gruum_request_exception, or run `npx @gruum/cli request <drift id> --reason "..."`. Never edit generated Gruum files, including .gruum/project.json, to make a check pass.']};function Wt(e){let t=(n,s)=>e.styles.filter(r=>r.hostId===n&&r.kind===s).map(r=>r.selector);return{about:{...Pi,drift:cs.map(n=>({kind:n,severity:e.settings.severity[n]??Vt[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),Ut(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!==ls||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 Li(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 Gt(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 ms(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 Li(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 hs(e){return{schema:1,checkedAt:e,baselineVersion:null,items:[],followups:{}}}function bs(e,t){if(!e||typeof e!="object")return hs(t);let n=e;return n.schema!==1||!Array.isArray(n.items)?hs(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 Ve={exceptions:!1,denyGit:[],maxFollowups:2};function ys(e){let t=e?.block===!0,n=Array.isArray(e?.denyGit)?e.denyGit.filter(r=>r==="commit"||r==="push"):t?["commit","push"]:Ve.denyGit,s=typeof e?.maxFollowups=="number"&&e.maxFollowups>=0?Math.floor(e.maxFollowups):Ve.maxFollowups;return{block:t,hooks:{...Ve,denyGit:n,maxFollowups:s}}}var Ht=8;function xs(e){let t=e.slice(0,Ht).map(n=>{let s=n.refs[0],r=s?` (${s.path}${s.line?`:${s.line}`:""})`:"";return`- ${n.title}${r}. ${n.fix}`});return e.length>Ht&&t.push(`- and ${e.length-Ht} more; run \`gruum check\`.`),t.join(`
6
- `)}var Kt="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 ks(e){let t="If gruum_button_spec is not available, read .gruum/baseline.json. Do not search the computer for a gruum program, and do not read the CLI package.",n=`Ask the user before you do anything else: "${Kt}" If they choose 1, restyle it to a spec look (call gruum_button_spec).`,s=e.exceptions?'If they choose 2, keep it and call gruum_request_exception with the drift id and a reason. If that tool is not available, run `npx @gruum/cli request <drift id> --reason "..."`. Do not request a review until they choose 2. Do not edit .gruum files.':"If they choose 2, stop and tell the developer which review you need. Do not invent a style.";return`${n} ${s} ${t}`}function ws(e,t,n=Ve,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
- ${xs(r)}
8
-
9
- ${ks(n)}`},ledger:{...e,followups:{...e.followups,[o]:i+1}}}}function Jt(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 vs(e,t,n=Ve,s={}){let r=Jt(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
- ${xs(o)}
11
-
12
- ${ks(n)}`}}var We="npx --no-install @gruum/cli",Cs="npx --yes @gruum/cli",qt="npx --yes @gruum/cli",$s={afterFileEdit:"after-file-edit",stop:"stop",beforeShellExecution:"before-shell"},Oi=/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+hook\s+(after-file-edit|stop|before-shell)\s*$/;function Zt(e){return typeof e=="string"&&Oi.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 Ss(e,t){let n=Xt(e),s=Yt(t);return!n.ok||!s.ok?!1:n.changed||s.changed}function Xt(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($s)){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 ${$s[a]}`,u=l.filter(f=>Zt(f?.command));u.length===1&&u[0].command===c||(o[a]=[...l.filter(f=>!Zt(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 Rs(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=>!Zt(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 Mi(e){let[t,...n]=e.trim().split(/\s+/);return{command:t,args:[...n,"mcp"]}}function Yt(e,t=qt){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=Mi(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 As(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 Y=".cursor/rules/gruum-buttons.mdc",_s="<!-- written by gruum init cursor -->",Ni=20,Es=["**/*.css","**/*.scss","**/*.tsx","**/*.jsx"];function Is(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,Ni);return n.length?n:Es}var Di=["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 search the computer for a gruum program, and do not read the CLI package.",`When the request needs a button the spec does not have, stop and ask the user exactly: "${Kt}" Do not write that look, and do not request a review, until they answer. After they choose review, call gruum_request_exception, or run \`npx @gruum/cli request <drift id> --reason "..."\`. Never edit Gruum's generated files, including .gruum/project.json, 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","---",_s,"",...Di,""].join(`
14
- `)}function js(e){let n=(e.match(/^globs: (.*)$/m)?.[1]??"").split(",").map(r=>r.trim()).filter(Boolean),s=Qt(n.length?n:Es);return{text:s,changed:s!==e}}function en(e){return e.includes(_s)}function Ti(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(Ti))return{text:t,changed:!1};let n=t===""||t.endsWith(`
2
+ import{chmodSync as Np,existsSync as Ue,rmSync as ds}from"node:fs";import N from"node:path";import{createInterface as Ui,emitKeypressEvents as Up}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 le(e){e.on("SIGINT",()=>{process.stderr.write(`
3
+ `),process.exit(130)})}var Ji=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"]),Zi=new Set(["page","index","layout","route","default"]);function Xi(e){return Ji.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=>!Xi(n)).map(n=>`${t.state}|${t.context}|${n.property}:${n.value}`)).sort().join(";")}function Yi(e){return Ve(e.states)}function Qi(e){return e.states.filter(t=>t.state==="default"&&t.context==="").flatMap(t=>t.declarations)}function ws(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ea(e){let t=e.via?/^bg-([\w-]+?)(?:\/(\d+))?$/.exec(e.via):null;if(t){let s=t[1].replace(/-/g," ");return ws(t[2]?`${s} ${t[2]}%`:s)}let n=/var\(\s*--(?:color-)?([\w-]+)/.exec(e.value)?.[1];return ws((n??e.value).replace(/-/g," "))}function ta(e){let t=Qi(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?`${ea(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 na(e){let t=e.split("/"),n=(t.pop()??e).replace(/\.[^.]+$/,""),s=t.pop();return Zi.has(n)&&s?`${s}/${n}`:n}function sa(e){let t=[...new Set(e.map(s=>na(s.path)))],n=t.slice(0,2).join(", ");return t.length>2?`${n} +${t.length-2}`:n}var xs=(e,t)=>e.path.localeCompare(t.path)||e.line-t.line;function ks(e){let t=new Map;for(let r of e){let o=ta(r.variant),i=t.get(o)??new Map,a=Yi(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(xs);i.sort((h,k)=>k.sites.length-h.sites.length||xs(h.sites[0],k.sites[0]));let[a,...l]=i,c=a.looks[0],u=l.map(h=>sa(h.sites)),f=l.map((h,k)=>{let C=h.looks[0],g={title:u.filter(p=>p===u[k]).length>1?`${u[k]} \xB7 line ${h.sites[0].line}`:u[k],selector:C.selector,path:h.sites[0].path,line:h.sites[0].line,element:C.element,usage:C.usage,states:C.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,places:a.sites.map(h=>({path:h.path,line:h.line})),...f.length?{modifiers:f}:{}};s.set(m,a.sites),n.push(m)}return{variants:n,sites:s}}var vs=1,$s=["style.new","state.changed","state.missing","token.unknown","value.hardcoded","native.element","prop.unknown","style.removed","guidance.rule"],Xt={"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 Yt(e){let t=0;for(let n=0;n<e.length;n++)t=t*33+e.charCodeAt(n)>>>0;return t.toString(36)}function ct(e){let t=`${e.path}::${e.selector}`;return`v2-style-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48)}-${Yt(t)}`}function ce(e){return e.context?`${e.state} @ ${e.context}`:e.state}var ra=/var\(\s*(--[\w-]+)/g;function oa(e){let t=new Set;for(let n of e)for(let s of n.declarations)for(let r of s.value.matchAll(ra))t.add(r[1]);return[...t].sort()}function ia(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 aa(e){let t=new Map;for(let n of e){let s=ce(n),r=t.get(s),o=ia([...r?.declarations??[],...n.declarations]);t.set(s,{state:n.state,context:n.context,declarations:o})}return[...t.values()]}function la(e){let t=[{path:e.path,line:e.line},...e.places??[]],n=new Set;return t.filter(s=>{let r=`${s.path}:${s.line}`;return n.has(r)?!1:(n.add(r),!0)})}function Cs(e){let t=new Map,n=(s,r,o)=>{let i=ct(s),a=t.get(i),l=aa([...a?ca(a.states):[],...r]),c=a?.stateLines??new Map;for(let u of r)c.has(ce(u))||c.set(ce(u),u.line);t.set(i,{...a??s,id:i,states:l,tokens:oa(l),line:a?.line??o,stateLines:c})};for(let s of e){let r=ct(s);if(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),s.places?.length){let o=t.get(r);o&&(o.places=s.places)}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 ca(e){return e.map(t=>({state:t.state,context:t.context,line:0,declarations:t.declarations}))}function ua(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 Jt=/^(\d+) native /;function pa(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 ut={hardcoded:"value.hardcoded",native:"native.element",props:"prop.unknown"},fa=new Set(Object.values(ut));function Ss(e){let t=e.find(n=>n.toLowerCase()==="button");return t||(e.length===1?e[0]:null)}var da={"value.hardcoded":()=>"Replace each literal with the spec token named, or with a spec token for that property.","native.element":e=>{let t=Ss(e.components);return t?`Render ${t} instead of a raw <button>, or ask for an exception.`:"Use a spec button 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 Rs(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:pa(n.id,s)});return t}function Ht(e){return`${e.path}#${Yt(e.text.replace(/\s+/g," ").trim())}`}function As(e,t={}){let n=ua(e.previewCss),s=[...Cs(e.variants).values()].map(({line:i,stateLines:a,places:l,...c})=>c),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:vs,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:Rs(e).filter(({check:i})=>i in ut).map(({check:i,finding:a,key:l})=>({check:i,key:l,message:a.message})),settings:{severity:{...Xt,...t.settings?.severity??{}}}}}function ga(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 Zt(e){return e.map(t=>`${t.property}: ${t.value}`).join("; ")}function qt(e,t){return e.length>t?`${e.slice(0,t).join(", ")}, and ${e.length-t} more`:e.join(", ")}function ma(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 _s(e,t){let n={...Xt,...t.settings.severity},s=[],r=(p,d="")=>{s.push({id:`${p.kind}:${Yt(`${p.styleId??""}|${p.state??""}|${d}`)}`,severity:n[p.kind],...p})},o=Cs(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(Ve(p.states),p);let f=new Map;for(let p of o.values()){if(!p.markup)continue;let d=u.get(Ve(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,b=p.markup?a.filter(R=>R.markup):a,x=b.filter(R=>R.path===p.path),w=(x.length?x:b).map(h),v=p.markup?`This one-off ${p.element??"button"} (${qt((p.states[0]?.declarations??[]).map(R=>`${R.property}: ${R.value}`),3)})`:p.selector,P=Ss(t.components),I=p.markup?P?`render ${P} with a spec look,`:w.length?`copy ${qt(w,3)},`:"use a spec style,":d?`restyle ${d.selector} only through spec modifiers`:w.length?`use ${qt(w,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:la(p),fix:`${v} is not in the spec; ${I} or ask for an exception.`},p.markup?Ve(p.states):p.selector)}for(let p of o.values()){let d=i.get(p.id);if(!d)continue;let b=new Map(d.states.map(x=>[ce(x),x]));for(let x of p.states){let w=ce(x),v=b.get(w),P=ga(v?.declarations??[],x.declarations);P.length!==0&&r({kind:"state.changed",styleId:p.id,title:v?`${p.title}: ${w} changed`:`${p.title}: new ${w} state`,state:w,baseline:v?{declarations:v.declarations}:null,observed:{declarations:x.declarations},refs:[{path:p.path,line:p.stateLines.get(w)??p.line}],fix:v?`Restore ${p.selector} ${w} to the spec (${P.slice(0,3).join("; ")}), or ask for an exception.`:`${w} is not a spec state of ${p.selector}; remove it, or ask for an exception.`},Zt(x.declarations))}}for(let p of o.values()){let d=i.get(p.id);if(!d)continue;let b=new Set(p.states.map(ce));for(let x of d.states){let w=ce(x);b.has(w)||r({kind:"state.missing",styleId:p.id,title:`${p.title}: ${w} state is missing`,state:w,baseline:{declarations:x.declarations},observed:null,refs:[{path:p.path,line:p.line}],fix:`Define ${p.selector} ${w} again: ${Zt(x.declarations)||"as in the spec"}.`})}}for(let p of o.values())for(let d of p.tokens){if(l.has(d))continue;let b=ma(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:b.length?`Use a spec token such as ${b.join(", ")} instead of ${d}, or ask for an exception.`:`${d} is not a spec token; ask for an exception to add it.`},d)}let k=new Map;for(let p of t.acceptedFindings)k.set(p.key,[...k.get(p.key)??[],p]);let C=Rs(e).filter(({check:p})=>p in ut);for(let p of $s)if(fa.has(p))for(let{check:d,finding:b,key:x}of C){if(ut[d]!==p)continue;let w=k.get(x)??[];if(w.some(R=>!ha(d,R.message,b.message)))continue;let v=w[0],P=b.styles?.[0],I=P?[...o.values()].find(R=>R.title===P):void 0;if(p==="native.element"){let R=b.refs[0]?.path??"",A=Number(Jt.exec(b.message)?.[1]??"1");if(s.filter(O=>O.kind==="style.new"&&O.observed?.markup===!0&&O.refs.some(V=>V.path===R)).length>=A)continue}r({kind:p,styleId:I?.id??null,title:b.message,baseline:v?{message:v.message}:null,observed:{message:b.message,...p==="native.element"?{element:"button"}:{}},waiverKey:x,refs:b.refs.map(({path:R,line:A})=>({path:R,line:A})),fix:da[p](t)},x)}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 $=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(Ht(d));for(let p of t.rules){if(g.has(Ht(p)))continue;let d=$.get(p.path);d&&d.total>d.passages.length||r({kind:"guidance.rule",styleId:null,title:`A written rule in ${p.path} changed or was removed`,baseline:{text:p.text},observed:null,refs:[{path:p.path,line:0}],fix:`Restore the rule under ${p.headings.join(" \u203A ")||p.path}, or publish a new spec.`},Ht(p))}return s}function ha(e,t,n){if(t===n)return!1;if(e==="native"){let s=Jt.exec(t)?.[1],r=Jt.exec(n)?.[1];if(s&&r)return Number(r)>Number(s)}return!0}var be=`You asked for a design element that is not in the spec.
4
+
5
+ 1. Use an existing spec style for it.
6
+ 2. Add it as it is and request review.`,ya={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: "${be}" Do not write that look, and do not request a review, until they answer. After they choose review, call gruum_request_exception, or run \`npx @gruum/cli request <drift id> --reason "..."\`. Never edit generated Gruum files, including .gruum/project.json, to make a check pass.`]};function Qt(e){let t=(n,s)=>e.styles.filter(r=>r.hostId===n&&r.kind===s).map(r=>r.selector);return{about:{...ya,drift:$s.map(n=>({kind:n,severity:e.settings.severity[n]??Xt[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=>[ce(s),Zt(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 ze(e){if(!e||typeof e!="object")return null;let t=e;return t.schema!==vs||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 ba(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 en(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 Es(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(`
7
+ `);for(let[o,i]of ba(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(`
8
+ `)}function Ps(e){return{schema:1,checkedAt:e,baselineVersion:null,items:[],followups:{}}}function Is(e,t){if(!e||typeof e!="object")return Ps(t);let n=e;return n.schema!==1||!Array.isArray(n.items)?Ps(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 Ge(e,t={}){return e.filter(n=>{if(n.severity!=="block")return!1;let s=t[n.id];return s!=="pending"&&s!=="accepted"})}var We={exceptions:!1,denyGit:[],maxFollowups:2};function Ls(e){let t=e?.block===!0,n=Array.isArray(e?.denyGit)?e.denyGit.filter(r=>r==="commit"||r==="push"):t?["commit","push"]:We.denyGit,s=typeof e?.maxFollowups=="number"&&e.maxFollowups>=0?Math.floor(e.maxFollowups):We.maxFollowups;return{block:t,hooks:{...We,denyGit:n,maxFollowups:s}}}var tn=8;function js(e){let t=e.slice(0,tn).map(n=>{let s=n.refs[0],r=s?` (${s.path}${s.line?`:${s.line}`:""})`:"";return`- ${n.title}${r}. ${n.fix}`});return e.length>tn&&t.push(`- and ${e.length-tn} more; run \`gruum check\`.`),t.join(`
9
+ `)}function Ms(e){let t="If gruum_button_spec is not available, read .gruum/baseline.json. Do not search the computer for a gruum program, and do not read the CLI package.",n=`Ask the user before you do anything else: "${be}" If they choose 1, restyle it to a spec look (call gruum_button_spec).`,s=e.exceptions?'If they choose 2, keep it and call gruum_request_exception with the drift id, a reason, and the page URL where the button renders. If Gruum says it could not tell the local URL, find that URL and pass it. Gruum saves it. If that tool is not available, run `npx @gruum/cli request <drift id> --reason "..." --url "<page>"`. Do not request a review until they choose 2. Do not edit .gruum files.':"If they choose 2, stop and tell the developer which review you need. Do not invent a style.";return`${n} ${s} ${t}`}function Ts(e,t,n=We,s={}){let r=Ge(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:
10
+ ${js(r)}
11
+
12
+ ${Ms(n)}`},ledger:{...e,followups:{...e.followups,[o]:i+1}}}}function nn(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 Os(e,t,n=We,s={}){let r=nn(t.command??"").filter(i=>n.denyGit.includes(i));if(r.length===0)return{permission:"allow"};let o=Ge(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:
13
+ ${js(o)}
14
+
15
+ ${Ms(n)}`}}var Ke="npx --no-install @gruum/cli",Ns="npx --yes @gruum/cli",rn="npx --yes @gruum/cli",Ds={afterFileEdit:"after-file-edit",stop:"stop",beforeShellExecution:"before-shell"},wa=/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+hook\s+(after-file-edit|stop|before-shell)\s*$/;function sn(e){return typeof e=="string"&&wa.test(e)}function pt(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 ft(e){return`${JSON.stringify(e,null,2)}
16
+ `}function Us(e,t){let n=on(e),s=an(t);return!n.ok||!s.ok?!1:n.changed||s.changed}function on(e,t=Ke){let n=".cursor/hooks.json",s=pt(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(Ds)){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 ${Ds[a]}`,u=l.filter(f=>sn(f?.command));u.length===1&&u[0].command===c||(o[a]=[...l.filter(f=>!sn(f?.command)),{command:c}],i=!0)}return i?{ok:!0,text:ft({version:r.version??1,...r,hooks:o}),changed:!0}:{ok:!0,text:e,changed:!1}}function Fs(e){let t=".cursor/hooks.json";if(e===null)return{ok:!0,text:"",changed:!1};let n=pt(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=>!sn(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:ft({...s,hooks:r}),changed:!0}}function xa(e){let[t,...n]=e.trim().split(/\s+/);return{command:t,args:[...n,"mcp"]}}function an(e,t=rn){let n=".cursor/mcp.json",s=pt(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=xa(t),a=o.gruum;return JSON.stringify(a)===JSON.stringify(i)?{ok:!0,text:e,changed:!1}:{ok:!0,text:ft({...r,mcpServers:{...o,gruum:i}}),changed:!0}}function Bs(e){let t=".cursor/mcp.json";if(e===null)return{ok:!0,text:"",changed:!1};let n=pt(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:ft({...s,mcpServers:r}),changed:!0}):{ok:!0,text:e,changed:!1}}var Y=".cursor/rules/gruum-buttons.mdc",Vs="<!-- written by gruum init cursor -->",ka=20,zs=["**/*.css","**/*.scss","**/*.tsx","**/*.jsx"];function Ws(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,ka);return n.length?n:zs}var va=["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 search the computer for a gruum program, and do not read the CLI package.",`When the request needs a button the spec does not have, stop and ask the user exactly: "${be}" Do not write that look, and do not request a review, until they answer. After they choose review, call gruum_request_exception with the drift id, a reason, and url set to the page where the new button renders, or run \`npx @gruum/cli request <drift id> --reason "..." --url "<page>"\`. If Gruum says it could not tell the local URL, find that URL and pass it. Gruum saves it. The review needs a screenshot and a SnapDOM of that rendered button. Never edit Gruum's generated files, including .gruum/project.json, to make a check pass.`];function ln(e){return["---","description: Buttons in this repository follow a spec published in Gruum.",`globs: ${e.join(",")}`,"alwaysApply: false","---",Vs,"",...va,""].join(`
17
+ `)}function Gs(e){let n=(e.match(/^globs: (.*)$/m)?.[1]??"").split(",").map(r=>r.trim()).filter(Boolean),s=ln(n.length?n:zs);return{text:s,changed:s!==e}}function cn(e){return e.includes(Vs)}function $a(e){let t=e.trim();if(!t||t.startsWith("#")||t.startsWith("!"))return!1;let n=t.replace(/\s+#.*$/,"").trim();return/^(?:\/|\*\*\/)?\.gruum(?:\/|\*\*|\/\*\*|\/\*)?$/.test(n)}function dt(e){let t=e??"";if(t.split(/\r?\n/).some($a))return{text:t,changed:!1};let n=t===""||t.endsWith(`
15
18
  `)?"":`
16
19
  `;return{text:`${t}${n}# Gruum local state
17
20
  .gruum/
18
- `,changed:!0}}function Ps(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 Bi=e=>`${e} check --staged`;function Ls(e,t=We){let n=Bi(t);if(e.lefthook)return{kind:"print",reason:"lefthook config found; add this to the pre-commit commands",snippet:`pre-commit:
21
+ `,changed:!0}}function Ks(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 Ca=e=>`${e} check --staged`;function Hs(e,t=Ke){let n=Ca(t);if(e.lefthook)return{kind:"print",reason:"lefthook config found; add this to the pre-commit commands",snippet:`pre-commit:
19
22
  commands:
20
23
  gruum:
21
24
  run: ${n}
22
25
  `};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){let l=o.split(/\r?\n/).map(u=>u.trim());if(l.includes(n))return{kind:s,path:r,text:o,changed:!1};let c=`${We} check --staged`;if(n!==c&&l.includes(c))return{kind:s,path:r,text:o.replace(c,n),changed:!0};if(l.some(u=>Os(u)))return{kind:s,path:r,text:o,changed:!1}}let i=o===null?s==="git"?`#!/bin/sh
26
+ `};let r=e.husky?".husky/pre-commit":`${e.gitHooksDir}/pre-commit`,o=e.hookText;if(o!==null){let l=o.split(/\r?\n/).map(u=>u.trim());if(l.includes(n))return{kind:s,path:r,text:o,changed:!1};let c=`${Ke} check --staged`;if(n!==c&&l.includes(c))return{kind:s,path:r,text:o.replace(c,n),changed:!0};if(l.some(u=>qs(u)))return{kind:s,path:r,text:o,changed:!1}}let i=o===null?s==="git"?`#!/bin/sh
24
27
  `:"":o,a=i===""||i.endsWith(`
25
28
  `)?"":`
26
29
  `;return{kind:s,path:r,text:`${i}${a}${n}
27
- `,changed:!0}}function Os(e){return/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+check\s+--staged\s*$/.test(e.trim())}function Ms(e){let t=e.split(`
28
- `),n=t.filter(o=>!Os(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 Fi=[" .d8888b.","d88P Y88b","888 888","888 888d888 888 888 888 888 88888b.d88b.",'888 88888 888P" 888 888 888 888 888 "888 "88b',"888 888 888 888 888 888 888 888 888 888","Y88b d88P 888 Y88b 888 Y88b 888 888 888 888",' "Y8888P88 888 "Y88888 "Y88888 888 888 888'].join(`
30
- `),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 Ns(e){let t=Ee.map((n,s)=>` ${s+1} ${n.name.padEnd(10)} ${n.blurb}`);return`${Fi}
30
+ `,changed:!0}}function qs(e){return/(^|[\s/])(?:@gruum\/cli|gruum(?:\.m?js)?)\s+check\s+--staged\s*$/.test(e.trim())}function Js(e){let t=e.split(`
31
+ `),n=t.filter(o=>!qs(o)),s=n.length!==t.length,r=n.join(`
32
+ `);return s&&/^(#!\/bin\/sh)?\s*$/.test(r)?{text:"",changed:s}:{text:r,changed:s}}var Zs=[" .d8888b.","d88P Y88b","888 888","888 888d888 888 888 888 888 88888b.d88b.",'888 88888 888P" 888 888 888 888 888 "888 "88b',"888 888 888 888 888 888 888 888 888 888","Y88b d88P 888 Y88b 888 Y88b 888 888 888 888",' "Y8888P88 888 "Y88888 "Y88888 888 888 888'].join(`
33
+ `),we=[{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"},{name:"login",args:[],blurb:"Sign this computer in",usage:"npx @gruum/cli login"}];function Xs(e){let t=we.map((n,s)=>` ${s+1} ${n.name.padEnd(10)} ${n.blurb}`);return`${Zs}
31
34
 
32
35
  gruum ${e}
33
36
 
34
37
  ${t.join(`
35
38
  `)}
36
- `}var Ds=`
37
- Choose 1\u20133, or press Enter to quit: `,Ts=`
38
- Would you like to run a (c) check, (b) baseline, or (q) quit? `,Bs=`
39
- You have no baseline. Would you like to run it? (Enter) baseline, (q) quit: `;function Fs(e){return`
39
+ `}var Sa="\u2191\u2193 move Enter select 1\u20133 jump q quit",un="\x1B[0m",Ra="\x1B[1m",Aa="\x1B[2m",_a="\x1B[36m";function Ys(e,t){let n=o=>`${o}\x1B[K`,s=we.map((o,i)=>{let a=`${i+1} ${o.name.padEnd(10)} ${o.blurb}`;return n(i===t?`${_a}\u276F${un} ${Ra}${a}${un}`:` ${a}`)});return[Zs.split(`
40
+ `).map(n).join(`
41
+ `),n(""),n(`gruum ${e}`),n(""),...s,n(""),n(`${Aa}${Sa}${un}`),""].join(`
42
+ `)}function Qs(e,t){let n=we.length,s=(t.name??"").toLowerCase();if(t.sequence===""||t.ctrl&&s==="c")return{type:"interrupt"};if(s==="up"||s==="k")return{type:"move",index:(e-1+n)%n};if(s==="down"||s==="j")return{type:"move",index:(e+1)%n};if(s==="return"||s==="enter")return{type:"select",index:e};if(s==="q"||s==="escape")return{type:"quit"};let r=Number(t.sequence);if(Number.isInteger(r)&&r>=1&&r<=n)return{type:"select",index:r-1};let o=(t.sequence??s).toLowerCase();if(o.length===1&&/[a-z]/.test(o)){let i=we.flatMap((a,l)=>a.name.startsWith(o)?[l]:[]);if(i.length===1)return{type:"select",index:i[0]}}return{type:"ignore"}}var er=`
43
+ Would you like to run a (c) check, (b) baseline, or (q) quit? `,tr=`
44
+ You have no baseline. Would you like to run it? (Enter) baseline, (q) quit: `;function nr(e){return`
40
45
  ${e?"This repo uses Cursor and Claude. Gruum can set up Cursor.":"This repo uses Cursor."}
41
46
 
42
- Set up Gruum in Cursor so checks run while you edit and before a commit? (Enter) yes, (n) no: `}function Us(e){let t=e.trim().toLowerCase();return t==="n"||t==="no"||t==="q"||t==="quit"?"no":!t||t==="y"||t==="yes"?"yes":null}function Vs(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 zs(e){let t=e.trim().toLowerCase();return t==="q"||t==="quit"||t==="n"||t==="no"?"quit":!t||t==="b"||t==="baseline"||t==="y"||t==="yes"?"baseline":null}function Ws(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 Ui="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, including .gruum/project.json, 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. If this tool is missing, run \`npx @gruum/cli request <drift id> --reason "..."\` instead of reading the CLI package. ${it}`,gruum_exception_status:`Pending, accepted, or rejected for this branch's exception requests. Pass an id to read one. ${it}`};function Gs(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 Hs(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:Ui,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 Vi=/(^|\/)(node_modules|\.git|\.next|dist|build|out|coverage|vendor|\.turbo|\.cache|__pycache__|target|\.venv|venv)\//,zi=/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb|Cargo\.lock|poetry\.lock|composer\.lock|Gemfile\.lock)$/,Wi=/\.(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,Gi=/(^|\/)\.gruum\//;function tn(e){return!Vi.test(`${e}/`)&&!Gi.test(`${e}/`)}function nn(e,t){return zi.test(e)||Wi.test(e)?!1:t<=3e5}function Ks(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}var Hi=/\.(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 Js(e){return Hi.test(e)}function sn(e){return e.replace(/\\/g,"/").replace(/^\.\/?/,"").replace(/^\/+|\/+$/g,"")}function rn(e,t){let n=sn(t),s=e.replace(/\\/g,"/");return n?s.startsWith(`${n}/`)?s.slice(n.length+1):null:s}function Zs(e,t,n){let s=new Map(e);for(let r of t){let o=rn(r.path,n);o===null||!tn(o.split("/").slice(0,-1).join("/")||".")||(r.content===null?s.delete(o):nn(o,r.content.length)&&s.set(o,r.content))}return s}function qs(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 Xs=e=>e.replace(/\\(.)/g,"$1");function Ki(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 on=/\*|[a-z][\w-]*|\.((?:\\.|[\w-])+)|#((?:\\.|[\w-])+)|\[\s*([\w-]+)\s*(?:([~|^$*]?=)\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*[is]?\s*\]|::([\w-]+)|:([\w-]+)(\((?:[^()]|\([^()]*\))*\))?/giy;function er(e){let t=[];on.lastIndex=0;let n=0;for(;n<e.length;){on.lastIndex=n;let s=on.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:Xs(s[1])});else if(s[2]!==void 0)t.push({kind:"id",raw:r,name:Xs(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=Ki(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=er(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 W(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 tr=e=>e.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(t=>t.toLowerCase());function Ys(e,t){let n=e.toLowerCase();return t.some(s=>n.includes(s.toLowerCase()))}function an(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"&&tr(r.name).some(o=>s.has(o)))}var Ji=new Set(["html","body"]),Zi=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(Ys(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&&Ys(n.value,t.classKeywords))return!0;break;case"pseudo":if((n.name==="is"||n.name==="where")&&n.args){let s=W(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 nr(e){return e.some(n=>n.kind==="universal")?e.length===1:e.some(n=>n.kind==="tag"&&Ji.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 sr(e){return e.some(t=>t.kind==="tag"&&Zi.has(t.name))}var ut=["hover","focus","active","selected","current","loading","disabled"],qi={hover:"hover",hovered:"hover",focus:"focus",focused:"focus","focus-visible":"focus","focus-within":"focus",active:"selected",pressed:"selected",selected:"selected",checked:"selected",on:"selected",current:"current",loading:"loading",busy:"loading",pending:"loading",disabled:"disabled"},Xi={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",checked:"selected",disabled:"disabled"},Yi={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"},Qi=new Set(["active","selected","pressed","checked","loading","busy","disabled","open","current","hover","focus","show","expanded","collapsed"]),Qs=e=>qi[e.toLowerCase()]??e.toLowerCase(),ce={hover:"__gs-hover",focus:"__gs-focus",active:"__gs-active"};function rr(e){if(e.kind==="pseudo"){let t=Xi[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:Qs(e.value),marker:{classes:[],attrs:{"data-state":e.value}}};let t=Yi[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]:Qi.has(e.name.toLowerCase())?e.name:null;return n?{state:Qs(n),marker:{classes:[e.name],attrs:{}}}:null}return null}function ea(e){return e.kind!=="pseudo"||e.name!=="not"||!e.args?!1:W(e.args).every(t=>{let n=er(t);return n!==null&&n.every(s=>rr(s)!==null)})}function ft(e){let t=[],n=new Map;for(let o of e){if(ea(o))continue;let i=rr(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 ln(e){return e.replace(/:hover\b/g,`.${ce.hover}`).replace(/:focus(?:-visible|-within)?\b/g,`.${ce.focus}`).replace(/:active\b/g,`.${ce.active}`)}var ta=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"]),na=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"]),sa=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 ta.has(t)?"paint":na.has(t)?"layout":sa.has(t)?"hint":"box"}var ra={shadow:/^box-shadow$/,cursor:/^cursor$/,rounded:/^border(?:-[a-z]+)*-radius$/,radius:/^border(?:-[a-z]+)*-radius$/};function or(e,t){let n=e.filter(o=>o.kind==="class");if(n.length!==1||e.length!==1)return!1;let s=tr(n[0].name)[0],r=s?ra[s]:void 0;return r?t.length>0&&t.every(o=>r.test(o.property.toLowerCase())):!1}var Bu={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 oa="data-gs-sheet";function ar(e){return`[${oa}="${e.replace(/["\\]/g,"")}"]`}function ir(e){return/\.module\.[a-z]+$/i.test(e)}var ia=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 aa(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=>aa(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(!ia.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 cn(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=cn(e,"display");if(/^none\b/i.test(t))return"display: none";let n=cn(e,"visibility");if(/^(hidden|collapse)\b/i.test(n))return`visibility: ${n.split(/\s+/)[0].toLowerCase()}`;let s=cn(e,"opacity");return/^(0|0\.0+)$/.test(s)?"opacity: 0":null}function lr(e,t){return e===t||!ir(e)&&!ir(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 la=40,ee=(e,t)=>({path:e,line:t});function te(e,t,n,s){return{...e,status:t.length===0?"ok":"attention",summary:t.length===0?n:s(t.length),findings:t.slice(0,la)}}function xe(e,t){return{...e,status:"na",summary:t,findings:[]}}var un=e=>e.state.split(" + ");function dr(e,t){if(!e.element||!t.element||e!==t&&!lr(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 gr(e,t){return t.filter(n=>dr(n,e)).flatMap(n=>n.states)}function ca(e,t,n){return gr(e,t).some(s=>un(s).includes(n))||t.filter(s=>dr(s,e)).some(s=>(s.parts??[]).some(r=>r.state.split(" + ").includes(n)))}var ua=[{state:"hover",severity:"issue"},{state:"focus",severity:"issue"},{state:"disabled",severity:"issue"},{state:"active",severity:"note"}];function pa(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 ua){let i=n.filter(a=>!ca(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=>ee(a.path,a.line))})}return te(t,s,"Every style has hover, focus, disabled, and active rules.",r=>`${r} state${r===1?"":"s"} missing on some styles.`)}var cr=new Set(["outline","outline-style","outline-width"]),ur=/^(?:none|0|0px)(?:\s+(?:none|0|0px))*$/i,fa=/^(?:outline(?:-color|-width|-style)?|box-shadow|border(?:-[a-z]+)*|background(?:-color)?|text-decoration(?:-[a-z]+)?|color)$/;function da(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=gr(r,e.variants),i=o.filter(l=>{let c=un(l);return c.includes("default")||c.includes("focus")}).flatMap(l=>l.declarations.map(c=>({s:l,d:c}))).find(({d:l})=>cr.has(l.property)&&ur.test(l.value.replace(/\s*!important/i,"")));!i||o.filter(l=>un(l).includes("focus")).some(l=>l.declarations.some(c=>fa.test(c.property)&&!(cr.has(c.property)&&ur.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:[ee(r.path,i.s.line)]})}return te(t,s,"No style removes the outline without a focus replacement.",r=>`${r} style${r===1?"":"s"} lose the focus indicator.`)}function ga(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=>ee(i.path,i.line))}});return te(t,s,`All ${e.tokens.length} tokens read are defined.`,r=>`${r} token${r===1?"":"s"} with no definition.`)}var ma=/var\((?:[^()]|\([^()]*\))*\)/g,pr=/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?)\([^)]*\)/gi,ha=/^(?:padding|margin|gap|row-gap|column-gap|height|min-height|max-height|border-radius|font-size|letter-spacing)(?:-[a-z]+)*$/,ba=/(?<![\w.-])(\d+(?:\.\d+)?)px\b/g;function fr(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 pn(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?pn(i,t,n+1):o!==void 0?pn(o.trim(),t,n+1):s})}var ya=[[/^(?: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 xa(e,t){if(!t)return null;let n=ya.find(([s])=>s.test(e))?.[1];return t.find(s=>!n||n.test(s))??null}function ka(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=pn(i,e.tokenValues).trim();if(new RegExp(`^(?:${pr.source})$`,"i").test(a)){let l=fr(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 u of c.declarations){if(u.via)continue;let f=u.value.replace(ma," ");for(let m of f.matchAll(pr)){let h=n.get(fr(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(ha.test(u.property))for(let m of f.matchAll(ba)){let h=xa(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:[ee(o.path,a.line)]})}return te(t,r,`No ${e.noun} style hard-codes a value a token already has.`,o=>`${o} style${o===1?"":"s"} hard-code values.`)}function wa(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:[ee(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:[ee(r.path,r.line),...r.usage.files.slice(0,2)]});return s.sort((r,o)=>+(o.severity==="issue")-+(r.severity==="issue")),te(t,s,`All ${n.length} styles are referenced.`,r=>`${r} style${r===1?"":"s"} unreferenced or unconfirmed.`)}function va(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=>ee(o.path,o.line))}));return te(t,s,"No two styles share the same default declarations.",r=>`${r} group${r===1?"":"s"} of identical styles.`)}function $a(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:[ee(s.path,s.line)]}));return te(t,n,`Every <${e.element}> goes through the component.`,s=>`${s} file${s===1?"":"s"} bypass the component.`)}function Ca(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:[ee(s.path,s.line)]}));return te(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 Sa(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 te(t,[],"Every style is named in written guidance.",()=>"");let s=e.variants.filter(r=>r.element&&n.undocumented.includes(r.title));return te(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=>ee(r.path,r.line))}],"",r=>`${r} finding${r===1?"":"s"}.`)}function mr(e){return[pa(e),da(e),wa(e),va(e),ga(e),ka(e),$a(e),Ca(e),Sa(e)]}var Ra=/\.(erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,hr=/^<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/,Aa=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),_a=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),Ea=new Set(["classNames","classnames","clsx","cn","cx"]),Ia=/^(?:ref|key|style|dangerouslySetInnerHTML)$/i;function xr(e,t){let n=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
43
- `&&n++;return n}function br(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function kr(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(`
44
- `)}function ja(e,t,n){let s=Math.max(0,Math.min(t,e.length)),r=Math.max(s,Math.min(n,e.length)),o=xr(e,s),i=e.slice(s,r).split(`
47
+ Set up Gruum in Cursor so checks run while you edit and before a commit? (Enter) yes, (n) no: `}function sr(e){let t=e.trim().toLowerCase();return t==="n"||t==="no"||t==="q"||t==="quit"?"no":!t||t==="y"||t==="yes"?"yes":null}function rr(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 or(e){let t=e.trim().toLowerCase();return t==="q"||t==="quit"||t==="n"||t==="no"?"quit":!t||t==="b"||t==="baseline"||t==="y"||t==="yes"?"baseline":null}var Ea="2025-06-18",gt=`Check before you finish. If the request needs a button the spec does not have, ask the user: "${be}" Do not request a review until they choose 2. Never edit Gruum's generated files, including .gruum/project.json, to make a check pass.`,mt={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. ${gt}`,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. ${gt}`,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. Pass url for the page where the new button renders. If package.json does not name one dev port, find that URL yourself and pass it. Gruum saves it for the next capture. The CLI opens that page and attaches a screenshot and a SnapDOM of the rendered button. If this tool is missing, run \`npx @gruum/cli request <drift id> --reason "..." --url "<page>"\` instead of reading the CLI package. ${gt}`,gruum_exception_status:`Pending, accepted, or rejected for this branch's exception requests. Pass an id to read one. ${gt}`};function ir(e){return[{name:"gruum_button_spec",description:mt.gruum_button_spec,inputSchema:{type:"object",properties:{},additionalProperties:!1},run:()=>e.spec()},{name:"gruum_check_buttons",description:mt.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:mt.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."},url:{type:"string",description:"Page where the new button renders. If the dev port is not obvious, find the local URL and pass it. Gruum saves it."}},required:["driftId","reason"],additionalProperties:!1},run:t=>e.request(typeof t.driftId=="string"?t.driftId:"",typeof t.reason=="string"?t.reason:"",typeof t.url=="string"?t.url:void 0)},{name:"gruum_exception_status",description:mt.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 He(e,t){return{jsonrpc:"2.0",id:e,result:t}}function ht(e,t,n){return{jsonrpc:"2.0",id:e,error:{code:t,message:n}}}async function ar(e,t,n){if(!e||typeof e!="object")return ht(null,-32600,"Invalid request");let s=e,r=!("id"in s),o=s.id??null;if(typeof s.method!="string")return r?null:ht(o,-32600,"Invalid request");let i=s.params??{};switch(s.method){case"initialize":{let a=i.protocolVersion;return He(o,{protocolVersion:typeof a=="string"?a:Ea,capabilities:{tools:{listChanged:!1}},serverInfo:n})}case"ping":return He(o,{});case"tools/list":return He(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 ht(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 He(o,{content:[{type:"text",text:c.text}],isError:c.isError??!1})}catch(c){return He(o,{content:[{type:"text",text:c instanceof Error?c.message:String(c)}],isError:!0})}}default:return r?null:ht(o,-32601,`Method not found: ${s.method}`)}}var Pa=/(^|\/)(node_modules|\.git|\.next|dist|build|out|coverage|vendor|\.turbo|\.cache|__pycache__|target|\.venv|venv)\//,Ia=/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb|Cargo\.lock|poetry\.lock|composer\.lock|Gemfile\.lock)$/,La=/\.(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,ja=/(^|\/)\.gruum\//;function pn(e){return!Pa.test(`${e}/`)&&!ja.test(`${e}/`)}function fn(e,t){return Ia.test(e)||La.test(e)?!1:t<=3e5}function lr(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}var Ma=/\.(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 cr(e){return Ma.test(e)}function dn(e){return e.replace(/\\/g,"/").replace(/^\.\/?/,"").replace(/^\/+|\/+$/g,"")}function gn(e,t){let n=dn(t),s=e.replace(/\\/g,"/");return n?s.startsWith(`${n}/`)?s.slice(n.length+1):null:s}function ur(e,t,n){let s=new Map(e);for(let r of t){let o=gn(r.path,n);o===null||!pn(o.split("/").slice(0,-1).join("/")||".")||(r.content===null?s.delete(o):fn(o,r.content.length)&&s.set(o,r.content))}return s}function pr(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 yt(e){let t=/^(?:git@|ssh:\/\/git@|https?:\/\/(?:[^@/]+@)?)github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(e.trim());return t?`${t[1]}/${t[2]}`:null}var fr=e=>e.replace(/\\(.)/g,"$1");function Ta(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 mn=/\*|[a-z][\w-]*|\.((?:\\.|[\w-])+)|#((?:\\.|[\w-])+)|\[\s*([\w-]+)\s*(?:([~|^$*]?=)\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*[is]?\s*\]|::([\w-]+)|:([\w-]+)(\((?:[^()]|\([^()]*\))*\))?/giy;function mr(e){let t=[];mn.lastIndex=0;let n=0;for(;n<e.length;){mn.lastIndex=n;let s=mn.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:fr(s[1])});else if(s[2]!==void 0)t.push({kind:"id",raw:r,name:fr(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=Ta(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=mr(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 qe(e){return e.map(t=>t.raw).join("")}function Je(e){return e.map((t,n)=>{let s=qe(t.simples);return n===0?s:t.combinator===" "?` ${s}`:` ${t.combinator} ${s}`}).join("")}function W(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 hr=e=>e.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(t=>t.toLowerCase());function dr(e,t){let n=e.toLowerCase();return t.some(s=>n.includes(s.toLowerCase()))}function hn(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"&&hr(r.name).some(o=>s.has(o)))}var Oa=new Set(["html","body"]),Da=new Set(["svg","path","use","img","picture","video","i","em","strong","b","small","kbd","sup","sub"]);function wt(e,t){for(let n of e)switch(n.kind){case"tag":if(t.elements.includes(n.name))return!0;break;case"class":if(dr(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&&dr(n.value,t.classKeywords))return!0;break;case"pseudo":if((n.name==="is"||n.name==="where")&&n.args){let s=W(n.args).map(Q);if(s.length>0&&s.every(r=>r!==null&&wt(r[r.length-1].simples,t)))return!0}break;default:break}return!1}function yr(e){return e.some(n=>n.kind==="universal")?e.length===1:e.some(n=>n.kind==="tag"&&Oa.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 br(e){return e.some(t=>t.kind==="tag"&&Da.has(t.name))}var bt=["hover","focus","active","selected","current","loading","disabled"],Na={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"},Ua={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",checked:"selected",disabled:"disabled"},Fa={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"},Ba=new Set(["active","selected","pressed","checked","loading","busy","disabled","open","current","hover","focus","show","expanded","collapsed"]),gr=e=>Na[e.toLowerCase()]??e.toLowerCase(),ue={hover:"__gs-hover",focus:"__gs-focus",active:"__gs-active"};function wr(e){if(e.kind==="pseudo"){let t=Ua[e.name];if(!t)return null;let n=ue[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:gr(e.value),marker:{classes:[],attrs:{"data-state":e.value}}};let t=Fa[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]:Ba.has(e.name.toLowerCase())?e.name:null;return n?{state:gr(n),marker:{classes:[e.name],attrs:{}}}:null}return null}function Va(e){return e.kind!=="pseudo"||e.name!=="not"||!e.args?!1:W(e.args).every(t=>{let n=mr(t);return n!==null&&n.every(s=>wr(s)!==null)})}function xt(e){let t=[],n=new Map;for(let o of e){if(Va(o))continue;let i=wr(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)=>K(o)-K(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 K(e){if(e==="default")return-1;let t=bt.indexOf(e);return t===-1?bt.length:t}function xe(e){return e.length?e.join(" + "):"default"}function yn(e){return e.replace(/:hover\b/g,`.${ue.hover}`).replace(/:focus(?:-visible|-within)?\b/g,`.${ue.focus}`).replace(/:active\b/g,`.${ue.active}`)}var za=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"]),Wa=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"]),Ga=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 Ze(e){let t=e.toLowerCase();return za.has(t)?"paint":Wa.has(t)?"layout":Ga.has(t)?"hint":"box"}var Ka={shadow:/^box-shadow$/,cursor:/^cursor$/,rounded:/^border(?:-[a-z]+)*-radius$/,radius:/^border(?:-[a-z]+)*-radius$/};function xr(e,t){let n=e.filter(o=>o.kind==="class");if(n.length!==1||e.length!==1)return!1;let s=hr(n[0].name)[0],r=s?Ka[s]:void 0;return r?t.length>0&&t.every(o=>r.test(o.property.toLowerCase())):!1}var mf={hover:{classes:[ue.hover],attrs:{}},focus:{classes:[ue.focus],attrs:{}},active:{classes:[ue.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 Ha="data-gs-sheet";function kr(e){return`[${Ha}="${e.replace(/["\\]/g,"")}"]`}function Xe(e){return/\.module\.[a-z]+$/i.test(e)}var qa=new Set(["button","a","div","span","input","summary","label"]);function ke(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 Ja(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 kt(e,t){let n=Q(e);if(!n||n.some(c=>c.combinator==="+"||c.combinator==="~"))return null;let s=n.map(c=>Ja(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(!qa.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 bn(e,t){let n="";for(let s of e)s.property.toLowerCase()===t&&(n=s.value.replace(/!important\s*$/i,"").trim());return n}function vt(e){let t=bn(e,"display");if(/^none\b/i.test(t))return"display: none";let n=bn(e,"visibility");if(/^(hidden|collapse)\b/i.test(n))return`visibility: ${n.split(/\s+/)[0].toLowerCase()}`;let s=bn(e,"opacity");return/^(0|0\.0+)$/.test(s)?"opacity: 0":null}function vr(e,t){return e===t||!Xe(e)&&!Xe(t)}function oe(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 Za=40,ee=(e,t)=>({path:e,line:t});function te(e,t,n,s){return{...e,status:t.length===0?"ok":"attention",summary:t.length===0?n:s(t.length),findings:t.slice(0,Za)}}function ve(e,t){return{...e,status:"na",summary:t,findings:[]}}var wn=e=>e.state.split(" + ");function Ar(e,t){if(!e.element||!t.element||e!==t&&!vr(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 _r(e,t){return t.filter(n=>Ar(n,e)).flatMap(n=>n.states)}function Xa(e,t,n){return _r(e,t).some(s=>wn(s).includes(n))||t.filter(s=>Ar(s,e)).some(s=>(s.parts??[]).some(r=>r.state.split(" + ").includes(n)))}var Ya=[{state:"hover",severity:"issue"},{state:"focus",severity:"issue"},{state:"disabled",severity:"issue"},{state:"active",severity:"note"}];function Qa(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 ve(t,"No styles that can be drawn on their own.");let s=[];for(let{state:r,severity:o}of Ya){let i=n.filter(a=>!Xa(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=>ee(a.path,a.line))})}return te(t,s,"Every style has hover, focus, disabled, and active rules.",r=>`${r} state${r===1?"":"s"} missing on some styles.`)}var $r=new Set(["outline","outline-style","outline-width"]),Cr=/^(?:none|0|0px)(?:\s+(?:none|0|0px))*$/i,el=/^(?:outline(?:-color|-width|-style)?|box-shadow|border(?:-[a-z]+)*|background(?:-color)?|text-decoration(?:-[a-z]+)?|color)$/;function tl(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 ve(t,"No styles that can be drawn on their own.");let s=[];for(let r of n){let o=_r(r,e.variants),i=o.filter(l=>{let c=wn(l);return c.includes("default")||c.includes("focus")}).flatMap(l=>l.declarations.map(c=>({s:l,d:c}))).find(({d:l})=>$r.has(l.property)&&Cr.test(l.value.replace(/\s*!important/i,"")));!i||o.filter(l=>wn(l).includes("focus")).some(l=>l.declarations.some(c=>el.test(c.property)&&!($r.has(c.property)&&Cr.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:[ee(r.path,i.s.line)]})}return te(t,s,"No style removes the outline without a focus replacement.",r=>`${r} style${r===1?"":"s"} lose the focus indicator.`)}function nl(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 ve(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=>ee(i.path,i.line))}});return te(t,s,`All ${e.tokens.length} tokens read are defined.`,r=>`${r} token${r===1?"":"s"} with no definition.`)}var sl=/var\((?:[^()]|\([^()]*\))*\)/g,Sr=/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?)\([^)]*\)/gi,rl=/^(?:padding|margin|gap|row-gap|column-gap|height|min-height|max-height|border-radius|font-size|letter-spacing)(?:-[a-z]+)*$/,ol=/(?<![\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 xn(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?xn(i,t,n+1):o!==void 0?xn(o.trim(),t,n+1):s})}var il=[[/^(?: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 al(e,t){if(!t)return null;let n=il.find(([s])=>s.test(e))?.[1];return t.find(s=>!n||n.test(s))??null}function ll(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=xn(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 ve(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(sl," ");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(rl.test(u.property))for(let m of f.matchAll(ol)){let h=al(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:[ee(o.path,a.line)]})}return te(t,r,`No ${e.noun} style hard-codes a value a token already has.`,o=>`${o} style${o===1?"":"s"} hard-code values.`)}function cl(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 ve(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:[ee(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:[ee(r.path,r.line),...r.usage.files.slice(0,2)]});return s.sort((r,o)=>+(o.severity==="issue")-+(r.severity==="issue")),te(t,s,`All ${n.length} styles are referenced.`,r=>`${r} style${r===1?"":"s"} unreferenced or unconfirmed.`)}function ul(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=>ee(o.path,o.line))}));return te(t,s,"No two styles share the same default declarations.",r=>`${r} group${r===1?"":"s"} of identical styles.`)}function pl(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 ve(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:[ee(s.path,s.line)]}));return te(t,n,`Every <${e.element}> goes through the component.`,s=>`${s} file${s===1?"":"s"} bypass the component.`)}function fl(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 ve(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:[ee(s.path,s.line)]}));return te(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 dl(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 te(t,[],"Every style is named in written guidance.",()=>"");let s=e.variants.filter(r=>r.element&&n.undocumented.includes(r.title));return te(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=>ee(r.path,r.line))}],"",r=>`${r} finding${r===1?"":"s"}.`)}function Er(e){return[Qa(e),tl(e),cl(e),ul(e),nl(e),ll(e),pl(e),fl(e),dl(e)]}var gl=/\.(erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,Pr=/^<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/,ml=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),hl=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),yl=new Set(["classNames","classnames","clsx","cn","cx"]),bl=/^(?:ref|key|style|dangerouslySetInnerHTML)$/i;function jr(e,t){let n=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
48
+ `&&n++;return n}function Ir(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Mr(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(`
49
+ `)}function wl(e,t,n){let s=Math.max(0,Math.min(t,e.length)),r=Math.max(s,Math.min(n,e.length)),o=jr(e,s),i=e.slice(s,r).split(`
45
50
  `).slice(0,12),a=e.slice(s,r).split(`
46
- `).length>12;return{source:kr(i)+(a?`
47
- \u2026`:""),startLine:o}}function Pa(e,t){let n=xr(e,Math.max(0,t)),s=e.split(`
48
- `),r=Math.max(0,n-1);return{source:kr(s.slice(r,r+12)),startLine:r+1}}function yr(e,t){return{kind:"other",...Pa(e,t)}}function yt(e,t){let n=hr.exec(e.slice(t));if(!n)return null;let s=n[1],r=n[2]??"",o=t+n[0].length;if(/\/\s*$/.test(r)||Aa.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=hr.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 dn(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 wr(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 vr(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 fn=/^[A-Za-z_$][\w$]*$/;function gn(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 mn(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 $r(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=mn(e);for(let c of["||","&&"]){let u=gn(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=$r(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 Cr(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=mn(e);if(!n)return{classes:[],dynamic:!1};let s=Cr(n);if(s){let c=Pe(s.condition,t);return c===null?{classes:[],dynamic:!0}:Ie(c?s.yes:s.no,t)}let r=gn(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 w=c.slice(m+2,h).trim();if(fn.test(w)){let C=t.values.get(w);if(typeof C!="string")return{classes:[],dynamic:!0};t.strings.add(w);let $=/[\w-]*$/.exec(u)?.[0];$&&t.prefixes.set(w,$),u+=C}else{let C=Ie(w,t);if(C.dynamic)return{classes:[],dynamic:!0};u+=C.classes.join(" ")}f=h+1}return{classes:je(u),dynamic:!1}}if(fn.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:[wr(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&&Ea.has(l[1])){let c=[];for(let u of vr(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=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 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=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 hn(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 Sr(e,t){return/[<>]/.test(t)?!1:e==="href"||e==="src"||e==="action"?/^(?:https?:|mailto:|\/|#)/i.test(t):!0}function La(e){return e==="class"||e==="className"?!1:!Ia.test(e)&&!/^on/i.test(e)}function Rr(e){let t={};for(let n of xt(e).list){if(!La(n.name)||n.expr!==void 0)continue;let s=n.value??"";Sr(n.name,s)&&(t[n.name]=s)}return t}var Oa=/^(?:data-[\w-]+|aria-[\w-]+|disabled|hidden)$/,Ma=new Set(["disabled","hidden"]);function mt(e,t,n=0){if(n>4)return null;let s=mn(e),r=ue(s,0);if(r&&r.end===s.length)return r.value;let o=Cr(s);if(o){let l=Pe(o.condition,t);return l===null?null:mt(l?o.yes:o.no,t,n+1)}let i=gn(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(!fn.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=$r(s,t,n);return l===null?null:l?"true":void 0}return t.values.has(s)?void 0:null}function Na(e,t){let n={};for(let s of xt(e).list){if(s.expr===void 0||!Oa.test(s.name))continue;let r=mt(s.expr,t);if(r!=null){if(Ma.has(s.name)){r!=="false"&&(n[s.name]="");continue}Sr(s.name,r)&&(n[s.name]=r)}}return n}function Da(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(_a.has(a)){let l=hn(i.attrs),c=l&&!l.dynamic&&l.classes.length?` class="${br(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+=br(e.slice(s,o)),s=o}return n}function Ta(e){let t=hn(e.attrs);return!t||t.dynamic||t.classes.length===0?null:{tag:e.tag.toLowerCase(),classes:t.classes,attrs:Rr(e.attrs)}}function Ar(e,t){let n=[],s=t-1;for(;n.length<3&&s>=0;){let r=dn(e,s);if(!r||r==="too-big"||/^[A-Z]/.test(r.tag))break;let o=Ta(r);if(!o)break;n.push(o),s=r.openStart-1}return n.reverse()}var Ba=8;function Fa(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 Ua(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 vr(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=Fa(a[3]);c!==null&&o.set(l,c)}return{values:o,end:s}}function Va(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=Ua(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 za(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 Wa(e,t,n,s){let r=ja(e,t.openStart,t.closeEnd);if(/^[A-Z]/.test(t.tag)){let m=Da(e.slice(t.openStart,t.openEnd),n-t.openStart);return{kind:"component",...r,component:{tag:t.tag,...m}}}let o=Va(e,t);for(let[m,h]of za(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=Ga(a.attrs,l);if(!c)return{kind:"dynamic",...r};let u={tag:t.tag.toLowerCase(),...c,ancestors:Ar(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,Ba).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 Ga(e,t){let n=hn(e,t);return n?.dynamic?null:{classes:n?.classes??[],attrs:{...Rr(e),...Na(e,t)}}}function bn(e,t,n,s){if(Ra.test(s))return yr(e,t);let r=dn(e,t);return r==="too-big"||!r?yr(e,t):Wa(e,r,t,n)}function Ha(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 _r(e,t){let n=Ha(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 yn(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 Ka(e,t,n,s,r){for(let o of yn(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 Er(e,t,n,s,r,o){if(e.kind!=="component"||!e.component||r.length===0)return e;let i=Ka(s,t,e.component.tag,r,o);if(!i)return e;let a=dn(t,n),l=e.component.tag;if(!a||a==="too-big"||a.tag!==l&&a.tag!==i.component)return e;let c=_r(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:Ar(t,a.openStart),bodyHtml:bt(a.body)}}:e}function kt(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 yn(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 w=yt(t,m);if(!w||w==="too-big"){u=m+f.length;continue}let C=_r(c,w.attrs);(C.selects.length||C.unknown.length)&&a.push({offset:m,component:l,selects:C.selects,unknown:C.unknown}),u=Math.max(w.closeEnd,m+f.length)}}return a}function Ja(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 Za(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 qa(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 Xa(e,t,n,s){let r=[];for(let o of yn(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 Ya(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:wr(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 Qa(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 Ir(e,t,n){let s=[];for(let r of e){let o=Xa(r.source,r.path,t,n);for(let i of r.names){let a=new RegExp(`(?:function\\s+${i}\\b|(?:const|let|var)\\s+${i}\\b)`,"g"),l=[...r.source.matchAll(a)],c=null;for(let u of l){let f=u.index??0,h=r.source.slice(f+u[0].length).search(/\nexport\s/),w=r.source.slice(f,f+u[0].length+(h<0?8e3:h)),C=Ja(r.source,f),$=0;for(;$<w.length;){if(w[$]!=="<"||w[$+1]==="/"||w[$+1]==="!"){$++;continue}let g=yt(w,$);if(!g||g==="too-big"){$++;continue}if($=g.openEnd,/^[A-Z]/.test(g.tag))continue;let p=Za(g.attrs);if(!p)continue;let d=Ya(p),y=d.prefixes.length?2:d.staticClasses.length?1:0,k=null,x=o.find(v=>new RegExp(`(?:^|[^\\w$])${v.local}\\s*\\(`).test(p));if(x){let v=p.search(new RegExp(`(?:^|[^\\w$])${x.local}\\s*\\(`)),I=p.indexOf("(",v),j=I<0?null:qa(p,I);if(j){y=3,k=Qa(x.recipe,j,C,d.staticClasses,d.classNameProp);for(let R of d.prefixes)k.axes.push({prop:R.prop,values:[],prefix:R.prefix,defaultValue:C[R.prop]})}}!k&&(d.prefixes.length||d.staticClasses.length)&&(k={staticClasses:d.staticClasses,axes:d.prefixes.map(v=>({prop:v.prop,values:[],prefix:v.prefix,defaultValue:C[v.prop]})),compounds:[],classNameProp:d.classNameProp}),k&&(!c||y>c.score)&&(c={score:y,tag:g.tag.toLowerCase(),body:k})}}c&&s.push({component:i,path:r.path,rootTag:c.tag,...c.body})}}return s}var el=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,tl=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,nl=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),sl=new Set(["icon","glyph","svg"]),rl=new Set(["label","text","title","caption"]),ol=e=>e.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(t=>t.toLowerCase());function Pr(e){let t=e.flatMap(ol);return t.some(n=>sl.has(n))?"icon":t.some(n=>rl.has(n))?"label":null}function il(e){let t=e.replace(/\{\s*\/\*[\s\S]*?\*\/\s*\}/g," "),n=[];for(let s of t.matchAll(el)){let r=s[1];if(!nl.has(r.toLowerCase())||r!==r.toLowerCase())continue;let o=[...s[2].matchAll(tl)].map(a=>a[1]??a[2]),i=Pr(o);i&&n.push({index:s.index??0,role:i,tag:r.toLowerCase(),classes:o})}return n}function al(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 W(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 ll=["text","icon-start","icon-end","icon"],jr={text:"Text","icon-start":"Icon left","icon-end":"Icon right",icon:"Icon"};function cl(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 Lr(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(il),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(w=>Pr([w])==="label"))),c=null,u=null;for(let h of i){let w=cl(h,o),C=o.reduce(($,g)=>{let p=Math.abs(g.index-h.index);return!$||p<$.dist?{hit:g,dist:p}:$},null);w==="start"&&C&&!c&&(c={icon:h,label:C.hit}),w==="end"&&C&&!u&&(u={icon:h,label:C.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=al(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:jr.text,sheets:t.get("text")??[]},...ll.filter(s=>s!=="text"&&t.has(s)).map(s=>({id:s,label:jr[s],sheets:t.get(s)??[]}))]}function ul(e,t){if(!e)return t;let n=W(e);return W(t).flatMap(s=>n.map(r=>s.includes("&")?s.replaceAll("&",r):`${r} ${s}`)).join(", ")}var pl=/^@(?:-\w+-)?(?:keyframes|font-face|property)\b/i;function ke(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===`
49
- `&&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":ul(m?.resolved??null,l),isAt:f,skip:(c?.skip??!1)||f&&pl.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 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 fl=25,dl=12,Or=700,gl=/\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 ml(e){let t=e.split(`
51
+ `).length>12;return{source:Mr(i)+(a?`
52
+ \u2026`:""),startLine:o}}function xl(e,t){let n=jr(e,Math.max(0,t)),s=e.split(`
53
+ `),r=Math.max(0,n-1);return{source:Mr(s.slice(r,r+12)),startLine:r+1}}function Lr(e,t){return{kind:"other",...xl(e,t)}}function Rt(e,t){let n=Pr.exec(e.slice(t));if(!n)return null;let s=n[1],r=n[2]??"",o=t+n[0].length;if(/\/\s*$/.test(r)||ml.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=Pr.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 vn(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=Rt(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 Tr(e){return e.replace(/([a-z\d])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function Le(e){return e.split(/\s+/).filter(Boolean)}function pe(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 Or(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 Ct(e=new Map,t=new Map){return{values:e,aliases:t,flags:new Set,strings:new Set,prefixes:new Map}}var kn=/^[A-Za-z_$][\w$]*$/;function $n(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 Dr(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)?je(s,t,n+1):(t.flags.add(e),!!t.values.get(e))}function je(e,t,n=0){if(n>4)return null;let s=Cn(e);for(let c of["||","&&"]){let u=$n(s,c);if(u<0)continue;let f=je(s.slice(0,u),t,n+1),m=je(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=Dr(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 Nr(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=Ct()){let n=Cn(e);if(!n)return{classes:[],dynamic:!1};let s=Nr(n);if(s){let c=je(s.condition,t);return c===null?{classes:[],dynamic:!0}:Ie(c?s.yes:s.no,t)}let r=$n(n,"&&");if(r>=0){let c=je(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:Le(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 k=c.slice(m+2,h).trim();if(kn.test(k)){let C=t.values.get(k);if(typeof C!="string")return{classes:[],dynamic:!0};t.strings.add(k);let $=/[\w-]*$/.exec(u)?.[0];$&&t.prefixes.set(k,$),u+=C}else{let C=Ie(k,t);if(C.dynamic)return{classes:[],dynamic:!0};u+=C.classes.join(" ")}f=h+1}return{classes:Le(u),dynamic:!1}}if(kn.test(n)&&t.values.has(n)){let c=t.values.get(n);return typeof c!="string"?{classes:[],dynamic:!1}:(t.strings.add(n),{classes:Le(c),dynamic:!1})}let o=/^(?:styles?|classes|css|cls)\.([A-Za-z_]\w*)$/.exec(n);if(o)return{classes:[Tr(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&&yl.has(l[1])){let c=[];for(let u of Or(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 At(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=pe(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=pe(l,0);c&&c.end===l.length?t.push({name:r[1],value:c.value}):t.push({name:r[1],expr:l});continue}s++}return{list:t,spread:n}}function Sn(e,t){let n=At(e).list.find(s=>s.name==="class"||s.name==="className");return n?n.value!==void 0?{classes:Le(n.value),dynamic:!1}:n.expr===void 0?{classes:[],dynamic:!0}:Ie(n.expr,t):null}function Ur(e,t){return/[<>]/.test(t)?!1:e==="href"||e==="src"||e==="action"?/^(?:https?:|mailto:|\/|#)/i.test(t):!0}function kl(e){return e==="class"||e==="className"?!1:!bl.test(e)&&!/^on/i.test(e)}function Fr(e){let t={};for(let n of At(e).list){if(!kl(n.name)||n.expr!==void 0)continue;let s=n.value??"";Ur(n.name,s)&&(t[n.name]=s)}return t}var vl=/^(?:data-[\w-]+|aria-[\w-]+|disabled|hidden)$/,$l=new Set(["disabled","hidden"]);function $t(e,t,n=0){if(n>4)return null;let s=Cn(e),r=pe(s,0);if(r&&r.end===s.length)return r.value;let o=Nr(s);if(o){let l=je(o.condition,t);return l===null?null:$t(l?o.yes:o.no,t,n+1)}let i=$n(s,"||");if(i>=0){let l=$t(s.slice(0,i),t,n+1);return l===null?null:l!==void 0?l:$t(s.slice(i+2),t,n+1)}if(s==="undefined"||s==="null"||s==="false")return;if(s==="true")return"true";if(!kn.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=Dr(s,t,n);return l===null?null:l?"true":void 0}return t.values.has(s)?void 0:null}function Cl(e,t){let n={};for(let s of At(e).list){if(s.expr===void 0||!vl.test(s.name))continue;let r=$t(s.expr,t);if(r!=null){if($l.has(s.name)){r!=="false"&&(n[s.name]="");continue}Ur(s.name,r)&&(n[s.name]=r)}}return n}function Sl(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 St(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=Rt(e,s);if(!i||i==="too-big"){s++;continue}let a=i.tag.toLowerCase();if(/^[A-Z]/.test(i.tag))n+=St(i.body,t+1);else if(hl.has(a)){let l=Sn(i.attrs),c=l&&!l.dynamic&&l.classes.length?` class="${Ir(l.classes.join(" "))}"`:"",u=St(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+=Ir(e.slice(s,o)),s=o}return n}function Rl(e){let t=Sn(e.attrs);return!t||t.dynamic||t.classes.length===0?null:{tag:e.tag.toLowerCase(),classes:t.classes,attrs:Fr(e.attrs)}}function Br(e,t){let n=[],s=t-1;for(;n.length<3&&s>=0;){let r=vn(e,s);if(!r||r==="too-big"||/^[A-Z]/.test(r.tag))break;let o=Rl(r);if(!o)break;n.push(o),s=r.openStart-1}return n.reverse()}var Al=8;function _l(e){let t=e.trim(),n=pe(t,0);return n&&n.end===t.length?n.value:t==="true"?!0:t==="false"?!1:/^-?\d+(?:\.\d+)?$/.test(t)?t:null}function El(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=pe(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 Or(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=_l(a[3]);c!==null&&o.set(l,c)}return{values:o,end:s}}function Pl(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=El(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 Ct(l.values,c)}return Ct()}function Il(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 Ll(e,t,n,s){let r=wl(e,t.openStart,t.closeEnd);if(/^[A-Z]/.test(t.tag)){let m=Sl(e.slice(t.openStart,t.openEnd),n-t.openStart);return{kind:"component",...r,component:{tag:t.tag,...m}}}let o=Pl(e,t);for(let[m,h]of Il(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=Ct(new Map(o.values),o.aliases),c=jl(a.attrs,l);if(!c)return{kind:"dynamic",...r};let u={tag:t.tag.toLowerCase(),...c,ancestors:Br(e,t.openStart),bodyHtml:St(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,Al).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 jl(e,t){let n=Sn(e,t);return n?.dynamic?null:{classes:n?.classes??[],attrs:{...Fr(e),...Cl(e,t)}}}function Rn(e,t,n,s){if(gl.test(s))return Lr(e,t);let r=vn(e,t);return r==="too-big"||!r?Lr(e,t):Ll(e,r,t,n)}function Ml(e){let t={},n=new Set,{list:s,spread:r}=At(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 Vr(e,t){let n=Ml(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(...Le(n.literals.className))),{draw:a?null:[...e.staticClasses,...o],selects:r,unknown:i}}function An(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 Tl(e,t,n,s,r){for(let o of An(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 zr(e,t,n,s,r,o){if(e.kind!=="component"||!e.component||r.length===0)return e;let i=Tl(s,t,e.component.tag,r,o);if(!i)return e;let a=vn(t,n),l=e.component.tag;if(!a||a==="too-big"||a.tag!==l&&a.tag!==i.component)return e;let c=Vr(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:Br(t,a.openStart),bodyHtml:St(a.body)}}:e}function _t(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 An(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 k=Rt(t,m);if(!k||k==="too-big"){u=m+f.length;continue}let C=Vr(c,k.attrs);(C.selects.length||C.unknown.length)&&a.push({offset:m,component:l,selects:C.selects,unknown:C.unknown}),u=Math.max(k.closeEnd,m+f.length)}}return a}function Ol(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 Dl(e){let t=/\bclassName\s*=\s*/.exec(e);if(!t)return null;let n=t.index+t[0].length,s=pe(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 Nl(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=pe(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=pe(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 Ul(e,t,n,s){let r=[];for(let o of An(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 Fl(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:Tr(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(...Le(c.text));let l=/(?:^|[(,\s])className\s*(?:[,)]|$)/.test(e);return{staticClasses:i,prefixes:a,classNameProp:l}}function Bl(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 Wr(e,t,n){let s=[];for(let r of e){let o=Ul(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/),k=r.source.slice(f,f+u[0].length+(h<0?8e3:h)),C=Ol(r.source,f),$=0;for(;$<k.length;){if(k[$]!=="<"||k[$+1]==="/"||k[$+1]==="!"){$++;continue}let g=Rt(k,$);if(!g||g==="too-big"){$++;continue}if($=g.openEnd,/^[A-Z]/.test(g.tag))continue;let p=Dl(g.attrs);if(!p)continue;let d=Fl(p),b=d.prefixes.length?2:d.staticClasses.length?1:0,x=null,w=o.find(v=>new RegExp(`(?:^|[^\\w$])${v.local}\\s*\\(`).test(p));if(w){let v=p.search(new RegExp(`(?:^|[^\\w$])${w.local}\\s*\\(`)),P=p.indexOf("(",v),I=P<0?null:Nl(p,P);if(I){b=3,x=Bl(w.recipe,I,C,d.staticClasses,d.classNameProp);for(let R of d.prefixes)x.axes.push({prop:R.prop,values:[],prefix:R.prefix,defaultValue:C[R.prop]})}}!x&&(d.prefixes.length||d.staticClasses.length)&&(x={staticClasses:d.staticClasses,axes:d.prefixes.map(v=>({prop:v.prop,values:[],prefix:v.prefix,defaultValue:C[v.prop]})),compounds:[],classNameProp:d.classNameProp}),x&&(!c||b>c.score)&&(c={score:b,tag:g.tag.toLowerCase(),body:x})}}c&&s.push({component:i,path:r.path,rootTag:c.tag,...c.body})}}return s}var Vl=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,zl=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,Wl=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),Gl=new Set(["icon","glyph","svg"]),Kl=new Set(["label","text","title","caption"]),Hl=e=>e.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(t=>t.toLowerCase());function Kr(e){let t=e.flatMap(Hl);return t.some(n=>Gl.has(n))?"icon":t.some(n=>Kl.has(n))?"label":null}function ql(e){let t=e.replace(/\{\s*\/\*[\s\S]*?\*\/\s*\}/g," "),n=[];for(let s of t.matchAll(Vl)){let r=s[1];if(!Wl.has(r.toLowerCase())||r!==r.toLowerCase())continue;let o=[...s[2].matchAll(zl)].map(a=>a[1]??a[2]),i=Kr(o);i&&n.push({index:s.index??0,role:i,tag:r.toLowerCase(),classes:o})}return n}function Jl(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 W(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 Zl=["text","icon-start","icon-end","icon"],Gr={text:"Text","icon-start":"Icon left","icon-end":"Icon right",icon:"Icon"};function Xl(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 Me(e){return{role:e.role,tag:e.tag,classes:e.classes}}function Hr(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(ql),o=r.filter(h=>h.role==="label"),i=r.filter(h=>h.role==="icon"),a=o[0];a&&n("text",{path:s.sheet,slots:[Me(a)],classes:[],attrs:{}});let l=new Set(o.flatMap(h=>h.classes.filter(k=>Kr([k])==="label"))),c=null,u=null;for(let h of i){let k=Xl(h,o),C=o.reduce(($,g)=>{let p=Math.abs(g.index-h.index);return!$||p<$.dist?{hit:g,dist:p}:$},null);k==="start"&&C&&!c&&(c={icon:h,label:C.hit}),k==="end"&&C&&!u&&(u={icon:h,label:C.hit})}c&&n("icon-start",{path:s.sheet,slots:[Me(c.icon),Me(c.label)],classes:[],attrs:{}}),u&&n("icon-end",{path:s.sheet,slots:[Me(u.label),Me(u.icon)],classes:[],attrs:{}});let f=null;for(let h of s.rules)if(f=Jl(h.selector,h.declarations,l),f)break;let m=c?.icon??u?.icon??i[0]??null;f&&m&&n("icon",{path:s.sheet,slots:[Me(m)],classes:f.classes,attrs:f.attrs})}return[{id:"text",label:Gr.text,sheets:t.get("text")??[]},...Zl.filter(s=>s!=="text"&&t.has(s)).map(s=>({id:s,label:Gr[s],sheets:t.get(s)??[]}))]}function Yl(e,t){if(!e)return t;let n=W(e);return W(t).flatMap(s=>n.map(r=>s.includes("&")?s.replaceAll("&",r):`${r} ${s}`)).join(", ")}var Ql=/^@(?:-\w+-)?(?:keyframes|font-face|property)\b/i;function $e(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===`
54
+ `&&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":Yl(m?.resolved??null,l),isAt:f,skip:(c?.skip??!1)||f&&Ql.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 fe(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 ec=25,tc=12,qr=700,nc=/\b(?:must(?: not)?|never|always|should(?: not|n't)?|do not|don't|avoid|prefer|forbidden|not allowed|no more than)\b/i,ie=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function sc(e){let t=e.split(`
50
55
  `),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(`
51
- `).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 hl(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 bl(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 u=/[-_]|[a-z][A-Z]/.test(c);i.tests.push(new RegExp(u?`(?<![\\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 yl(e,t){return e.toLowerCase().replace(new RegExp(`\\b(?:${t.map(re).join("|")})s?\\b`,"g")," ").replace(/[^a-z0-9]+/g," ").trim()}function xl(e){return e.length>Or?`${e.slice(0,Or).trimEnd()}\u2026`:e}function Mr(e,t,n,s){let r=hl(n.classKeywords,n.prose),o=bl(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 ml(f)){if(!r.test(h.text)&&!h.headings.some($=>r.test($)))continue;let w=h.headings.length?yl(h.headings[h.headings.length-1],n.classKeywords):"",C=o.filter($=>$.tests.some(g=>g.test(h.text))||w!==""&&$.heading===w).map($=>$.title);for(let $ of C)i.add($);m.push({path:u.path,line:h.start,endLine:h.end,headings:h.headings,text:xl(h.text),rule:gl.test(h.text),styles:C})}m.length!==0&&a.push({path:u.path,kind:u.kind,passages:m.slice(0,dl),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,fl).map(({rules:u,...f})=>f),documented:[...i].sort(),undocumented:[...c.keys()].filter(u=>!i.has(u))}}var Nr=new Set(["tone","size","variant","kind","type","style","theme","color","colour","appearance","intent","emphasis","shape","level"]),kl=new Set(["is","has","js","c","component","comp","el","ui","the","root"]),wl={xs:["extra","small"],sm:["small"],md:["medium"],lg:["large"],xl:["extra","large"],xxl:["extra","extra","large"]},vl=new Set(["cta","ui","ux","faq","cms","api","url","ios"]);function kn(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 $l(e){return new Set(e.flatMap(t=>[t,`${t}s`]))}function xn(e){let t=e.map(n=>vl.has(n)?n.toUpperCase():n).join(" ");return t.charAt(0).toUpperCase()+t.slice(1)}function Oe(e,t){let n=kn(e).filter(r=>!t.has(r)&&!kl.has(r)),s=null;return n.length>1&&Nr.has(n[0])&&(s=n[0],n=n.slice(1)),{words:n.flatMap(r=>wl[r]??[r]),axis:s}}var Dr=/\.((?:\\.|[\w-])+)/g,Cl=/\[\s*([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*))\s*\]/g;function Sl(e,t){let n=e.split("/"),s=(n.pop()??"").replace(/(\.module)?\.[a-z]+$/i,""),r=n.pop()??"";return kn(s).some(a=>t.has(a))||kn(r).some(a=>t.has(a))?Oe(s,t).words:[]}function Rl(e,t){let n=[];for(let s of e.split(/[\s>+~]+/).filter(Boolean)){let r=[...s.matchAll(Dr)].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=$l(t),s=ye(e.selector),r=e.selector.slice(0,s),o=e.selector.slice(s),i=[...o.matchAll(Dr)].map(u=>Oe(u[1],n));for(let u of o.matchAll(Cl)){let f=u[1].replace(/^data-/,"").toLowerCase();if(!Nr.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=>xn(u.words)).join(" + "),axis:a.length===1?a[0].axis:null};let l=Rl(r,n);if(l.length>0)return{title:`In ${l.join(" ")}`,axis:null};let c=Sl(e.path,n);if(c.length>0)return{title:xn(c),axis:null};if(e.base){let u=Al(e.path,n);return u.length>0?{title:`${xn(u)} Base`,axis:null}:{title:"Base",axis:null}}return{title:"Unnamed",axis:null}}function Al(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 _l=60;function Ze(e,t,n){let s=Q(e);if(!s)return null;let r=s.length-1,o=s[r].simples;if(nr(o)||an(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)&&!an(a,t))return{compounds:s,at:i}}return!n||r===0&&sr(o)?null:{compounds:s,at:0}}function Tr(e,t,n){return Ke([...e,{combinator:e.length?t.combinator:null,simples:n}])}function Br(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 El(e,t){return e.length>=t.length?!1:e.every(n=>t.some(s=>Br(n,s)))}function Il(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 jl(e,t){for(let n of t.classes)e.classes.includes(n)||e.classes.push(n);Object.assign(e.attrs,t.attrs)}function Fr(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 Pl(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 wn(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 Ur(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 W(g.selector)){let d=Ze(p,n,s);if(!d)continue;let{compounds:y,at:k}=d,x=y[k],v=ft(x.simples);if(v.identity.length===0)continue;let I=y.slice(0,k),j=Tr(I,x,v.identity),R=be(v.states);if(k<y.length-1){i.push({hostKey:j,part:{selector:Ke(y),path:e,line:g.line,state:R}});continue}if(or(v.identity,g.declarations))continue;let A=o.get(j);if(!A){if(o.size>=_l)continue;A={key:j,prefix:I,identity:v.identity,line:g.line,states:[],modifiers:[],contexts:[],parts:[],movedInto:null},o.set(j,A)}let P=A.states.find(N=>N.state===R&&N.context===g.context);P||(P={state:R,context:g.context,line:g.line,declarations:[]},v.states.length&&(P.marker={classes:[],attrs:{}}),A.states.push(P)),P.marker&&jl(P.marker,v.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)),k=d.every(x=>Je(x.property)==="hint");(y||k)&&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=>Pl(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 k=[...y.classes.map(x=>({kind:"class",raw:`.${x}`,name:x})),...Object.entries(y.attrs).map(([x,v])=>({kind:"attr",raw:`[${x}="${v}"]`,name:x,op:"=",value:v}))];for(let x of g){let v=[...x.identity,...k],I={combinator:x.prefix.length?" ":null,simples:v},j=Tr(x.prefix,I,v);for(let R of x.states){let A=R.state.split(" + ").filter(P=>P!==d);if(R.state=be(A),A.length===0)delete R.marker;else if(R.marker){R.marker.classes=R.marker.classes.filter(P=>!y.classes.includes(P));for(let P of Object.keys(y.attrs))delete R.marker.attrs[P]}}o.delete(x.key),o.set(j,{...x,key:j,identity:v})}}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=>Il(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()],w=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 C=l().filter(g=>g.identity.filter(p=>p.kind!=="tag"&&p.kind!=="universal").length>=2).sort((g,p)=>g.identity.length-p.identity.length);for(let g of C){let p=h.filter(y=>y!==g&&y!==u&&y.prefix.length===0&&El(y.identity,g.identity));if(p.length===0)continue;p.sort((y,k)=>k.identity.length-y.identity.length||c(k)-c(y)||y.line-k.line);let d=w(p[0].key);d&&d!==g&&m(g,d,"modifiers")}for(let{hostKey:g,part:p}of i){let d=w(g)??(s?u:null);d&&o.has(d.key)&&d.parts.push(p)}let $=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:wn(g.states),modifiers:g.modifiers.length?g.modifiers.map(y=>{let k=y.identity.filter(x=>!g.identity.some(v=>Br(v,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:wn(y.states)}}):void 0,contexts:g.contexts.length?g.contexts.map(y=>{let k=Fr(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:wn(y.states)}}):void 0,parts:g.parts.length?g.parts:void 0}};return[...o.values()].map($)}function Vr(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=Fr(i.states.flatMap(c=>c.declarations));a.contexts=[...a.contexts??[],{selector:i.selector,path:i.path,line:i.line,role:l,element:l==="override"?i.element:null,states:i.states}],i.parts?.length&&(a.parts=[...a.parts??[],...i.parts]),i.modifiers?.length&&(a.modifiers=[...a.modifiers??[],...i.modifiers]),r.add(i)}return e.filter(i=>!r.has(i))}var Ll={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 zr(e){let t=e.lastIndexOf("-");return t<=0?null:Ll[e.slice(0,t)]?.[e.slice(t+1)]??null}var E=(e,t)=>({property:e,value:t});function Rn(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 Sn(e){let t=Rn(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 Ol(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 Wr(e,t){return{full:"100%",screen:t==="w"?"100vw":"100vh",auto:"auto",fit:"fit-content",min:"min-content",max:"max-content"}[e]??Ol(e)??Rn(e)??Sn(e)}var Ml={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"}},Nl={thin:"100",extralight:"200",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"},Dl={none:"1",tight:"1.25",snug:"1.375",normal:"1.5",relaxed:"1.625",loose:"2"},Tl={none:"0",sm:"0.125rem","":"0.25rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem","3xl":"1.5rem",full:"9999px"},Bl={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"},Fl={"":"3px",0:"0px",1:"1px",2:"2px",4:"4px",8:"8px"};function vn(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=zr(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 Ul(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 $n(){return E("box-shadow","0 0 0 var(--gs-ring-w, 3px) var(--gs-ring-c, currentColor)")}var Vl={flex:"flex","inline-flex":"inline-flex",block:"block","inline-block":"inline-block",inline:"inline",grid:"grid","inline-grid":"inline-grid",hidden:"none",contents:"contents"},Cn={start:"flex-start",end:"flex-end",center:"center",baseline:"baseline",stretch:"stretch",between:"space-between",around:"space-around",evenly:"space-evenly"};function Gr(e){let t=e.startsWith("-"),n=t?e.slice(1):e,{body:s,opacity:r}=Ul(n),o=Vl[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 A=i[1]==="col"?"column":i[1]==="col-reverse"?"column-reverse":i[1];return[E("flex-direction",A)]}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",Cn[a[1]])];let l=/^justify-(start|end|center|between|around|evenly)$/.exec(s);if(l&&!t)return[E("justify-content",Cn[l[1]])];let c=/^self-(start|end|center|stretch|auto)$/.exec(s);if(c&&!t)return[E("align-self",c[1]==="auto"?"auto":Cn[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=Ml[s.replace(/^text-/,"")];if(s.startsWith("text-")&&m&&!r&&!t)return[E("font-size",m.size),E("line-height",m.leading)];let h=Nl[s.replace(/^font-/,"")];if(s.startsWith("font-")&&h&&!r)return[E("font-weight",h)];if(s.startsWith("leading-")&&!r){let A=s.slice(8),N=Dl[A]??Sn(A);if(N)return[E("line-height",N)]}let w=/^cursor-(pointer|default|not-allowed|wait|text|move)$/.exec(s);if(w)return[E("cursor",w[1])];if(s==="pointer-events-none")return[E("pointer-events","none")];if(s==="pointer-events-auto")return[E("pointer-events","auto")];if(s==="select-none")return[E("user-select","none")];let C=/^opacity-(\d+)$/.exec(s);if(C&&!t)return[E("opacity",String(Number(C[1])/100))];if(s==="transition"||s==="transition-colors"||s==="transition-all")return[E("transition-property",s==="transition-colors"?"color, background-color, border-color, text-decoration-color, fill, stroke":s==="transition-all"?"all":"color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter"),E("transition-timing-function","cubic-bezier(0.4, 0, 0.2, 1)"),E("transition-duration","150ms")];let $=/^duration-(\d+)$/.exec(s);if($)return[E("transition-duration",`${$[1]}ms`)];let g={linear:"linear",in:"cubic-bezier(0.4, 0, 1, 1)",out:"cubic-bezier(0, 0, 0.2, 1)","in-out":"cubic-bezier(0.4, 0, 0.2, 1)"};if(s.startsWith("ease-")&&g[s.slice(4)])return[E("transition-timing-function",g[s.slice(4)])];if(s==="outline-none")return[E("outline","2px solid transparent"),E("outline-offset","2px")];if(s==="outline")return[E("outline-style","solid")];let p=/^outline-(\d+)$/.exec(s);if(p)return[E("outline-width",`${p[1]}px`)];if(s==="shadow"||s.startsWith("shadow-")){let A=s==="shadow"?"":s.slice(7),P=Bl[A];if(P)return[E("box-shadow",P)]}if(s==="ring"||/^ring(?:-(?:0|1|2|4|8))?$/.test(s)){let A=s==="ring"?"":s.slice(5),P=Fl[A];if(P)return[E("--gs-ring-w",P),$n()]}if(s.startsWith("ring-")&&r===null){let A=vn(s.slice(5),null);if(A)return[E("--gs-ring-c",A),$n()]}if(s.startsWith("ring-")&&r){let A=vn(s.slice(5),r);if(A)return[E("--gs-ring-c",A),$n()]}let d=s==="rounded"?"":s.startsWith("rounded-")?s.slice(8):null;if(d!==null&&!t){let A=/^(t|r|b|l|s|e|tl|tr|bl|br|ss|se)(?:-(.+))?$/.exec(d),P=A?A[2]??"":d,N=Tl[P];if(!N)return null;if(!A)return[E("border-radius",N)];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"]}[A[1]];return X?X.map(tt=>E(tt,N)):null}if(/^border(?:-[trblxy])?$/.test(s)&&!r)return[E("border-width","1px"),E("border-style","solid")];let y=/^border-(\d+)$/.exec(s);if(y&&!r)return[E("border-width",`${y[1]}px`),E("border-style","solid")];let 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),v=x?.[1],I=x?.[2];if(v&&I&&!r){let A=v==="w"||v==="min-w"||v==="max-w"?Wr(I,"w"):v==="h"||v==="min-h"||v==="max-h"?Wr(I,"h"):Sn(I);if(!A)return null;let P=t?A==="0"?"0":`-${A}`:A,V={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"]}[v];return V?V.map(X=>E(X,P)):null}let j={bg:"background-color",text:"color",border:"border-color",outline:"outline-color",decoration:"text-decoration-color",accent:"accent-color",caret:"caret-color",fill:"fill",stroke:"stroke"};for(let[A,P]of Object.entries(j))if(s===A||s.startsWith(`${A}-`)){let N=s===A?"":s.slice(A.length+1);if(!N||/^(?:gradient|clip|ellipsis|wrap|nowrap|balance|pretty|opacity)/.test(N))return null;if(A==="text"&&!t){let X=Rn(N);if(X)return[E("font-size",X)]}let V=vn(N,r);return!V||t?null:[E(P,V)]}let R=/^\[([a-z-]+):(.+)\]$/i.exec(s);if(R&&!t&&!r){let A=R[1].toLowerCase(),P=R[2].replace(/_/g," ").trim();if(/^[a-z][\w-]*$/.test(A)&&P&&!/[<>]/.test(P))return[E(A,P)]}return null}var zl=48,Wl={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",disabled:"disabled"},Gl=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]===`
52
- `&&n++;return n}function Hl(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 G(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;return t}function wt(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"?`
53
- `: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 En(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=wt(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 Kl(e,t){let n=0;for(let s=t;s<e.length;s++){let r=e[s];if(r==='"'||r==="'"||r==="`"){let o=wt(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 Hr(e){if(e.t==="str")return e.v;if(e.t==="arr"){let t=[];for(let n of e.items){let s=Hr(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 Jl(e,t){let n=t+1,s=[];for(;n<e.length;){if(n=G(e,n),e[n]===")")return{v:s.join(" ").replace(/\s+/g," ").trim()||null,end:n+1};if(e[n]===","){n++;continue}let r=ne(e,n);if(!r)return null;let o=G(e,r.end);if(e[o]===","||e[o]===")"){let i=Hr(r.val);i&&s.push(i),n=r.end;continue}n=Kl(e,n)}return null}function ne(e,t){if(t=G(e,t),t>=e.length)return null;let n=e[t];if(n==='"'||n==="'"||n==="`"){let r=wt(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=G(e,r),e[r]==="]")return{val:{t:"arr",items:o,at:t},end:r+1};if(e[r]===","){r++;continue}let i=ne(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=G(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=ne(e,r+3);if(!c)return null;r=c.end;continue}let i="",a=r;if(e[r]==='"'||e[r]==="'"||e[r]==="`"){let c=wt(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=G(e,r),e[r]!==":"){e[r]==="("&&(r=En(e,r,"(",")"));continue}let l=ne(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=G(e,r);if(e[i]==="("){if(Gl.has(o)){let a=Jl(e,i);return a?{val:{t:"str",v:a.v,at:s},end:a.end}:null}return{val:{t:"other",at:s},end:En(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 Kr(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 An={sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"};function Zl(e,t,n,s){let r=Wl[e];if(r)return t.includes(r)||t.push(r),!0;if(e==="dark")return s.on=!0,!0;if(An[e])return n.min.push(An[e]),!0;let o=/^max-(sm|md|lg|xl|2xl)$/.exec(e);if(o)return n.below.push(An[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 ql(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 Jr(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||!Zl(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:be(a),context:ql(l,c.on),utility:i,important:n,stem:u}}function Zr(e){let t=Gr(e.utility);return t?t.map(n=>({property:n.property,value:e.important?`${n.value} !important`:n.value,via:e.token})):[]}function Xl(e){return e.some(t=>Je(t.property)!=="hint")}function $t(e){let t=[];for(let n of e.matchAll(/@apply\s+([^;{}]+)/g))for(let s of Kr(n[1])){let r=Jr(s);if(!r)continue;let o=Zr(r).filter(i=>se(i.property,i.value));o.length!==0&&t.push({state:r.state,context:r.context,declarations:o})}return t}function qr(e){return e==="default"?"":e.split(" + ").map(t=>t==="hover"?":hover":t==="focus"?":focus":t==="active"?":active":t==="disabled"?":disabled":"").join("")}function Pn(e,t,n){let s=t.map(f=>`${f.property}:${f.value}`).join(";");if(!s)return[];let r=ln(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 Yl(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 Ql(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 ec(e,t,n,s,r){let o=ne(e,t),i={slots:[],defaults:{}};if(!o)return i;let a=vt(o.val)??"",l=G(e,o.end);if(e[l]!==",")return a.trim()?{slots:[_n(a,fe(e,t),r)],defaults:{}}:i;let c=ne(e,l+1);if(!c||c.val.t!=="obj")return a.trim()?{slots:[_n(a,fe(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(_n(a,fe(e,t),r)),u&&u.t==="obj"){for(let h of u.entries)if(h.value.t==="obj")for(let w of h.value.entries){let C=vt(w.value);if(!C||!C.trim()||w.key==="false")continue;m.set(`${h.key}\0${w.key}`,C);let $=w.key==="true"?`.${h.key}`:`.${h.key}-${w.key}`,g=Me({selector:$,path:s,base:!1},n.classKeywords);f.push({title:g.title,axis:w.key==="true"?h.key:g.axis??h.key,base:!1,classes:`${a} ${C}`.trim(),line:fe(e,w.at),group:r,prop:h.key,value:w.key})}}return f.push(...tc(c.val,a,m,n,s,e,r)),{slots:f,defaults:Ql(c.val)}}function Xr(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=Xr(n);if(!s||s.length!==1)return null;t.push(s[0])}return t.length?t:null}return null}function tc(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 C of c.entries){if(C.key==="class"||C.key==="className"){f=vt(C.value)??"",m=C.at,C.value.t!=="str"&&C.value.t!=="arr"&&f===""&&(h=!0);continue}let $=Xr(C.value);if(!$){h=!0;break}u.push({axis:C.key,values:$})}if(h)continue;let w=[[]];for(let C of u){let $=[];for(let g of w){for(let p of C.values)if($.push([...g,{axis:C.axis,value:p}]),$.length>=8)break;if($.length>=8)break}w=$}for(let C of w){if(C.length<2&&!f.trim())continue;let $=[t],g=[];for(let y of C){let k=n.get(`${y.axis}\0${y.value}`);k&&$.push(k),g.push(y.value==="true"?y.axis:y.value)}f.trim()&&$.push(f);let p=$.join(" ").replace(/\s+/g," ").trim();if(!p)continue;let d=Me({selector:`.${g.join("-")}`,path:r,base:!1},s.classKeywords);l.push({title:d.title,axis:d.axis,base:!1,classes:p,line:fe(o,m),group:i,when:C.map(y=>({prop:y.axis,value:y.value}))})}}return l}function _n(e,t,n){return{title:"Base",axis:null,base:!0,classes:e,line:t,group:n}}function Yr(e,t){return t.elements.includes(e.toLowerCase())?!0:t.identifier.test(e)}function nc(e){let t=e.match(/\bclassName\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*"([^"]*)"\s*\}|\{\s*'([^']*)'\s*\})/);return t?.[1]??t?.[2]??t?.[3]??t?.[4]??null}var sc=new Set(["opacity","z-index","font-weight","line-height","flex","flex-grow","flex-shrink","order","zoom"]);function rc(e){return e.replace(/^[A-Z]/,t=>`-${t.toLowerCase()}`).replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function oc(e,t){return t.t==="str"?t.v:t.t==="num"?sc.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=rc(o.key),a=oc(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 In(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"?`
54
- `: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 ic(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 jn(e){let t=[];for(let n of ke(`.__gs {
56
+ `).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 rc(e,t){let n=e.map(ie).join("|"),s=e.map(r=>ie(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 oc(e,t){let n=t.map(ie).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(ke(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-])${ie(c)}(?![\\w-])`:`(?:\\.|["'\`])${ie(c)}(?![\\w-])`))}if(!r.title.includes(" + ")){let l=r.title.toLowerCase().split(/\s+/).map(ie).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${ie(r.axis)}\\s*[=:]\\s*\\{?\\s*["'\`]${ie(r.title.toLowerCase())}["'\`]`,"i")),i.heading=r.title.toLowerCase()}s.set(r.title,i)}return[...s.values()]}function ic(e,t){return e.toLowerCase().replace(new RegExp(`\\b(?:${t.map(ie).join("|")})s?\\b`,"g")," ").replace(/[^a-z0-9]+/g," ").trim()}function ac(e){return e.length>qr?`${e.slice(0,qr).trimEnd()}\u2026`:e}function Jr(e,t,n,s){let r=rc(n.classKeywords,n.prose),o=oc(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 sc(f)){if(!r.test(h.text)&&!h.headings.some($=>r.test($)))continue;let k=h.headings.length?ic(h.headings[h.headings.length-1],n.classKeywords):"",C=o.filter($=>$.tests.some(g=>g.test(h.text))||k!==""&&$.heading===k).map($=>$.title);for(let $ of C)i.add($);m.push({path:u.path,line:h.start,endLine:h.end,headings:h.headings,text:ac(h.text),rule:nc.test(h.text),styles:C})}m.length!==0&&a.push({path:u.path,kind:u.kind,passages:m.slice(0,tc),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,ec).map(({rules:u,...f})=>f),documented:[...i].sort(),undocumented:[...c.keys()].filter(u=>!i.has(u))}}var Zr=new Set(["tone","size","variant","kind","type","style","theme","color","colour","appearance","intent","emphasis","shape","level"]),lc=new Set(["is","has","js","c","component","comp","el","ui","the","root"]),cc={xs:["extra","small"],sm:["small"],md:["medium"],lg:["large"],xl:["extra","large"],xxl:["extra","extra","large"]},uc=new Set(["cta","ui","ux","faq","cms","api","url","ios"]);function En(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 pc(e){return new Set(e.flatMap(t=>[t,`${t}s`]))}function _n(e){let t=e.map(n=>uc.has(n)?n.toUpperCase():n).join(" ");return t.charAt(0).toUpperCase()+t.slice(1)}function Te(e,t){let n=En(e).filter(r=>!t.has(r)&&!lc.has(r)),s=null;return n.length>1&&Zr.has(n[0])&&(s=n[0],n=n.slice(1)),{words:n.flatMap(r=>cc[r]??[r]),axis:s}}var Xr=/\.((?:\\.|[\w-])+)/g,fc=/\[\s*([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*))\s*\]/g;function dc(e,t){let n=e.split("/"),s=(n.pop()??"").replace(/(\.module)?\.[a-z]+$/i,""),r=n.pop()??"";return En(s).some(a=>t.has(a))||En(r).some(a=>t.has(a))?Te(s,t).words:[]}function gc(e,t){let n=[];for(let s of e.split(/[\s>+~]+/).filter(Boolean)){let r=[...s.matchAll(Xr)].map(o=>o[1]);if(r.length)for(let o of r)n.push(...Te(o,t).words);else{let o=/^[a-z][\w-]*/i.exec(s)?.[0]?.toLowerCase();o&&!["div","span","html","body"].includes(o)&&n.push(...Te(o,t).words)}}return n}function Oe(e,t){let n=pc(t),s=ke(e.selector),r=e.selector.slice(0,s),o=e.selector.slice(s),i=[...o.matchAll(Xr)].map(u=>Te(u[1],n));for(let u of o.matchAll(fc)){let f=u[1].replace(/^data-/,"").toLowerCase();if(!Zr.has(f))continue;let m=u[2]??u[3]??u[4]??"",h=Te(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=>_n(u.words)).join(" + "),axis:a.length===1?a[0].axis:null};let l=gc(r,n);if(l.length>0)return{title:`In ${l.join(" ")}`,axis:null};let c=dc(e.path,n);if(c.length>0)return{title:_n(c),axis:null};if(e.base){let u=mc(e.path,n);return u.length>0?{title:`${_n(u)} Base`,axis:null}:{title:"Base",axis:null}}return{title:"Unnamed",axis:null}}function mc(e,t){let n=e.split("/").pop()??"";if(!/\.module\.[a-z]+$/i.test(n))return[];let s=n.replace(/\.module\.[a-z]+$/i,"");return Te(s,t).words}var hc=60;function Ye(e,t,n){let s=Q(e);if(!s)return null;let r=s.length-1,o=s[r].simples;if(yr(o)||hn(o,t))return null;if(wt(o,t))return{compounds:s,at:r};for(let i=r-1;i>=0;i--){let a=s[i].simples;if(wt(a,t)&&!hn(a,t))return{compounds:s,at:i}}return!n||r===0&&br(o)?null:{compounds:s,at:0}}function Yr(e,t,n){return Je([...e,{combinator:e.length?t.combinator:null,simples:n}])}function Qr(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 yc(e,t){return e.length>=t.length?!1:e.every(n=>t.some(s=>Qr(n,s)))}function bc(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 wc(e,t){for(let n of t.classes)e.classes.includes(n)||e.classes.push(n);Object.assign(e.attrs,t.attrs)}function eo(e){let t=new Set(e.map(n=>Ze(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 xc(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=>K(o)===bt.length);return r.length===1?r[0]:null}function Pn(e){return e.sort((t,n)=>+(t.context!=="")-+(n.context!=="")||K(t.state.split(" + ")[0])-K(n.state.split(" + ")[0])||t.state.localeCompare(n.state))}function to(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 W(g.selector)){let d=Ye(p,n,s);if(!d)continue;let{compounds:b,at:x}=d,w=b[x],v=xt(w.simples);if(v.identity.length===0)continue;let P=b.slice(0,x),I=Yr(P,w,v.identity),R=xe(v.states);if(x<b.length-1){i.push({hostKey:I,part:{selector:Je(b),path:e,line:g.line,state:R}});continue}if(xr(v.identity,g.declarations))continue;let A=o.get(I);if(!A){if(o.size>=hc)continue;A={key:I,prefix:P,identity:v.identity,line:g.line,states:[],modifiers:[],contexts:[],parts:[],movedInto:null},o.set(I,A)}let L=A.states.find(O=>O.state===R&&O.context===g.context);L||(L={state:R,context:g.context,line:g.line,declarations:[]},v.states.length&&(L.marker={classes:[],attrs:{}}),A.states.push(L)),L.marker&&wc(L.marker,v.marker),L.declarations.push(...g.declarations)}for(let[g,p]of o){let d=p.states.flatMap(w=>w.declarations),b=p.states.every(w=>vt(w.declarations)),x=d.every(w=>Ze(w.property)==="hint");(b||x)&&o.delete(g)}let a=new Map;for(let g of o.values()){let p=qe(g.identity);a.set(p,[...a.get(p)??[],g])}for(let g of a.values()){let p=g.map(w=>xc(w.states)),d=p[0];if(!d||p.some(w=>w!==d))continue;let b=g.flatMap(w=>w.states).find(w=>w.marker&&w.state.split(" + ").includes(d))?.marker;if(!b)continue;let x=[...b.classes.map(w=>({kind:"class",raw:`.${w}`,name:w})),...Object.entries(b.attrs).map(([w,v])=>({kind:"attr",raw:`[${w}="${v}"]`,name:w,op:"=",value:v}))];for(let w of g){let v=[...w.identity,...x],P={combinator:w.prefix.length?" ":null,simples:v},I=Yr(w.prefix,P,v);for(let R of w.states){let A=R.state.split(" + ").filter(L=>L!==d);if(R.state=xe(A),A.length===0)delete R.marker;else if(R.marker){R.marker.classes=R.marker.classes.filter(L=>!b.classes.includes(L));for(let L of Object.keys(b.attrs))delete R.marker.attrs[L]}}o.delete(w.key),o.set(I,{...w,key:I,identity:v})}}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=>bc(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()],k=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 C=l().filter(g=>g.identity.filter(p=>p.kind!=="tag"&&p.kind!=="universal").length>=2).sort((g,p)=>g.identity.length-p.identity.length);for(let g of C){let p=h.filter(b=>b!==g&&b!==u&&b.prefix.length===0&&yc(b.identity,g.identity));if(p.length===0)continue;p.sort((b,x)=>x.identity.length-b.identity.length||c(x)-c(b)||b.line-x.line);let d=k(p[0].key);d&&d!==g&&m(g,d,"modifiers")}for(let{hostKey:g,part:p}of i){let d=k(g)??(s?u:null);d&&o.has(d.key)&&d.parts.push(p)}let $=g=>{let p=g===u,d=kt(g.key,f);return{...Oe({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:Pn(g.states),modifiers:g.modifiers.length?g.modifiers.map(b=>{let x=b.identity.filter(w=>!g.identity.some(v=>Qr(v,w)));return{title:Oe({selector:x.map(w=>w.raw).join(""),path:e,base:!1},n.classKeywords).title,selector:b.key,path:e,line:b.line,element:kt(b.key,f),usage:{status:"unknown",files:[],fileCount:0},states:Pn(b.states)}}):void 0,contexts:g.contexts.length?g.contexts.map(b=>{let x=eo(b.states.flatMap(w=>w.declarations));return{selector:b.key,path:e,line:b.line,role:x,element:x==="override"?kt(b.key,f):null,states:Pn(b.states)}}):void 0,parts:g.parts.length?g.parts:void 0}};return[...o.values()].map($)}function no(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:qe(l),bareTag:!l.some(f=>f.kind==="class"||f.kind==="attr"||f.kind==="id"),bare:u.length&&u.length<l.length?qe(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=eo(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 kc={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 so(e){let t=e.lastIndexOf("-");return t<=0?null:kc[e.slice(0,t)]?.[e.slice(t+1)]??null}var E=(e,t)=>({property:e,value:t});function Tn(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 Mn(e){let t=Tn(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 vc(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 ro(e,t){return{full:"100%",screen:t==="w"?"100vw":"100vh",auto:"auto",fit:"fit-content",min:"min-content",max:"max-content"}[e]??vc(e)??Tn(e)??Mn(e)}var $c={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"}},Cc={thin:"100",extralight:"200",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"},Sc={none:"1",tight:"1.25",snug:"1.375",normal:"1.5",relaxed:"1.625",loose:"2"},Rc={none:"0",sm:"0.125rem","":"0.25rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem","3xl":"1.5rem",full:"9999px"},Ac={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"},_c={"":"3px",0:"0px",1:"1px",2:"2px",4:"4px",8:"8px"};function In(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=so(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 Ec(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 Ln(){return E("box-shadow","0 0 0 var(--gs-ring-w, 3px) var(--gs-ring-c, currentColor)")}var Pc={flex:"flex","inline-flex":"inline-flex",block:"block","inline-block":"inline-block",inline:"inline",grid:"grid","inline-grid":"inline-grid",hidden:"none",contents:"contents"},jn={start:"flex-start",end:"flex-end",center:"center",baseline:"baseline",stretch:"stretch",between:"space-between",around:"space-around",evenly:"space-evenly"};function oo(e){let t=e.startsWith("-"),n=t?e.slice(1):e,{body:s,opacity:r}=Ec(n),o=Pc[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 A=i[1]==="col"?"column":i[1]==="col-reverse"?"column-reverse":i[1];return[E("flex-direction",A)]}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",jn[a[1]])];let l=/^justify-(start|end|center|between|around|evenly)$/.exec(s);if(l&&!t)return[E("justify-content",jn[l[1]])];let c=/^self-(start|end|center|stretch|auto)$/.exec(s);if(c&&!t)return[E("align-self",c[1]==="auto"?"auto":jn[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=$c[s.replace(/^text-/,"")];if(s.startsWith("text-")&&m&&!r&&!t)return[E("font-size",m.size),E("line-height",m.leading)];let h=Cc[s.replace(/^font-/,"")];if(s.startsWith("font-")&&h&&!r)return[E("font-weight",h)];if(s.startsWith("leading-")&&!r){let A=s.slice(8),O=Sc[A]??Mn(A);if(O)return[E("line-height",O)]}let k=/^cursor-(pointer|default|not-allowed|wait|text|move)$/.exec(s);if(k)return[E("cursor",k[1])];if(s==="pointer-events-none")return[E("pointer-events","none")];if(s==="pointer-events-auto")return[E("pointer-events","auto")];if(s==="select-none")return[E("user-select","none")];let C=/^opacity-(\d+)$/.exec(s);if(C&&!t)return[E("opacity",String(Number(C[1])/100))];if(s==="transition"||s==="transition-colors"||s==="transition-all")return[E("transition-property",s==="transition-colors"?"color, background-color, border-color, text-decoration-color, fill, stroke":s==="transition-all"?"all":"color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter"),E("transition-timing-function","cubic-bezier(0.4, 0, 0.2, 1)"),E("transition-duration","150ms")];let $=/^duration-(\d+)$/.exec(s);if($)return[E("transition-duration",`${$[1]}ms`)];let g={linear:"linear",in:"cubic-bezier(0.4, 0, 1, 1)",out:"cubic-bezier(0, 0, 0.2, 1)","in-out":"cubic-bezier(0.4, 0, 0.2, 1)"};if(s.startsWith("ease-")&&g[s.slice(4)])return[E("transition-timing-function",g[s.slice(4)])];if(s==="outline-none")return[E("outline","2px solid transparent"),E("outline-offset","2px")];if(s==="outline")return[E("outline-style","solid")];let p=/^outline-(\d+)$/.exec(s);if(p)return[E("outline-width",`${p[1]}px`)];if(s==="shadow"||s.startsWith("shadow-")){let A=s==="shadow"?"":s.slice(7),L=Ac[A];if(L)return[E("box-shadow",L)]}if(s==="ring"||/^ring(?:-(?:0|1|2|4|8))?$/.test(s)){let A=s==="ring"?"":s.slice(5),L=_c[A];if(L)return[E("--gs-ring-w",L),Ln()]}if(s.startsWith("ring-")&&r===null){let A=In(s.slice(5),null);if(A)return[E("--gs-ring-c",A),Ln()]}if(s.startsWith("ring-")&&r){let A=In(s.slice(5),r);if(A)return[E("--gs-ring-c",A),Ln()]}let d=s==="rounded"?"":s.startsWith("rounded-")?s.slice(8):null;if(d!==null&&!t){let A=/^(t|r|b|l|s|e|tl|tr|bl|br|ss|se)(?:-(.+))?$/.exec(d),L=A?A[2]??"":d,O=Rc[L];if(!O)return null;if(!A)return[E("border-radius",O)];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"]}[A[1]];return X?X.map(lt=>E(lt,O)):null}if(/^border(?:-[trblxy])?$/.test(s)&&!r)return[E("border-width","1px"),E("border-style","solid")];let b=/^border-(\d+)$/.exec(s);if(b&&!r)return[E("border-width",`${b[1]}px`),E("border-style","solid")];let x=/^border-(solid|dashed|dotted|double|none|hidden)$/.exec(s);if(x)return[E("border-style",x[1])];let w=/^(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),v=w?.[1],P=w?.[2];if(v&&P&&!r){let A=v==="w"||v==="min-w"||v==="max-w"?ro(P,"w"):v==="h"||v==="min-h"||v==="max-h"?ro(P,"h"):Mn(P);if(!A)return null;let L=t?A==="0"?"0":`-${A}`:A,V={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"]}[v];return V?V.map(X=>E(X,L)):null}let I={bg:"background-color",text:"color",border:"border-color",outline:"outline-color",decoration:"text-decoration-color",accent:"accent-color",caret:"caret-color",fill:"fill",stroke:"stroke"};for(let[A,L]of Object.entries(I))if(s===A||s.startsWith(`${A}-`)){let O=s===A?"":s.slice(A.length+1);if(!O||/^(?:gradient|clip|ellipsis|wrap|nowrap|balance|pretty|opacity)/.test(O))return null;if(A==="text"&&!t){let X=Tn(O);if(X)return[E("font-size",X)]}let V=In(O,r);return!V||t?null:[E(L,V)]}let R=/^\[([a-z-]+):(.+)\]$/i.exec(s);if(R&&!t&&!r){let A=R[1].toLowerCase(),L=R[2].replace(/_/g," ").trim();if(/^[a-z][\w-]*$/.test(A)&&L&&!/[<>]/.test(L))return[E(A,L)]}return null}var Ic=48,Lc={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",disabled:"disabled"},jc=new Set(["cn","clsx","classNames","classnames","cx","twMerge"]);function de(e,t){let n=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
57
+ `&&n++;return n}function Mc(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 G(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;return t}function Et(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"?`
58
+ `: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 Nn(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=Et(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 Tc(e,t){let n=0;for(let s=t;s<e.length;s++){let r=e[s];if(r==='"'||r==="'"||r==="`"){let o=Et(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 io(e){if(e.t==="str")return e.v;if(e.t==="arr"){let t=[];for(let n of e.items){let s=io(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 Oc(e,t){let n=t+1,s=[];for(;n<e.length;){if(n=G(e,n),e[n]===")")return{v:s.join(" ").replace(/\s+/g," ").trim()||null,end:n+1};if(e[n]===","){n++;continue}let r=ne(e,n);if(!r)return null;let o=G(e,r.end);if(e[o]===","||e[o]===")"){let i=io(r.val);i&&s.push(i),n=r.end;continue}n=Tc(e,n)}return null}function ne(e,t){if(t=G(e,t),t>=e.length)return null;let n=e[t];if(n==='"'||n==="'"||n==="`"){let r=Et(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=G(e,r),e[r]==="]")return{val:{t:"arr",items:o,at:t},end:r+1};if(e[r]===","){r++;continue}let i=ne(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=G(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=ne(e,r+3);if(!c)return null;r=c.end;continue}let i="",a=r;if(e[r]==='"'||e[r]==="'"||e[r]==="`"){let c=Et(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=G(e,r),e[r]!==":"){e[r]==="("&&(r=Nn(e,r,"(",")"));continue}let l=ne(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=G(e,r);if(e[i]==="("){if(jc.has(o)){let a=Oc(e,i);return a?{val:{t:"str",v:a.v,at:s},end:a.end}:null}return{val:{t:"other",at:s},end:Nn(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 Pt(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 ao(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 On={sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"};function Dc(e,t,n,s){let r=Lc[e];if(r)return t.includes(r)||t.push(r),!0;if(e==="dark")return s.on=!0,!0;if(On[e])return n.min.push(On[e]),!0;let o=/^max-(sm|md|lg|xl|2xl)$/.exec(e);if(o)return n.below.push(On[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 Nc(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 lo(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||!Dc(f,a,l,c))return null;a.sort((f,m)=>K(f)-K(m));let u=/^[\w-]+$/.test(i)?i:null;return{token:e,state:xe(a),context:Nc(l,c.on),utility:i,important:n,stem:u}}function co(e){let t=oo(e.utility);return t?t.map(n=>({property:n.property,value:e.important?`${n.value} !important`:n.value,via:e.token})):[]}function Uc(e){return e.some(t=>Ze(t.property)!=="hint")}function It(e){let t=[];for(let n of e.matchAll(/@apply\s+([^;{}]+)/g))for(let s of ao(n[1])){let r=lo(s);if(!r)continue;let o=co(r).filter(i=>oe(i.property,i.value));o.length!==0&&t.push({state:r.state,context:r.context,declarations:o})}return t}function uo(e){return e==="default"?"":e.split(" + ").map(t=>t==="hover"?":hover":t==="focus"?":focus":t==="active"?":active":t==="disabled"?":disabled":"").join("")}function Bn(e,t,n){let s=t.map(f=>`${f.property}:${f.value}`).join(";");if(!s)return[];let r=yn(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 Fc(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 Bc(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 Vc(e,t,n,s,r){let o=ne(e,t),i={slots:[],defaults:{}};if(!o)return i;let a=Pt(o.val)??"",l=G(e,o.end);if(e[l]!==",")return a.trim()?{slots:[Dn(a,de(e,t),r)],defaults:{}}:i;let c=ne(e,l+1);if(!c||c.val.t!=="obj")return a.trim()?{slots:[Dn(a,de(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(Dn(a,de(e,t),r)),u&&u.t==="obj"){for(let h of u.entries)if(h.value.t==="obj")for(let k of h.value.entries){let C=Pt(k.value);if(!C||!C.trim()||k.key==="false")continue;m.set(`${h.key}\0${k.key}`,C);let $=k.key==="true"?`.${h.key}`:`.${h.key}-${k.key}`,g=Oe({selector:$,path:s,base:!1},n.classKeywords);f.push({title:g.title,axis:k.key==="true"?h.key:g.axis??h.key,base:!1,classes:`${a} ${C}`.trim(),line:de(e,k.at),group:r,prop:h.key,value:k.key})}}return f.push(...zc(c.val,a,m,n,s,e,r)),{slots:f,defaults:Bc(c.val)}}function po(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=po(n);if(!s||s.length!==1)return null;t.push(s[0])}return t.length?t:null}return null}function zc(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 C of c.entries){if(C.key==="class"||C.key==="className"){f=Pt(C.value)??"",m=C.at,C.value.t!=="str"&&C.value.t!=="arr"&&f===""&&(h=!0);continue}let $=po(C.value);if(!$){h=!0;break}u.push({axis:C.key,values:$})}if(h)continue;let k=[[]];for(let C of u){let $=[];for(let g of k){for(let p of C.values)if($.push([...g,{axis:C.axis,value:p}]),$.length>=8)break;if($.length>=8)break}k=$}for(let C of k){if(C.length<2&&!f.trim())continue;let $=[t],g=[];for(let b of C){let x=n.get(`${b.axis}\0${b.value}`);x&&$.push(x),g.push(b.value==="true"?b.axis:b.value)}f.trim()&&$.push(f);let p=$.join(" ").replace(/\s+/g," ").trim();if(!p)continue;let d=Oe({selector:`.${g.join("-")}`,path:r,base:!1},s.classKeywords);l.push({title:d.title,axis:d.axis,base:!1,classes:p,line:de(o,m),group:i,when:C.map(b=>({prop:b.axis,value:b.value}))})}}return l}function Dn(e,t,n){return{title:"Base",axis:null,base:!0,classes:e,line:t,group:n}}function fo(e,t){return t.elements.includes(e.toLowerCase())?!0:t.identifier.test(e)}function Wc(e){let t=e.match(/\bclassName\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*"([^"]*)"\s*\}|\{\s*'([^']*)'\s*\})/);return t?.[1]??t?.[2]??t?.[3]??t?.[4]??null}var Gc=new Set(["opacity","z-index","font-weight","line-height","flex","flex-grow","flex-shrink","order","zoom"]);function Kc(e){return e.replace(/^[A-Z]/,t=>`-${t.toLowerCase()}`).replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Hc(e,t){return t.t==="str"?t.v:t.t==="num"?Gc.has(e)?String(t.v):`${t.v}px`:null}function Lt(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(...Lt(o.value,c));continue}let i=Kc(o.key),a=Hc(i,o.value);!a||!oe(i,a)||n.push({property:i,value:a,via:"style"})}return[...n.length?[{state:t,context:"",declarations:n}]:[],...s]}function Un(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"?`
59
+ `: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 qc(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)=>K(s)-K(r)||s.localeCompare(r)),xe(n)}function Fn(e){let t=[];for(let n of $e(`.__gs {
55
60
  ${e}
56
- }`)){let s=Q(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:ic(i,l.state),context:[n.context,l.context].filter(Boolean).join(" \xB7 "),declarations:l.declarations})}return t}function ac(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=G(e,s+1);e[r]==="{"&&(s=r);let o=ne(e,s);return o?Ct(o.val,"default"):[]}function lc(e){let t=nc(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=G(e,s+1);if(e.startsWith("css",r)&&!/[\w$]/.test(e[r+3]??"")){let i=G(e,r+3);if(e[i]==="`"){let a=In(e,i);return{classes:"",painted:a?jn(a.css):[]}}if(e[i]==="("){let a=ne(e,i+1);return{classes:"",painted:a?Ct(a.val,"default"):[]}}}let o=ne(e,r);return o?{classes:vt(o.val)??"",painted:[]}:{classes:"",painted:[]}}function cc(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 uc(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(!Yr(i,t))continue;let a=G(e,(o.index??0)+o[0].length);e.startsWith(".attrs",a)&&(a=G(e,a+6),e[a]==="("&&(a=En(e,a,"(",")")),a=G(e,a));let l=[];if(e[a]==="`"){let c=In(e,a);c&&(l=jn(c.css))}else if(e[a]==="("){let c=ne(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(!cc(i,t))continue;let a=e.indexOf("`",o.index??0),l=a<0?null:In(e,a);if(!l)continue;let c=jn(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 pc(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 fc(e,t,n,s,r){let o=Kr(e.classes).map(Jr).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,k)=>{if(k.length===0)return;let x=`${d}\0${y}`,v=l.get(x)??{state:d,context:y,declarations:[]};v.declarations.push(...k),l.set(x,v)},u=[r];for(let d of o){let y=Zr(d).filter(k=>se(k.property,k.value));c(d.state,d.context,y),d.state==="default"&&d.context===""&&d.stem&&u.push(d.stem)}for(let d of a)c(d.state,d.context,d.declarations);let f=[...l.values()].flatMap(d=>d.declarations);if(!Xl(f))return null;let m=l.get("default\0")?.declarations??[];if(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)),w=[...new Set(o.map(d=>d.stem).filter(d=>d!==null))],C=w.length?w.map(d=>`.${d}`).join(""):n.elements[0]??"button",$=h.flatMap(d=>Pn(pc(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:C,path:t,line:e.line,base:e.base,states:h},rules:$}}function Qr(e,t,n,s,r){let o=Hl(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,k=a.length,x=ec(o,y,n,e,k);a.push({name:Yl(o,d),defaults:x.defaults}),i.push(...x.slots)}i.push(...uc(o,n));let c=/<([A-Za-z][\w.]*)\b([^>]*?)>/g;for(let p of o.matchAll(c)){let d=p[1];if(!Yr(d,n))continue;let y=p[2]??"",k=lc(y),x=[...k.painted,...ac(y)],v=k.classes.trim();if(!v&&x.length===0)continue;let I=p.index??0,j=fe(o,I);i.push({title:v?"Base":k.painted.length?"Css":"Inline",axis:null,base:!0,classes:v,line:j,painted:x,...v&&x.length===0?{site:{path:e,line:j,offset:I}}:{}})}let u=[],f=[],m=new Map,h=[],w=new Map,C=new Map,$=r;for(let p=0;p<i.length;p++){let d=i[p];if(u.length+f.length>=zl)break;let y=(d.painted??[]).map(j=>`${j.state}|${j.context}|${j.declarations.map(R=>`${R.property}:${R.value}`).join(";")}`).join("||"),k=`${d.classes.replace(/\s+/g," ").trim()}##${y}`,x=w.get(k);if(x){d.group!==void 0&&C.set(p,x),d.site&&m.get(x)?.sites.push(d.site);continue}$+=1;let v=`__gs-recipe-${$}`,I=fc(d,e,n,s,v);if(I){if(w.set(k,v),d.group!==void 0&&C.set(p,v),d.site){let j={variant:I.variant,sites:[d.site]};m.set(v,j),f.push(j)}else u.push(I.variant);h.push(...I.rules)}}let g=[];for(let p=0;p<a.length;p++){let d=a[p],y={path:e,name:d.name,staticClasses:[],axes:[],compounds:[]},k=new Map;for(let x=0;x<i.length;x++){let v=i[x];if(v.group!==p)continue;let I=C.get(x);if(!I)continue;if(!v.prop&&!v.when){y.staticClasses.push(I);continue}if(v.when){y.compounds.push({when:v.when,classes:[I]});continue}let j=k.get(v.prop)??[];j.push({value:v.value,classes:[I]}),k.set(v.prop,j)}for(let[x,v]of k)y.axes.push({prop:x,values:v,...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:$,recipes:g}}function eo(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 Ln=6,dc=/"([^"\\\n]{0,400})"|'([^'\\\n]{0,400})'|`([^`\\]{0,400})`/g,gc=/\bclass(?:Name)?\s*=\s*(?:"([^"]*)"|'([^']*)')/g,mc=/\b(?:styles?|classes|css|cls|s)\.([A-Za-z_]\w*)/g,qe=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function hc(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 bc(e,t){let n=hc(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(dc))i(a[1]??a[2]??a[3]??"",a.index);for(let a of n.matchAll(gc))i(a[1]??a[2]??"",a.index);for(let a of n.matchAll(mc))o(r,a[1],a.index);return{path:e,text:n,original:t,words:s,ids:r}}function to(e,t){let n=1;for(let s=e.indexOf(`
61
+ }`)){let s=Q(n.selector),r=s?.[s.length-1];if(!r)continue;let o=xt(r.simples),i=xe(o.states),a=fe(n.ownBody).filter(l=>oe(l.property,l.value));a.length&&t.push({state:i,context:n.context,declarations:a});for(let l of It(n.ownBody))t.push({state:qc(i,l.state),context:[n.context,l.context].filter(Boolean).join(" \xB7 "),declarations:l.declarations})}return t}function Jc(e){let t=e.match(/\bstyle\s*=\s*"([^"]*)"/);if(t){let i=fe(t[1]).filter(a=>oe(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=G(e,s+1);e[r]==="{"&&(s=r);let o=ne(e,s);return o?Lt(o.val,"default"):[]}function Zc(e){let t=Wc(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=G(e,s+1);if(e.startsWith("css",r)&&!/[\w$]/.test(e[r+3]??"")){let i=G(e,r+3);if(e[i]==="`"){let a=Un(e,i);return{classes:"",painted:a?Fn(a.css):[]}}if(e[i]==="("){let a=ne(e,i+1);return{classes:"",painted:a?Lt(a.val,"default"):[]}}}let o=ne(e,r);return o?{classes:Pt(o.val)??"",painted:[]}:{classes:"",painted:[]}}function Xc(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 Yc(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(!fo(i,t))continue;let a=G(e,(o.index??0)+o[0].length);e.startsWith(".attrs",a)&&(a=G(e,a+6),e[a]==="("&&(a=Nn(e,a,"(",")")),a=G(e,a));let l=[];if(e[a]==="`"){let c=Un(e,a);c&&(l=Fn(c.css))}else if(e[a]==="("){let c=ne(e,a+1);c&&(l=Lt(c.val,"default"))}l.length!==0&&n.push({title:"Styled",axis:null,base:!0,classes:"",line:de(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(!Xc(i,t))continue;let a=e.indexOf("`",o.index??0),l=a<0?null:Un(e,a);if(!l)continue;let c=Fn(l.css);c.length!==0&&n.push({title:"Css",axis:null,base:!0,classes:"",line:de(e,o.index??0),painted:c})}return n}function Qc(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 eu(e,t,n,s,r){let o=ao(e.classes).map(lo).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,b,x)=>{if(x.length===0)return;let w=`${d}\0${b}`,v=l.get(w)??{state:d,context:b,declarations:[]};v.declarations.push(...x),l.set(w,v)},u=[r];for(let d of o){let b=co(d).filter(x=>oe(x.property,x.value));c(d.state,d.context,b),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(!Uc(f))return null;let m=l.get("default\0")?.declarations??[];if(vt(m))return null;let h=[...l.values()].map(d=>({state:d.state,context:d.context,line:e.line,declarations:d.declarations})).sort((d,b)=>d.state!==b.state?d.state==="default"?-1:b.state==="default"?1:K(d.state.split(" + ")[0])-K(b.state.split(" + ")[0])||d.state.localeCompare(b.state):d.context===""?-1:b.context===""?1:d.context.localeCompare(b.context)),k=[...new Set(o.map(d=>d.stem).filter(d=>d!==null))],C=k.length?k.map(d=>`.${d}`).join(""):n.elements[0]??"button",$=h.flatMap(d=>Bn(Qc(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:C,path:t,line:e.line,base:e.base,states:h},rules:$}}function go(e,t,n,s,r){let o=Mc(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])),b=(p.index??0)+p[0].length,x=a.length,w=Vc(o,b,n,e,x);a.push({name:Fc(o,d),defaults:w.defaults}),i.push(...w.slots)}i.push(...Yc(o,n));let c=/<([A-Za-z][\w.]*)\b([^>]*?)>/g;for(let p of o.matchAll(c)){let d=p[1];if(!fo(d,n))continue;let b=p[2]??"",x=Zc(b),w=[...x.painted,...Jc(b)],v=x.classes.trim();if(!v&&w.length===0)continue;let P=p.index??0,I=de(o,P);i.push({title:v?"Base":x.painted.length?"Css":"Inline",axis:null,base:!0,classes:v,line:I,painted:w,...v&&w.length===0?{site:{path:e,line:I,offset:P}}:{}})}let u=[],f=[],m=new Map,h=[],k=new Map,C=new Map,$=r;for(let p=0;p<i.length;p++){let d=i[p];if(u.length+f.length>=Ic)break;let b=(d.painted??[]).map(I=>`${I.state}|${I.context}|${I.declarations.map(R=>`${R.property}:${R.value}`).join(";")}`).join("||"),x=`${d.classes.replace(/\s+/g," ").trim()}##${b}`,w=k.get(x);if(w){d.group!==void 0&&C.set(p,w),d.site&&m.get(w)?.sites.push(d.site);continue}$+=1;let v=`__gs-recipe-${$}`,P=eu(d,e,n,s,v);if(P){if(k.set(x,v),d.group!==void 0&&C.set(p,v),d.site){let I={variant:P.variant,sites:[d.site]};m.set(v,I),f.push(I)}else u.push(P.variant);h.push(...P.rules)}}let g=[];for(let p=0;p<a.length;p++){let d=a[p],b={path:e,name:d.name,staticClasses:[],axes:[],compounds:[]},x=new Map;for(let w=0;w<i.length;w++){let v=i[w];if(v.group!==p)continue;let P=C.get(w);if(!P)continue;if(!v.prop&&!v.when){b.staticClasses.push(P);continue}if(v.when){b.compounds.push({when:v.when,classes:[P]});continue}let I=x.get(v.prop)??[];I.push({value:v.value,classes:[P]}),x.set(v.prop,I)}for(let[w,v]of x)b.axes.push({prop:w,values:v,...d.defaults[w]?{defaultValue:d.defaults[w]}:{}});(b.staticClasses.length||b.axes.length||b.compounds.length)&&g.push(b)}return{variants:u,inline:f,previewRules:h,nextId:$,recipes:g}}function mo(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 Vn=6,tu=/"([^"\\\n]{0,400})"|'([^'\\\n]{0,400})'|`([^`\\]{0,400})`/g,nu=/\bclass(?:Name)?\s*=\s*(?:"([^"]*)"|'([^']*)')/g,su=/\b(?:styles?|classes|css|cls|s)\.([A-Za-z_]\w*)/g,Qe=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function ru(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 ou(e,t){let n=ru(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(tu))i(a[1]??a[2]??a[3]??"",a.index);for(let a of n.matchAll(nu))i(a[1]??a[2]??"",a.index);for(let a of n.matchAll(su))o(r,a[1],a.index);return{path:e,text:n,original:t,words:s,ids:r}}function ho(e,t){let n=1;for(let s=e.indexOf(`
57
62
  `);s!==-1&&s<t;)n++,s=e.indexOf(`
58
- `,s+1);return n}var yc=e=>e.replace(/[-_]+(\w)/g,(t,n)=>n.toUpperCase()),xc=/\[\s*([\w-]+)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*\]/g,kc=new Set(["data-component","data-slot","role"]);function wc(e,t){return[...e.slice(ye(e)).matchAll(xc)].map(s=>({name:s[1],value:s[2]??s[3]??s[4]??null})).filter(s=>!kc.has(s.name)&&!(s.value!==null&&t.has(s.value.toLowerCase())))}function vc(e){return[...e.slice(ye(e)).matchAll(/\.((?:\\.|[\w-])+)/g)].map(n=>n[1].replace(/\\(.)/g,"$1"))}function On(e,t,n,s,r=!1,o=[],i=()=>null){let a=null,l=()=>a??=t.map(g=>bc(g,e.get(g)??"")),c=new Map,u=g=>{let p=c.get(g);if(!p){let d=new RegExp(`["'\`]${qe(g)}["'\`]\\s*\\+`);p=l().filter(y=>y.text.includes(`${g}\${`)||d.test(y.text)),c.set(g,p)}return p},f=(g,p,d)=>Er(bn(g.original,p,d,g.path),g.original,p,g.path,o,i),m=(g,p)=>({files:g.slice(0,Ln).map(({file:d,offset:y,example:k})=>({path:d.path,line:to(d.text,y),...r?{example:k??f(d,y,p)}:{}})),fileCount:g.length}),h=(g,p)=>{let d=[],y=yc(g);for(let k of l()){let x=[...s.has(g)?[]:k.words.get(g)??[],...k.ids.get(y)??k.ids.get(g)??[]],v=x[0];if(v===void 0)continue;let I=v,j;if(r)for(let R of x){let A=f(k,R,p);if(A.kind!=="other"){I=R,j=A;break}}d.push({file:k,offset:I,example:j})}if(d.length)return{status:"used",...m(d,p)};for(let k=g.length-1;k>0;k--){if(g[k]!=="-"&&g[k]!=="_")continue;let x=g.slice(0,k+1),v=g.slice(k+1),I=u(x);if(I.length===0||!v)continue;let j=x.slice(0,-1),R=new RegExp(`\\b${qe(j)}\\s*[=:]\\s*\\{?\\s*["'\`]${qe(v)}["'\`]`),A=[];for(let P of l()){let N=R.exec(P.text);N&&A.push({file:P,offset:N.index})}return A.length?{status:"used",via:`via ${j} prop`,...m(A,p)}:{status:"dynamic",via:`built as ${x}\${\u2026}`,...m(I.map(P=>({file:P,offset:0})),p)}}return{status:"unreferenced",files:[],fileCount:0}},w=(g,p)=>{let d=qe(g.name),y=g.value===null?new RegExp(`\\b${d}\\b`):new RegExp(`\\b${d}\\s*[=:]\\s*\\{?\\s*["'\`]${qe(g.value)}["'\`]`),k=[];for(let I of l()){let j=y.exec(I.text);j&&k.push({file:I,offset:j.index})}if(k.length)return{status:"used",via:`via ${g.name} attribute`,...m(k,p)};let x=new RegExp(`\\b${d}\\s*=\\s*\\{(?!\\s*["'\`])`),v=[];for(let I of l()){let j=x.exec(I.text);j&&v.push({file:I,offset:j.index})}return v.length?{status:"dynamic",via:`${g.name} is set from a variable`,...m(v,p)}:{status:"unreferenced",files:[],fileCount:0}},C=new Map;if(r&&o.length>0)for(let g of l())for(let p of kt(g.path,g.text,o,i))for(let d of p.selects){let y=C.get(d)??[];y.push({file:g,offset:p.offset}),C.set(d,y)}let $={used:0,unknown:0,dynamic:1,unreferenced:2};for(let g of n){let p=vc(g.selector),d=wc(g.selector,s);if(p.length===0&&d.length===0){g.usage={status:"unknown",files:[],fileCount:0};continue}let y=[...p.map(R=>h(R,p)),...d.map(R=>w(R,p))];g.usage=y.reduce((R,A)=>$[A.status]>=$[R.status]?A:R);let k=g.element?.classes.find(R=>R.startsWith("__gs-recipe-")),x=k?C.get(k):void 0;if(!x||x.length===0)continue;let v=new Set(g.usage.files.map(R=>R.path)),I=g.usage.fileCount,j=[...g.usage.files];for(let R of x)v.has(R.file.path)||(v.add(R.file.path),I+=1,!(j.length>=Ln)&&j.push({path:R.file.path,line:to(R.file.text,R.offset),...r?{example:f(R.file,R.offset,[])}:{}}));g.usage={...g.usage,status:g.usage.status==="unknown"?"unknown":"used",files:j,fileCount:I}}}function no(e,t,n){let s=[],r=new Set;for(let o of t)r.has(o.path)||(r.add(o.path),!(s.length>=Ln)&&s.push({path:o.path,line:o.line,...n?{example:bn(e.get(o.path)??"",o.offset,[],o.path)}:{}}));return{status:"used",files:s,fileCount:r.size}}var $c={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},lo={button:$c},co=12,Nn=200,we=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro)$/i,so=/\.(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,ro=/\.(mdx?|markdown|txt|rst|adoc)$/i,oo=/(^|\/)(tokens?|design-tokens?|theme)[^/]*\.json$/i,Z=/(^|\/)(__tests__|tests?|spec|e2e|cypress|playwright)(\/|$)|\.(test|spec)\.[a-z]+$/i,Cc=/(^|\/)(plans?|results?|changelogs?|history|archive)(\/|\.|$)|(^|\/)CHANGELOG/i;function Sc(e){return St.test(e)&&!/(^|\/)README\.md$/i.test(e)?"instruction":Cc.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 Rc(e){return(e.split("/").pop()??"").replace(/(\.module)?\.[^.]+$/i,"")}function io(e,t){let n=Rc(e).toLowerCase();return t.some(s=>{let r=s.toLowerCase();return n===r||n===`${r}s`})}function Ac(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(`
59
- `),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<co)){let a=i.trim();r.push({line:o+1,text:a.length>Nn?`${a.slice(0,Nn)}\u2026`:a})}}return{count:s,lines:r}}function uo(e){let t=e.lastIndexOf("/");return t<0?"":e.slice(0,t)}function po(e){let t=[];for(let n of e.split("/"))!n||n==="."||(n===".."?t.pop():t.push(n));return t.join("/")}var _c=["",".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=po(`${uo(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 _c)if(n(s+r))return s+r;return null}var Ec=/import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]|require\(\s*['"]([^'"]+)['"]\s*\)|@import\s+(?:url\()?['"]([^'"]+)['"]/g;function Mn(e){let t=[];for(let n of e.matchAll(Ec)){let s=n[1]??n[2]??n[3];s&&t.push(s)}return t}var Ic=/export\s+(?:default\s+)?(?:async\s+)?(?:function|const|let|class|var)\s+([A-Za-z_$][\w$]*)|export\s*\{([^}]*)\}/g;function ao(e){let t=new Set;for(let n of e.matchAll(Ic))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 Dn=/var\(\s*(--[\w-]+)/g;function Rt(e){return e.split(" \xB7 ").every(t=>t===""||/^@layer\b/i.test(t))}function fo(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 jc(e,t,n){let s=t.startsWith(".")?po(`${uo(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 Pc(e){let t=new Map;for(let[n,s]of e)if(Xe.test(n)){for(let r of ke(s))if(Rt(r.context))for(let o of W(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(...fo(r.ownBody)),t.set(a,l)}}return t}function Lc(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"),w=m.slice(0,h);m.slice(h+1)!==f||/\.module\./i.test(w)||i(w,f,u)}else if(c.from){let m=jc(l,c.from,s);m&&i(m,f,u)}else i(l,f,u)};for(let l of fo(t))a(e,l,0);return r}function Oc(e,t){let n=qr(t);return n?W(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 Mc=/^(?::root|html|body|\*)$/i,Nc=25e4,Dc=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,Tc=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,Bc=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]);function Fc(e){let t=new Set,n=new Set;for(let s of e.matchAll(Dc)){let r=s[1],o=Bc.has(r.toLowerCase())&&r===r.toLowerCase()?t:n;for(let i of s[2].matchAll(Tc))o.add(i[1]??i[2])}return{parts:new Set([...t].filter(s=>!n.has(s))),controls:n}}function Uc(e,t){let n=new Map;for(let s of t)if(Xe.test(s)){for(let r of ke(e.get(s)))if(Rt(r.context)&&W(r.selector).some(o=>Mc.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 Vc(e,t){let n=new Set,s=[],r=a=>{for(let l of a.matchAll(Dn))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(";")}}
63
+ `,s+1);return n}var iu=e=>e.replace(/[-_]+(\w)/g,(t,n)=>n.toUpperCase()),au=/\[\s*([\w-]+)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*\]/g,lu=new Set(["data-component","data-slot","role"]);function cu(e,t){return[...e.slice(ke(e)).matchAll(au)].map(s=>({name:s[1],value:s[2]??s[3]??s[4]??null})).filter(s=>!lu.has(s.name)&&!(s.value!==null&&t.has(s.value.toLowerCase())))}function uu(e){return[...e.slice(ke(e)).matchAll(/\.((?:\\.|[\w-])+)/g)].map(n=>n[1].replace(/\\(.)/g,"$1"))}function zn(e,t,n,s,r=!1,o=[],i=()=>null){let a=null,l=()=>a??=t.map(g=>ou(g,e.get(g)??"")),c=new Map,u=g=>{let p=c.get(g);if(!p){let d=new RegExp(`["'\`]${Qe(g)}["'\`]\\s*\\+`);p=l().filter(b=>b.text.includes(`${g}\${`)||d.test(b.text)),c.set(g,p)}return p},f=(g,p,d)=>zr(Rn(g.original,p,d,g.path),g.original,p,g.path,o,i),m=(g,p)=>({files:g.slice(0,Vn).map(({file:d,offset:b,example:x})=>({path:d.path,line:ho(d.text,b),...r?{example:x??f(d,b,p)}:{}})),fileCount:g.length}),h=(g,p)=>{let d=[],b=iu(g);for(let x of l()){let w=[...s.has(g)?[]:x.words.get(g)??[],...x.ids.get(b)??x.ids.get(g)??[]],v=w[0];if(v===void 0)continue;let P=v,I;if(r)for(let R of w){let A=f(x,R,p);if(A.kind!=="other"){P=R,I=A;break}}d.push({file:x,offset:P,example:I})}if(d.length)return{status:"used",...m(d,p)};for(let x=g.length-1;x>0;x--){if(g[x]!=="-"&&g[x]!=="_")continue;let w=g.slice(0,x+1),v=g.slice(x+1),P=u(w);if(P.length===0||!v)continue;let I=w.slice(0,-1),R=new RegExp(`\\b${Qe(I)}\\s*[=:]\\s*\\{?\\s*["'\`]${Qe(v)}["'\`]`),A=[];for(let L of l()){let O=R.exec(L.text);O&&A.push({file:L,offset:O.index})}return A.length?{status:"used",via:`via ${I} prop`,...m(A,p)}:{status:"dynamic",via:`built as ${w}\${\u2026}`,...m(P.map(L=>({file:L,offset:0})),p)}}return{status:"unreferenced",files:[],fileCount:0}},k=(g,p)=>{let d=Qe(g.name),b=g.value===null?new RegExp(`\\b${d}\\b`):new RegExp(`\\b${d}\\s*[=:]\\s*\\{?\\s*["'\`]${Qe(g.value)}["'\`]`),x=[];for(let P of l()){let I=b.exec(P.text);I&&x.push({file:P,offset:I.index})}if(x.length)return{status:"used",via:`via ${g.name} attribute`,...m(x,p)};let w=new RegExp(`\\b${d}\\s*=\\s*\\{(?!\\s*["'\`])`),v=[];for(let P of l()){let I=w.exec(P.text);I&&v.push({file:P,offset:I.index})}return v.length?{status:"dynamic",via:`${g.name} is set from a variable`,...m(v,p)}:{status:"unreferenced",files:[],fileCount:0}},C=new Map;if(r&&o.length>0)for(let g of l())for(let p of _t(g.path,g.text,o,i))for(let d of p.selects){let b=C.get(d)??[];b.push({file:g,offset:p.offset}),C.set(d,b)}let $={used:0,unknown:0,dynamic:1,unreferenced:2};for(let g of n){let p=uu(g.selector),d=cu(g.selector,s);if(p.length===0&&d.length===0){g.usage={status:"unknown",files:[],fileCount:0};continue}let b=[...p.map(R=>h(R,p)),...d.map(R=>k(R,p))];g.usage=b.reduce((R,A)=>$[A.status]>=$[R.status]?A:R);let x=g.element?.classes.find(R=>R.startsWith("__gs-recipe-")),w=x?C.get(x):void 0;if(!w||w.length===0)continue;let v=new Set(g.usage.files.map(R=>R.path)),P=g.usage.fileCount,I=[...g.usage.files];for(let R of w)v.has(R.file.path)||(v.add(R.file.path),P+=1,!(I.length>=Vn)&&I.push({path:R.file.path,line:ho(R.file.text,R.offset),...r?{example:f(R.file,R.offset,[])}:{}}));g.usage={...g.usage,status:g.usage.status==="unknown"?"unknown":"used",files:I,fileCount:P}}}function yo(e,t,n){let s=[],r=new Set;for(let o of t)r.has(o.path)||(r.add(o.path),!(s.length>=Vn)&&s.push({path:o.path,line:o.line,...n?{example:Rn(e.get(o.path)??"",o.offset,[],o.path)}:{}}));return{status:"used",files:s,fileCount:r.size}}var pu={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},$o={button:pu},Co=12,Gn=200,Ce=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro)$/i,bo=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro|html?|mdx|erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,et=/\.(css|scss|sass|less|styl)$/i,wo=/\.(mdx?|markdown|txt|rst|adoc)$/i,xo=/(^|\/)(tokens?|design-tokens?|theme)[^/]*\.json$/i,Z=/(^|\/)(__tests__|tests?|spec|e2e|cypress|playwright)(\/|$)|\.(test|spec)\.[a-z]+$/i,fu=/(^|\/)(plans?|results?|changelogs?|history|archive)(\/|\.|$)|(^|\/)CHANGELOG/i;function du(e){return jt.test(e)&&!/(^|\/)README\.md$/i.test(e)?"instruction":fu.test(e)?"record":"documentation"}var jt=/(^|\/)(AGENTS|CLAUDE|CONTRIBUTING|README|GUIDELINES?)\.md$|(^|\/)(eslint|stylelint|\.eslintrc|\.stylelintrc)[^/]*$|(^|\/)\.cursor\/|(^|\/)\.claude\//i;function ge(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function gu(e){return(e.split("/").pop()??"").replace(/(\.module)?\.[^.]+$/i,"")}function ko(e,t){let n=gu(e).toLowerCase();return t.some(s=>{let r=s.toLowerCase();return n===r||n===`${r}s`})}function mu(e,t){let n=1;for(let s=0;s<t;s++)e.charCodeAt(s)===10&&n++;return n}function me(e,t){let n=e.split(`
64
+ `),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<Co)){let a=i.trim();r.push({line:o+1,text:a.length>Gn?`${a.slice(0,Gn)}\u2026`:a})}}return{count:s,lines:r}}function So(e){let t=e.lastIndexOf("/");return t<0?"":e.slice(0,t)}function Ro(e){let t=[];for(let n of e.split("/"))!n||n==="."||(n===".."?t.pop():t.push(n));return t.join("/")}var hu=["",".tsx",".ts",".jsx",".js",".mjs",".vue",".svelte",".css",".module.css",".scss","/index.tsx","/index.ts","/index.js"];function Se(e,t,n){let s;if(t.startsWith("."))s=Ro(`${So(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 hu)if(n(s+r))return s+r;return null}var yu=/import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]|require\(\s*['"]([^'"]+)['"]\s*\)|@import\s+(?:url\()?['"]([^'"]+)['"]/g;function Wn(e){let t=[];for(let n of e.matchAll(yu)){let s=n[1]??n[2]??n[3];s&&t.push(s)}return t}var bu=/export\s+(?:default\s+)?(?:async\s+)?(?:function|const|let|class|var)\s+([A-Za-z_$][\w$]*)|export\s*\{([^}]*)\}/g;function vo(e){let t=new Set;for(let n of e.matchAll(bu))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 Kn=/var\(\s*(--[\w-]+)/g;function Mt(e){return e.split(" \xB7 ").every(t=>t===""||/^@layer\b/i.test(t))}function Ao(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 wu(e,t,n){let s=t.startsWith(".")?Ro(`${So(e)}/${t}`):t.startsWith("@/")?t.slice(2):t.startsWith("~/")||t.startsWith("/")?t.replace(/^~?\//,""):null;return s&&n(s)?s:Se(e,t.replace(/\.(?:module\.)?(?:css|scss|sass|less)$/i,""),n)}function xu(e){let t=new Map;for(let[n,s]of e)if(et.test(n)){for(let r of $e(s))if(Mt(r.context))for(let o of W(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(...fe(r.ownBody));for(let c of It(r.ownBody))c.state==="default"&&c.context===""&&l.decls.push(...c.declarations);l.composes.push(...Ao(r.ownBody)),t.set(a,l)}}return t}function ku(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"),k=m.slice(0,h);m.slice(h+1)!==f||/\.module\./i.test(k)||i(k,f,u)}else if(c.from){let m=wu(l,c.from,s);m&&i(m,f,u)}else i(l,f,u)};for(let l of Ao(t))a(e,l,0);return r}function vu(e,t){let n=uo(t);return n?W(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 $u=/^(?::root|html|body|\*)$/i,Cu=25e4,Su=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,Ru=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,Au=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]);function _u(e){let t=new Set,n=new Set;for(let s of e.matchAll(Su)){let r=s[1],o=Au.has(r.toLowerCase())&&r===r.toLowerCase()?t:n;for(let i of s[2].matchAll(Ru))o.add(i[1]??i[2])}return{parts:new Set([...t].filter(s=>!n.has(s))),controls:n}}function Eu(e,t){let n=new Map;for(let s of t)if(et.test(s)){for(let r of $e(e.get(s)))if(Mt(r.context)&&W(r.selector).some(o=>$u.test(o)))for(let o of fe(r.ownBody))o.property.startsWith("--")&&!n.has(o.property)&&n.set(o.property,o.value)}return n}function Pu(e,t){let n=new Set,s=[],r=a=>{for(let l of a.matchAll(Kn))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||!oe(a,l)||(o.push(`${a}:${l}`),r(l))}return`${o.length?`:root{${o.join(";")}}
60
65
  `:""}${t.join(`
61
- `)}`.slice(0,Nc)}function go(e,t){let n=[...e.keys()].sort(),s=b=>e.has(b),r=new Map,o=(b,S,_,L)=>{let M=`${S}:${b}`,F=r.get(M);if(F){F.note.includes(_)||(F.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),_=ao(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 F=_.length?new RegExp(`\\b(?:${_.map(de).join("|")})\\b`,"g"):t.prose;o(b,"implements",_.length?`exports ${_.join(", ")}`:"named for the concept",ge(S,F))}let l=new Set,c=[],u=[],f=new Map,m=b=>io(b,t.classKeywords)||/\.module\.[a-z]+$/i.test(b)&&f.has(b),h=null,w=()=>h??=Pc(e),C=b=>{let S=m(b),_=[],L=0;for(let O of ke(e.get(b))){let U=W(O.selector).filter(D=>Ze(D,t,S));if(U.length===0)continue;L+=1;for(let D of O.ownBody.matchAll(Dn))l.add(D[1]);let z=$t(O.ownBody),ae=[...Lc(b,O.ownBody,w(),s),...pe(O.ownBody),...z.filter(D=>D.state==="default"&&D.context==="").flatMap(D=>D.declarations)];for(let D of ae)for(let J of D.value.matchAll(Dn))l.add(J[1]);_.push({block:O,parts:U,declarations:ae,previewContext:Rt(O.context)?"":null,listed:!0});for(let D of z){if(D.state==="default"&&D.context==="")continue;let J=Oc(U.join(", "),D.state),Te=W(J).filter(ci=>Ze(ci,t,S));if(Te.length===0)continue;let li=[O.context,D.context].filter(Boolean).join(" \xB7 ");_.push({block:{...O,selector:J,context:li},parts:Te,declarations:D.declarations,previewContext:Rt(O.context)?D.context:null,listed:!1})}}let M={parts:new Set,controls:new Set};for(let O of f.get(b)??[]){let U=Fc(e.get(O)??"");for(let z of U.parts)M.parts.add(z);for(let z of U.controls)M.controls.add(z)}c.push(...Ur(b,_.map(({block:O,parts:U,declarations:z})=>({selector:U.join(", "),declarations:z,line:O.line,context:O.context})),t,S,M));let F=/\.module\.[a-z]+$/i.test(b)?`${ar(b)} `:"";for(let{parts:O,declarations:U,previewContext:z}of _){if(z===null)continue;let ae=O.flatMap(J=>{let Te=Ze(J,t,S);return Te?[`${F}${Ke(Te.compounds)}`]:[]}),D=U.filter(J=>se(J.property,J.value));if(!(ae.length===0||D.length===0))for(let J of ae)u.push(...Pn(J,D,z))}return{count:L,lines:_.filter(O=>O.listed).slice(0,co).map(({block:O})=>({line:O.line,text:O.selector.replace(/\s+/g," ").slice(0,Nn)}))}},$=new Map;for(let b of a)for(let S of Mn(e.get(b))){let _=ve(b,S,s);if(_&&Xe.test(_)){let L=$.get(_)??[];L.push(b.split("/").pop()??b),$.set(_,L),io(b,t.classKeywords)&&f.set(_,[...f.get(_)??[],b])}}for(let b of n){if(!Xe.test(b))continue;let S=C(b),_=$.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=>`<${de(b)}\\b`),...t.roles.map(b=>`role=["']${de(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 Mn(e.get(b))){let _=ve(b,S,s);!_||!we.test(_)||Z.test(_)||eo(_,t.classKeywords)&&p.add(_)}let y=0,k=[],x=[];for(let b of p){let S=Qr(b,e.get(b)??"",t,g,y);y=S.nextId,k.push(...S.recipes),c.push(...S.variants),x.push(...S.inline),u.push(...S.previewRules)}let v=is(x);c.push(...v.variants);let I=Ir([...a].map(b=>({path:b,source:e.get(b)??"",names:ao(e.get(b)??"").filter(S=>t.identifier.test(S))})),k,(b,S)=>ve(b,S,s)),j=[];if(l.size>0){let b=new RegExp(`(?:^|[\\s{;])(${[...l].map(de).join("|")})\\s*:`),S=new Map;for(let _ of n){if(!Xe.test(_)&&!oo.test(_))continue;let L=e.get(_),M=ge(L,b);if(M.count!==0){for(let F of L.matchAll(new RegExp(b.source,"gm"))){let O=S.get(F[1])??[];O.includes(_)||O.push(_),S.set(F[1],O)}o(_,"tokens",`defines ${M.count} token${M.count===1?"":"s"} read by ${t.label.toLowerCase()} styles`,M)}}for(let _ of[...l].sort())j.push({name:_,definedIn:S.get(_)??[]})}for(let b of n){if(!oo.test(b))continue;let S=ge(e.get(b),t.prose);S.count>0&&o(b,"tokens","token file mentions the concept",S)}let R=[...i],A=new RegExp([...R.length?[`<(?:${R.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(!we.test(b)||a.has(b))continue;let S=e.get(b),_=Z.test(b),L=ge(S,A),M=Mn(S).some(O=>{let U=ve(b,O,s);return U!=null&&a.has(U)});if(L.count===0&&!M)continue;let F=L.count>0?`${L.count} render${L.count===1?"":"s"}`:"imports a button component";o(b,_?"tests":"uses",F,L.count?L:ge(S,t.prose))}for(let b of n){if(!(ro.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}`)||!we.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)),N={implements:0,styles:0,tokens:0,uses:0,describes:0,tests:0};for(let b of P)N[b.role]++;let V=Vr(c);On(e,n.filter(b=>so.test(b)&&!Z.test(b)),V,new Set(t.elements),!0,I,(b,S)=>ve(b,S,s)),On(e,n.filter(b=>so.test(b)&&!Z.test(b)),V.flatMap(b=>b.modifiers??[]),new Set(t.elements));for(let[b,S]of v.sites)b.usage=no(e,S,!("alike"in b));let X=Uc(e,n),tt=[];if(i.size>0){let b=new RegExp(t.elements.map(S=>`<${de(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=ge(_,new RegExp(b.source));tt.push({path:S,line:M.lines[0]?.line??1,count:L})}}let ts=[],ns=new Set;for(let b of n){if(!we.test(b)||Z.test(b))continue;let S=e.get(b),_=kt(b,S,I,(L,M)=>ve(L,M,s));for(let L of _)for(let M of L.unknown){let F=[...M.known].sort();if(M.cls!==void 0){if(g.has(M.cls))continue;let z=M.cls.slice(0,M.cls.length-M.value.length),ae=[...g].filter(D=>D.startsWith(z)&&D.length>z.length).map(D=>D.slice(z.length));if(ae.length===0)continue;F=[...new Set([...M.known,...ae])].sort()}if(F.length===0)continue;let O=Ac(S,L.offset),U=`${b}\0${L.component}\0${M.prop}\0${M.value}`;ns.has(U)||(ns.add(U),ts.push({path:b,line:O,component:L.component,prop:M.prop,value:M.value,known:F}))}}let ii=n.filter(b=>(ro.test(b)||St.test(b))&&!Z.test(b)).map(b=>({path:b,kind:Sc(b)}));V.sort((b,S)=>Number(S.base)-Number(b.base)||b.path.localeCompare(S.path)||b.line-S.line);let ss=Mr(e,ii,t,V),ai=Lr([...f.entries()].map(([b,S])=>({sheet:b,sources:S.map(_=>e.get(_)??""),rules:ke(e.get(b)??"").map(_=>({selector:_.selector,declarations:pe(_.ownBody)}))})));return{components:R.sort(),tokens:j,findings:P,variants:V,audit:mr({variants:V,tokens:j,tokenValues:X,hasComponent:i.size>0,nativeUses:tt,unknownProps:ts,guidance:ss,noun:t.label.toLowerCase(),element:t.elements[0]??t.id}),guidance:ss,content:ai,previewCss:Vc(X,u),counts:N}}import{execFileSync as Wc}from"node:child_process";import{readdirSync as Gc,readFileSync as Hc,statSync as Kc}from"node:fs";import At from"node:path";function $e(e,t){try{return Wc("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:64*1024*1024})}catch{return null}}function Tn(e,t=""){let s=$e(e,["rev-parse","--show-toplevel"])?.trim()||e;return{repoDir:s,root:sn(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=Gc(l).sort()}catch{return}for(let f of u){let m=c?`${c}/${f}`:f,h=At.join(l,f),w;try{w=Kc(h)}catch{continue}if(w.isDirectory()){tn(m)&&a(h,m);continue}if(!w.isFile())continue;if(!nn(m,w.size)){o++;continue}let C=Hc(h);if(Ks(C)){o++;continue}if(r+C.length>4e7){i=!0;return}r+=C.length,n.set(m,s.decode(C))}};return a(t,""),{files:n,truncated:i,skipped:o}}function mo(e,t){let n=$e(e.repoDir,["diff","--cached","--name-status","-z"]);if(n===null)return t;let s=qs(n).map(({path:r,deleted:o})=>({path:r,content:o?null:$e(e.repoDir,["show",`:${r}`])}));return{...t,files:Zs(t.files,s,e.root)}}function ho(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 bo(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=lo[t.concept??"button"],s=_t(e);return t.staged&&(s=mo(e,s)),{concept:n.id,label:n.label,...go(s.files,n),repo:ho(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:gs(s,t)}}import{mkdirSync as Jc,readFileSync as Zc,writeFileSync as yo}from"node:fs";import oe from"node:path";function Se(e){try{return Zc(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){Jc(oe.dirname(e),{recursive:!0}),yo(e,t)}function ie(e,t){me(e,`${JSON.stringify(t,null,2)}
62
- `),qc(e)}function qc(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&&(yo(s,r.text),process.stderr.write(`Added .gruum/ to .gitignore.
63
- `))}var Re=e=>oe.join(e.stateDir,"baseline.json"),xo=e=>oe.join(e.stateDir,"drift.json"),Bn=e=>oe.join(e.stateDir,"exceptions.json"),Xc=e=>oe.join(e.stateDir,"config.json");function he(e,t){return Ue(It(t?oe.resolve(t):Re(e)))}function jt(e){return bs(It(xo(e)),new Date().toISOString())}function Fn(e,t){ie(xo(e),t)}function Yc(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 Yc(It(Bn(e)))}function Lt(e){let t=It(Xc(e)),{block:n,hooks:s}=ys(t);return{...typeof t?.root=="string"?{root:t.root}:{},block:n,hooks:s}}import{chmodSync as tu,mkdirSync as nu,readFileSync as Fo,writeFileSync as su}from"node:fs";import{hostname as ru,homedir as ou}from"node:os";import Wn from"node:path";import{createInterface as Uo}from"node:readline/promises";function ko(e){return`/v2/projects/${encodeURIComponent(e)}`}function Un(e,t,n,s){return!(!e||e.repo!==t||!e.workspaceId||!e.host&&s||n&&!n.includes(e.id))}function wo(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 vo(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 $o="http://localhost:3000";function Co(e){return((e.split("/").pop()||e).replace(/\.git$/i,"").split(/[-_]/)[0]??"").toLowerCase().replace(/[^a-z]/g,"")}function So(e,t){if(!/^[a-z]+$/.test(t))return null;let n=new RegExp(`https?://(?:[a-z0-9-]+\\.)*${t}\\.\\w{2,3}(?![\\w.])`,"gi"),s=null;for(let r of e.matchAll(n)){let o=r[0].toLowerCase();if(o.startsWith("https://"))return o;s??=o}return s}function Ro(e){let t=e?`For example: ${$o} or ${e}.`:`For example: ${$o}.`,n=e?`URL (${e}): `:"URL: ";return`
66
+ `)}`.slice(0,Cu)}function _o(e,t){let n=[...e.keys()].sort(),s=y=>e.has(y),r=new Map,o=(y,S,_,j)=>{let T=`${S}:${y}`,F=r.get(T);if(F){F.note.includes(_)||(F.note+=`; ${_}`);return}r.set(T,{path:y,role:S,note:_,matches:j.count,lines:j.lines})},i=new Set,a=new Set;for(let y of n){if(!Ce.test(y)||Z.test(y))continue;let S=e.get(y),_=vo(S).filter(M=>t.identifier.test(M)),j=y.split("/").pop()??"",T=new RegExp(t.classKeywords.join("|"),"i").test(j);if(_.length===0&&!T)continue;for(let M of _)i.add(M);a.add(y);let F=_.length?new RegExp(`\\b(?:${_.map(ge).join("|")})\\b`,"g"):t.prose;o(y,"implements",_.length?`exports ${_.join(", ")}`:"named for the concept",me(S,F))}let l=new Set,c=[],u=[],f=new Map,m=y=>ko(y,t.classKeywords)||/\.module\.[a-z]+$/i.test(y)&&f.has(y),h=null,k=()=>h??=xu(e),C=y=>{let S=m(y),_=[],j=0;for(let M of $e(e.get(y))){let B=W(M.selector).filter(D=>Ye(D,t,S));if(B.length===0)continue;j+=1;for(let D of M.ownBody.matchAll(Kn))l.add(D[1]);let z=It(M.ownBody),ae=[...ku(y,M.ownBody,k(),s),...fe(M.ownBody),...z.filter(D=>D.state==="default"&&D.context==="").flatMap(D=>D.declarations)];for(let D of ae)for(let J of D.value.matchAll(Kn))l.add(J[1]);_.push({block:M,parts:B,declarations:ae,previewContext:Mt(M.context)?"":null,listed:!0});for(let D of z){if(D.state==="default"&&D.context==="")continue;let J=vu(B.join(", "),D.state),Fe=W(J).filter(qi=>Ye(qi,t,S));if(Fe.length===0)continue;let Hi=[M.context,D.context].filter(Boolean).join(" \xB7 ");_.push({block:{...M,selector:J,context:Hi},parts:Fe,declarations:D.declarations,previewContext:Mt(M.context)?D.context:null,listed:!1})}}let T={parts:new Set,controls:new Set};for(let M of f.get(y)??[]){let B=_u(e.get(M)??"");for(let z of B.parts)T.parts.add(z);for(let z of B.controls)T.controls.add(z)}c.push(...to(y,_.map(({block:M,parts:B,declarations:z})=>({selector:B.join(", "),declarations:z,line:M.line,context:M.context})),t,S,T));let F=/\.module\.[a-z]+$/i.test(y)?`${kr(y)} `:"";for(let{parts:M,declarations:B,previewContext:z}of _){if(z===null)continue;let ae=M.flatMap(J=>{let Fe=Ye(J,t,S);return Fe?[`${F}${Je(Fe.compounds)}`]:[]}),D=B.filter(J=>oe(J.property,J.value));if(!(ae.length===0||D.length===0))for(let J of ae)u.push(...Bn(J,D,z))}return{count:j,lines:_.filter(M=>M.listed).slice(0,Co).map(({block:M})=>({line:M.line,text:M.selector.replace(/\s+/g," ").slice(0,Gn)}))}},$=new Map;for(let y of a)for(let S of Wn(e.get(y))){let _=Se(y,S,s);if(_&&et.test(_)){let j=$.get(_)??[];j.push(y.split("/").pop()??y),$.set(_,j),ko(y,t.classKeywords)&&f.set(_,[...f.get(_)??[],y])}}for(let y of n){if(!et.test(y))continue;let S=C(y),_=$.get(y);if(S.count===0)continue;let j=[];_&&j.push(`imported by ${_.join(", ")}`),S.count>0&&j.push(`${S.count} matching rule${S.count===1?"":"s"}`),o(y,"styles",j.join("; "),S)}let g=new Set;for(let y of c)for(let S of y.selector.matchAll(/\.((?:\\.|[\w-])+)/g))g.add(S[1].replace(/\\(.)/g,"$1"));let p=new Set(a),d=new RegExp([...t.elements.map(y=>`<${ge(y)}\\b`),...t.roles.map(y=>`role=["']${ge(y)}["']`)].join("|"));for(let y of n)!Ce.test(y)||Z.test(y)||d.test(e.get(y)??"")&&p.add(y);for(let y of a)for(let S of Wn(e.get(y))){let _=Se(y,S,s);!_||!Ce.test(_)||Z.test(_)||mo(_,t.classKeywords)&&p.add(_)}let b=0,x=[],w=[];for(let y of p){let S=go(y,e.get(y)??"",t,g,b);b=S.nextId,x.push(...S.recipes),c.push(...S.variants),w.push(...S.inline),u.push(...S.previewRules)}let v=ks(w);c.push(...v.variants);let P=Wr([...a].map(y=>({path:y,source:e.get(y)??"",names:vo(e.get(y)??"").filter(S=>t.identifier.test(S))})),x,(y,S)=>Se(y,S,s)),I=[];if(l.size>0){let y=new RegExp(`(?:^|[\\s{;])(${[...l].map(ge).join("|")})\\s*:`),S=new Map;for(let _ of n){if(!et.test(_)&&!xo.test(_))continue;let j=e.get(_),T=me(j,y);if(T.count!==0){for(let F of j.matchAll(new RegExp(y.source,"gm"))){let M=S.get(F[1])??[];M.includes(_)||M.push(_),S.set(F[1],M)}o(_,"tokens",`defines ${T.count} token${T.count===1?"":"s"} read by ${t.label.toLowerCase()} styles`,T)}}for(let _ of[...l].sort())I.push({name:_,definedIn:S.get(_)??[]})}for(let y of n){if(!xo.test(y))continue;let S=me(e.get(y),t.prose);S.count>0&&o(y,"tokens","token file mentions the concept",S)}let R=[...i],A=new RegExp([...R.length?[`<(?:${R.map(ge).join("|")})\\b`]:[],...t.elements.map(y=>`<${ge(y)}\\b`),...t.roles.map(y=>`role=["']${ge(y)}["']`)].join("|"));for(let y of n){if(!Ce.test(y)||a.has(y))continue;let S=e.get(y),_=Z.test(y),j=me(S,A),T=Wn(S).some(M=>{let B=Se(y,M,s);return B!=null&&a.has(B)});if(j.count===0&&!T)continue;let F=j.count>0?`${j.count} render${j.count===1?"":"s"}`:"imports a button component";o(y,_?"tests":"uses",F,j.count?j:me(S,t.prose))}for(let y of n){if(!(wo.test(y)||jt.test(y)))continue;let _=e.get(y),j=me(_,t.prose);j.count!==0&&o(y,Z.test(y)?"tests":"describes",jt.test(y)?"repo rules / instructions":"documentation",j)}for(let y of n){if(!Z.test(y)||r.has(`tests:${y}`)||!Ce.test(y))continue;let S=me(e.get(y),t.prose);S.count>0&&o(y,"tests","mentions the concept",S)}let L=[...r.values()].sort((y,S)=>S.matches-y.matches||y.path.localeCompare(S.path)),O={implements:0,styles:0,tokens:0,uses:0,describes:0,tests:0};for(let y of L)O[y.role]++;let V=no(c);zn(e,n.filter(y=>bo.test(y)&&!Z.test(y)),V,new Set(t.elements),!0,P,(y,S)=>Se(y,S,s)),zn(e,n.filter(y=>bo.test(y)&&!Z.test(y)),V.flatMap(y=>y.modifiers??[]),new Set(t.elements));for(let[y,S]of v.sites)y.usage=yo(e,S,!("alike"in y));let X=Eu(e,n),lt=[];if(i.size>0){let y=new RegExp(t.elements.map(S=>`<${ge(S)}\\b`).join("|"),"g");for(let S of n){if(!Ce.test(S)||Z.test(S)||a.has(S))continue;let _=e.get(S),j=(_.match(y)??[]).length;if(j===0)continue;let T=me(_,new RegExp(y.source));lt.push({path:S,line:T.lines[0]?.line??1,count:j})}}let hs=[],ys=new Set;for(let y of n){if(!Ce.test(y)||Z.test(y))continue;let S=e.get(y),_=_t(y,S,P,(j,T)=>Se(j,T,s));for(let j of _)for(let T of j.unknown){let F=[...T.known].sort();if(T.cls!==void 0){if(g.has(T.cls))continue;let z=T.cls.slice(0,T.cls.length-T.value.length),ae=[...g].filter(D=>D.startsWith(z)&&D.length>z.length).map(D=>D.slice(z.length));if(ae.length===0)continue;F=[...new Set([...T.known,...ae])].sort()}if(F.length===0)continue;let M=mu(S,j.offset),B=`${y}\0${j.component}\0${T.prop}\0${T.value}`;ys.has(B)||(ys.add(B),hs.push({path:y,line:M,component:j.component,prop:T.prop,value:T.value,known:F}))}}let Gi=n.filter(y=>(wo.test(y)||jt.test(y))&&!Z.test(y)).map(y=>({path:y,kind:du(y)}));V.sort((y,S)=>Number(S.base)-Number(y.base)||y.path.localeCompare(S.path)||y.line-S.line);let bs=Jr(e,Gi,t,V),Ki=Hr([...f.entries()].map(([y,S])=>({sheet:y,sources:S.map(_=>e.get(_)??""),rules:$e(e.get(y)??"").map(_=>({selector:_.selector,declarations:fe(_.ownBody)}))})));return{components:R.sort(),tokens:I,findings:L,variants:V,audit:Er({variants:V,tokens:I,tokenValues:X,hasComponent:i.size>0,nativeUses:lt,unknownProps:hs,guidance:bs,noun:t.label.toLowerCase(),element:t.elements[0]??t.id}),guidance:bs,content:Ki,previewCss:Pu(X,u),counts:O}}import{execFileSync as Lu}from"node:child_process";import{readdirSync as ju,readFileSync as Mu,statSync as Tu}from"node:fs";import Tt from"node:path";function Re(e,t){try{return Lu("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:64*1024*1024})}catch{return null}}function Hn(e,t=""){let s=Re(e,["rev-parse","--show-toplevel"])?.trim()||e;return{repoDir:s,root:dn(t),stateDir:Tt.join(s,".gruum")}}function Ot(e){let t=Tt.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=ju(l).sort()}catch{return}for(let f of u){let m=c?`${c}/${f}`:f,h=Tt.join(l,f),k;try{k=Tu(h)}catch{continue}if(k.isDirectory()){pn(m)&&a(h,m);continue}if(!k.isFile())continue;if(!fn(m,k.size)){o++;continue}let C=Mu(h);if(lr(C)){o++;continue}if(r+C.length>4e7){i=!0;return}r+=C.length,n.set(m,s.decode(C))}};return a(t,""),{files:n,truncated:i,skipped:o}}function Eo(e,t){let n=Re(e.repoDir,["diff","--cached","--name-status","-z"]);if(n===null)return t;let s=pr(n).map(({path:r,deleted:o})=>({path:r,content:o?null:Re(e.repoDir,["show",`:${r}`])}));return{...t,files:ur(t.files,s,e.root)}}function Po(e){let t=Re(e.repoDir,["remote","get-url","origin"])?.trim()??"",n=yt(t)??Tt.basename(e.repoDir),s=Re(e.repoDir,["rev-parse","HEAD"])?.trim()||"working-tree";return{fullName:n,ref:s,rootPath:e.root,htmlUrl:n.includes("/")?`https://github.com/${n}`:""}}function Io(e){let t=Re(e.repoDir,["config","--get","core.hooksPath"])?.trim();return t||Re(e.repoDir,["rev-parse","--git-path","hooks"])?.trim()||null}function Dt(e,t={}){let n=$o[t.concept??"button"],s=Ot(e);return t.staged&&(s=Eo(e,s)),{concept:n.id,label:n.label,..._o(s.files,n),repo:Po(e),index:{files:s.files.size,truncated:s.truncated,skipped:s.skipped}}}function Ae(e,t,n={}){let s=Dt(e,{concept:t.concept,...n});return{result:s,baseline:t,items:_s(s,t)}}import{mkdirSync as Uu,readFileSync as Fu,writeFileSync as Wo}from"node:fs";import se from"node:path";function Lo(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 jo="http://localhost:3000";function To(e){return((e.split("/").pop()||e).replace(/\.git$/i,"").split(/[-_]/)[0]??"").toLowerCase().replace(/[^a-z]/g,"")}function Oo(e,t){if(!/^[a-z]+$/.test(t))return null;let n=new RegExp(`https?://(?:[a-z0-9-]+\\.)*${t}\\.\\w{2,3}(?![\\w.])`,"gi"),s=null;for(let r of e.matchAll(n)){let o=r[0].toLowerCase();if(o.startsWith("https://"))return o;s??=o}return s}function Do(e){let t={};try{t=JSON.parse(e).scripts??{}}catch{return null}let n=typeof t.dev=="string"?t.dev:"",s=typeof t.start=="string"?t.start:"",r=Mo(n)??Mo(s);return r?`http://localhost:${r}`:null}function Mo(e){let t=/(?:--port|-p)(?:=|\s+)(\d{2,5})\b/.exec(e),n=/\b(?:localhost|127\.0\.0\.1):(\d{2,5})\b/.exec(e),s=t?.[1]??n?.[1];if(!s)return null;let r=Number(s);return!Number.isInteger(r)||r<1||r>65535||r===80||r===443?null:String(r)}function No(e){return`
67
+ This repo starts its app at ${e}.
68
+ The Chrome window Gruum opens is signed out.
69
+
70
+ (Enter) open ${e}, or type a URL: `}function Uo(){return`
71
+ What URL does this app run on locally?
72
+
73
+ URL: `}var Fo='Gruum could not tell which URL this app runs on locally. Find it from the dev script in package.json, or from the server you started, and call gruum_request_exception again with url set to that page (for example "http://localhost:3200/"). Gruum saves that URL for the next capture.';function Ou(e,t){return e?tt(e).replace(/\/$/,"")===t.replace(/\/$/,""):!1}function qn(e){if(!e||typeof e!="object")return null;let t=e.url;if(typeof t!="string")return null;try{let n=new URL(t);return n.protocol!=="http:"&&n.protocol!=="https:"?null:n.toString()}catch{return null}}function Bo(e){let t=e.pageUrl?.trim();return t?{action:"open",url:t,onlyPage:!0,save:!0}:e.saved?{action:"open",url:e.saved,onlyPage:!0,save:!1}:e.devServer?Ou(e.host,e.devServer)?{action:"open",onlyPage:!1,save:!1}:e.interactive?{action:"ask-person",suggested:e.devServer}:{action:"open",url:e.devServer,onlyPage:!0,save:!0}:e.interactive?{action:"ask-person",suggested:null}:{action:"ask-agent"}}function Vo(e){let t=e?`For example: ${jo} or ${e}.`:`For example: ${jo}.`,n=e?`URL (${e}): `:"URL: ";return`
64
74
  Live URL for this repo's website.
65
75
  ${t}
66
76
  You may not use wildcards.
67
77
 
68
- ${n}`}function Qc(e){let t=e.toLowerCase().replace(/:\d+$/,"");return t==="localhost"||t==="127.0.0.1"}function Ao(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=eu(t);if(n)return n;let s=/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:`https://${t}`;return vo(s)}function eu(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 Qc(e)?`http://${e}`:`https://${e}`}function Eo(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 Io="No project for this repo found. Creating\u2026";function jo(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 Po(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((o,i)=>` ${i+1} ${o}`),r=e.length===1?"Which project should this checkout use? (1): ":"Which project should this checkout use? ";return`
78
+ ${n}`}function Du(e){let t=e.toLowerCase().replace(/:\d+$/,"");return t==="localhost"||t==="127.0.0.1"}function zo(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=Nu(t);if(n)return n;let s=/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?t:`https://${t}`;return Lo(s)}function Nu(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 tt(e){return Du(e)?`http://${e}`:`https://${e}`}function _e(e){try{return Fu(e,"utf8")}catch{return null}}function nt(e){let t=_e(e);if(t===null)return null;try{return JSON.parse(t)}catch{return null}}function he(e,t){Uu(se.dirname(e),{recursive:!0}),Wo(e,t)}function re(e,t){he(e,`${JSON.stringify(t,null,2)}
79
+ `),Bu(e)}function Bu(e){let t=e.split(se.sep),n=t.lastIndexOf(".gruum");if(n<=0)return;let s=se.join(t.slice(0,n).join(se.sep),".gitignore"),r=dt(_e(s));r.changed&&(Wo(s,r.text),process.stderr.write(`Added .gruum/ to .gitignore.
80
+ `))}var Ee=e=>se.join(e.stateDir,"baseline.json"),Go=e=>se.join(e.stateDir,"drift.json"),Jn=e=>se.join(e.stateDir,"exceptions.json"),Vu=e=>se.join(e.stateDir,"config.json"),Ko=e=>se.join(e.stateDir,"local.json");function Ho(e){return qn(nt(Ko(e)))}function Nt(e,t){let n=qn({url:t});n&&re(Ko(e),{url:n})}function ye(e,t){return ze(nt(t?se.resolve(t):Ee(e)))}function Ut(e){return Is(nt(Go(e)),new Date().toISOString())}function Zn(e,t){re(Go(e),t)}function zu(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 Ft(e){return zu(nt(Jn(e)))}function Bt(e){let t=nt(Vu(e)),{block:n,hooks:s}=Ls(t);return{...typeof t?.root=="string"?{root:t.root}:{},block:n,hooks:s}}import{chmodSync as $p,mkdirSync as Cp,readFileSync as os,writeFileSync as Sp}from"node:fs";import{hostname as Rp,homedir as Ap}from"node:os";import zt from"node:path";import{createInterface as is}from"node:readline/promises";var Wu=/\.((?:\\.|[\w-])+)/g;function qo(e){let t=e.trim().split(/[\s>+~]+/).pop()??"",n=[];for(let s of t.matchAll(Wu)){let r=s[1].replace(/\\/g,"");/^[A-Za-z_][\w-]*$/.test(r)&&n.push(r)}return n}function Jo(e){let t=e.replace(/\\/g,"/").replace(/^\.\//,"");return Gu(t)??Ku(t)??Hu(t)}function Xn(e,t){let n=e.replace(/\/$/,"");return t==="/"?`${n}/`:`${n}${t}`}function Gu(e){let t=/(?:^|\/)app\/(.*)$/.exec(e);if(!t)return null;let n=t[1];if(!/(?:^|\/)page\.(tsx|jsx|js|mdx)$/.test(n))return null;let s=n.replace(/(?:^|\/)page\.(tsx|jsx|js|mdx)$/,"");return Zo(s.split("/").filter(Boolean),"app")}function Ku(e){let t=/(?:^|\/)pages\/(.*)$/.exec(e);if(!t)return null;let n=t[1];return n==="api"||n.startsWith("api/")||/(?:^|\/)_/.test(n)||!/\.(tsx|jsx|js|mdx)$/.test(n)?null:(n=n.replace(/\.(tsx|jsx|js|mdx)$/,""),n==="index"?n="":n.endsWith("/index")&&(n=n.slice(0,-6)),Zo(n.split("/").filter(Boolean),"pages"))}function Hu(e){let t=/(?:^|\/)src\/routes\/(.*)$/.exec(e);if(!t)return null;let n=t[1];if(!/\.(tsx|jsx|js|mdx)$/.test(n))return null;n=n.replace(/\.(tsx|jsx|js|mdx)$/,""),n==="_index"?n="":n.endsWith("/_index")&&(n=n.slice(0,-7));let s=[];for(let r of n.split("/").filter(Boolean))for(let o of r.split("."))if(!(!o||o.startsWith("_"))){if(o.startsWith("$")||o.includes("["))return null;s.push(o)}return"/"+s.join("/")}function Zo(e,t){let n=[];for(let s of e)if(!(t==="app"&&s.startsWith("(")&&s.endsWith(")"))&&!(t==="app"&&s.startsWith("@"))){if(s.includes("[")||s.includes("]")||s.startsWith("_"))return null;n.push(s)}return"/"+n.join("/")}var qu=4e5,Ju=12,Zu=/^__gs-recipe-\d+$/,Xu=/^data:image\/(?:jpeg|png|svg\+xml)(?:;charset=utf-8)?;base64,[A-Za-z0-9+/]+=*$/i;function Vt(e){return!!(e?.screenshot||e?.snapdom)}function ei(e){let t=e.trim().toLowerCase();return t===""?"capture":t==="q"||t==="n"?"skip":null}function ti(e){return`
81
+ ${e?"Still not seeing the button in that Chrome window.":`The button is not in that Chrome window yet.
82
+ Sign in there and open the screen where it shows.`}
83
+
84
+ (Enter) capture, (q) use the scanned styles: `}function Qn(e){switch(e){case"no-url":return"No live URL. Set one with gruum, or pass the page where this button renders.";case"no-browser":return"Could not find Chrome to open the app and capture the button.";case"no-query":return"Not enough to find this control on the page.";case"page-skipped":return"The page did not open. Is the app running at that URL?";case"not-on-opened-pages":return"The button was not found on the opened pages. Pass the page URL where it renders.";case"capture-failed":return"Opened the page but could not take a picture of the button."}}function Xo(e){if(!e?.length)return;let t=e.find(s=>s.property==="background-color")?.value.trim(),n=e.find(s=>s.property==="color")?.value.trim();if(!(!t&&!n))return{...t?{backgroundColor:t}:{},...n?{color:n}:{}}}function Yo(e){return(e??[]).filter(t=>/^[A-Za-z_][\w-]*$/.test(t)&&!Zu.test(t))}function Yu(e){let t=e?.usage.files.map(s=>s.example?.element?.bodyHtml).find(s=>!!s);if(!t)return;let n=t.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();if(!(n.length<2||n.length>80))return n}function ni(e,t){if(!t)return null;if(e.styleId){let s=t.variants.find(r=>ct(r)===e.styleId);if(s)return s}let n=e.refs[0]?.path;return n?t.variants.find(s=>s.markup&&(s.path===n||s.places?.some(r=>r.path===n)))??null:null}function si(e,t){let n=ni(e,t),s=n?.usage.files.map(c=>Yo(c.example?.element?.classes)).find(c=>c.length>0),r=n?Yo(qo(n.selector)):[],o=s?.length?s:r,i=n?.element?.tag||e.observed?.element||(e.observed?.markup||o.length===0?"button":void 0),a=Xo(e.observed?.states?.find(c=>c.state==="default"||c.state==="rest")?.declarations??e.observed?.declarations)??Xo(n?.states.find(c=>c.state==="default")?.declarations),l=Yu(n);return o.length===0&&!a&&!l?null:{key:e.id.slice(0,200),classes:o,...n&&Xe(n.path)?{module:!0}:{},...i&&/^[a-z][a-z0-9-]*$/i.test(i)?{tag:i.toLowerCase()}:{},...l?{text:l}:{},...a?{paint:a}:{}}}function es(e){if(typeof e!="string")return null;let t=e.trim();if(!t||t.length>2e3)return null;try{let n=new URL(t);return n.protocol!=="http:"&&n.protocol!=="https:"?null:n.toString()}catch{return null}}function ri(e){let t=[],n=s=>{!s||t.includes(s)||t.length>=3||t.push(s)};if(n(es(e.pageUrl)),e.onlyPage&&t.length>0)return t;if(e.host){let s=tt(e.host);n(Xn(s,"/"));let r=e.refs[0]?Jo(e.refs[0].path):null;r&&n(Xn(s,r))}return t}function oi(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.url=="string"&&t.url.length<=2e3?t.url:void 0,s=Qo(t.screenshot),r=Qo(t.snapdom),o=tp(t.miss)?t.miss:void 0;if(!n&&!s&&!r&&!o)return null;let i=t.preview===!0&&(s||r)?!0:void 0;return{...n?{url:n}:{},...s?{screenshot:s}:{},...r?{snapdom:r}:{},...i?{preview:i}:{},...o?{miss:o}:{}}}var Qu=/^(button|a|span|div)$/;function Yn(e,t){let n=e.trim().toLowerCase(),s=t.trim();return!/^[a-z]+(?:-[a-z]+)*$/.test(n)||n.length>40||!s||s.length>180||/[<>{}\\;]|url\s*\(|expression\s*\(|javascript:/i.test(s)?null:`${n}:${s}`}function ii(e,t){let n=/<(button|a)\b[^>]*>([\s\S]*?)<\/\1>/gi,s=[];for(let r of e.matchAll(n)){let o=r[2]??"";if(o.includes("{")||o.includes("<"))continue;let i=o.replace(/\s+/g," ").trim();if(i.length<2||i.length>80)continue;let a=r.index??0,l=e.slice(0,a).split(`
85
+ `).length;s.push({line:l,text:i})}if(s.length!==0){if(typeof t=="number"){let r=s.find(o=>Math.abs(o.line-t)<=12);if(r)return r.text}return s.length===1?s[0].text:void 0}}function ep(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ai(e,t,n){let s=ni(e,t),r=e.observed?.declarations??[],o=s?.states.find(u=>u.state==="default"||u.state==="rest")?.declarations??[],i=(r.length?r:o).map(u=>Yn(u.property,u.value)).filter(u=>!!u).slice(0,40),a=n.paint;if(a?.backgroundColor&&!i.some(u=>u.startsWith("background-color:"))){let u=Yn("background-color",a.backgroundColor);u&&i.push(u)}if(a?.color&&!i.some(u=>u.startsWith("color:"))){let u=Yn("color",a.color);u&&i.push(u)}if(i.length===0)return null;let l=n.tag&&Qu.test(n.tag)?n.tag:"button",c=ep(n.text||"Button");return`<!doctype html><html><head><meta charset="utf-8"><style>
86
+ html,body{margin:0;background:#f4f4f5}
87
+ body{min-height:100vh;display:flex;align-items:center;justify-content:center;font-family:Inter,system-ui,sans-serif}
88
+ .stage{width:240px}
89
+ [data-gruum-capture]{box-sizing:border-box;border:0;appearance:none;font:inherit;cursor:default;${i.join(";")}}
90
+ </style></head><body><div class="stage"><${l} type="button" data-gruum-capture="1">${c}</${l}></div></body></html>`}function Qo(e){if(typeof e=="string"&&!(e.length>qu))return Xu.test(e)?e:void 0}function tp(e){return e==="no-url"||e==="no-browser"||e==="no-query"||e==="page-skipped"||e==="not-on-opened-pages"||e==="capture-failed"}function li(e){return`(async () => {
91
+ const query = ${JSON.stringify(e)};
92
+ const pad = ${Ju};
93
+ const find = ${np()};
94
+ const element = find(query);
95
+ if (!element) return { found: false };
96
+ try { element.scrollIntoView({ block: "center", inline: "center", behavior: "instant" }); } catch (e) {}
97
+ await new Promise((resolve) => setTimeout(resolve, 160));
98
+ const rect = element.getBoundingClientRect();
99
+ if (rect.width < 12 || rect.height < 12) return { found: false };
100
+ const box = {
101
+ x: Math.max(0, rect.x - pad),
102
+ y: Math.max(0, rect.y - pad),
103
+ width: Math.max(1, Math.ceil(rect.width + pad * 2)),
104
+ height: Math.max(1, Math.ceil(rect.height + pad * 2)),
105
+ };
106
+ let snapdom = "";
107
+ const api = globalThis.snapdom;
108
+ if (api && typeof api.toSvg === "function") {
109
+ try {
110
+ const image = await api.toSvg(element, {
111
+ scale: 1,
112
+ outerShadows: true,
113
+ fast: true,
114
+ reconcile: false,
115
+ });
116
+ if (image && typeof image.src === "string" && image.src.indexOf("image/svg+xml") !== -1 && image.src.length <= 120000) {
117
+ snapdom = image.src;
118
+ }
119
+ } catch (e) {}
120
+ }
121
+ return {
122
+ found: true,
123
+ box: box,
124
+ snapdom: snapdom,
125
+ dpr: window.devicePixelRatio || 1,
126
+ };
127
+ })()`}function np(){return`function (query) {
128
+ const classes = Array.isArray(query.classes) ? query.classes : [];
129
+ const names = classes.filter(function (name) {
130
+ return typeof name === "string" && /^[A-Za-z0-9_-]+$/.test(name);
131
+ });
132
+ const visible = function (node) {
133
+ const rect = node.getBoundingClientRect();
134
+ if (rect.width < 12 || rect.height < 12) return false;
135
+ const style = window.getComputedStyle(node);
136
+ return style.display !== "none" && style.visibility !== "hidden" && style.opacity !== "0";
137
+ };
138
+ if (query.studio === true) {
139
+ try {
140
+ const node = document.querySelector("[data-gruum-capture]");
141
+ if (node && visible(node)) return node;
142
+ } catch (e) {}
143
+ return null;
144
+ };
145
+ if (names.length > 0 && names.length === classes.length) {
146
+ try {
147
+ const exact = document.querySelectorAll(names.map(function (name) { return "." + name; }).join(""));
148
+ for (let i = 0; i < exact.length; i++) {
149
+ if (visible(exact[i])) return exact[i];
150
+ }
151
+ } catch (e) {}
152
+ if (query.module === true && names[0]) {
153
+ const safe = names[0].replace(/[^A-Za-z0-9_-]/g, "");
154
+ const selector = '[class~="' + safe + '"],[class*="_' + safe + '__"],[class*="__' + safe + '___"],[class*="_' + safe + '_"]';
155
+ try {
156
+ const nodes = document.querySelectorAll(selector);
157
+ for (let i = 0; i < nodes.length; i++) {
158
+ if (visible(nodes[i])) return nodes[i];
159
+ }
160
+ } catch (e) {}
161
+ }
162
+ }
163
+ const tag = typeof query.tag === "string" ? query.tag.toLowerCase() : "";
164
+ const label = typeof query.text === "string" ? query.text.replace(/s+/g, " ").trim().toLowerCase() : "";
165
+ const byText = function (list) {
166
+ if (!label) return null;
167
+ for (let i = 0; i < list.length; i++) {
168
+ const node = list[i];
169
+ if (!visible(node)) continue;
170
+ const text = (node.innerText || "").replace(/s+/g, " ").trim().toLowerCase();
171
+ if (text === label || (label.length >= 2 && text.indexOf(label) !== -1)) return node;
172
+ }
173
+ return null;
174
+ };
175
+ const paint = query.paint || {};
176
+ const background = typeof paint.backgroundColor === "string" ? paint.backgroundColor : "";
177
+ const foreground = typeof paint.color === "string" ? paint.color : "";
178
+ if (!/^[a-z][a-z0-9-]*$/.test(tag)) {
179
+ if (!label) return null;
180
+ try { return byText(document.querySelectorAll("button, a, [role='button']")); } catch (e) { return null; }
181
+ }
182
+ let nodes;
183
+ try { nodes = document.querySelectorAll(tag); } catch (e) { return null; }
184
+ if (background || foreground) {
185
+ let wantBackground = "";
186
+ let wantForeground = "";
187
+ try {
188
+ const probe = document.createElement("span");
189
+ if (background) probe.style.setProperty("background-color", background);
190
+ if (foreground) probe.style.setProperty("color", foreground);
191
+ (document.body || document.documentElement).appendChild(probe);
192
+ const style = window.getComputedStyle(probe);
193
+ wantBackground = background ? style.getPropertyValue("background-color").trim() : "";
194
+ wantForeground = foreground ? style.getPropertyValue("color").trim() : "";
195
+ probe.remove();
196
+ } catch (e) {
197
+ return byText(nodes);
198
+ }
199
+ for (let i = 0; i < nodes.length; i++) {
200
+ const node = nodes[i];
201
+ if (!visible(node)) continue;
202
+ const style = window.getComputedStyle(node);
203
+ if (wantBackground && style.getPropertyValue("background-color").trim() !== wantBackground) continue;
204
+ if (wantForeground && style.getPropertyValue("color").trim() !== wantForeground) continue;
205
+ return node;
206
+ }
207
+ }
208
+ return byText(nodes);
209
+ }`}import{spawn as sp}from"node:child_process";import{existsSync as ci,mkdtempSync as rp,readFileSync as pi,rmSync as op}from"node:fs";import{tmpdir as ip}from"node:os";import De from"node:path";import{createInterface as ap}from"node:readline";var lp=2e4,cp=8e3;async function fi(e){let t=ri({host:e.host,pageUrl:e.pageUrl,refs:e.item.refs,onlyPage:e.onlyPage}),n=pp(si(e.item,e.result),e.repoDir,e.item.refs);if(!n)return{miss:"no-query"};let s=ai(e.item,e.result,n);if(t.length===0&&!s)return{miss:"no-url"};let r=yp();if(!r)return{miss:"no-browser"};let o=hp(),i=!!process.stdin.isTTY,a=!1;try{let l=await bp(r,i);try{for(let c of t){let u=await l.open(c);if(!u)continue;a=!0;let f=await ts(l,n,o,u);if(f)return f}if(a&&i){let c=!1;for(;await up(c)!=="skip";){c=!0;let f=await l.location();if(!f||f==="about:blank")continue;let m=await ts(l,n,o,f);if(m)return m}}if(s&&await l.show(s)){a=!0;let c=await ts(l,{...n,studio:!0},o);if(c)return{...c,preview:!0}}}finally{await l.close()}}catch{return{miss:a?"capture-failed":"page-skipped"}}return a?{miss:"not-on-opened-pages"}:{miss:"page-skipped"}}async function ts(e,t,n,s){if(n)try{await e.evaluate(`(() => { ${n}
210
+ ; return 0; })()`,!1)}catch{}let r;try{r=await e.evaluate(li(t),!0)}catch{return null}let o=dp(r);if(!o)return null;let i=await e.screenshot(o.box,o.dpr)||await e.screenshotViewport(),a=oi({...s?{url:s}:{},screenshot:i,snapdom:gp(o.snapdom)});return a&&Vt(a)?a:null}function di(e){return Vt(e)&&e.preview?"Rendered the button from its scanned styles. It was not on the opened pages.":Vt(e)&&e.url?`Captured the rendered button from ${e.url}.`:e.miss?Qn(e.miss):Qn("capture-failed")}function up(e){let t=ap({input:process.stdin,output:process.stdout});return le(t),new Promise(n=>{let s=()=>{t.question(ti(e),r=>{let o=ei(r);if(o){t.close(),n(o);return}process.stdout.write(`Press Enter to capture, or q to continue.
211
+ `),s()})};s()})}function pp(e,t,n){if(!e||e.text||!t)return e;for(let s of n.slice(0,4)){let r=fp(t,s.path),o=r?ii(r,s.line):void 0;if(o)return{...e,text:o}}return e}function fp(e,t){if(!(!t||t.includes("..")||De.isAbsolute(t)))try{let n=De.resolve(e,t),s=De.resolve(e);if(n!==s&&!n.startsWith(s+De.sep))return;let r=pi(n,"utf8");return r.length>2e5?void 0:r}catch{return}}function dp(e){if(!e||typeof e!="object")return null;let t=e;if(t.found!==!0)return null;let n=t.box,s=Number(n?.x),r=Number(n?.y),o=Number(n?.width),i=Number(n?.height);return![s,r,o,i].every(a=>Number.isFinite(a))||o<1||i<1?null:{box:{x:s,y:r,width:o,height:i},snapdom:typeof t.snapdom=="string"?t.snapdom:"",dpr:Number(t.dpr)||1}}function gp(e){if(!e)return;if(mp.test(e))return e;let t=e.indexOf(",");if(t<0||e.slice(0,t).indexOf("image/svg+xml")===-1)return;let n=decodeURIComponent(e.slice(t+1));return`data:image/svg+xml;base64,${Buffer.from(n,"utf8").toString("base64")}`}var mp=/^data:image\/[^,]*;base64,/;function hp(){return'/*\n* SnapDOM\n* v2.24.15\n* Author: Juan Martin Muda\n* License: MIT\n*/\n"use strict";(()=>{var Kr=Object.defineProperty;var st=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(o){throw n=[o],o}};var Gt=(t,e)=>{for(var n in e)Kr(t,n,{get:e[n],enumerable:!0})};function _n(t){if(t===!0)return"soft";if(t===!1)return"disabled";if(typeof t=="string"){let e=t.toLowerCase().trim();if(e==="auto")return"auto";if(e==="full")return"full";if(e==="soft"||e==="disabled")return e}return"soft"}function pe(t="soft"){switch(t){case"auto":{C.session.styleMap=new Map,C.session.nodeMap=new Map;return}case"soft":{C.session.styleMap=new Map,C.session.nodeMap=new Map,C.session.styleCache=new WeakMap;return}case"full":return;case"disabled":{C.session.styleMap=new Map,C.session.nodeMap=new Map,C.session.styleCache=new WeakMap,C.computedStyle=new WeakMap,C.measureHints=new WeakMap,C.baseStyle=new Y(50),C.defaultStyle=new Y(30),C.image=new Y(100),C.background=new Y(100),C.resource=new Y(150),C.compress=new Y(50),C.font=new Set;return}default:{C.session.styleMap=new Map,C.session.nodeMap=new Map,C.session.styleCache=new WeakMap;return}}}var Y,C,rt=st(()=>{"use strict";Y=class extends Map{constructor(e=100,...n){super(...n),this._maxSize=e}set(e,n){if(this.size>=this._maxSize&&!this.has(e)){let o=this.keys().next().value;o!==void 0&&this.delete(o)}return super.set(e,n)}},C={image:new Y(100),background:new Y(100),resource:new Y(150),defaultStyle:new Y(30),baseStyle:new Y(50),compress:new Y(50),computedStyle:new WeakMap,measureHints:new WeakMap,burstAdvice:new WeakMap,warnedReconcile:!1,font:new Set,session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map}}});function Et(t){let e=t.match(/url\\(([\'"]?)(.*?)(\\1)\\)/);if(!e)return null;let n=e[2].trim();return n.startsWith("#")?null:n}function Yt(t,e=1){let n=t.match(/^\\s*-?(?:webkit-)?image-set\\(([\\s\\S]*)\\)\\s*$/i);if(!n)return null;let o=[];for(let s of n[1].split(",")){let i=s.match(/url\\(([\'"]?)(.*?)(\\1)\\)/);if(!i)continue;let a=s.match(/type\\(\\s*["\']([^"\']+)["\']\\s*\\)/i);if(a&&!Qr.test(a[1].trim()))continue;let c=s.match(/(\\d+(?:\\.\\d+)?)\\s*(x|dpi|dppx)/i),u=1;if(c){let l=parseFloat(c[1]);u=/dpi/i.test(c[2])?l/96:l}o.push({url:i[2].trim(),dppx:u})}return o.length?(o.sort((s,i)=>s.dppx-i.dppx),(o.find(s=>s.dppx>=e)||o[o.length-1]).url):null}function De(t){if(!t||t==="none")return"";let e=t.replace(/translate[XY]?\\([^)]*\\)/g,"");return e=e.replace(/matrix\\(([^)]+)\\)/g,(n,o)=>{let r=o.split(",").map(s=>s.trim());return r.length!==6?`matrix(${o})`:(r[4]="0",r[5]="0",`matrix(${r.join(", ")})`)}),e=e.replace(/matrix3d\\(([^)]+)\\)/g,(n,o)=>{let r=o.split(",").map(s=>s.trim());return r.length!==16?`matrix3d(${o})`:(r[12]="0",r[13]="0",`matrix3d(${r.join(", ")})`)}),e.trim().replace(/\\s{2,}/g," ")}function St(t){if(/%[0-9A-Fa-f]{2}/.test(t))return t;try{return encodeURI(t)}catch{return t}}function He(t,e){if(!t||/^(data|blob|about|#)/i.test(t.trim()))return t;try{let n=e||typeof document<"u"&&(document.baseURI||document.location?.href)||"http://localhost/";return new URL(t,n).href}catch{return t}}var Qr,Kt=st(()=>{"use strict";Qr=/^image\\/(jpeg|jpg|png|gif|webp|avif|apng|svg\\+xml|bmp|x-icon|vnd\\.microsoft\\.icon)\\s*(;|$)/i});function Zr(t="[snapDOM]",{ttlMs:e=5*6e4,maxEntries:n=12}={}){let o=new Map,r=0;function s(i,a,c){if(r>=n)return;let u=Date.now();(o.get(a)||0)>u||(o.set(a,u+e),r++,i==="warn"&&console&&console.warn?console.warn(`${t} ${c}`):console&&console.error&&console.error(`${t} ${c}`))}return{warnOnce(i,a){s("warn",i,a)},errorOnce(i,a){s("error",i,a)},reset(){o.clear(),r=0}}}function Jr(t){return/^data:|^blob:|^about:blank$/i.test(t)}function ti(t,e){try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",o=e.includes("{url}")?e.split("{url}")[0]:e,r=new URL(o||".",n),s=new URL(t,n);if(s.origin===r.origin)return!0;let i=s.searchParams;if(i&&(i.has("url")||i.has("target")))return!0}catch{}return!1}function ei(t,e){if(!e||Jr(t)||ti(t,e))return!1;try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",o=new URL(t,n);return typeof location<"u"?o.origin!==location.origin:!0}catch{return!!e}}function ni(t,e){if(!e)return t;if(e.includes("{url}"))return e.replace("{urlRaw}",St(t)).replace("{url}",encodeURIComponent(t));if(/[?&]url=?$/.test(e))return`${e}${encodeURIComponent(t)}`;if(e.endsWith("?"))return`${e}url=${encodeURIComponent(t)}`;if(e.endsWith("/"))return`${e}${St(t)}`;let n=e.includes("?")?"&":"?";return`${e}${n}url=${encodeURIComponent(t)}`}function On(t){return new Promise((e,n)=>{let o=new FileReader;o.onload=()=>e(String(o.result||"")),o.onerror=()=>n(new Error("read_failed")),o.readAsDataURL(t)})}function oi(t,e){return[e.as||"blob",e.timeout??3e3,e.useProxy||"",e.errorTTL??8e3,t].join("|")}async function G(t,e={}){let n=e.as??"blob",o=e.timeout??3e3,r=e.useProxy||"",s=e.errorTTL??8e3,i=e.headers||{},a=!!e.silent;if(/^data:/i.test(t))try{if(n==="text")return{ok:!0,data:String(t),status:200,url:t,fromCache:!1};if(n==="dataURL")return{ok:!0,data:String(t),status:200,url:t,fromCache:!1,mime:String(t).slice(5).split(";")[0]||""};let[,b="",y=""]=String(t).match(/^data:([^,]*),(.*)$/)||[],S=/;base64/i.test(b)?atob(y):decodeURIComponent(y),g=new Uint8Array([...S].map(v=>v.charCodeAt(0))),x=new Blob([g],{type:(b||"").split(";")[0]||""});return{ok:!0,data:x,status:200,url:t,fromCache:!1,mime:x.type||""}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(t))try{let b=await fetch(t);if(!b.ok)return{ok:!1,data:null,status:b.status,url:t,fromCache:!1,reason:"http_error"};let y=await b.blob(),w=y.type||b.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await On(y),status:b.status,url:t,fromCache:!1,mime:w}:n==="text"?{ok:!0,data:await y.text(),status:b.status,url:t,fromCache:!1,mime:w}:{ok:!0,data:y,status:b.status,url:t,fromCache:!1,mime:w}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"network"}}if(/^about:blank$/i.test(t))return n==="dataURL"?{ok:!0,data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",status:200,url:t,fromCache:!1,mime:"image/png"}:{ok:!0,data:n==="text"?"":new Blob([]),status:200,url:t,fromCache:!1};let c=oi(t,{as:n,timeout:o,useProxy:r,errorTTL:s}),u=he.get(c);if(u&&u.until>Date.now())return{...u.result,fromCache:!0};u&&he.delete(c);let l=ze.get(c);if(l)return l;let d=ei(t,r)?ni(t,r):t,f=e.credentials;if(!f)try{let b=typeof location<"u"&&location.href?location.href:"http://localhost/",y=new URL(t,b);f=typeof location<"u"&&y.origin===location.origin?"include":"omit"}catch{f="omit"}let p=new AbortController,m=setTimeout(()=>p.abort("timeout"),o),h=(async()=>{try{let b=await fetch(d,{signal:p.signal,credentials:f,headers:i});if(!b.ok){let S={ok:!1,data:null,status:b.status,url:d,fromCache:!1,reason:"http_error"};if(s>0&&he.set(c,{until:Date.now()+s,result:S}),!a){let g=`${b.status} ${b.statusText||""}`.trim();Wn.warnOnce(`http:${b.status}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,`HTTP error ${g} while fetching ${n} ${t}`)}return e.onError&&e.onError(S),S}if(n==="text")return{ok:!0,data:await b.text(),status:b.status,url:d,fromCache:!1};let y=await b.blob(),w=y.type||b.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await On(y),status:b.status,url:d,fromCache:!1,mime:w}:{ok:!0,data:y,status:b.status,url:d,fromCache:!1,mime:w}}catch(b){let y=b&&typeof b=="object"&&"name"in b&&b.name==="AbortError"?String(b.message||"").includes("timeout")?"timeout":"abort":"network",w={ok:!1,data:null,status:0,url:d,fromCache:!1,reason:y};if(!/^blob:/i.test(t)&&s>0&&he.set(c,{until:Date.now()+s,result:w}),!a){let S=`${y}:${n}:${new URL(t,location?.href??"http://localhost/").origin}`,g=y==="timeout"?`Timeout after ${o}ms. Consider increasing timeout or using a proxy for ${t}`:y==="abort"?`Request aborted while fetching ${n} ${t}`:`Network/CORS issue while fetching ${n} ${t}. A proxy may be required`;Wn.errorOnce(S,g)}return e.onError&&e.onError(w),w}finally{clearTimeout(m),ze.delete(c)}})();return ze.set(c,h),h}var Wn,ze,he,vt=st(()=>{"use strict";Kt();Wn=Zr("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),ze=new Map,he=new Map});async function Rt(t,e={}){if(/^((repeating-)?(linear|radial|conic)-gradient)\\(/i.test(t)||t.trim()==="none")return t;let o=Yt(t,typeof devicePixelRatio<"u"&&devicePixelRatio||1)??Et(t);if(!o)return t;let r=He(o),s=St(r),i=(e.useProxy||"")+"|"+s;if(C.background.has(i)){let a=C.background.get(i);return a?`url("${a}")`:"none"}try{let a=await G(s,{as:"dataURL",useProxy:e.useProxy});return a.ok?(C.background.set(i,a.data),`url("${a.data}")`):(C.background.set(i,null),"none")}catch{return C.background.set(i,null),"none"}}var Bn=st(()=>{"use strict";rt();Kt();vt()});function Ve(){for(let t of ri){let e=String(t).toLowerCase();me.has(e)||ge.has(e)||ye(e)}}function ye(t){if(t=String(t).toLowerCase(),ge.has(t)){let s={};return C.defaultStyle.set(t,s),s}if(C.defaultStyle.has(t))return C.defaultStyle.get(t);let e=document.getElementById("snapdom-sandbox");e||(e=document.createElement("div"),e.id="snapdom-sandbox",e.setAttribute("data-snapdom-sandbox","true"),e.setAttribute("aria-hidden","true"),e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",e.style.width="0px",e.style.height="0px",e.style.overflow="hidden",document.body.appendChild(e));let n=document.createElement(t);n.style.all="initial",e.appendChild(n);let o=getComputedStyle(n),r={};for(let s of o){if(Qt(s))continue;let i=o.getPropertyValue(s);r[s]=i}return e.removeChild(n),C.defaultStyle.set(t,r),r}function Qt(t){let e=Un.get(t);if(e===void 0){let n=String(t).toLowerCase();e=ai.has(n)||si.test(n)||ii.test(n),Un.set(t,e)}return e}function be(t,e){return!li.has(t)&&(e==="inline"||ci.has(t)||Dn.has(t))}function je(t,e,n){let o=(e.display||"").toLowerCase();if(o==="inline"||Dn.has(t))return!1;if(n)return!0;if((e.float||"none").toLowerCase()!=="none")return!1;let s=(e.position||"static").toLowerCase();return s==="absolute"||s==="fixed"?!1:!pi.has(o)}function Wt(t,e,n=!0,o=!1){if(e=String(e||"").toLowerCase(),ge.has(e))return"";let r=[],s=ye(e),i=(t.display||"").toLowerCase(),a=i==="inline",c=be(e,i),u=t["text-wrap-mode"]||t["white-space"]||"",l=u==="nowrap"||u==="pre",f=c&&n&&!(c&&n&&!a&&l),p=!1;for(let m in t){if(Qt(m))continue;let h=t[m];if(f){if(fi.has(m))continue;if(ui.has(m)){h&&h!==s[m]&&(r.push(`${m}:${h}`),h!=="auto"&&(p=!0));continue}}if(h&&h!==s[m]){if(!l&&(m==="width"||m==="inline-size")&&h.endsWith("px")&&h.includes(".")){let b=parseFloat(h);if(Number.isFinite(b)){r.push(`${m}:${(b+di).toFixed(3)}px`);continue}}r.push(`${m}:${h}`)}}if(f&&!a&&!o&&!p){let m=t.width;m&&m!=="auto"&&m!==s.width&&r.push(`min-width:${m}`)}return r.sort(),r.join(";")}function qe(t){let e=new Set;return t.nodeType!==Node.ELEMENT_NODE&&t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?[]:(t.tagName&&e.add(t.tagName.toLowerCase()),typeof t.querySelectorAll=="function"&&t.querySelectorAll("*").forEach(n=>e.add(n.tagName.toLowerCase())),Array.from(e))}function Xe(t){let e=new Map;for(let o of t){let r=ye(o);if(!r)continue;let s=Object.entries(r).map(([i,a])=>`${i}:${a};`).sort().join("");s&&(e.has(s)||e.set(s,[]),e.get(s).push(o))}let n="";for(let[o,r]of e.entries())n+=`${r.join(",")} { ${o} }\n`;return n}function Ge(t){let e=Array.from(new Set(t.values())).filter(Boolean).sort(),n=new Map,o=1;for(let r of e)n.set(r,`c${o++}`);return n}function hi(t){try{let e=t?.ownerDocument;if(!e)return typeof window<"u"?window:null;let n=e.defaultView;if(n&&typeof n.getComputedStyle=="function")return n;if(typeof window<"u"&&window.frames)for(let o=0;o<window.frames.length;o++)try{if(window.frames[o]?.document===e)return window.frames[o]}catch{}}catch{}return typeof window<"u"?window:null}function N(t,e=null){let n=()=>{let s={length:0,getPropertyValue:()=>"",item:()=>""};return s[Symbol.iterator]=function*(){},s};if(t?.nodeType!==1){let s=typeof window<"u"?window:null;if(s&&typeof s.getComputedStyle=="function")try{return s.getComputedStyle(t,e)||n()}catch{return n()}return n()}let o=C.computedStyle.get(t);o||(o=new Map,C.computedStyle.set(t,o));let r=o.get(e);if(!r){let s=hi(t),i=null;try{i=s&&typeof s.getComputedStyle=="function"?s.getComputedStyle(t,e):null}catch{}if(!i&&typeof window<"u"&&typeof window.getComputedStyle=="function")try{t.ownerDocument===document&&(i=window.getComputedStyle(t,e))}catch{}r=i||n(),o.set(e,r)}return r}function we(t){let e={};for(let n of t)e[n]=t.getPropertyValue(n);for(let n of mi){let o=e[`border-${n}-style`],r=e[`border-${n}-width`];(o==="none"||o==="hidden"||r==="0px")&&(delete e[`border-${n}-style`],delete e[`border-${n}-width`],delete e[`border-${n}-color`])}return e}function Ot(t){let e=[],n=0,o=0;for(let r=0;r<t.length;r++){let s=t[r];s==="("&&n++,s===")"&&n--,s===","&&n===0&&(e.push(t.slice(o,r).trim()),o=r+1)}return e.push(t.slice(o).trim()),e}var me,ge,ri,ii,si,ai,Un,ci,Dn,li,fi,ui,di,pi,mi,Zt=st(()=>{"use strict";rt();me=new Set(["meta","script","noscript","title","link","template"]),ge=new Set(["meta","link","style","title","noscript","script","template","g","defs","use","marker","mask","clipPath","pattern","symbol","path","polygon","polyline","line","circle","ellipse","rect","filter","lineargradient","radialgradient","stop"]),ri=["div","span","p","a","img","ul","li","button","input","select","textarea","label","section","article","header","footer","nav","main","aside","h1","h2","h3","h4","h5","h6","table","thead","tbody","tr","td","th"];ii=/(?:^|-)(animation|transition)(?:-|$)/i,si=/^(--.+|view-timeline|scroll-timeline|animation-trigger|offset-|position-try|app-region|interactivity|overlay|view-transition|-webkit-locale|-webkit-user-(?:drag|modify)|-webkit-tap-highlight-color|-webkit-text-security)$/i,ai=new Set(["cursor","pointer-events","touch-action","user-select","print-color-adjust","speak","reading-flow","reading-order","anchor-name","anchor-scope","container-name","container-type","timeline-scope","zoom","stroke-color"]),Un=new Map;ci=new Set(["span","small","em","strong","b","i","u","s","code","cite","mark","sub","sup"]),Dn=new Set(["table","thead","tbody","tfoot","tr","td","th"]),li=new Set(["img","video","canvas","svg","iframe","embed","object","input","textarea","select"]),fi=new Set(["width","max-width","inline-size","max-inline-size"]),ui=new Set(["min-width","min-inline-size"]),di=.001;pi=new Set(["inline-block","inline-flex","inline-grid","inline-table","inline-flow-root","table"]);mi=["top","right","bottom","left"]});function $t(t,{fast:e=!1}={}){if(e)return t();"requestIdleCallback"in window?requestIdleCallback(t,{timeout:50}):setTimeout(t,1)}function mt(t=1e3){return typeof requestAnimationFrame!="function"||typeof document<"u"&&document.visibilityState==="hidden"?Promise.resolve():new Promise(e=>{let n=!1,o=()=>{n||(n=!0,e())};try{requestAnimationFrame(o)}catch{o();return}setTimeout(o,t)})}function Ye(){if(typeof navigator>"u")return!1;if(navigator.userAgentData)return navigator.userAgentData.platform==="iOS";let t=navigator.userAgent||"",e=/iPhone|iPad|iPod/.test(t),n=navigator.maxTouchPoints>2&&/Macintosh/.test(t);return e||n}function K(){if(typeof navigator>"u")return!1;let t=navigator.userAgent||"",e=t.toLowerCase(),n=e.includes("safari")&&!e.includes("chrome")&&!e.includes("crios")&&!e.includes("fxios")&&!e.includes("android"),o=/applewebkit/i.test(t),r=/mobile/i.test(t),s=!/safari/i.test(t),i=o&&r&&s,a=/(micromessenger|wxwork|wecom|windowswechat|macwechat)/i.test(t),c=/(baiduboxapp|baidubrowser|baidusearch|baiduboxlite)/i.test(e),u=/ipad|iphone|ipod/.test(e)&&o;return n||i||a||c||u}function Hn(){if(typeof navigator>"u")return!1;let t=(navigator.userAgent||"").toLowerCase();return t.includes("firefox")||t.includes("fxios")}var Ct=st(()=>{"use strict"});function _(t,e,n){let o=t&&typeof t=="object"&&(t.options||t);o&&o.debug&&(n!==void 0?console.warn("[snapdom]",e,n):console.warn("[snapdom]",e))}var Ke=st(()=>{"use strict"});var at=st(()=>{"use strict";Bn();Zt();Ct();Kt();Ke()});var Lr={};Gt(Lr,{decodeSvgFromDataURL:()=>We,encodeSvgToDataURL:()=>Oe,fixSafariShadows:()=>Be,toCanvas:()=>Pt});function Ca(t){try{let e=t.match(/<svg\\b[^>]*>/i);if(!e)return t;let n=e[0],o=parseFloat((n.match(/\\bwidth="([\\d.]+)/i)||[])[1]),r=parseFloat((n.match(/\\bheight="([\\d.]+)/i)||[])[1]);if(!Number.isFinite(o)||!Number.isFinite(r)||o<=0||r<=0)return t;let s=Math.min(1,At/o,At/r,Math.sqrt(Sn/(o*r)));if(s>=1)return t;let i=Math.max(1,Math.floor(o*s)),a=Math.max(1,Math.floor(r*s));return console.warn(`[snapDOM] Capture ${Math.round(o)}\\xD7${Math.round(r)}px exceeds the browser image-decode limit (${At}px/side); downscaling to ${i}\\xD7${a}px. Lower \\`scale\\` or set \\`width\\`/\\`height\\` to control output size.`),t.replace(n,n.replace(/(\\bwidth=")[\\d.]+/i,`$1${i}`).replace(/(\\bheight=")[\\d.]+/i,`$1${a}`))}catch{return t}}function Aa(t,e){let n=["x","y","width","height"].map(v=>Number(e?.[v]));if(!n.every(Number.isFinite)||n[2]<=0||n[3]<=0)throw new RangeError("[snapdom] canvas crop requires finite x/y and positive width/height");let o=t.match(/<svg\\b[^>]*>/i);if(!o)throw new Error("[snapdom] cannot crop a non-SVG capture");let r=o[0],s=(r.match(/\\bviewBox="([^"]+)"/i)||[])[1],i=String(s||"").trim().split(/[\\s,]+/).map(Number);if(i.length!==4||!i.every(Number.isFinite)||i[2]<=0||i[3]<=0)throw new Error("[snapdom] cannot crop an SVG without a finite viewBox");let[a,c,u,l]=i,d=Math.max(a,n[0]),f=Math.max(c,n[1]),p=Math.min(a+u,n[0]+n[2]),m=Math.min(c+l,n[1]+n[3]);if(!(p>d)||!(m>f))throw new RangeError("[snapdom] canvas crop does not intersect the SVG viewBox");let h=parseFloat((r.match(/\\bwidth="([\\d.]+)/i)||[])[1]),b=parseFloat((r.match(/\\bheight="([\\d.]+)/i)||[])[1]),y=Number.isFinite(h)&&h>0?h/u:1,w=Number.isFinite(b)&&b>0?b/l:1,S=Math.max(1,(p-d)*y),g=Math.max(1,(m-f)*w),x=r.replace(/(\\bwidth=")[^"]*/i,`$1${S}`).replace(/(\\bheight=")[^"]*/i,`$1${g}`).replace(/(\\bviewBox=")[^"]*/i,`$1${d} ${f} ${p-d} ${m-f}`);return t.replace(r,x)}function Tr(t){return typeof t=="string"&&/^data:image\\/svg\\+xml/i.test(t)}function We(t){let e=t.indexOf(",");return e>=0?decodeURIComponent(t.slice(e+1)):""}function ka(t){let e=t.indexOf(",");if(e<0)return"";let n=t.slice(e+1,e+1201).replace(/%[0-9A-Fa-f]?$/,"");try{return decodeURIComponent(n)}catch{return""}}function Oe(t){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}function Pr(t){let e=[],n="",o=0;for(let r=0;r<t.length;r++){let s=t[r];s==="("&&o++,s===")"&&(o=Math.max(0,o-1)),s===";"&&o===0?(e.push(n),n=""):n+=s}return n.trim()&&e.push(n),e.map(r=>r.trim()).filter(Boolean)}function Ma(t){let e=[],n="",o=0;for(let s=0;s<t.length;s++){let i=t[s];i==="("&&o++,i===")"&&(o=Math.max(0,o-1)),i===","&&o===0?(e.push(n.trim()),n=""):n+=i}n.trim()&&e.push(n.trim());let r=[];for(let s of e){if(/\\binset\\b/i.test(s))continue;let i=s.match(/-?\\d+(?:\\.\\d+)?px/gi)||[],[a="0px",c="0px",u="0px"]=i;u=`${parseFloat(u)/2}px`;let l=s.replace(/-?\\d+(?:\\.\\d+)?px/gi,"").replace(/\\binset\\b/ig,"").trim().replace(/\\s{2,}/g," "),d=!!l&&l!==",";r.push(`drop-shadow(${a} ${c} ${u}${d?` ${l}`:""})`)}return r.join(" ")}function Nr(t){let e=Pr(t),n=null,o=null,r=null,s=[];for(let a of e){let c=a.indexOf(":");if(c<0)continue;let u=a.slice(0,c).trim().toLowerCase(),l=a.slice(c+1).trim();u==="box-shadow"?r=l:u==="filter"?n=l:u==="-webkit-filter"?o=l:s.push([u,l])}if(r){let a=Ma(r);a&&(n=n?`${n} ${a}`:a,o=o?`${o} ${a}`:a)}let i=[...s];return n&&i.push(["filter",n]),o&&i.push(["-webkit-filter",o]),i.map(([a,c])=>`${a}:${c}`).join(";")}function Fa(t){return t.replace(/([^{}]+)\\{([^}]*)\\}/g,(e,n,o)=>`${n}{${Nr(o)}}`)}function Ea(t){return t=t.replace(/<style[^>]*>([\\s\\S]*?)<\\/style>/gi,(e,n)=>e.replace(n,Fa(n))),t=t.replace(/style=([\'"])([\\s\\S]*?)\\1/gi,(e,n,o)=>`style=${n}${Nr(o)}${n}`),t}function Ra(){return _e||(_e=(async()=>{try{let t=\'<svg xmlns="http://www.w3.org/2000/svg" width="8" height="20"><foreignObject width="8" height="20"><div xmlns="http://www.w3.org/1999/xhtml" style="width:4px;height:4px;margin-top:8px;background:#000;box-shadow:0 8px 0 0 #000"></div></foreignObject></svg>\',e=new Image;e.decoding="sync",e.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`,await e.decode();let n=document.createElement("canvas");n.width=8,n.height=20;let o=n.getContext("2d",{willReadFrequently:!0});o.drawImage(e,0,0);let r=o.getImageData(2,18,1,1).data[3]>128,s=o.getImageData(2,2,1,1).data[3]>128;return{native:r||s,flippedY:s&&!r}}catch{return{native:!1,flippedY:!1}}})(),_e)}function $a(t){let e=[],n=0,o=0;for(let r=0;r<t.length;r++){let s=t[r];s==="("?n++:s===")"?n=Math.max(0,n-1):s===","&&n===0&&(e.push(t.slice(o,r)),o=r+1)}return e.push(t.slice(o)),e.map(r=>{let s=0,i=0,a="",c=0;for(;c<r.length;){let u=r[c];if(u==="("?s++:u===")"&&(s=Math.max(0,s-1)),s===0&&(c===0||r[c-1]===" ")){let l=/^-?\\d*\\.?\\d+px/.exec(r.slice(c));if(l){i++,a+=i===2?`${-parseFloat(l[0])}px`:l[0],c+=l[0].length;continue}}a+=u,c++}return a}).join(",")}function Ta(t,e){let n=o=>Pr(o).map(r=>{let s=r.indexOf(":");if(s<0)return r;let i=r.slice(0,s).trim().toLowerCase();return i==="text-shadow"||e&&i==="box-shadow"?`${i}:${$a(r.slice(s+1))}`:r}).join(";");return t=t.replace(/<style[^>]*>([\\s\\S]*?)<\\/style>/gi,(o,r)=>o.replace(r,r.replace(/([^{}]+)\\{([^}]*)\\}/g,(s,i,a)=>`${i}{${n(a)}}`))),t=t.replace(/style=([\'"])([\\s\\S]*?)\\1/gi,(o,r,s)=>`style=${r}${n(s)}${r}`),t}async function Be(t){if(!/(?:box-shadow|text-shadow)\\s*:[^;"}]*px/i.test(t))return{svg:t,naturalOnly:!1};let{native:n,flippedY:o}=await Ra();try{let r=t;return n||(r=Ea(r)),o&&(r=Ta(r,n)),{svg:r,naturalOnly:!0}}catch{return{svg:t,naturalOnly:!0}}}async function Pa(t,e){t.setAttribute("data-snapdom-internal",""),t.style.cssText="position:fixed;left:-99999px;top:-99999px;pointer-events:none",document.body.appendChild(t);try{let n=document.createElement("canvas");n.width=16,n.height=16;let o=()=>new Promise(i=>{requestAnimationFrame(i),setTimeout(i,50)}),r=n.getContext("2d",{willReadFrequently:!0});if(!r){await o(),await o();return}let s=performance.now()+(e?600:150);for(;;){r.clearRect(0,0,16,16);try{r.drawImage(t,0,0,16,16)}catch{return}let i=r.getImageData(0,0,16,16).data,a=!1;for(let c=3;c<i.length;c+=4)if(i[c]>0){a=!0;break}if(a||performance.now()>s)return;await o()}}finally{try{t.remove()}catch{}}}async function Pt(t,e){let{width:n,height:o,scale:r=1,dpr:s=1,meta:i={},backgroundColor:a,crop:c=null}=e,u=t,l=!1,d=!1;if(c&&!Tr(t))throw new RangeError("[snapdom] canvas crop requires an SVG capture payload");if(Tr(t)){let F=(ka(t).match(/<svg\\b[^>]*>/i)||[])[0]||"",E=parseFloat((F.match(/\\bwidth="([\\d.]+)/i)||[])[1]),$=parseFloat((F.match(/\\bheight="([\\d.]+)/i)||[])[1]),W=Number.isFinite(E)&&Number.isFinite($)&&E>0&&$>0&&Math.min(1,At/E,At/$,Math.sqrt(Sn/(E*$)))<1;if(c||W||K())try{let T=We(t);if(c&&(T=Aa(T,c)),K()){let I=await Be(T);T=I.svg,l=I.naturalOnly,d=/@font-face|data:image\\//i.test(T)}(W||c)&&(T=Ca(T)),u=Oe(T)}catch(T){if(c)throw T;u=t}}let f=new Image;f.loading="eager",f.decoding="sync",f.crossOrigin="anonymous",f.src=u,await f.decode(),K()&&await Pa(f,d);let p=f.naturalWidth,m=f.naturalHeight,h=c?p:Number.isFinite(i.vbW)?i.vbW:Number.isFinite(i.w0)?i.w0:p,b=c?m:Number.isFinite(i.vbH)?i.vbH:Number.isFinite(i.h0)?i.h0:m,y,w,S=Number.isFinite(n),g=Number.isFinite(o);if(S&&g)y=Math.max(1,n),w=Math.max(1,o);else if(S){let F=n/Math.max(1,h);y=n,w=b*F}else if(g){let F=o/Math.max(1,b);w=o,y=h*F}else y=p,w=m;y=y*r,w=w*r;let x=y*s,v=w*s,k=Math.max(x/At,v/At,Math.sqrt(x*v/Sn));k>1&&(console.warn(`[snapDOM] Output ${Math.round(x)}\\xD7${Math.round(v)}px exceeds the browser canvas limit (${At}px/side); downscaling. Lower \\`scale\\`/\\`dpr\\` or set \\`width\\`/\\`height\\`.`),y/=k,w/=k);let A=document.createElement("canvas");A.width=y*s,A.height=w*s,A.style.width=`${y}px`,A.style.height=`${w}px`;let M=A.getContext("2d");if(s!==1&&M.scale(s,s),a&&(M.save(),M.fillStyle=a,M.fillRect(0,0,y,w),M.restore()),l&&(Math.round(y*s)!==p||Math.round(w*s)!==m)){let F=document.createElement("canvas");F.width=p,F.height=m,F.getContext("2d").drawImage(f,0,0),M.drawImage(F,0,0,y,w)}else M.drawImage(f,0,0,y,w);return A}var At,Sn,_e,qt=st(()=>{"use strict";Ct();At=16384,Sn=16384*16384;_e=null});var Ue={};Gt(Ue,{rasterize:()=>vn});async function vn(t,e){let n=await Pt(t,e),o=await new Promise(s=>{let i=()=>s(n.toDataURL(`image/${e.format}`,e.quality));try{n.toBlob(a=>{if(!a)return i();let c=new FileReader;c.onload=()=>s(String(c.result||"")),c.onerror=i,c.readAsDataURL(a)},`image/${e.format}`,e.quality)}catch{i()}}),r=new Image;return r.src=o,await r.decode(),r.style.width=`${n.width/e.dpr}px`,r.style.height=`${n.height/e.dpr}px`,r}var ae=st(()=>{"use strict";qt()});var Cn={};Gt(Cn,{toImg:()=>Na,toSvg:()=>Na});async function Na(t,e){let{scale:n=1,width:o,height:r,meta:s={}}=e,i=Number.isFinite(o),a=Number.isFinite(r),c=Number.isFinite(n)&&n!==1||i||a;if(K()&&c)try{let{svg:l}=await Be(We(t)),d=(l.match(/<svg\\b[^>]*>/i)||[])[0]||"",f=parseFloat((d.match(/\\bwidth="([\\d.]+)/i)||[])[1]),p=parseFloat((d.match(/\\bheight="([\\d.]+)/i)||[])[1]);if(!Number.isFinite(f)||!Number.isFinite(p))throw new Error("svg without dimensions");let m=Number.isFinite(s.vbW)?s.vbW:Number.isFinite(s.w0)?s.w0:f,h=Number.isFinite(s.vbH)?s.vbH:Number.isFinite(s.h0)?s.h0:p,b,y;i&&a?(b=o,y=r):i?(b=o,y=Math.round(h*(o/Math.max(1,m)))):a?(y=r,b=Math.round(m*(r/Math.max(1,h)))):(b=Math.round(f*n),y=Math.round(p*n));let w=l.replace(/width="[^"]*"/,`width="${b}"`).replace(/height="[^"]*"/,`height="${y}"`),S=new Image;return S.decoding="sync",S.loading="eager",S.src=Oe(w),await S.decode(),S.style.width=`${b}px`,S.style.height=`${y}px`,S}catch(l){return _(e,"safari vector toImg failed, falling back to PNG",l),vn(t,{...e,format:"png",quality:1,meta:s})}let u=new Image;if(u.decoding="sync",u.loading="eager",u.src=t,await u.decode(),i&&a)u.style.width=`${o}px`,u.style.height=`${r}px`;else if(i){let l=Number.isFinite(s.vbW)?s.vbW:Number.isFinite(s.w0)?s.w0:u.naturalWidth,d=Number.isFinite(s.vbH)?s.vbH:Number.isFinite(s.h0)?s.h0:u.naturalHeight,f=o/Math.max(1,l);u.style.width=`${o}px`,u.style.height=`${Math.round(d*f)}px`}else if(a){let l=Number.isFinite(s.vbW)?s.vbW:Number.isFinite(s.w0)?s.w0:u.naturalWidth,d=Number.isFinite(s.vbH)?s.vbH:Number.isFinite(s.h0)?s.h0:u.naturalHeight,f=r/Math.max(1,d);u.style.height=`${r}px`,u.style.width=`${Math.round(l*f)}px`}else{let l=Math.round(u.naturalWidth*n),d=Math.round(u.naturalHeight*n);if(u.style.width=`${l}px`,u.style.height=`${d}px`,typeof t=="string"&&t.startsWith("data:image/svg+xml"))try{let p=decodeURIComponent(t.split(",")[1]).replace(/width="[^"]*"/,`width="${l}"`).replace(/height="[^"]*"/,`height="${d}"`);t=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(p)}`,u.src=t}catch(f){_(e,"SVG width/height patch in toImg failed",f)}}return u}var An=st(()=>{"use strict";at();ae();qt()});var Ir={};Gt(Ir,{toBlob:()=>kn});async function kn(t,e){let n=e.type;if(n==="svg"){let r=decodeURIComponent(t.split(",")[1]);return new Blob([r],{type:"image/svg+xml"})}let o=await Pt(t,e);return new Promise(r=>o.toBlob(s=>r(s),`image/${n}`,e.quality))}var Mn=st(()=>{"use strict";qt()});var Wr={};Gt(Wr,{download:()=>La});async function _r(t,e){let n=new File([t],e,{type:t.type});if(!navigator.canShare?.({files:[n]}))return!1;try{await navigator.share({files:[n],title:e})}catch(o){if(o.name!=="AbortError")return!1}return!0}async function La(t,e){let n=new Set(["png","jpeg","jpg","webp","svg"]),o=(e?.type||"").toLowerCase(),r=n.has(o)?o:"",s=(e?.format||r||"").toLowerCase(),i=s==="jpg"?"jpeg":s||"png",a=e?.filename||`snapdom.${i}`,c={...e||{},format:i,type:i};c.dpr=1;let u=Ye();if(i==="svg"){let f=await kn(t,{...c,type:"svg"});if(u&&await _r(f,a))return;let p=URL.createObjectURL(f),m=document.createElement("a");m.href=p,m.download=a,document.body.appendChild(m),m.click(),URL.revokeObjectURL(p),m.remove();return}let l=await Pt(t,c);if(u){let f=`image/${i}`,p=await new Promise(m=>l.toBlob(m,f,e?.quality));if(p&&await _r(p,a))return}let d=document.createElement("a");d.href=l.toDataURL(`image/${i}`,e?.quality),d.download=a,document.body.appendChild(d),d.click(),d.remove()}var Or=st(()=>{"use strict";Mn();qt();Ct()});at();at();rt();var Ze=new WeakMap,Jt=new Map,gi=2e3,Se=0;function xe(){Se++,Jt.size>gi&&Jt.clear()}var yi="[data-snapdom-sandbox],[data-snapdom-internal],[data-snapdom]";function Qe(t){let e=t&&(t.nodeType===1?t:t.parentElement);return!!(e&&e.closest&&e.closest(yi))}function Je(t){for(let e of t)if(!Qe(e.target)){if(e.type==="childList"){let n=!0;for(let o of e.addedNodes)if(!Qe(o)){n=!1;break}if(n){for(let o of e.removedNodes)if(!Qe(o)){n=!1;break}}if(n)continue}return!0}return!1}var zn=!1;function bi(t=document.documentElement){if(zn)return;zn=!0;let e=n=>{Je(n)&&xe()};try{new MutationObserver(e).observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{new MutationObserver(e).observe(document.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0})}catch{}try{let n=document.fonts;n&&(n.addEventListener?.("loadingdone",xe),n.ready?.then(()=>xe()).catch(()=>{}))}catch{}}var wi=["mask","mask-image","-webkit-mask","-webkit-mask-image","mask-source","mask-box-image-source","mask-border-source","-webkit-mask-box-image-source","border-image","border-image-source"];function tn(t){let e=Ze.get(t);if(e&&e.epoch===Se){let n=e.snapshot&&e.snapshot.__needsBgInline;if(n!==void 0)return n}return!0}function xi(t,e={}){let n={},o=e.excludeStyleProps;for(let d=0;d<t.length;d++){let f=t[d];if(Qt(f)||o&&(o instanceof RegExp&&o.test(f)||typeof o=="function"&&o(f)))continue;let p=t.getPropertyValue(f);(f==="background-image"||f==="content")&&p.includes("url(")&&!p.includes("data:")&&(p="none"),n[f]=p}let r=["text-decoration-line","text-decoration-color","text-decoration-style","text-decoration-thickness","text-underline-offset","text-decoration-skip-ink"];for(let d of r)if(!n[d])try{let f=t.getPropertyValue(d);f&&(n[d]=f)}catch{}let s=["-webkit-text-stroke","-webkit-text-stroke-width","-webkit-text-stroke-color","paint-order"];for(let d of s)if(!n[d])try{let f=t.getPropertyValue(d);f&&(n[d]=f)}catch{}if(e.embedFonts){let d=["font-feature-settings","font-variation-settings","font-kerning","font-variant","font-variant-ligatures","font-optical-sizing"];for(let f of d)if(!n[f])try{let p=t.getPropertyValue(f);p&&(n[f]=p)}catch{}}try{(n["content-visibility"]||t.getPropertyValue("content-visibility"))==="hidden"&&(n["content-visibility"]="hidden")}catch{}let i=!1;{let d=t.getPropertyValue("background-image");if(d&&d!=="none"&&(i=!0),!i){let f=t.getPropertyValue("background-color");f&&f!=="rgba(0, 0, 0, 0)"&&f!=="transparent"&&(i=!0)}if(!i)for(let f of wi){let p=t.getPropertyValue(f);if(p&&p!=="none"){i=!0;break}}if(!i){let f=t.getPropertyValue("background");f&&/url\\s*\\(/i.test(f)&&(i=!0)}}Object.defineProperty(n,"__needsBgInline",{value:i,enumerable:!1});let a=parseFloat(t.getPropertyValue("border-top-width")||0)||0,c=parseFloat(t.getPropertyValue("border-right-width")||0)||0,u=parseFloat(t.getPropertyValue("border-bottom-width")||0)||0,l=parseFloat(t.getPropertyValue("border-left-width")||0)||0;if(a===0&&c===0&&u===0&&l===0){let d=(t.getPropertyValue("border-image-source")||"").trim(),f=d&&d!=="none",p=["border","border-top","border-right","border-bottom","border-left","border-width","border-style","border-color","border-top-width","border-top-style","border-top-color","border-right-width","border-right-style","border-right-color","border-bottom-width","border-bottom-style","border-bottom-color","border-left-width","border-left-style","border-left-color","border-block","border-block-width","border-block-style","border-block-color","border-inline","border-inline-width","border-inline-style","border-inline-color"];for(let m of p)delete n[m];f||(n.border="none")}return n}function Si(t){for(let e=t.firstChild;e;e=e.nextSibling){if(e.nodeType===3&&/\\S/.test(e.nodeValue||""))return!0;if(e.nodeType===1){let n=N(e).position;if(n!=="absolute"&&n!=="fixed")return!0}}return!1}function vi(t,e,n){try{if(typeof t.computedStyleMap=="function"){let r=t.computedStyleMap().get("width");if(r!=null)return!Vn(String(r).trim().toLowerCase())}}catch{}let o=t.style&&(t.style.width||t.style.inlineSize);return o&&!Vn(String(o).trim().toLowerCase())?!0:Ai(t,e)?n||ki(t,e):!1}var Ci=new Set(["auto","min-content","max-content","stretch","fill-available","-webkit-fill-available"]);function Vn(t){return Ci.has(t)||t.startsWith("fit-content")}function Ai(t,e){let n=t.getBoundingClientRect().width-(parseFloat(e.paddingLeft)||0)-(parseFloat(e.paddingRight)||0)-(parseFloat(e.borderLeftWidth)||0)-(parseFloat(e.borderRightWidth)||0);if(!(n>0))return!1;let o=1/0,r=-1/0,s=null;for(let i=t.firstChild;i;i=i.nextSibling){let a;if(i.nodeType===3){if(!/\\S/.test(i.nodeValue||"")||(s=s||document.createRange(),s.selectNode(i),a=s.getBoundingClientRect(),!a.width&&!a.height))continue}else if(i.nodeType===1){let c=N(i);if(c.display==="none"||c.position==="absolute"||c.position==="fixed")continue;a=i.getBoundingClientRect()}else continue;a.left<o&&(o=a.left),a.right>r&&(r=a.right)}return r===-1/0?!1:r-o<n-.5}function ki(t,e){let n=t.parentElement;if(!n)return!1;let o=N(n),r=n.getBoundingClientRect().width-(parseFloat(o.paddingLeft)||0)-(parseFloat(o.paddingRight)||0)-(parseFloat(o.borderLeftWidth)||0)-(parseFloat(o.borderRightWidth)||0)-(parseFloat(e.marginLeft)||0)-(parseFloat(e.marginRight)||0);return r>0?Math.abs(t.getBoundingClientRect().width-r)>.5:!1}var jn=new WeakMap;function Mi(t){let e=jn.get(t);return e||(e=Object.entries(t).sort((o,r)=>o[0]<r[0]?-1:o[0]>r[0]?1:0).map(([o,r])=>`${o}:${r}`).join(";"),jn.set(t,e),e)}function Fi(t,e=null,n={}){let o=Ze.get(t),r=!!(n&&n.embedFonts),s=n&&n.excludeStyleProps||null;if(o&&o.epoch===Se&&o.embedFonts===r&&o.excludeStyleProps===s)return o.snapshot;let i=e||getComputedStyle(t),a=xi(i,n);return Ni(t,i,a),Ze.set(t,{epoch:Se,snapshot:a,embedFonts:r,excludeStyleProps:s}),a}function Ei(t,e){return t&&t.session&&t.persist?t:t&&(t.styleMap||t.styleCache||t.nodeMap)?{session:t,persist:{snapshotKeyCache:Jt,defaultStyle:C.defaultStyle,baseStyle:C.baseStyle,image:C.image,resource:C.resource,background:C.background,font:C.font},options:e||{}}:{session:C.session,persist:{snapshotKeyCache:Jt,defaultStyle:C.defaultStyle,baseStyle:C.baseStyle,image:C.image,resource:C.resource,background:C.background,font:C.font},options:t||e||{}}}function Ri(t,e,n){if(!(!t.style||t.style.length===0))for(let o=0;o<t.style.length;o++){let r=t.style[o],s=n.getPropertyValue(r);s&&e.style.setProperty(r,s)}}async function ct(t,e,n,o){if(t.tagName==="STYLE")return;let r=Ei(n,o),s=r.options&&r.options.cache||"auto";s!=="disabled"&&bi(document.documentElement),s==="disabled"&&!r.session.__bumpedForDisabled&&(xe(),Jt.clear(),r.session.__bumpedForDisabled=!0);let{session:i,persist:a}=r;if(!i.styleCache.has(t)){let b=null;try{b=getComputedStyle(t)}catch{}i.styleCache.set(t,b||getComputedStyle(document.documentElement))}let c=i.styleCache.get(t);t.getAttribute?.("style")&&Ri(t,e,c);let u=c.getPropertyValue("animation-name");e&&e.style&&u&&u!=="none"&&e.style.setProperty("animation","none","important");let l=Fi(t,c,r.options),d=qn(t);if(d){let b=c.getPropertyValue("min-width");(!b||b==="auto"||b==="0px")&&(l["min-width"]="0px")}let f=t.tagName?.toLowerCase()||"div",p=Mi(l),m=!0;if(be(f,(l.display||"").toLowerCase())){m=Si(t),m&&je(f,l,d)&&vi(t,c,d)&&(m=!1),p=`${p}|${f}${m?"|c":""}${d?"|f":""}`;let b=l["text-wrap-mode"]||l["white-space"]||"";m&&b!=="nowrap"&&b!=="pre"&&(i.reconcileRisk=(i.reconcileRisk||0)+1)}let h=a.snapshotKeyCache.get(p);h===void 0&&(h=Wt(l,f,m,d),a.snapshotKeyCache.set(p,h)),i.styleMap.set(e,h)}function $i(t){return t.backgroundImage&&t.backgroundImage!=="none"||t.backgroundColor&&t.backgroundColor!=="rgba(0, 0, 0, 0)"&&t.backgroundColor!=="transparent"||(parseFloat(t.borderTopWidth)||0)>0||(parseFloat(t.borderBottomWidth)||0)>0||(parseFloat(t.paddingTop)||0)>0||(parseFloat(t.paddingBottom)||0)>0?!0:(t.overflowBlock||t.overflowY||"visible")!=="visible"}function qn(t){let e=t.parentElement;if(!e)return!1;let n=N(e).display||"";return n.includes("flex")||n.includes("grid")}function Ti(t){for(let o=t.firstChild;o;o=o.nextSibling)if(o.nodeType===3&&/\\S/.test(o.nodeValue))return!0;let e=t.firstElementChild,n=t.lastElementChild;if(e&&e.tagName==="BR"||n&&n.tagName==="BR")return!0;for(let o=t.firstElementChild;o;o=o.nextElementSibling){let r=N(o);if(r.display==="none")continue;let s=r.position;if(s!=="absolute"&&s!=="fixed")return!0}return!1}function Pi(t){let e=t.getBoundingClientRect().top,n=-1/0,o=null;for(let r=t.firstChild;r;r=r.nextSibling){if(r.nodeType===3){if(!/\\S/.test(r.nodeValue||""))continue;o=o||document.createRange(),o.selectNode(r);let a=o.getBoundingClientRect();(a.width||a.height)&&(n=Math.max(n,a.bottom));continue}if(r.nodeType!==1)continue;let s=N(r);if(s.display==="none")continue;let i=s.position;i==="absolute"||i==="fixed"||s.float&&s.float!=="none"||(n=Math.max(n,r.getBoundingClientRect().bottom))}return n===-1/0?NaN:n-e}function Ni(t,e,n){if(t instanceof HTMLElement&&t.style&&t.style.height)return;let o=t.tagName&&t.tagName.toLowerCase();if(!o||!["div","section","article","main","aside","header","footer","nav"].includes(o)||e.aspectRatio&&e.aspectRatio!=="none"&&e.aspectRatio!=="auto")return;let s=e.display||"";if(s.includes("flex")||s.includes("grid"))return;let i=e.position;if(i==="absolute"||i==="fixed"||i==="sticky"||e.transform!=="none"||$i(e)||qn(t))return;let a=e.overflowX||e.overflow||"visible",c=e.overflowY||e.overflow||"visible";if(a!=="visible"||c!=="visible")return;let u=e.clip;if(u&&u!=="auto"&&u!=="rect(auto, auto, auto, auto)"||e.visibility==="hidden"||e.opacity==="0"||!Ti(t))return;let l=parseFloat(e.height),d=Pi(t);Number.isFinite(l)&&Number.isFinite(d)&&Math.abs(l-d)>2||(delete n.height,delete n["block-size"])}Zt();var Gn=["fill","stroke","color","background-color","stop-color"],Li=new Set(["symbol","defs","pattern","marker","linearGradient","radialGradient","filter"]);function ve(t){let e=t;for(;e&&e.nodeType===1;){if(e.namespaceURI==="http://www.w3.org/2000/svg"){if(e.localName==="mask"||e.localName==="clipPath")return!1;if(Li.has(e.localName))return!0}e=e.parentNode}return!1}var Xn=new Map;function Ii(t,e){let n=e+"::"+t.toLowerCase(),o=Xn.get(n);if(o)return o;let r=document,s=e==="http://www.w3.org/2000/svg"?r.createElementNS(e,t):r.createElement(t),i=r.createElement("div");i.setAttribute("data-snapdom-internal",""),i.style.cssText="position:absolute;left:-99999px;top:-99999px;contain:strict;display:block;",i.appendChild(s),r.documentElement.appendChild(i);let a=getComputedStyle(s),c={};for(let u of Gn)c[u]=a.getPropertyValue(u)||"";return i.remove(),Xn.set(n,c),c}function Yn(t,e){if(t?.nodeType!==1||e?.nodeType!==1||ve(t))return;let n=t.getAttribute?.("style"),o=!!(n&&n.includes("var("));if(!o&&t.attributes?.length){let s=t.attributes;for(let i=0;i<s.length;i++){let a=s[i];if(a&&typeof a.value=="string"&&a.value.includes("var(")){o=!0;break}}}let r=null;if(o)try{r=getComputedStyle(t)}catch{}if(o){let s=t.style;if(s&&s.length){let i=new Set;for(let a=0;a<s.length;a++){let c=s[a];if(i.has(c))continue;i.add(c);let u=s.getPropertyValue(c);if(!u||!u.includes("var("))continue;let l=r&&r.getPropertyValue(c);if(l)try{e.style.setProperty(c,l.trim(),s.getPropertyPriority(c))}catch{}}}}if(o&&t.attributes?.length){let s=t.attributes;for(let i=0;i<s.length;i++){let a=s[i];if(!a||typeof a.value!="string"||!a.value.includes("var("))continue;let c=a.name,u=r&&r.getPropertyValue(c);if(u)try{e.style.setProperty(c,u.trim())}catch{}}}if(!o){if(!r)try{r=getComputedStyle(t)}catch{r=null}if(!r)return;let s=t.namespaceURI||"html",i=Ii(t.tagName,s);for(let a of Gn){let c=r.getPropertyValue(a)||"",u=i[a]||"";if(c&&c!==u)try{e.style.setProperty(a,c.trim())}catch{}}}}at();at();rt();vt();vt();function Tt(t){return!!(!t||t.startsWith("data:")||t.startsWith("blob:")||/^data:image\\/(gif|png|svg)/.test(t)&&t.length<200)}var Kn="img[data-src], img[data-lazy-src], img[data-original], img[data-hi-res-src], img[data-srcset], img[data-lazy-srcset]";function _i(t,e){return!t||t?.nodeType!==1?!1:t.matches?.("picture")||t.querySelector("picture")?!0:e?!!(t.matches?.(Kn)||t.querySelector(Kn)):!1}var Wi=/^image\\/(jpeg|jpg|png|gif|webp|avif|apng|svg\\+xml|bmp|x-icon|vnd\\.microsoft\\.icon)\\s*(;|$)/i;function Bt(t,e){if(!t)return null;let n=0;try{n=e?e.getBoundingClientRect().width||e.width:0}catch{}n||(n=window.innerWidth||1e3);let o=[];for(let s of t.split(",")){let i=s.trim().split(/\\s+/);if(!i[0])continue;let a=i[1]||"",c=1;/^\\d*\\.?\\d+x$/i.test(a)?c=parseFloat(a):/^\\d+w$/i.test(a)&&(c=parseInt(a,10)/n),o.push({url:i[0],d:c})}if(!o.length)return null;o.sort((s,i)=>s.d-i.d);let r=window.devicePixelRatio||1;return(o.find(s=>s.d>=r)||o[o.length-1]).url}function en(t,e){let n=t.currentSrc||"";if(n&&!Tt(n))return n;let o=e.querySelectorAll("source[srcset]"),r=null;for(let s of o){let i=s.getAttribute("srcset");if(!i||Tt(i))continue;let a=s.getAttribute("type");if(a&&!Wi.test(a.trim()))continue;let c=s.getAttribute("media");if(c)try{if(window.matchMedia(c).matches)return Bt(i,t)}catch{}r||(r=Bt(i,t))}return r}function Oi(t){let e=[t.getAttribute("data-src"),t.getAttribute("data-lazy-src"),t.getAttribute("data-original"),t.getAttribute("data-hi-res-src")];for(let o of e)if(o&&!Tt(o))return o;let n=t.getAttribute("data-srcset")||t.getAttribute("data-lazy-srcset");if(n){let o=n.split(",")[0].trim().split(/\\s+/)[0];if(o&&!Tt(o))return o}return null}function Bi(t={}){let e=t.pictureResolver&&typeof t.pictureResolver=="object"?t.pictureResolver:{};return{timeout:e.timeout??5e3,concurrency:e.concurrency??4,resolveLazySrc:e.resolveLazySrc!==!1,silent:e.silent??!1,useProxy:typeof t.useProxy=="string"?t.useProxy:""}}async function Qn(t,e={}){if(!t||t?.nodeType!==1||e.resolvePicturePlaceholders===!1)return null;let{timeout:n,concurrency:o,resolveLazySrc:r,silent:s,useProxy:i}=Bi(e);if(!_i(t,r))return null;let a=[],c=[];async function u(f){let p=await G(f,{as:"dataURL",timeout:n,useProxy:i,silent:!0});return p.ok?p.data:null}async function l(f){for(let p=0;p<f.length;p+=o){let m=f.slice(p,p+o);await Promise.allSettled(m.map(h=>h()))}}let d=Array.from(t.querySelectorAll("picture"));t.matches?.("picture")&&d.unshift(t);for(let f of d){let p=f.querySelector("img");if(!p)continue;let m=p.getAttribute("src")||"";if(!Tt(m))continue;let h=en(p,f);h&&c.push(async()=>{let b=await u(h);if(!b){s||console.warn(`[snapdom:picture-resolver] Failed to fetch: ${h.slice(0,60)}`);return}let y=p.getAttribute("src"),w=p.getAttribute("srcset"),S=p.getAttribute("sizes"),g=[];p.src=b,p.setAttribute("src",b),p.removeAttribute("srcset"),p.removeAttribute("sizes");let x=f.querySelectorAll("source");for(let v of x)g.push({el:v,parent:v.parentElement,next:v.nextSibling}),v.remove();a.push(()=>{y!==null?p.setAttribute("src",y):p.removeAttribute("src"),w!==null&&p.setAttribute("srcset",w),S!==null&&p.setAttribute("sizes",S);for(let{el:v,parent:k,next:A}of g)k&&k.insertBefore(v,A)})})}if(r){let f=Array.from(t.querySelectorAll("img"));t.localName==="img"&&f.unshift(t);for(let p of f){if(p.closest("picture")&&Tt(p.getAttribute("src")||""))continue;let m=p.getAttribute("src")||"",h=Oi(p);h&&Tt(m)&&c.push(async()=>{let b=await u(h);if(!b)return;let y=p.getAttribute("src");p.src=b,p.setAttribute("src",b),p.removeAttribute("srcset"),p.removeAttribute("sizes"),a.push(()=>{y!==null?p.setAttribute("src",y):p.removeAttribute("src")})})}}return c.length===0?null:(await l(c),async function(){for(let p of a)try{p()}catch{}})}function ke(t,e,n){return n?Promise.all(t.map(o=>new Promise(r=>e(o,r)))):Promise.all(t.map(o=>new Promise(r=>{function s(){$t(i=>{(i&&typeof i.timeRemaining=="function"?i.timeRemaining()>0:!0)?e(o,r):s()},{fast:n})}s()})))}function Ui(t,e){if(t=t.trim(),!t)return t;let n=e?`[data-sd-slotted~="${e}"]`:"[data-sd-slotted]";return t.endsWith(":not([data-sd-slotted])")||t.endsWith(`:not(${n})`)?t:`${t}:not(${n})`}function Di(t,e,n=!0,o){return t.split(",").map(r=>r.trim()).filter(Boolean).map(r=>{if(r.startsWith(":where(")||r.startsWith("@"))return r;let s=n?Ui(r,o):r;return`:where(${e} ${s})`}).join(", ")}function Jn(t,e,n){return t?(t=t.replace(/:host\\(([^)]+)\\)/g,(o,r)=>`:where(${e}:is(${r.trim()}))`),t=t.replace(/:host\\b/g,`:where(${e})`),t=t.replace(/:host-context\\(([^)]+)\\)/g,(o,r)=>`:where(:where(${r.trim()}) ${e})`),t=t.replace(/::slotted\\(([^)]+)\\)/g,(o,r)=>`:where(${e} ${r.trim()})`),t=t.replace(/(^|})(\\s*)([^@}{]+){/g,(o,r,s,i)=>{let a=Di(i,e,!0,n);return`${r}${s}${a}{`}),t):""}function to(t){return t.shadowScopeSeq=(t.shadowScopeSeq||0)+1,`s${t.shadowScopeSeq}`}function eo(t){let e="";try{t.querySelectorAll("style").forEach(o=>{e+=(o.textContent||"")+`\n`});let n=t.adoptedStyleSheets||[];for(let o of n)try{if(o&&o.cssRules)for(let r of o.cssRules)e+=r.cssText+`\n`}catch{}}catch{}return e}function no(t,e,n){if(!e)return;let o=document.createElement("style");o.setAttribute("data-sd",n),o.textContent=e,t.insertBefore(o,t.firstChild||null)}function oo(t,e){try{let n=null,o=N(t).content;if(o&&o.includes("url(")){let i=o.match(/url\\(["\']?([^"\')]+)["\']?\\)/);i&&(n=i[1])}let r=t.closest?.("picture"),s=n||(r?en(t,r):t.currentSrc)||t.src||Bt(t.getAttribute("srcset"),t)||"";if(!s)return;e.setAttribute("src",s),e.removeAttribute("srcset"),e.removeAttribute("sizes"),e.loading="eager",e.decoding="sync"}catch{}}function ro(t){let e=new Set;if(!t)return e;let n=/var\\(\\s*(--[A-Za-z0-9_-]+)\\b/g,o;for(;o=n.exec(t);)e.add(o[1]);return e}function Hi(t,e){try{let o=getComputedStyle(t).getPropertyValue(e).trim();if(o)return o}catch{}try{let o=getComputedStyle(document.documentElement).getPropertyValue(e).trim();if(o)return o}catch{}return""}function io(t,e,n){let o=[];for(let r of e){let s=Hi(t,r);s&&o.push(`${r}: ${s};`)}return o.length?`${n}{${o.join("")}}\n`:""}function so(t,e){if(!t)return;let n=o=>{let r=o.getAttribute("data-sd-slotted")||"";e?` ${r} `.includes(` ${e} `)||o.setAttribute("data-sd-slotted",r?`${r} ${e}`:e):o.setAttribute("data-sd-slotted",r)};t.nodeType===Node.ELEMENT_NODE&&n(t),t.querySelectorAll?.("*").forEach(n)}async function zi(t,e=3){let n=()=>{try{return t.contentDocument||t.contentWindow?.document||null}catch{return null}},o=n(),r=0;for(;r<e&&(!o||!o.body&&!o.documentElement);)await new Promise(s=>setTimeout(s,0)),o=n(),r++;return o&&(o.body||o.documentElement)?o:null}function Vi(t){let e=t.getBoundingClientRect(),n=0,o=0,r=0,s=0;try{let c=getComputedStyle(t);n=parseFloat(c.borderLeftWidth)||0,o=parseFloat(c.borderRightWidth)||0,r=parseFloat(c.borderTopWidth)||0,s=parseFloat(c.borderBottomWidth)||0}catch{}let i=Math.max(0,Math.round(e.width-(n+o))),a=Math.max(0,Math.round(e.height-(r+s)));return{contentWidth:i,contentHeight:a,rect:e}}function ut(t){let e=0,n=0;if(t.offsetWidth>0&&(e=t.offsetWidth),t.offsetHeight>0&&(n=t.offsetHeight),e===0||n===0)try{let o=getComputedStyle(t);if(e===0){let r=parseFloat(o.width);!isNaN(r)&&r>0&&(e=r)}if(n===0){let r=parseFloat(o.height);!isNaN(r)&&r>0&&(n=r)}}catch{}if(e===0||n===0)try{if(e===0){let o=parseFloat(t.getAttribute("width"));!isNaN(o)&&o>0&&(e=o)}if(n===0){let o=parseFloat(t.getAttribute("height"));!isNaN(o)&&o>0&&(n=o)}}catch{}if((e===0||n===0)&&(t.naturalWidth||t.naturalHeight))try{e===0&&t.naturalWidth>0&&(e=t.naturalWidth),n===0&&t.naturalHeight>0&&(n=t.naturalHeight)}catch{}return{width:e,height:n}}function ji(t,e,n){let o=t.defaultView,r=o?o.scrollX:0,s=o?o.scrollY:0,i=t.body?t.body.scrollLeft:0,a=t.body?t.body.scrollTop:0,c=t.documentElement?t.documentElement.scrollLeft:0,u=t.documentElement?t.documentElement.scrollTop:0,l=0,d=0,f=0,p=0;try{let h=o&&t.body?o.getComputedStyle(t.body):null;h&&(l=(parseFloat(h.marginTop)||0)+(parseFloat(h.paddingTop)||0),d=(parseFloat(h.marginRight)||0)+(parseFloat(h.paddingRight)||0),f=(parseFloat(h.marginBottom)||0)+(parseFloat(h.paddingBottom)||0),p=(parseFloat(h.marginLeft)||0)+(parseFloat(h.paddingLeft)||0))}catch{}try{t.documentElement.setAttribute("data-sd-pinned","")}catch{}let m=t.createElement("style");return m.setAttribute("data-sd-iframe-pin",""),m.textContent=`html {margin: 0 !important;padding: 0 !important;width: ${e}px !important;height: ${n}px !important;min-width: ${e}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}body {margin: 0 !important;padding: ${l}px ${d}px ${f}px ${p}px !important;width: ${e}px !important;height: ${n}px !important;min-width: ${e}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,(t.head||t.documentElement).appendChild(m),()=>{try{m.remove()}catch{}try{t.documentElement.removeAttribute("data-sd-pinned")}catch{}try{o&&typeof o.scrollTo=="function"&&o.scrollTo(r,s),t.body&&(t.body.scrollLeft=i,t.body.scrollTop=a),t.documentElement&&(t.documentElement.scrollLeft=c,t.documentElement.scrollTop=u)}catch{}}}async function ao(t,e,n){let o=await zi(t,3);if(!o)throw new Error("iframe document not accessible/ready");let{contentWidth:r,contentHeight:s,rect:i}=Vi(t),a=n?.snap;if(!a&&typeof window<"u"&&window.snapdom&&(a=window.snapdom),!a||typeof a.toPng!="function")throw new Error("[snapdom] iframe capture requires snapdom.toPng. Use snapdom(el) or pass options.snap. With ESM, assign window.snapdom = snapdom after import if using iframes.");let c={...n,scale:1,clip:null},u=ji(o,r,s),l=C.session.nodeMap,d=C.session.styleMap,f=C.session.styleCache,p;try{p=await a.toPng(o.documentElement,c)}finally{u(),C.session.nodeMap=l,C.session.styleMap=d,C.session.styleCache=f}p.style.display="block",p.style.width=`${r}px`,p.style.height=`${s}px`;let m=document.createElement("div");return e.nodeMap.set(m,t),ct(t,m,e,n),m.style.overflow="hidden",m.style.display="block",m.style.width||(m.style.width=`${Math.round(i.width)}px`),m.style.height||(m.style.height=`${Math.round(i.height)}px`),m.appendChild(p),m}function co(t){let{width:e,height:n}=ut(t),o=t.getBoundingClientRect(),r;try{r=window.getComputedStyle(t)}catch{}let s=r?parseFloat(r.width):NaN,i=r?parseFloat(r.height):NaN,a=Math.round(e||o.width||0),c=Math.round(n||o.height||0),u=Number.isFinite(s)&&s>0?Math.round(s):Math.max(12,a||16),l=Number.isFinite(i)&&i>0?Math.round(i):Math.max(12,c||16),d=(t.type||"text").toLowerCase()==="checkbox",f=!!t.checked,p=!!t.indeterminate,h=Math.max(Math.min(u,l),12),b="middle";try{r&&r.verticalAlign&&(b=r.verticalAlign)}catch{}let y=document.createElement("div");y.setAttribute("data-snapdom-input-replacement",t.type||"checkbox"),y.style.cssText=`display:inline-block;width:${h}px;height:${h}px;vertical-align:${b};flex-shrink:0;line-height:0;`;let w=document.createElementNS("http://www.w3.org/2000/svg","svg");w.setAttribute("width",String(h)),w.setAttribute("height",String(h)),w.setAttribute("viewBox",`0 0 ${h} ${h}`),y.appendChild(w);function S(){let g="#0a6ed1";try{r&&(g=r.accentColor||r.color||g)}catch{}let x=2,v=x/2,k=h-x;if(w.innerHTML="",d){let A=document.createElementNS("http://www.w3.org/2000/svg","rect");if(A.setAttribute("x",String(v)),A.setAttribute("y",String(v)),A.setAttribute("width",String(k)),A.setAttribute("height",String(k)),A.setAttribute("rx","2"),A.setAttribute("ry","2"),A.setAttribute("fill",f?g:"none"),A.setAttribute("stroke",g),A.setAttribute("stroke-width",String(x)),w.appendChild(A),f){let M=document.createElementNS("http://www.w3.org/2000/svg","path");M.setAttribute("d",`M ${v+2} ${h/2} L ${h/2-1} ${h-v-2} L ${h-v-2} ${v+2}`),M.setAttribute("stroke","white"),M.setAttribute("stroke-width",String(Math.max(1.5,x))),M.setAttribute("fill","none"),M.setAttribute("stroke-linecap","round"),M.setAttribute("stroke-linejoin","round"),w.appendChild(M)}else if(p){let M=document.createElementNS("http://www.w3.org/2000/svg","rect"),F=Math.max(6,k-4);M.setAttribute("x",String((h-F)/2)),M.setAttribute("y",String((h-x)/2)),M.setAttribute("width",String(F)),M.setAttribute("height",String(x)),M.setAttribute("fill",g),M.setAttribute("rx","1"),w.appendChild(M)}}else{let A=document.createElementNS("http://www.w3.org/2000/svg","circle");if(A.setAttribute("cx",String(h/2)),A.setAttribute("cy",String(h/2)),A.setAttribute("r",String((h-x)/2)),A.setAttribute("fill",f?g:"none"),A.setAttribute("stroke",g),A.setAttribute("stroke-width",String(x)),w.appendChild(A),f){let M=document.createElementNS("http://www.w3.org/2000/svg","circle"),F=Math.max(2,(h-x*2)*.35);M.setAttribute("cx",String(h/2)),M.setAttribute("cy",String(h/2)),M.setAttribute("r",String(F)),M.setAttribute("fill","white"),w.appendChild(M)}}y.style.setProperty("width",`${h}px`,"important"),y.style.setProperty("height",`${h}px`,"important"),y.style.setProperty("min-width",`${h}px`,"important"),y.style.setProperty("min-height",`${h}px`,"important")}return S(),{el:y,applyVisual:S}}var te=new Y(80);async function ee(t){if(C.resource?.has(t))return C.resource.get(t);if(te.has(t))return te.get(t);let e=(async()=>{let n=await G(t,{as:"dataURL",silent:!0});if(!n.ok||typeof n.data!="string")throw new Error(`[snapDOM] Failed to read blob URL: ${t}`);return C.resource?.set(t,n.data),n.data})();te.set(t,e);try{let n=await e;return te.set(t,n),n}catch(n){throw te.delete(t),n}}var qi=/\\bblob:[^)"\'\\s]+/g;async function Zn(t){if(!t||t.indexOf("blob:")===-1)return t;let e=Array.from(new Set(t.match(qi)||[]));if(e.length===0)return t;let n=t;for(let o of e)try{let r=await ee(o);n=n.split(o).join(r)}catch{}return n}function Ce(t){return typeof t=="string"&&t.startsWith("blob:")}function Xi(t){return(t||"").split(",").map(e=>e.trim()).filter(Boolean).map(e=>{let n=e.match(/^(\\S+)(\\s+.+)?$/);return n?{url:n[1],desc:n[2]||""}:null}).filter(Boolean)}function Gi(t){return t.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(", ")}function Ae(t,e){let n=t.querySelectorAll?Array.from(t.querySelectorAll(e)):[];return t.matches?.(e)&&n.unshift(t),n}async function lo(t,e=null){if(!t)return;let n=e,o=Ae(t,"img");for(let c of o)try{let l=c.getAttribute("src")||c.currentSrc||"";if(Ce(l)){let f=await ee(l);c.setAttribute("src",f)}let d=c.getAttribute("srcset");if(d&&d.includes("blob:")){let f=Xi(d),p=!1;for(let m of f)if(Ce(m.url))try{m.url=await ee(m.url),p=!0}catch(h){_(n,"blobUrlToDataUrl for srcset item failed",h)}p&&c.setAttribute("srcset",Gi(f))}}catch(u){_(n,"resolveBlobUrls for img failed",u)}let r=Ae(t,"image");for(let c of r)try{let u="http://www.w3.org/1999/xlink",l=c.getAttribute("href")||c.getAttributeNS?.(u,"href");if(Ce(l)){let d=await ee(l);c.setAttribute("href",d),c.removeAttributeNS?.(u,"href")}}catch(u){_(n,"resolveBlobUrls for SVG image href failed",u)}let s=Ae(t,"[style*=\'blob:\']");for(let c of s)try{let u=c.getAttribute("style");if(u&&u.includes("blob:")){let l=await Zn(u);c.setAttribute("style",l)}}catch(u){_(n,"replaceBlobUrls in inline style failed",u)}let i=t.querySelectorAll?t.querySelectorAll("style"):[];for(let c of i)try{let u=c.textContent||"";u.includes("blob:")&&(c.textContent=await Zn(u))}catch(u){_(n,"replaceBlobUrls in style tag failed",u)}let a=["poster"];for(let c of a){let u=Ae(t,`[${c}^=\'blob:\']`);for(let l of u)try{let d=l.getAttribute(c);Ce(d)&&l.setAttribute(c,await ee(d))}catch(d){_(n,`resolveBlobUrls for ${c} failed`,d)}}}Ct();var on=new Map,fo=new Set(["IFRAME"]);function Fe(t,e){on.set(String(t).toUpperCase(),e)}function nn(t){let{width:e,height:n}=ut(t),o=e,r=n;if(!o||!r){let i=t.getBoundingClientRect();o=o||i.width||0,r=r||i.height||0}let s=document.createElement("div");return s.style.cssText=`display:inline-block;width:${o}px;height:${r}px;visibility:hidden;`,s}var Me=200,Yi=new Set(["img","canvas","video","iframe","object","embed"]);function uo(t,e){return t.right>=e.left-Me&&t.left<=e.right+Me&&t.bottom>=e.top-Me&&t.top<=e.bottom+Me}function Ki(t,e){if(t===e.root)return!1;let n;try{n=t.getBoundingClientRect()}catch{return!1}if(n.width===0&&n.height===0)return!1;let o=N(t);if(o.display==="inline"&&!Yi.has((t.localName||"").toLowerCase()))return!1;let r=e.rect,s=t.scrollWidth||0,i=t.scrollHeight||0,a={left:o.direction==="rtl"?Math.min(n.left,n.right-s):n.left,top:n.top,right:Math.max(n.right,n.left+s),bottom:Math.max(n.bottom,n.top+i)},c=o.writingMode||"";if((c.startsWith("vertical")||c.startsWith("sideways"))&&(a.top=Math.min(n.top,n.bottom-i),a.left=Math.min(a.left,n.right-s)),uo(a,r))return!1;let u=(t.ownerDocument||document).createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;u.nextNode();){let l=u.currentNode.getBoundingClientRect();if((l.width>0||l.height>0)&&uo(l,r))return!1}return!0}function Qi(t,e,n){let o=t.cloneNode(!1);t.tagName==="IMG"&&(o.removeAttribute("src"),o.removeAttribute("srcset"),o.removeAttribute("sizes")),ct(t,o,e,n);let{width:r,height:s}=ut(t);return r>0&&(o.style.width=`${r}px`,o.style.minWidth=`${r}px`,o.style.maxWidth=`${r}px`),s>0&&(o.style.height=`${s}px`,o.style.minHeight=`${s}px`,o.style.maxHeight=`${s}px`),o.style.visibility="hidden",o.style.overflow="hidden",o.style.boxSizing="border-box",o}async function ne(t,e,n){if(!t)throw new Error("Invalid node");let o=new Set,r=null,s=null;if(t.nodeType===Node.ELEMENT_NODE){let l=(t.localName||t.tagName||"").toLowerCase();if(t.id==="snapdom-sandbox"||t.hasAttribute("data-snapdom-sandbox")||me.has(l))return null;if(l==="foreignobject"&&t.parentElement?.closest?.("foreignObject"))return _(e,"Nested <foreignObject> skipped (SVG spec limitation \\u2014 not rendered by browsers)"),null;if(l==="source"&&t.parentElement?.localName==="picture")return null}if(t.nodeType===Node.TEXT_NODE||t.nodeType!==Node.ELEMENT_NODE)return t.cloneNode(!0);if(t.getAttribute("data-capture")==="exclude"){if(n.excludeMode==="hide")return nn(t);if(n.excludeMode==="remove")return null}if(n.exclude&&Array.isArray(n.exclude))for(let l of n.exclude)try{if(t.matches?.(l)){if(n.excludeMode==="hide")return nn(t);if(n.excludeMode==="remove")return null}}catch(d){console.warn(`Invalid selector in exclude option: ${l}`,d)}if(typeof n.filter=="function")try{if(!n.filter(t)){if(n.filterMode==="hide")return nn(t);if(n.filterMode==="remove")return null}}catch(l){console.warn("Error in filter function:",l)}if(e.clip&&Ki(t,e.clip))return Qi(t,e,n);if(n.__resolveNodeHooks)for(let l of n.__resolveNodeHooks){let d;try{d=await l(t,n)}catch(f){_(e,"resolveNode plugin hook failed",f)}if(d===null)return null;if(d instanceof Node)return d.nodeType===Node.ELEMENT_NODE&&(e.nodeMap.set(d,t),ct(t,d,e,n)),d}{let l=fo.has(t.tagName)&&on.get(t.tagName);if(l){let d=await l(t,e,n);if(d!==void 0)return d}}if(t.getAttribute("data-capture")==="placeholder"){let l=t.cloneNode(!1);e.nodeMap.set(l,t),ct(t,l,e,n);let d=document.createElement("div");return d.textContent=t.getAttribute("data-placeholder-text")||"",d.style.cssText="color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;",l.appendChild(d),l}{let l=!fo.has(t.tagName)&&on.get(t.tagName);if(l){let d=await l(t,e,n);if(d!==void 0)return d}}let i;try{if(i=t.cloneNode(!1),i.attributes?.length)try{for(let l of i.attributes)/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\uFFFE\\uFFFF]/.test(l.value)&&i.setAttribute(l.name,l.value.replace(/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\uFFFE\\uFFFF]/g,""))}catch{}if(Yn(t,i),e.nodeMap.set(i,t),t.tagName==="IMG"){oo(t,i);try{let{width:l,height:d}=ut(t),f=Math.round(l||0),p=Math.round(d||0);f&&(i.dataset.snapdomWidth=String(f)),p&&(i.dataset.snapdomHeight=String(p))}catch(l){_(e,"getUnscaledDimensions for IMG failed",l)}try{let l=t.getAttribute("style")||"",d=window.getComputedStyle(t),f=S=>{let g=l.match(new RegExp(`${S}\\\\s*:\\\\s*([^;]+)`,"i")),x=g?g[1].trim():d.getPropertyValue(S);return/%|auto/i.test(String(x||""))},p=parseInt(i.dataset.snapdomWidth||"0",10),m=parseInt(i.dataset.snapdomHeight||"0",10),h=f("width")||!p,b=f("height")||!m;h&&p&&(i.style.width=`${p}px`),b&&m&&(i.style.height=`${m}px`);let y=d.getPropertyValue("object-fit"),w=d.getPropertyValue("object-position");y&&y!=="fill"?(i.style.objectFit=y,w&&(i.style.objectPosition=w)):(p&&(i.style.minWidth=`${p}px`),m&&(i.style.minHeight=`${m}px`))}catch(l){_(e,"IMG dimension freeze failed",l)}}}catch(l){throw console.error("[Snapdom] Failed to clone node:",t,l),l}let a=null;if(t instanceof HTMLTextAreaElement){let{width:l,height:d}=ut(t),f=l||t.getBoundingClientRect().width||0,p=d||t.getBoundingClientRect().height||0;f&&(i.style.width=`${f}px`),p&&(i.style.height=`${p}px`)}if(t instanceof HTMLInputElement){let l=(t.type||"text").toLowerCase();if((l==="checkbox"||l==="radio")&&Hn()){let{el:f,applyVisual:p}=co(t);e.nodeMap.set(f,t),a=p,i=f}else i.value=t.value,i.setAttribute("value",t.value),t.checked!==void 0&&(i.checked=t.checked,t.checked&&i.setAttribute("checked",""),t.indeterminate&&(i.indeterminate=t.indeterminate))}if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&!t.value&&t.placeholder)try{let l=window.getComputedStyle(t,"::placeholder"),d=l&&l.color;if(d&&d!=="rgba(0, 0, 0, 0)"){let f="snapdom-ph-"+(Math.random()*1e6|0);i.classList.add(f);let p=document.createElement("style");p.textContent=`.${f}::placeholder{color:${d}!important;opacity:${l.opacity||"1"}!important;-webkit-text-fill-color:${d}!important;}`,i.prepend(p)}}catch{}if(t instanceof HTMLSelectElement&&(r=t.value),t instanceof HTMLTextAreaElement&&(s=t.value),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement){t.disabled&&i.setAttribute("disabled",""),t.required&&i.setAttribute("required",""),t.readOnly&&i.setAttribute("readonly","");let l=t;l.min!==void 0&&l.min!==""&&i.setAttribute("min",l.min),l.max!==void 0&&l.max!==""&&i.setAttribute("max",l.max),l.pattern!==void 0&&l.pattern!==""&&i.setAttribute("pattern",l.pattern);let d=t.getAttribute("aria-invalid");d!==null&&i.setAttribute("aria-invalid",d)}if(ve(t)||ct(t,i,e,n),a&&a(),t instanceof SVGElement&&!ve(t)){let l=["fill","stroke","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","opacity","fill-opacity","stroke-opacity","fill-rule","clip-rule","marker","marker-start","marker-mid","marker-end","visibility","display"];try{let d=window.getComputedStyle(t);for(let f of l){let p=d.getPropertyValue(f);p&&i.style.setProperty(f,p)}}catch{}}if(t.shadowRoot){try{let S=t.shadowRoot.querySelectorAll("slot");for(let g of S){let x=g.assignedNodes?.()||[];for(let v of x)o.add(v)}}catch{}let l=to(e),d=`[data-sd="${l}"]`;e.shadowScopes||(e.shadowScopes=new WeakMap),e.shadowScopes.set(t.shadowRoot,l);try{i.setAttribute("data-sd",l)}catch{}let f=eo(t.shadowRoot),p=Jn(f,d,l),m=ro(f),h=io(t,m,d);no(i,h+p,l);let b=document.createDocumentFragment(),y=(S,g)=>{if(S.nodeType===Node.ELEMENT_NODE&&S.tagName==="STYLE")return g(null);ne(S,e,n).then(x=>{g(x||null)}).catch(()=>{g(null)})},w=await ke(Array.from(t.shadowRoot.childNodes),y,n.fast);b.append(...w.filter(S=>!!S)),i.appendChild(b)}if(t.tagName==="SLOT"){let l=e.shadowScopes?.get(t.getRootNode()),d=t.assignedNodes?.()||[],f=d.length?t.assignedNodes?.({flatten:!0})||d:[],p=f.length?f:Array.from(t.childNodes),m=document.createDocumentFragment(),h=(y,w)=>{ne(y,e,n).then(S=>{S&&d.length&&so(S,l),w(S||null)}).catch(()=>{w(null)})},b=await ke(Array.from(p),h,n.fast);return m.append(...b.filter(y=>!!y)),m}function c(l,d){if(o.has(l)||t.shadowRoot&&!l.assignedSlot)return d(null);ne(l,e,n).then(f=>{d(f||null)}).catch(()=>{d(null)})}let u=await ke(Array.from(t.childNodes),c,n.fast);if(i.append(...u.filter(l=>!!l)),r!==null&&i instanceof HTMLSelectElement){i.value=r;for(let l of i.options)l.value===r?l.setAttribute("selected",""):l.removeAttribute("selected")}return s!==null&&i instanceof HTMLTextAreaElement&&(i.textContent=s),i}async function Zi(t,e,n){let o=!1;try{o=!!(t.contentDocument||t.contentWindow?.document)}catch(r){_(e,"iframe same-origin probe failed",r)}if(o)try{return await ao(t,e,n)}catch(r){console.warn("[SnapDOM] iframe rasterization failed, fallback:",r)}if(o||console.warn("[snapdom] cross-origin <iframe> skipped (its document cannot be read). Captured as a placeholder that keeps the frame\'s box; pass { placeholders: false } for an invisible spacer.",t),n.placeholders){let{width:r,height:s}=ut(t),i=document.createElement("div");return i.style.cssText=`width:${r}px;height:${s}px;background-image:repeating-linear-gradient(45deg,#ddd,#ddd 5px,#f9f9f9 5px,#f9f9f9 10px);display:flex;align-items:center;justify-content:center;font-size:12px;color:#555;border:1px solid #aaa;`,ct(t,i,e,n),i}else{let{width:r,height:s}=ut(t),i=document.createElement("div");return i.style.cssText=`display:inline-block;width:${r}px;height:${s}px;visibility:hidden;`,ct(t,i,e,n),i}}function Ji(t){try{let e=Math.max(1,Math.min(32,t.width)),n=Math.max(1,Math.min(32,t.height)),o=document.createElement("canvas");o.width=e,o.height=n;let r=o.getContext("2d",{willReadFrequently:!0});if(!r)return!1;r.drawImage(t,0,0,e,n);let s=r.getImageData(0,0,e,n).data;for(let i=3;i<s.length;i+=4)if(s[i]!==0)return!1;return!0}catch{return!1}}async function ts(t,e,n){let o="";try{let a=t.getContext("2d",{willReadFrequently:!0});try{a&&a.getImageData(0,0,1,1)}catch{}if((K()||!a)&&await mt(),o=t.toDataURL("image/png"),!o||o==="data:,"){try{a&&a.getImageData(0,0,1,1)}catch{}if(await mt(),o=t.toDataURL("image/png"),!o||o==="data:,"){let c=document.createElement("canvas");c.width=t.width,c.height=t.height;let u=c.getContext("2d");u&&(u.drawImage(t,0,0),o=c.toDataURL("image/png"))}}}catch(a){_(e,"Canvas toDataURL failed, using empty/fallback",a)}n&&n.debug&&o&&Ji(t)&&_(e,"canvas is empty at capture time \\u2014 capture it after its first frame is drawn",t);let r=document.createElement("img");try{r.decoding="sync",r.loading="eager"}catch(a){_(e,"img decoding/loading hints failed",a)}o&&(r.src=o),r.width=t.width,r.height=t.height;let{width:s,height:i}=ut(t);return s>0&&(r.style.width=`${s}px`),i>0&&(r.style.height=`${i}px`),e.nodeMap.set(r,t),ct(t,r,e,n),r}async function es(t,e,n){let o="";try{let a=document.createElement("canvas");a.width=t.videoWidth||t.offsetWidth||320,a.height=t.videoHeight||t.offsetHeight||240;let c=a.getContext("2d");c&&(c.drawImage(t,0,0,a.width,a.height),o=a.toDataURL("image/png"),(!o||o==="data:,")&&(o=""))}catch(a){_(e,"Video frame capture failed, using poster fallback",a)}let r=document.createElement("img");try{r.decoding="sync",r.loading="eager"}catch{}o?r.src=o:t.poster&&(r.src=t.poster),r.width=t.videoWidth||t.offsetWidth||0,r.height=t.videoHeight||t.offsetHeight||0;let{width:s,height:i}=ut(t);return s>0&&(r.style.width=`${s}px`),i>0&&(r.style.height=`${i}px`),r.style.objectFit="contain",e.nodeMap.set(r,t),ct(t,r,e,n),r}async function ns(t,e,n){if(!t.controls)return;let{width:o,height:r}=ut(t),s=Math.round(o||t.offsetWidth||300),i=Math.round(r||t.offsetHeight||54),a=i/2,c=Math.max(4,i*.16),u=i*.34,l=s-i*.34,d=u+c+i*.55,f=Math.max(0,l-i*.7-d),p=Math.max(9,Math.round(i*.24)),m=`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${i}" viewBox="0 0 ${s} ${i}"><rect width="${s}" height="${i}" rx="${Math.min(i/2,10)}" fill="#f1f3f4"/><path d="M ${u} ${a-c} L ${u+c} ${a} L ${u} ${a+c} Z" fill="#5f6368"/><rect x="${d}" y="${a-1.5}" width="${f}" height="3" rx="1.5" fill="#bdc1c6"/><circle cx="${d}" cy="${a}" r="${Math.max(3,i*.09)}" fill="#5f6368"/><text x="${l}" y="${a}" fill="#5f6368" font-family="sans-serif" font-size="${p}" text-anchor="end" dominant-baseline="central">0:00</text></svg>`,h=document.createElement("img");try{h.decoding="sync",h.loading="eager"}catch{}return h.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(m)}`,h.width=s,h.height=i,h.style.width=`${s}px`,h.style.height=`${i}px`,e.nodeMap.set(h,t),ct(t,h,e,n),h}Fe("IFRAME",Zi);Fe("CANVAS",ts);Fe("VIDEO",es);Fe("AUDIO",ns);at();Kt();Zt();rt();rt();var os=[/font\\s*awesome/i,/material\\s*icons/i,/ionicons/i,/glyphicons/i,/feather/i,/bootstrap\\s*icons/i,/remix\\s*icons/i,/heroicons/i,/layui/i,/lucide/i],Ut=Object.assign({materialIconsFilled:"https://fonts.gstatic.com/s/materialicons/v48/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2",materialIconsOutlined:"https://fonts.gstatic.com/s/materialiconsoutlined/v110/gok-H7zzDkdnRel8-DQ6KAXJ69wP1tGnf4ZGhUcel5euIg.woff2",materialIconsRound:"https://fonts.gstatic.com/s/materialiconsround/v109/LDItaoyNOAY6Uewc665JcIzCKsKc_M9flwmPq_HTTw.woff2",materialIconsSharp:"https://fonts.gstatic.com/s/materialiconssharp/v110/oPWQ_lt5nv4pWNJpghLP75WiFR4kLh3kvmvRImcycg.woff2"},typeof window<"u"&&window.__SNAPDOM_ICON_FONTS__||{}),mo=[],po=new Set;function rs(t){return t.replace(/[.*+?^${}()|[\\]\\\\]/g,"\\\\$&")}function go(t){let e=Array.isArray(t)?t:[t];for(let n of e){let o;if(n instanceof RegExp)o=n;else if(typeof n=="string")o=new RegExp(rs(n),"i");else{console.warn("[snapdom] Ignored invalid iconFont value:",n);continue}let r=`${o.source}/${o.flags}`;po.has(r)||(po.add(r),mo.push(o))}}function dt(t){let e=typeof t=="string"?t:"",n=[...os,...mo];for(let o of n)if(o instanceof RegExp&&o.test(e))return!0;return!!(/icon/i.test(e)||/glyph/i.test(e)||/symbols/i.test(e)||/feather/i.test(e)||/fontawesome/i.test(e))}function is(t=""){let e=String(t).toLowerCase();return/\\bmaterial\\s*icons\\b/.test(e)||/\\bmaterial\\s*symbols\\b/.test(e)}var ho=new Map;function ss(t=""){let e=Object.create(null),n=String(t||""),o=/[\'"]?\\s*([A-Za-z]{3,4})\\s*[\'"]?\\s*([+-]?\\d+(?:\\.\\d+)?)\\s*/g,r;for(;r=o.exec(n);)e[r[1].toUpperCase()]=Number(r[2]);return e}async function as(t,e,n){let o=String(t||""),r=o.toLowerCase(),s=String(e||"").toLowerCase();if(/\\bmaterial\\s*icons\\b/.test(r)&&!/\\bsymbols\\b/.test(r))return{familyForMeasure:o,familyForCanvas:o};if(!/\\bmaterial\\s*symbols\\b/.test(r))return{familyForMeasure:o,familyForCanvas:o};let a=n&&(n.FILL??n.fill),c="outlined";/\\brounded\\b/.test(s)||/\\bround\\b/.test(s)?c="rounded":/\\bsharp\\b/.test(s)?c="sharp":/\\boutlined\\b/.test(s)&&(c="outlined");let u=a===1,l=null;if(u&&(c==="outlined"&&Ut.materialIconsFilled?l={url:Ut.materialIconsFilled,alias:"snapdom-mi-filled"}:c==="rounded"&&Ut.materialIconsRound?l={url:Ut.materialIconsRound,alias:"snapdom-mi-round"}:c==="sharp"&&Ut.materialIconsSharp&&(l={url:Ut.materialIconsSharp,alias:"snapdom-mi-sharp"})),!l)return{familyForMeasure:o,familyForCanvas:o};if(!ho.has(l.alias))try{let f=new FontFace(l.alias,`url(${l.url})`,{style:"normal",weight:"400"});document.fonts.add(f),await f.load(),ho.set(l.alias,!0)}catch{return{familyForMeasure:o,familyForCanvas:o}}let d=`"${l.alias}"`;return{familyForMeasure:d,familyForCanvas:d}}async function cs(t="Material Icons",e=24){try{await Promise.all([document.fonts.load(`400 ${e}px "${String(t).replace(/["\']/g,"")}"`),document.fonts.ready])}catch{}}function ls(t){let e=t.getPropertyValue("-webkit-text-fill-color")?.trim()||"",n=/^transparent$/i.test(e)||/rgba?\\(\\s*0\\s*,\\s*0\\s*,\\s*0\\s*,\\s*0\\s*\\)/i.test(e);if(e&&!n&&e.toLowerCase()!=="currentcolor")return e;let o=t.color?.trim();return o&&o!=="inherit"?o:"#000"}async function fs(t,{family:e="Material Icons",weight:n="normal",fontSize:o=32,color:r="#000",variation:s="",className:i=""}={}){let a=String(e||"").replace(/^[\'"]+|[\'"]+$/g,""),c=window.devicePixelRatio||1,u=ss(s),{familyForMeasure:l,familyForCanvas:d}=await as(a,i,u);await cs(d.replace(/^["\']+|["\']+$/g,""),o);let f=document.createElement("span");f.setAttribute("data-snapdom-internal",""),f.textContent=t,f.style.position="absolute",f.style.visibility="hidden",f.style.left="-99999px",f.style.whiteSpace="nowrap",f.style.fontFamily=l,f.style.fontWeight=String(n||"normal"),f.style.fontSize=`${o}px`,f.style.lineHeight="1",f.style.margin="0",f.style.padding="0",f.style.fontFeatureSettings="\'liga\' 1",f.style.fontVariantLigatures="normal",f.style.color=r,document.body.appendChild(f);let p=f.getBoundingClientRect(),m=Math.max(1,Math.ceil(p.width)),h=Math.max(1,Math.ceil(p.height));document.body.removeChild(f);let b=document.createElement("canvas");b.width=m*c,b.height=h*c;let y=b.getContext("2d");y.scale(c,c),y.font=`${n?`${n} `:""}${o}px ${d}`,y.textAlign="left",y.textBaseline="top",y.fillStyle=r;try{y.fontKerning="normal"}catch{}return y.fillText(t,0,0),{dataUrl:b.toDataURL(),width:m,height:h}}async function yo(t,e,n=C.session.nodeMap){if(t?.nodeType!==1)return 0;let o=\'.material-icons, [class*="material-symbols"]\',r=Array.from(t.querySelectorAll(o)).filter(a=>a&&a.textContent&&a.textContent.trim());if(t.matches?.(o)&&t.textContent&&t.textContent.trim()&&r.unshift(t),r.length===0)return 0;let s=e?.nodeType===1?Array.from(e.querySelectorAll(o)).filter(a=>a&&a.textContent&&a.textContent.trim()):[];e?.nodeType===1&&e.matches?.(o)&&e.textContent&&e.textContent.trim()&&s.unshift(e);let i=0;for(let a=0;a<r.length;a++){let c=r[a],u=n&&n.get(c)||s[a]||null;try{let l=getComputedStyle(u||c),d=l.fontFamily||"Material Icons";if(!is(d))continue;let f=(u||c).textContent.trim();if(!f)continue;let p=parseInt(l.fontSize,10)||24,m=l.fontWeight&&l.fontWeight!=="normal"?l.fontWeight:"normal",h=ls(l),b=l.fontVariationSettings&&l.fontVariationSettings!=="normal"?l.fontVariationSettings:"",y=(u||c).className||"",{dataUrl:w,width:S,height:g}=await fs(f,{family:d,weight:m,fontSize:p,color:h,variation:b,className:y});c.textContent="";let x=c.ownerDocument.createElement("img");x.src=w,x.alt=f,x.style.height=`${p}px`,x.style.width=`${Math.max(1,Math.round(S/g*p))}px`,x.style.objectFit="contain",x.style.verticalAlign=getComputedStyle(c).verticalAlign||"baseline",c.appendChild(x),i++}catch{}}return i}vt();Ct();async function So(t,e,n,o=32,r="#000"){e=e.replace(/^[\'"]+|[\'"]+$/g,"");let s=window.devicePixelRatio||1;try{await document.fonts.ready}catch{}let i=document.createElement("span");i.setAttribute("data-snapdom-internal",""),i.textContent=t,i.style.position="absolute",i.style.visibility="hidden",i.style.fontFamily=`"${e}"`,i.style.fontWeight=n||"normal",i.style.fontSize=`${o}px`,i.style.lineHeight="1",i.style.whiteSpace="nowrap",i.style.padding="0",i.style.margin="0",document.body.appendChild(i);let a=i.getBoundingClientRect(),c=Math.ceil(a.width),u=Math.ceil(a.height);document.body.removeChild(i);let l=document.createElement("canvas");l.width=Math.max(1,c*s),l.height=Math.max(1,u*s);let d=l.getContext("2d");return d.scale(s,s),d.font=n?`${n} ${o}px "${e}"`:`${o}px "${e}"`,d.textAlign="left",d.textBaseline="top",d.fillStyle=r,d.fillText(t,0,0),{dataUrl:l.toDataURL(),width:c,height:u}}var vo=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","emoji","math","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]),us=["katex","mathjax","mathml"];function an(t){if(!t)return"";for(let e of t.split(",")){let n=e.trim().replace(/^[\'"]+|[\'"]+$/g,"");if(n&&!vo.has(n.toLowerCase()))return n}return""}function ds(t){if(!t)return[];let e=[];for(let n of t.split(",")){let o=n.trim().replace(/^[\'"]+|[\'"]+$/g,"");o&&(vo.has(o.toLowerCase())||e.push(o))}return e}function Ee(t){let e=String(t??"400").trim().toLowerCase();if(e==="normal")return 400;if(e==="bold")return 700;let n=parseInt(e,10);return Number.isFinite(n)?Math.min(900,Math.max(100,n)):400}function Re(t){let e=String(t??"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function ps(t){let e=String(t??"100%").match(/(\\d+(?:\\.\\d+)?)\\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}function hs(t){let e=String(t||"400").trim(),n=e.match(/^(\\d{2,3})\\s+(\\d{2,3})$/);if(n){let r=Ee(n[1]),s=Ee(n[2]);return{min:Math.min(r,s),max:Math.max(r,s)}}let o=Ee(e);return{min:o,max:o}}function ms(t){let e=String(t||"normal").trim().toLowerCase();return e==="italic"?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}function gs(t){let e=String(t||"100%").trim(),n=e.match(/(\\d+(?:\\.\\d+)?)\\s*%\\s+(\\d+(?:\\.\\d+)?)\\s*%/);if(n){let s=parseFloat(n[1]),i=parseFloat(n[2]);return{min:Math.min(s,i),max:Math.max(s,i)}}let o=e.match(/(\\d+(?:\\.\\d+)?)\\s*%/),r=o?parseFloat(o[1]):100;return{min:r,max:r}}function ys(t){return!t||typeof t!="string"?"":t.replace(/\\s+(variable|vf|v[0-9]+)$/i,"").trim().toLowerCase().replace(/\\s+/g,"-")}function bs(t,e,n=[]){if(!t)return!1;try{let o=new URL(t,location.href);if(o.origin===location.origin)return!0;let s=o.host.toLowerCase();if(["fonts.googleapis.com","fonts.gstatic.com","use.typekit.net","p.typekit.net","kit.fontawesome.com","use.fontawesome.com","cdn.jsdelivr.net","unpkg.com","cdnjs.cloudflare.com","esm.sh"].some(c=>s.endsWith(c))||n.some(c=>s===c.toLowerCase()||s.endsWith("."+c.toLowerCase())))return!0;let a=(o.pathname+o.search).toLowerCase();if(/\\bfont(s)?\\b/.test(a)||/\\.woff2?(\\b|$)/.test(a)||us.some(c=>a.includes(c)))return!0;for(let c of e){let u=c.toLowerCase().replace(/\\s+/g,"+"),l=c.toLowerCase().replace(/\\s+/g,"-"),d=ys(c);if(a.includes(u)||a.includes(l)||d&&a.includes(d))return!0}return!1}catch{return!1}}function ws(t){let e=new Set;for(let n of t||[]){let o=String(n).split("__")[0]?.trim();o&&e.add(o)}return e}function bo(t,e){return t&&t.replace(/url\\(\\s*([\'"]?)([^)\'"]+)\\1\\s*\\)/g,(n,o,r)=>{let s=(r||"").trim();if(!s||/^data:|^blob:|^https?:|^file:|^about:/i.test(s))return n;let i=s;try{i=new URL(s,e||location.href).href}catch{}return`url("${i}")`})}var rn=/@import\\s+(?:url\\(\\s*([\'"]?)([^)"\']+)\\1\\s*\\)|([\'"])([^"\']+)\\3)([^;]*);/g,$e=4;async function xs(t,e,n){if(!t)return t;let o=new Set;function r(a,c){try{return new URL(a,c||location.href).href}catch{return a}}async function s(a,c,u=0){if(u>$e)return console.warn(`[snapDOM] @import depth exceeded (${$e}) at ${c}`),a;let l="",d=0,f;for(;f=rn.exec(a);){l+=a.slice(d,f.index),d=rn.lastIndex;let p=(f[2]||f[4]||"").trim(),m=r(p,c);if(o.has(m)){console.warn(`[snapDOM] Skipping circular @import: ${m}`);continue}o.add(m);let h="";try{let b=await G(m,{as:"text",useProxy:n,silent:!0});b.ok&&typeof b.data=="string"&&(h=b.data)}catch{}h?(h=bo(h,m),h=await s(h,m,u+1),l+=`\n/* inlined: ${m} */\n${h}\n`):l+=f[0]}return l+=a.slice(d),l}let i=bo(t,e||location.href);return i=await s(i,e||location.href,0),i}var Co=/url\\((["\']?)([^"\')]+)\\1\\)/g,Ss=/@font-face[^{}]*\\{[^}]*\\}/g;function lt(t,e,n=""){return(t.match(new RegExp(`${e}\\\\s*:\\\\s*([^;}]+)[;}]`,"i"))?.[1]||n).trim()}function Ao(t){if(!t)return[];let e=[],n=t.split(",").map(o=>o.trim()).filter(Boolean);for(let o of n){let r=o.match(/^U\\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!r)continue;let s=r[1],i=r[2],a=c=>{if(!c.includes("?"))return parseInt(c,16);let u=parseInt(c.replace(/\\?/g,"0"),16),l=parseInt(c.replace(/\\?/g,"F"),16);return[u,l]};if(i){let c=a(s),u=a(i),l=Array.isArray(c)?c[0]:c,d=Array.isArray(u)?u[1]:u;e.push([Math.min(l,d),Math.max(l,d)])}else{let c=a(s);Array.isArray(c)?e.push([c[0],c[1]]):e.push([c,c])}}return e}function ko(t,e){if(!e.length||!t||t.size===0)return!0;for(let n of t)for(let[o,r]of e)if(n>=o&&n<=r)return!0;return!1}function cn(t,e){let n=[];if(!t)return n;for(let o of t.matchAll(Co)){let r=(o[2]||"").trim();if(!(!r||r.startsWith("data:"))){if(!/^https?:/i.test(r))try{r=new URL(r,e||location.href).href}catch{}n.push(r)}}return n}async function sn(t,e,n=""){let o=t;for(let r of t.matchAll(Co)){let s=Et(r[0]);if(!s)continue;let i=s;if(!i.startsWith("http")&&!i.startsWith("data:"))try{i=new URL(i,e||location.href).href}catch{}if(!dt(i)){if(C.resource?.has(i)){C.font?.add(i),o=o.replace(r[0],`url(${C.resource.get(i)})`);continue}try{let a=await G(i,{as:"dataURL",useProxy:n,silent:!0});if(a.ok&&typeof a.data=="string"){let c=a.data;C.resource?.set(i,c),C.font?.add(i),o=o.replace(r[0],`url(${c})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",i)}}}return o}function vs(t){if(!t.length)return null;let e=(a,c)=>t.some(([u,l])=>!(l<a||u>c)),n=e(0,255)||e(305,305),o=e(256,591)||e(7680,7935),r=e(880,1023),s=e(1024,1279);return e(7840,7929)||e(258,259)||e(416,417)||e(431,432)?"vietnamese":s?"cyrillic":r?"greek":o?"latin-ext":n?"latin":null}function wo(t={}){let e=new Set((t.families||[]).map(r=>String(r).toLowerCase())),n=new Set((t.domains||[]).map(r=>String(r).toLowerCase())),o=new Set((t.subsets||[]).map(r=>String(r).toLowerCase()));return(r,s)=>{if(e.size&&e.has(r.family.toLowerCase()))return!0;if(n.size)for(let i of r.srcUrls)try{if(n.has(new URL(i).host.toLowerCase()))return!0}catch{}if(o.size){let i=vs(s);if(i&&o.has(i))return!0}return!1}}function Cs(t){if(!t)return t;let e=/@font-face[^{}]*\\{[^}]*\\}/gi,n=new Set,o=[];for(let s of t.match(e)||[]){let i=lt(s,"font-family"),a=an(i),c=lt(s,"font-weight","400"),u=lt(s,"font-style","normal"),l=lt(s,"font-stretch","100%"),d=lt(s,"unicode-range"),f=lt(s,"src"),p=cn(f,location.href),m=p.length?p.map(b=>String(b).toLowerCase()).sort().join("|"):f.toLowerCase(),h=[String(a||"").toLowerCase(),c,u,l,d.toLowerCase(),m].join("|");n.has(h)||(n.add(h),o.push(s))}if(o.length===0)return t;let r=0;return t.replace(e,()=>o[r++]||"")}var xo=new WeakMap,As=0;function ks(t){let e=xo.get(t);return e===void 0&&(e=As++,xo.set(t,e)),e}function Ms(t,e,n,o,r,s){let i=Array.from(t||[]).sort().join("|"),a=e?JSON.stringify({families:(e.families||[]).map(f=>String(f).toLowerCase()).sort(),domains:(e.domains||[]).map(f=>String(f).toLowerCase()).sort(),subsets:(e.subsets||[]).map(f=>String(f).toLowerCase()).sort()}):"",c=(n||[]).map(f=>`${(f.family||"").toLowerCase()}::${f.weight||"normal"}::${f.style||"normal"}::${f.src||""}`).sort().join("|"),u=o||"",l=(r||[]).map(f=>String(f).toLowerCase()).sort().join("|"),d=ks(s||document);return`fonts-embed-css::req=${i}::ex=${a}::lf=${c}::px=${u}::fd=${l}::doc=${d}`}async function Mo(t,e,n,o){let r;try{r=t.cssRules||[]}catch{return}let s=(i,a)=>{try{return new URL(i,a||location.href).href}catch{return i}};for(let i of r){if(i.type===CSSRule.IMPORT_RULE&&i.styleSheet){let a=i.href?s(i.href,e):e;if(o.depth>=$e){console.warn(`[snapDOM] CSSOM import depth exceeded (${$e}) at ${a}`);continue}if(a&&o.visitedSheets.has(a)){console.warn(`[snapDOM] Skipping circular CSSOM import: ${a}`);continue}a&&o.visitedSheets.add(a);let c={...o,depth:(o.depth||0)+1};await Mo(i.styleSheet,a,n,c);continue}if(i.type===CSSRule.FONT_FACE_RULE){let a=(i.style.getPropertyValue("font-family")||"").trim(),c=an(a);if(!c||dt(c))continue;let u=(i.style.getPropertyValue("font-weight")||"").trim(),l=(i.style.getPropertyValue("font-style")||"").trim(),d=(i.style.getPropertyValue("font-stretch")||"").trim(),f=(i.style.getPropertyValue("font-variation-settings")||"").trim(),p=(i.style.getPropertyValue("src")||"").trim(),m=(i.style.getPropertyValue("unicode-range")||"").trim(),h=u||"400",b=l||"normal",y=d||"100%",w=(l?`font-style:${l};`:"")+(u?`font-weight:${u};`:"")+(d?`font-stretch:${d};`:"")+(f?`font-variation-settings:${f};`:"")+(m?`unicode-range:${m};`:""),S=o.faceMatchesRequired(c,b,h,y);if(!S&&!o.requiredIndex.has(c.toLowerCase()))continue;let g=Ao(m);if(!ko(o.usedCodepoints,g))continue;let x={family:c,weightSpec:h,styleSpec:b,stretchSpec:y,unicodeRange:m,srcRaw:p,srcUrls:cn(p,e||location.href),href:e||location.href};if(o.simpleExcluder&&o.simpleExcluder(x,g))continue;if(!S){o.provisionalFaces.push({family:c.toLowerCase(),block:`@font-face{font-family:${c};src:${p};${w}}`,srcRaw:p,baseHref:e||location.href});continue}if(o.coveredFamilies.add(c.toLowerCase()),/url\\(/i.test(p)){let v=await sn(p,e||location.href,o.useProxy);await n(`@font-face{font-family:${c};src:${v};${w}}`)}else await n(`@font-face{font-family:${c};src:${p};${w}}`)}}}async function Te({required:t,usedCodepoints:e,exclude:n=void 0,localFonts:o=[],useProxy:r="",fontStylesheetDomains:s=[],doc:i=document}={}){t instanceof Set||(t=new Set),e instanceof Set||(e=new Set);let a=new Map;for(let g of t){let[x,v,k,A]=String(g).split("__");if(!x)continue;let M=x.toLowerCase(),F=a.get(M)||[];F.push({w:parseInt(v,10),s:k,st:parseInt(A,10)}),a.set(M,F)}function c(g,x,v,k){let A=String(g).toLowerCase();if(!a.has(A))return!1;let M=a.get(A),F=hs(v),E=ms(x),$=gs(k),W=F.min!==F.max,T=F.min,I=U=>E.kind==="normal"&&U==="normal"||E.kind!=="normal"&&(U==="italic"||U==="oblique"),O=!1;for(let U of M){let P=W?U.w>=F.min&&U.w<=F.max:U.w===T,z=I(Re(U.s)),j=U.st>=$.min&&U.st<=$.max;if(P&&z&&j){O=!0;break}}if(O)return!0;if(!W)for(let U of M){let P=I(Re(U.s)),z=U.st>=$.min&&U.st<=$.max;if(Math.abs(T-U.w)<=300&&P&&z)return!0}if(!W&&E.kind==="normal"&&M.some(P=>Re(P.s)!=="normal"))for(let P of M){let z=Math.abs(T-P.w)<=300,j=P.st>=$.min&&P.st<=$.max;if(z&&j)return!0}return!1}let u=wo(n),l=Ms(t,n,o,r,s,i);if(C.resource?.has(l))return C.resource.get(l);let d=ws(t),f=[],p=rn;for(let g of i.querySelectorAll("style")){let x=g.textContent||"";for(let v of x.matchAll(p)){let k=(v[2]||v[4]||"").trim();if(!k||dt(k))continue;i.querySelector(`link[rel="stylesheet"][href="${k}"]`)||f.push(k)}}let m=[];f.length&&await Promise.all(f.map(g=>new Promise(x=>{if(i.querySelector(`link[rel="stylesheet"][href="${g}"]`))return x(null);let v=i.createElement("link");v.rel="stylesheet",v.href=g,v.setAttribute("data-snapdom","injected-import"),v.onload=()=>x(v),v.onerror=()=>x(null),i.head.appendChild(v),m.push(v)})));let h="",b=new Set,y=[],w=Array.from(i.querySelectorAll(\'link[rel="stylesheet"]\')).filter(g=>!!g.href);for(let g of m)try{g.remove()}catch{}for(let g of w)try{if(dt(g.href))continue;let x="",v=!1;try{v=new URL(g.href,location.href).origin===location.origin}catch{}if(!v){let A=Array.isArray(s)?s:[];if(!bs(g.href,d,A))continue}if(v){let A=Array.from(i.styleSheets).find(M=>M.href===g.href);if(A)try{let M=A.cssRules||[];x=Array.from(M).map(F=>F.cssText).join("")}catch{}}if(!x){let A=await G(g.href,{as:"text",useProxy:r});if(A?.ok&&typeof A.data=="string"&&(x=A.data),dt(g.href))continue}x=await xs(x,g.href,r);let k="";for(let A of x.match(Ss)||[]){let M=lt(A,"font-family"),F=an(M);if(!F||dt(F))continue;let E=lt(A,"font-weight","400"),$=lt(A,"font-style","normal"),W=lt(A,"font-stretch","100%"),T=lt(A,"unicode-range"),I=lt(A,"src"),O=cn(I,g.href),U=c(F,$,E,W);if(!U&&!a.has(F.toLowerCase()))continue;let P=Ao(T);if(!ko(e,P))continue;let z={family:F,weightSpec:E,styleSpec:$,stretchSpec:W,unicodeRange:T,srcRaw:I,srcUrls:O,href:g.href};if(n&&u(z,P))continue;if(!U){y.push({family:F.toLowerCase(),block:A,srcRaw:I,baseHref:g.href});continue}b.add(F.toLowerCase());let j=/url\\(/i.test(I)?await sn(A,g.href,r):A;k+=j}k.trim()&&(h+=k)}catch{console.warn("[snapDOM] Failed to process stylesheet:",g.href)}let S={requiredIndex:a,usedCodepoints:e,faceMatchesRequired:c,coveredFamilies:b,provisionalFaces:y,simpleExcluder:n?wo(n):null,useProxy:r,visitedSheets:new Set,depth:0};for(let g of i.styleSheets)if(!(g.href&&w.some(x=>x.href===g.href)))try{let x=g.href||location.origin+"/";x&&S.visitedSheets.add(x),await Mo(g,x,async v=>{h+=v},S)}catch{}for(let g of y)b.has(g.family)||(h+=/url\\(/i.test(g.srcRaw)?await sn(g.block,g.baseHref,r):g.block);try{for(let g of i.fonts||[]){if(!g||!g.family||g.status!=="loaded"||!g._snapdomSrc)continue;let x=String(g.family).replace(/^[\'"]+|[\'"]+$/g,"");if(dt(x)||!a.has(x.toLowerCase())||n?.families&&n.families.some(k=>String(k).toLowerCase()===x.toLowerCase()))continue;let v=g._snapdomSrc;if(!String(v).startsWith("data:")){if(C.resource?.has(g._snapdomSrc))v=C.resource.get(g._snapdomSrc),C.font?.add(g._snapdomSrc);else if(!C.font?.has(g._snapdomSrc))try{let k=await G(g._snapdomSrc,{as:"dataURL",useProxy:r,silent:!0});if(k.ok&&typeof k.data=="string")v=k.data,C.resource?.set(g._snapdomSrc,v),C.font?.add(g._snapdomSrc);else continue}catch{console.warn("[snapDOM] Failed to fetch dynamic font src:",g._snapdomSrc);continue}}h+=`@font-face{font-family:\'${x}\';src:url(${v});font-style:${g.style||"normal"};font-weight:${g.weight||"normal"};}`}}catch{}for(let g of o){if(!g||typeof g!="object")continue;let x=String(g.family||"").replace(/^[\'"]+|[\'"]+$/g,"");if(!x||dt(x)||!a.has(x.toLowerCase())||n?.families&&n.families.some(E=>String(E).toLowerCase()===x.toLowerCase()))continue;let v=g.weight!=null?String(g.weight):"normal",k=g.style!=null?String(g.style):"normal",A=g.stretchPct!=null?`${g.stretchPct}%`:"100%",M=String(g.src||""),F=M;if(!F.startsWith("data:")){if(C.resource?.has(M))F=C.resource.get(M),C.font?.add(M);else if(!C.font?.has(M))try{let E=await G(M,{as:"dataURL",useProxy:r,silent:!0});if(E.ok&&typeof E.data=="string")F=E.data,C.resource?.set(M,F),C.font?.add(M);else continue}catch{console.warn("[snapDOM] Failed to fetch localFonts src:",M);continue}}h+=`@font-face{font-family:\'${x}\';src:url(${F});font-style:${k};font-weight:${v};font-stretch:${A};}`}return h&&(h=Cs(h),C.resource?.set(l,h)),h}function oe(t,e){let n=new Set,o=new Set;if(!t)return{required:n,usedCodepoints:o};let r=c=>{if(c)for(let u of c)o.add(u.codePointAt(0))},s=c=>{let u=ds(c.fontFamily);if(u.length)for(let l of u)n.add(`${l}__${Ee(c.fontWeight)}__${Re(c.fontStyle)}__${ps(c.fontStretch)}`)},i=c=>{s(N(c));for(let u of["::before","::after"]){let l=N(c,u),d=l&&l.content;if(!(!d||d==="none"||d==="normal"))if(s(l),/^["\']/.test(d))r(d.slice(1,-1));else{let f=d.match(/\\\\[0-9A-Fa-f]{1,6}/g);if(f)for(let p of f)try{o.add(parseInt(p.slice(1),16))}catch{}}}};i(t);let a=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;a.nextNode();){let c=a.currentNode;if(c.nodeType===Node.TEXT_NODE){if(e&&c.parentElement&&!e(c.parentElement))continue;r(c.nodeValue||"")}else{if(e&&!e(c))continue;i(c)}}return{required:n,usedCodepoints:o}}function Fo(t,e){return oe(t,e).required}async function Dt(t,e=2,n=document){try{await n.fonts.ready}catch{}let o=Array.from(t||[]).filter(Boolean);if(o.length===0)return;let r=()=>{let s=n.createElement("div");s.setAttribute("data-snapdom-internal",""),s.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;opacity:0!important;pointer-events:none!important;contain:layout size style;";for(let i of o){let a=n.createElement("span");a.textContent="AaBbGg1234\\xC1\\xC9\\xCD\\xD3\\xDA\\xE7\\xF1\\u2014\\u221E",a.style.fontFamily=`"${i}"`,a.style.fontWeight="700",a.style.fontStyle="italic",a.style.fontSize="32px",a.style.lineHeight="1",a.style.whiteSpace="nowrap",a.style.margin="0",a.style.padding="0",s.appendChild(a)}n.body.appendChild(s),s.offsetWidth,n.body.removeChild(s)};for(let s=0;s<Math.max(1,e);s++)r(),await mt(),await mt()}function To(t){return/\\bcounter\\s*\\(|\\bcounters\\s*\\(/.test(t||"")}function Eo(t,e=!1){let n="",o=Math.max(1,t);for(;o>0;)o--,n=String.fromCharCode(97+o%26)+n,o=Math.floor(o/26);return e?n.toUpperCase():n}function Ro(t,e=!0){let n=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]],o=Math.max(1,Math.min(3999,t)),r="";for(let[s,i]of n)for(;o>=s;)r+=i,o-=s;return e?r:r.toLowerCase()}function $o(t,e){switch((e||"decimal").toLowerCase()){case"decimal":return String(t);case"decimal-leading-zero":{let n=Math.abs(t);return(t<0?"-":"")+(n<10?"0":"")+String(n)}case"lower-alpha":return Eo(t,!1);case"upper-alpha":return Eo(t,!0);case"lower-roman":return Ro(t,!1);case"upper-roman":return Ro(t,!0);default:return String(t)}}function Po(t){let e=new WeakMap,n=t instanceof Document?t.documentElement:t,o=u=>u&&u.tagName==="LI",r=u=>{let l=0,d=u?.parentElement;if(!d)return 0;for(let f of d.children){if(f===u)break;f.tagName==="LI"&&l++}return l},s=u=>{let l=new Map;for(let[d,f]of u)l.set(d,f.slice());return l},i=(u,l,d)=>{let f=s(u),p;try{p=d.style?.counterReset||getComputedStyle(d).counterReset}catch{}if(p&&p!=="none")for(let b of p.split(",")){let y=b.trim().split(/\\s+/),w=y[0],S=Number.isFinite(Number(y[1]))?Number(y[1]):0;if(!w)continue;let g=l.get(w);if(g&&g.length){let x=g.slice();x.push(S),f.set(w,x)}else f.set(w,[S])}let m;try{m=d.style?.counterSet||getComputedStyle(d).counterSet}catch{}if(m&&m!=="none")for(let b of m.split(",")){let y=b.trim().split(/\\s+/),w=y[0],S=Number.isFinite(Number(y[1]))?Number(y[1]):0;if(!w)continue;let g=f.get(w)||[];g.length===0&&g.push(0),g[g.length-1]=S,f.set(w,g)}let h;try{h=d.style?.counterIncrement||getComputedStyle(d).counterIncrement}catch{}if(h&&h!=="none")for(let b of h.split(",")){let y=b.trim().split(/\\s+/),w=y[0],S=Number.isFinite(Number(y[1]))?Number(y[1]):1;if(!w)continue;let g=f.get(w)||[];g.length===0&&g.push(0),g[g.length-1]+=S,f.set(w,g)}try{if(getComputedStyle(d).display==="list-item"&&o(d)){let y=d.parentElement,w=1;if(y&&y.tagName==="OL"){let g=y.getAttribute("start"),x=Number.isFinite(Number(g))?Number(g):1,v=r(d),k=d.getAttribute("value");w=Number.isFinite(Number(k))?Number(k):x+v}else w=1+r(d);let S=f.get("list-item")||[];S.length===0&&S.push(0),S[S.length-1]=w,f.set("list-item",S)}}catch{}return f},a=(u,l,d)=>{let f=i(d,l,u);e.set(u,f);let p=f;for(let h of u.children)p=a(h,f,p);let m=new Map;for(let[h,b]of d){let y=b.length,w=p.get(h);m.set(h,w&&w.length?w.slice(0,y):b.slice())}for(let[h,b]of p)!m.has(h)&&b.length&&!l.has(h)&&m.set(h,b.slice(0,1));return m},c=new Map;return a(n,c,c),{get(u,l){let d=e.get(u)?.get(l);return d&&d.length?d[d.length-1]:0},getStack(u,l){let d=e.get(u)?.get(l);return d?d.slice():[]}}}function No(t,e,n){if(!t||t==="none")return t;try{let o=/\\b(counter|counters)\\s*\\(([^)]+)\\)/g;return t.replace(o,(r,s,i)=>{let a=String(i).split(",").map(c=>c.trim());if(s==="counter"){let c=a[0]?.replace(/^["\']|["\']$/g,""),u=(a[1]||"decimal").toLowerCase(),l=n.get(e,c);return $o(l,u)}else{let c=a[0]?.replace(/^["\']|["\']$/g,""),u=a[1]?.replace(/^["\']|["\']$/g,"")??"",l=(a[2]||"decimal").toLowerCase(),d=n.getStack(e,c);return d.length?d.map(p=>$o(p,l)).join(u):""}})}catch{return"- "}}vt();var Ht=new WeakMap,Lo=1e3;function Fs(t,e){let n=Oo(t);return e?(e.__pseudoPreflightFp!==n&&(e.__pseudoPreflight=_o(t,n),e.__pseudoPreflightFp=n),!!e.__pseudoPreflight):_o(t,n)}function ln(t){try{return t&&t.cssRules?t.cssRules:null}catch{return null}}function Oo(t){let e=t.querySelectorAll(\'style,link[rel~="stylesheet"]\'),n=`n:${e.length}|`,o=0;for(let s=0;s<e.length;s++){let i=e[s];if(i.tagName==="STYLE"){let a=i.textContent?i.textContent.length:0;n+=`S${a}|`;let c=i.sheet,u=c?ln(c):null;u&&(o+=u.length)}else{let a=i.getAttribute("href")||"",c=i.getAttribute("media")||"all";n+=`L${a}|m:${c}|`;let u=i.sheet,l=u?ln(u):null;l&&(o+=l.length)}}let r=t.adoptedStyleSheets;return n+=`ass:${Array.isArray(r)?r.length:0}|tr:${o}`,n}function Io(t,e,n){let o=ln(t);if(!o)return!1;for(let r=0;r<o.length;r++){if(n.budget<=0)return!1;let s=o[r],i=s&&s.cssText?s.cssText:"";n.budget--;for(let a of e)if(i.includes(a))return!0;if(s&&s.cssRules&&s.cssRules.length)for(let a=0;a<s.cssRules.length&&n.budget>0;a++){let c=s.cssRules[a],u=c&&c.cssText?c.cssText:"";n.budget--;for(let l of e)if(u.includes(l))return!0}if(n.budget<=0)return!1}return!1}function _o(t=document,e=Oo(t)){let n=Ht.get(t);if(n&&n.fingerprint===e)return n.result;let o=["::before","::after","::first-letter",":before",":after",":first-letter","counter(","counters(","counter-increment","counter-reset"],r=t.querySelectorAll("style");for(let i=0;i<r.length;i++){let a=r[i].textContent||"";for(let c of o)if(a.includes(c))return Ht.set(t,{fingerprint:e,result:!0}),!0}let s=t.adoptedStyleSheets;if(Array.isArray(s)&&s.length){let i={budget:Lo};try{for(let a of s)if(Io(a,o,i))return Ht.set(t,{fingerprint:e,result:!0}),!0}catch{}}{let i=t.querySelectorAll(\'style,link[rel~="stylesheet"]\'),a={budget:Lo};for(let c=0;c<i.length&&a.budget>0;c++){let u=i[c],l=null;if(u.tagName,l=u.sheet||null,l&&Io(l,o,a))return Ht.set(t,{fingerprint:e,result:!0}),!0}}return t.querySelector(\'[style*="counter("], [style*="counters("]\')?(Ht.set(t,{fingerprint:e,result:!0}),!0):(Ht.set(t,{fingerprint:e,result:!1}),!1)}function Wo(t){for(let e of["Top","Right","Bottom","Left"]){let n=parseFloat(t[`border${e}Width`])||0,o=t[`border${e}Style`];if(n>0&&o&&o!=="none"&&o!=="hidden")return!0}return!1}function Es(t,e){let n=null,o=()=>{if(!n)try{n=Po(t)}catch(r){_(e,"buildCounterContext failed",r),n={get:()=>0,getStack:()=>[]}}return n};return{get(r,s){return o().get(r,s)},getStack(r,s){return o().getStack(r,s)}}}function Rs(t){let e=!1;for(let n=0;n<t.length;n++){let o=t[n];if(o===\'"\')e=!e;else if(o==="/"&&!e)return t.slice(0,n).trim()}return t}function $s(t){if(!t)return"";let e=[],n=/"([^"]*)"/g,o=0,r;for(;r=n.exec(t);){let i=t.slice(o,r.index).trim();i&&e.push(i),e.push(r[1]),o=n.lastIndex}let s=t.slice(o).trim();return s&&e.push(s),e.join("")}function fn(t,e,n){let o=t.parentElement,r=o&&n?n.get(o):null;return r?{get(s,i){let a=e.get(s,i),c=r.get(i);return typeof c=="number"?Math.max(a,c):a},getStack(s,i){let a=e.getStack(s,i);if(!a.length)return a;let c=r.get(i);if(typeof c=="number"){let u=a.slice();return u[u.length-1]=Math.max(u[u.length-1],c),u}return a}}:e}function un(t,e,n){let o=new Map;function r(u){let l=[];if(!u||u==="none")return l;for(let d of String(u).split(",")){let f=d.trim().split(/\\s+/),p=f[0],m=Number.isFinite(Number(f[1]))?Number(f[1]):void 0;p&&l.push({name:p,num:m})}return l}let s=r(e?.counterReset),i=r(e?.counterSet),a=r(e?.counterIncrement);function c(u){if(o.has(u))return o.get(u).slice();let l=n.getStack(t,u);l=l.length?l.slice():[];let d=s.find(m=>m.name===u);if(d){let m=Number.isFinite(d.num)?d.num:0;l=l.length?[...l,m]:[m]}let f=i.find(m=>m.name===u);if(f){let m=Number.isFinite(f.num)?f.num:0;l.length===0&&(l=[0]),l[l.length-1]=m}let p=a.find(m=>m.name===u);if(p){let m=Number.isFinite(p.num)?p.num:1;l.length===0&&(l=[0]),l[l.length-1]+=m}return o.set(u,l.slice()),l}return{get(u,l){let d=c(l);return d.length?d[d.length-1]:0},getStack(u,l){return c(l)},__incs:a}}function Ts(t,e,n,o){let r;try{r=N(t,e)}catch{}let s=r?.content;if(!s||s==="none"||s==="normal")return{text:"",incs:[]};s=Rs(s);let i=fn(t,n,o),a=un(t,r,i),c=To(s)?No(s,t,a):s;return{text:$s(c),incs:a.__incs||[]}}async function Pe(t,e,n,o){if(t?.nodeType!==1||e?.nodeType!==1||t.tagName==="TEXTAREA")return;let r=t.ownerDocument||document;if(!Fs(r,n))return;n.__siblingCounters||(n.__siblingCounters=new WeakMap),n.__counterCtx||(n.__counterCtx=Es(t.ownerDocument||document,n));let s=n.__counterCtx;for(let a of["::before","::after","::first-letter"])try{let c=N(t,a);if(!c||c.content==="none"&&c.backgroundImage==="none"&&c.backgroundColor==="transparent"&&!Wo(c)&&(!c.transform||c.transform==="none")&&c.display==="inline")continue;if(a==="::first-letter"){let L=N(t),B=(L?.display||"").toLowerCase();if(B.includes("flex")||B.includes("grid"))continue;let D=bt=>c[bt]!==L[bt]&&(parseFloat(c[bt])||0)!==0;if(!(c.color!==L.color||c.fontSize!==L.fontSize||c.fontWeight!==L.fontWeight||c.fontFamily!==L.fontFamily||c.fontStyle!==L.fontStyle||c.textTransform!==L.textTransform||c.float!==L.float&&c.float!=="none"||D("paddingTop")||D("paddingRight")||D("paddingBottom")||D("paddingLeft")||D("marginTop")||D("marginRight")||D("marginBottom")||D("marginLeft")))continue;let q=Array.from(e.childNodes).find(bt=>bt.nodeType===Node.TEXT_NODE&&bt.textContent?.trim().length>0);if(!q)continue;let J=q.textContent,yt=J.match(/^([^\\p{L}\\p{N}\\s]*[\\p{L}\\p{N}](?:[\'\u2019])?)/u)?.[0],Nt=J.slice(yt?.length||0);if(!yt||/[\\uD800-\\uDFFF]/.test(yt))continue;let it=document.createElement("span");it.textContent=yt,it.dataset.snapdomPseudo="::first-letter";let Lt=we(c),It=Wt(Lt,"span");n.styleMap.set(it,It);let kt=document.createTextNode(Nt);e.replaceChild(kt,q),e.insertBefore(it,kt);continue}let l=c.content??"",d=l===""||l==="none"||l==="normal",{text:f,incs:p}=Ts(t,a,s,n.__siblingCounters),m=c.backgroundImage,h=c.backgroundColor,b=c.fontFamily,y=parseInt(c.fontSize)||32,w=parseInt(c.fontWeight)||!1,S=c.color||"#000",g=c.transform,x=dt(b),v=!d&&f!=="",k=m&&m!=="none",A=h&&h!=="transparent"&&h!=="rgba(0, 0, 0, 0)",M=Wo(c),F=g&&g!=="none",E=l!=="none"&&l!=="normal",$=E&&((parseFloat(c.width)||0)>0||(parseFloat(c.height)||0)>0),W=E&&c.boxShadow&&c.boxShadow!=="none",T=E&&c.outlineStyle&&c.outlineStyle!=="none"&&(parseFloat(c.outlineWidth)||0)>0;if(!(v||k||A||M||F||$||W||T)){if(p&&p.length&&t.parentElement){let L=n.__siblingCounters.get(t.parentElement)||new Map;for(let{name:B}of p){if(!B)continue;let D=fn(t,s,n.__siblingCounters),q=un(t,N(t,a),D).get(t,B);L.set(B,q)}n.__siblingCounters.set(t.parentElement,L)}continue}let O=f.startsWith("url(")||/^-?(?:webkit-)?image-set\\(/i.test(f),U=!1;if(v&&!x&&f.length>1&&!O){let L=N(t),B=parseFloat(L.fontSize)||16,D=parseFloat(L.lineHeight);Number.isFinite(D)||(D=B*1.5),t.getBoundingClientRect().height<D*1.6&&(e.style.whiteSpace="nowrap",U=!0)}let P=document.createElement("span");P.dataset.snapdomPseudo=a,P.style.pointerEvents="none",U&&(P.style.whiteSpace="nowrap");let z=we(c),j=(N(t).display||"").toLowerCase(),tt=j.includes("flex")||j.includes("grid");if(tt){let L=z["min-width"];(!L||L==="auto"||L==="0px")&&(z["min-width"]="0px")}let et=Wt(z,"span",v,tt);if(n.styleMap.set(P,et),x&&f&&f.length===1){let{dataUrl:L,width:B,height:D}=await So(f,b,w,y,S),V=document.createElement("img");V.src=L,V.style=`height:${y}px;width:${B/D*y}px;object-fit:contain;`,P.appendChild(V),e.dataset.snapdomHasIcon="true"}else if(f&&O){let L=Yt(f,typeof devicePixelRatio<"u"&&devicePixelRatio||1)??Et(f);if(L?.trim())try{let B=await G(St(L),{as:"dataURL",useProxy:o.useProxy});if(B?.ok&&typeof B.data=="string"){let D=document.createElement("img");D.src=B.data,D.style=`width:${y}px;height:auto;object-fit:contain;`,P.appendChild(D)}}catch(B){console.error(`[snapdom] Error in pseudo ${a} for`,t,B)}}else!x&&v&&(P.textContent=f);P.style.backgroundImage="none","maskImage"in P.style&&(P.style.maskImage="none"),"webkitMaskImage"in P.style&&(P.style.webkitMaskImage="none");try{P.style.backgroundRepeat=c.backgroundRepeat,P.style.backgroundSize=c.backgroundSize,c.backgroundPositionX&&c.backgroundPositionY?(P.style.backgroundPositionX=c.backgroundPositionX,P.style.backgroundPositionY=c.backgroundPositionY):P.style.backgroundPosition=c.backgroundPosition,P.style.backgroundOrigin=c.backgroundOrigin,P.style.backgroundClip=c.backgroundClip,P.style.backgroundAttachment=c.backgroundAttachment,P.style.backgroundBlendMode=c.backgroundBlendMode}catch{}if(k)try{let L=Ot(m),B=await Promise.all(L.map(Rt));P.style.backgroundImage=B.join(", ")}catch(L){console.warn(`[snapdom] Failed to inline background-image for ${a}`,L)}A&&(P.style.backgroundColor=h);let ft=P.childNodes.length>0||P.textContent?.trim()!==""||k||A||M||F||$||W||T;if(p&&p.length&&t.parentElement){let L=n.__siblingCounters.get(t.parentElement)||new Map,B=fn(t,s,n.__siblingCounters),D=un(t,N(t,a),B);for(let{name:V}of p){if(!V)continue;let q=D.get(t,V);L.set(V,q)}n.__siblingCounters.set(t.parentElement,L)}if(!ft)continue;a==="::before"?(e.dataset.snapdomHasBefore="1",e.insertBefore(P,e.firstChild)):(e.dataset.snapdomHasAfter="1",e.appendChild(P))}catch(c){console.warn(`[snapdom] Failed to capture ${a} for`,t,c)}let i=Array.from(e.children).filter(a=>!a.dataset.snapdomPseudo);if(n.nodeMap)for(let a of i){let c=n.nodeMap.get(a);c?.nodeType===1&&await Pe(c,a,n,o)}else{let a=Array.from(t.children);for(let c=0;c<Math.min(a.length,i.length);c++)await Pe(a[c],i[c],n,o)}}function Bo(t,e){if(!t||t?.nodeType!==1)return;let n=t.ownerDocument||document,o=e||n,r=t instanceof SVGSVGElement?[t]:Array.from(t.querySelectorAll("svg"));if(r.length===0)return;let s=/url\\(\\s*#([^)]+)\\)/g,i=["fill","stroke","filter","clip-path","mask","marker","marker-start","marker-mid","marker-end"],a=g=>window.CSS&&CSS.escape?CSS.escape(g):g.replace(/[^a-zA-Z0-9_-]/g,"\\\\$&"),c="http://www.w3.org/1999/xlink",u=g=>{if(!g||!g.getAttribute)return null;let x=g.getAttribute("href")||g.getAttribute("xlink:href")||(typeof g.getAttributeNS=="function"?g.getAttributeNS(c,"href"):null);if(x)return x;let v=g.attributes;if(!v)return null;for(let k=0;k<v.length;k++){let A=v[k];if(!A||!A.name)continue;if(A.name==="href")return A.value;let M=A.name.indexOf(":");if(M!==-1&&A.name.slice(M+1)==="href")return A.value}return null},l=new Set(Array.from(t.querySelectorAll("[id]")).map(g=>g.id)),d=new Set,f=!1,p=(g,x=null)=>{if(!g)return;s.lastIndex=0;let v;for(;v=s.exec(g);){f=!0;let k=(v[1]||"").trim();k&&(l.has(k)||(d.add(k),x&&!x.has(k)&&x.add(k)))}},m=g=>{let x=g.querySelectorAll("use");for(let A of x){let M=u(A);if(!M||!M.startsWith("#"))continue;f=!0;let F=M.slice(1).trim();F&&!l.has(F)&&d.add(F)}let v=\'*[style*="url("],*[fill^="url("], *[stroke^="url("],*[filter^="url("],*[clip-path^="url("],*[mask^="url("],*[marker^="url("],*[marker-start^="url("],*[marker-mid^="url("],*[marker-end^="url("]\';p(g.getAttribute("style")||"");for(let A of i)p(g.getAttribute(A));let k=g.querySelectorAll(v);for(let A of k){p(A.getAttribute("style")||"");for(let M of i)p(A.getAttribute(M))}};for(let g of r)m(g);if(!f)return;let h=t.querySelector("svg.inline-defs-container");h||(h=n.createElementNS("http://www.w3.org/2000/svg","svg"),h.classList.add("inline-defs-container"),h.setAttribute("aria-hidden","true"),h.setAttribute("style","position:absolute;width:0;height:0;overflow:hidden"),t.insertBefore(h,t.firstChild||null));let b=h.querySelector("defs")||null,y=g=>{if(!g||l.has(g))return null;let x=a(g),v=k=>{let A=o.querySelector(k);return A&&!t.contains(A)?A:null};return v(`svg defs > *#${x}`)||v(`svg > symbol#${x}`)||v(`*#${x}`)};if(!d.size)return;let w=new Set(d),S=new Set;for(;w.size;){let g=w.values().next().value;if(w.delete(g),!g||l.has(g)||S.has(g))continue;let x=y(g);if(!x){S.add(g);continue}b||(b=n.createElementNS("http://www.w3.org/2000/svg","defs"),h.appendChild(b));let v=x.cloneNode(!0);v.id||v.setAttribute("id",g),b.appendChild(v),S.add(g),l.add(g);let k=[v,...v.querySelectorAll("*")];for(let A of k){let M=u(A);if(M&&M.startsWith("#")){let E=M.slice(1).trim();E&&!l.has(E)&&!S.has(E)&&w.add(E)}let F=A.getAttribute?.("style")||"";F&&p(F,w);for(let E of i){let $=A.getAttribute?.(E);$&&p($,w)}}}}rt();function Uo(t){let e=getComputedStyle(t),n=e.outlineStyle,o=e.outlineWidth,r=e.borderStyle,s=e.borderWidth,i=n!=="none"&&parseFloat(o)>0,a=r==="none"||parseFloat(s)===0;if(i&&a){let c=t.style.border;return t.style.border=`${o} solid transparent`,()=>{t.style.border=c}}return()=>{}}function Do(t){let e=[];try{let n=t.querySelectorAll("*");for(let o of n){if(!(o instanceof HTMLElement))continue;let r=o.style.contentVisibility||"",s=getComputedStyle(o);(s.contentVisibility||s.getPropertyValue("content-visibility")||"")==="auto"&&(e.push({el:o,original:r}),o.style.contentVisibility="visible")}if(t instanceof HTMLElement){let o=getComputedStyle(t);(o.contentVisibility||o.getPropertyValue("content-visibility")||"")==="auto"&&(e.push({el:t,original:t.style.contentVisibility||""}),t.style.contentVisibility="visible")}}catch{}return()=>{for(let{el:n,original:o}of e)try{n.style.contentVisibility=o}catch{}}}at();Zt();function Ho(t){return Vo(t.boxShadow)}function zo(t){return Vo(t.textShadow)}function Vo(t){if(!t||t==="none")return{top:0,right:0,bottom:0,left:0};let e=[],n="",o=0;for(let c=0;c<t.length;c++){let u=t[c];u==="("?o++:u===")"&&(o=Math.max(0,o-1)),u===","&&o===0?(e.push(n),n=""):n+=u}n.trim()&&e.push(n);let r=0,s=0,i=0,a=0;for(let c of e){if(/\\binset\\b/i.test(c))continue;let u=c.match(/-?\\d+(\\.\\d+)?px/g)?.map(b=>parseFloat(b))||[];if(u.length<2)continue;let[l,d,f=0,p=0]=u,m=Math.abs(l)+f+p,h=Math.abs(d)+f+p;s=Math.max(s,m+Math.max(l,0)),a=Math.max(a,m+Math.max(-l,0)),i=Math.max(i,h+Math.max(d,0)),r=Math.max(r,h+Math.max(-d,0))}return{top:Math.ceil(r),right:Math.ceil(s),bottom:Math.ceil(i),left:Math.ceil(a)}}function jo(t){let e=t.filter&&t.filter!=="none"?t.filter:t.webkitFilter||"",n=/blur\\(\\s*([0-9.]+)px\\s*\\)/gi,o=0,r;for(;r=n.exec(e);)o+=parseFloat(r[1])||0;let s=Math.ceil(o);return{top:s,right:s,bottom:s,left:s}}function qo(t){if((t.outlineStyle||"none")==="none")return{top:0,right:0,bottom:0,left:0};let e=Math.ceil(parseFloat(t.outlineWidth||"0")||0),n=parseFloat(t.outlineOffset||"0")||0,o=e+Math.max(0,Math.ceil(n));return{top:o,right:o,bottom:o,left:o}}function Xo(t){let e=`${t.filter||""} ${t.webkitFilter||""}`.trim();if(!e||e==="none")return{bleed:{top:0,right:0,bottom:0,left:0},has:!1};let n=e.match(/drop-shadow\\((?:[^()]|\\([^()]*\\))*\\)/gi)||[],o=0,r=0,s=0,i=0,a=!1;for(let c of n){a=!0;let u=c.match(/-?\\d+(?:\\.\\d+)?px/gi)?.map(h=>parseFloat(h))||[],[l=0,d=0,f=0]=u,p=Math.abs(l)+f,m=Math.abs(d)+f;r=Math.max(r,p+Math.max(l,0)),i=Math.max(i,p+Math.max(-l,0)),s=Math.max(s,m+Math.max(d,0)),o=Math.max(o,m+Math.max(-d,0))}return{bleed:{top:R(o),right:R(r),bottom:R(s),left:R(i)},has:a}}function Go(t,e){if(!t||!e||!e.style)return null;let n=getComputedStyle(t);try{e.style.transformOrigin="0 0"}catch{}try{"translate"in e.style&&(e.style.translate="none"),"rotate"in e.style&&(e.style.rotate="none")}catch{}let o=n.transform||"none";if(!o||o==="none"){let a=null;try{a=Vt(t).scale}catch{}try{e.style.transform="none"}catch{}if(!a)return{a:1,b:0,c:0,d:1};let c=a.trim().split(/\\s+/).map(parseFloat),u=Number.isFinite(c[0])?c[0]:1,l=Number.isFinite(c[1])?c[1]:u;return{a:u,b:0,c:0,d:l}}function r(a,c,u,l){let d=Math.sqrt(a*a+c*c)||0,f=0,p=0;if(d>0){let m=a/d,h=c/d;f=m*u+h*l;let b=u-m*f,y=l-h*f;p=Math.sqrt(b*b+y*y)||0,p>0?f=f/p:f=0}return{a:d,b:0,c:f*p,d:p}}let s=o.match(/^matrix\\(\\s*([^)]+)\\)$/i);if(s){let a=s[1].split(",").map(c=>parseFloat(c.trim()));if(a.length===6&&a.every(Number.isFinite)){let[c,u,l,d]=a,f=r(c,u,l,d);try{e.style.transform=`matrix(${f.a}, ${f.b}, ${f.c}, ${f.d}, 0, 0)`}catch{}return f}}let i=o.match(/^matrix3d\\(\\s*([^)]+)\\)$/i);if(i){let a=i[1].split(",").map(c=>parseFloat(c.trim()));if(a.length===16&&a.every(Number.isFinite)){let c=a[0],u=a[1],l=a[4],d=a[5],f=r(c,u,l,d);try{e.style.transform=`matrix(${f.a}, ${f.b}, ${f.c}, ${f.d}, 0, 0)`}catch{}return f}}try{let a=new DOMMatrix(o),c=r(a.a,a.b,a.c,a.d);try{e.style.transform=`matrix(${c.a}, ${c.b}, ${c.c}, ${c.d}, 0, 0)`}catch{}return c}catch{return null}}function zt(t,e,n,o,r){let s=n.a,i=n.b,a=n.c,c=n.d,u=n.e||0,l=n.f||0;function d(y,w){let S=y-o,g=w-r,x=s*S+a*g,v=i*S+c*g;return x+=o+u,v+=r+l,[x,v]}let f=[d(0,0),d(t,0),d(0,e),d(t,e)],p=1/0,m=1/0,h=-1/0,b=-1/0;for(let[y,w]of f)y<p&&(p=y),w<m&&(m=w),y>h&&(h=y),w>b&&(b=w);return{minX:p,minY:m,maxX:h,maxY:b,width:h-p,height:b-m}}function re(t,e,n){let o=(t.transformOrigin||"0 0").trim().split(/\\s+/),[r,s]=[o[0]||"0",o[1]||"0"],i=(a,c)=>{let u=a.toLowerCase();return u==="left"||u==="top"?0:u==="center"?c/2:u==="right"||u==="bottom"?c:u.endsWith("px")?parseFloat(u)||0:u.endsWith("%")?(parseFloat(u)||0)*c/100:/^-?\\d+(\\.\\d+)?$/.test(u)&&parseFloat(u)||0};return{ox:i(r,e),oy:i(s,n)}}function Vt(t){let e={rotate:"0deg",scale:null,translate:null},n=typeof t.computedStyleMap=="function"?t.computedStyleMap():null;if(n){let r=c=>{try{return typeof n.has=="function"&&!n.has(c)||typeof n.get!="function"?null:n.get(c)}catch{return null}},s=r("rotate");if(s)if(s.angle){let c=s.angle;e.rotate=c.unit==="rad"?c.value*180/Math.PI+"deg":c.value+c.unit}else s.unit?e.rotate=s.unit==="rad"?s.value*180/Math.PI+"deg":s.value+s.unit:e.rotate=String(s);else{let c=getComputedStyle(t);e.rotate=c.rotate&&c.rotate!=="none"?c.rotate:"0deg"}let i=r("scale");if(i){let c="x"in i&&i.x?.value!=null?i.x.value:Array.isArray(i)?i[0]?.value:Number(i)||1,u="y"in i&&i.y?.value!=null?i.y.value:Array.isArray(i)?i[1]?.value:c;e.scale=`${c} ${u}`}else{let c=getComputedStyle(t);e.scale=c.scale&&c.scale!=="none"?c.scale:null}let a=r("translate");if(a){let c="x"in a&&"value"in a.x?a.x.value:Array.isArray(a)?a[0]?.value:0,u="y"in a&&"value"in a.y?a.y.value:Array.isArray(a)?a[1]?.value:0,l="x"in a&&a.x?.unit?a.x.unit:"px",d="y"in a&&a.y?.unit?a.y.unit:"px";e.translate=`${c}${l} ${u}${d}`}else{let c=getComputedStyle(t);e.translate=c.translate&&c.translate!=="none"?c.translate:null}return e}let o=getComputedStyle(t);return e.rotate=o.rotate&&o.rotate!=="none"?o.rotate:"0deg",e.scale=o.scale&&o.scale!=="none"?o.scale:null,e.translate=o.translate&&o.translate!=="none"?o.translate:null,e}var dn=null;function Ps(){if(dn)return dn;let t=document.createElement("div");return t.id="snapdom-measure-slot",t.setAttribute("aria-hidden","true"),Object.assign(t.style,{position:"absolute",left:"-99999px",top:"0px",width:"0px",height:"0px",overflow:"hidden",opacity:"0",pointerEvents:"none",contain:"size layout style"}),document.documentElement.appendChild(t),dn=t,t}function Yo(t){let e=Ps(),n=document.createElement("div");n.style.transformOrigin="0 0",t.baseTransform&&(n.style.transform=t.baseTransform),t.rotate&&(n.style.rotate=t.rotate),t.scale&&(n.style.scale=t.scale),t.translate&&(n.style.translate=t.translate),e.appendChild(n);let o=Ns(n);return e.removeChild(n),o}function Ko(t){let e=N(t),n=e.transform||"none";if(n!=="none"&&!/^matrix\\(\\s*1\\s*,\\s*0\\s*,\\s*0\\s*,\\s*1\\s*,\\s*0\\s*,\\s*0\\s*\\)$/i.test(n))return!0;let r=e.rotate&&e.rotate!=="none"&&e.rotate!=="0deg",s=e.scale&&e.scale!=="none"&&e.scale!=="1",i=e.translate&&e.translate!=="none"&&e.translate!=="0px 0px";return!!(r||s||i)}function Ns(t){let e=getComputedStyle(t).transform;if(!e||e==="none")return new DOMMatrix;try{return new DOMMatrix(e)}catch{return new WebKitCSSMatrix(e)}}var pn="http://www.w3.org/1999/xhtml",tr=new WeakSet;function Ne(t,e){if(!e)return null;let n=t.ownerDocument||document,o=n.defaultView||window,r,s,i,a;if(e==="viewport")r=0,s=0,i=n.documentElement?.clientWidth||o.innerWidth,a=n.documentElement?.clientHeight||o.innerHeight;else if(typeof e=="object")r=(Number(e.x)||0)-(o.scrollX||0),s=(Number(e.y)||0)-(o.scrollY||0),i=Number(e.width),a=Number(e.height);else return null;return i>0&&a>0?{left:r,top:s,width:i,height:a,right:r+i,bottom:s+a}:null}function hn(t){if(t.parentElement)return t.parentElement;let e=t.getRootNode&&t.getRootNode();return e instanceof ShadowRoot?e.host:null}function Ls(t,e){for(let n=e;n;n=hn(n))if(n===t)return!0;return!1}function Is(t,e){for(let n=hn(t);n&&n!==e&&n?.nodeType===1;n=hn(n)){let o=N(n);if(o.position!=="static"||o.transform&&o.transform!=="none"||o.filter&&o.filter!=="none"||o.backdropFilter&&o.backdropFilter!=="none"||o.perspective&&o.perspective!=="none"||/transform|perspective|filter/.test(o.willChange||"")||/layout|paint|strict|content/.test(o.contain||""))return n}return null}function gn(t,e){try{let n=new DOMMatrix;if(e&&e.rotate&&e.rotate!=="0deg"&&(n=n.multiply(new DOMMatrix(`rotate(${e.rotate})`))),e&&e.scale){let o=String(e.scale).trim().split(/\\s+/).filter(Boolean);o.length&&o.every(r=>Number.isFinite(Number(r)))&&(n=n.multiply(new DOMMatrix(`scale(${o.join(",")})`)))}return t&&(n=n.multiply(new DOMMatrix(t))),n}catch{return null}}function er(t,e,n,o,r){let s=t.getBoundingClientRect();e?.nodeType===1&&e.namespaceURI===pn&&N(t).position==="static"&&(e.style.position="relative");let i=[];for(let[a,c]of n){if(a?.nodeType!==1||a.namespaceURI!==pn||c?.nodeType!==1||c===t||!Ls(t,c))continue;let u=o.get(c)||N(c),l=u.position;if(l!=="fixed"&&l!=="sticky"&&l!=="-webkit-sticky"||a.style.position==="absolute")continue;let d=c.getBoundingClientRect();if(!(d.width>0&&d.height>0))continue;tr.add(a);let f=u.transform&&u.transform!=="none"?u.transform:"",p=Vt(c),m=!!(f||p.rotate!=="0deg"||p.scale||p.translate),h=m?gn(f,p):null,b=!h||!h.is2D||h.a===1&&h.b===0&&h.c===0&&h.d===1,y=d.width,w=d.height;b||(y=c.offsetWidth||d.width,w=c.offsetHeight||d.height);let S=c.getRootNode&&c.getRootNode()instanceof ShadowRoot,g=s,x=t.clientLeft||0,v=t.clientTop||0;if(S){let E=Is(c,t);E&&(g=E.getBoundingClientRect(),x=E.clientLeft||0,v=E.clientTop||0)}let k=d.left-g.left-x,A=d.top-g.top-v;if(m)if(a.style.translate="none",a.style.rotate="none",a.style.scale="none",b)a.style.transform="none";else{a.style.transform=`matrix(${h.a},${h.b},${h.c},${h.d},0,0)`;let{ox:E,oy:$}=re(u,y,w),W=zt(y,w,{a:h.a,b:h.b,c:h.c,d:h.d,e:0,f:0},E,$);k-=W.minX,A-=W.minY}if(l!=="fixed"){let E=a.cloneNode(!1);E.setAttribute("data-snap-ph","1"),E.style.position="static",E.style.visibility="hidden",E.style.width=`${y}px`,E.style.height=`${w}px`,E.style.boxSizing="border-box",a.parentElement?.insertBefore(E,a)}let M=y+2,F=w;r&&(Math.abs(A-r.y)<.5&&(A-=1,F+=1),Math.abs(k-r.x)<.5&&(k-=1,M+=1)),a.style.position="absolute",a.style.left=`${k}px`,a.style.top=`${A}px`,a.style.right="auto",a.style.bottom="auto",a.style.margin="0",a.style.width=`${M}px`,a.style.height=`${F}px`,a.style.boxSizing="border-box",S||i.push(a)}for(let a of i)e.appendChild(a)}function nr(t,e,n={}){if(!t||!e||!e.style)return;let o=getComputedStyle(t);try{e.style.boxShadow="none"}catch(i){_(n,"stripRootShadows boxShadow",i)}try{e.style.textShadow="none"}catch(i){_(n,"stripRootShadows textShadow",i)}try{e.style.outline="none"}catch(i){_(n,"stripRootShadows outline",i)}let s=(o.filter||"").replace(/\\bdrop-shadow\\((?:[^()]|\\([^()]*\\))*\\)\\s*/gi,"").trim().replace(/\\s+/g," ");try{e.style.filter=s.length?s:"none"}catch(i){_(n,"stripRootShadows filter",i)}}function or(t,e){if(!t||!e||!e.style)return;let n=1;try{n=parseFloat(getComputedStyle(t).zoom)}catch{return}if(!(!e.style.getPropertyValue("zoom")&&(!Number.isFinite(n)||n===1)))try{e.style.setProperty("zoom","1","important")}catch{}}function Qo(t){let e=t.display||"";if(e.includes("flex")||e.includes("grid")||e.startsWith("table")||e==="inline-block"||e==="flow-root"||t.position==="absolute"||t.position==="fixed"||t.float&&t.float!=="none")return!0;let n=t.overflowX||t.overflow||"visible",o=t.overflowY||t.overflow||"visible";return!!(n!=="visible"||o!=="visible"||t.contain&&/\\b(layout|content|paint|strict)\\b/.test(t.contain))}function _s(t,e){let n=Array.from(t.childNodes),o=e==="top"?n:n.reverse();for(let r of o){if(r.nodeType===Node.TEXT_NODE){if(/\\S/.test(r.textContent||""))return null;continue}if(r.nodeType!==Node.ELEMENT_NODE)continue;let s=getComputedStyle(r),i=String(s.display||"");if(!(i==="none"||i==="contents")&&!(s.position==="absolute"||s.position==="fixed"))return s.float&&s.float!=="none"||i.startsWith("inline")?null:r}return null}function rr(t,e,n){if(!t||!e||!e.style)return;let o=getComputedStyle(t);if(!Qo(o))for(let r of["top","bottom"]){let s=r==="top"?"Top":"Bottom";if((parseFloat(o[`border${s}Width`])||0)>0||(parseFloat(o[`padding${s}`])||0)>0)continue;let i=t,a=e;for(;i&&a;){let c=_s(i,r);if(!c)break;let u=n?Array.from(a.children).find(f=>n.get(f)===c)||null:a.children[Array.from(i.children).indexOf(c)]||null,l=getComputedStyle(c),d=parseFloat(l[`margin${s}`])||0;if(u&&u.style&&d>0&&(u.style[`margin${s}`]="0px"),Qo(l)||(parseFloat(l[`border${s}Width`])||0)>0||(parseFloat(l[`padding${s}`])||0)>0)break;i=c,a=u}}}function Ws(t){let e=document.createTreeWalker(t,NodeFilter.SHOW_COMMENT),n=[];for(;e.nextNode();)n.push(e.currentNode);for(let o of n)o.remove()}function Os(t,e={}){let{stripFrameworkDirectives:n=!0}=e,o=new Set(["xml","xlink"]),r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;r.nextNode();){let s=r.currentNode;for(let i of Array.from(s.attributes)){let a=i.name;if(a.startsWith("*")){s.removeAttribute(a);continue}if(a.includes("@")){s.removeAttribute(a);continue}if(a.includes(":")){let c=a.split(":",1)[0];if(!o.has(c)){s.removeAttribute(a);continue}}if(n&&(a.startsWith("x-")||a.startsWith("v-")||a.startsWith(":")||a.startsWith("on:")||a.startsWith("bind:")||a.startsWith("let:")||a.startsWith("class:"))){s.removeAttribute(a);continue}}}}var Zo=/[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\uFFFE\\uFFFF]/g;function Bs(t){if(!t)return;let e=r=>{if(r.nodeType===Node.ELEMENT_NODE){if(r.attributes)for(let s of Array.from(r.attributes)){let i=s.value.replace(Zo,"");if(i!==s.value)try{r.setAttribute(s.name,i)}catch{}}}else if(r.nodeType===Node.TEXT_NODE||r.nodeType===Node.CDATA_SECTION_NODE){let s=r.data.replace(Zo,"");s!==r.data&&(r.data=s)}};e(t);let n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT),o;for(;o=n.nextNode();)e(o)}function ir(t,e={}){t&&(Os(t,e),Ws(t),Bs(t))}function Us(t){try{let e=t.getAttribute?.("style")||"";return/\\b(height|width|block-size|inline-size)\\s*:/.test(e)}catch{return!1}}function Ds(t){return t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof HTMLIFrameElement||t instanceof SVGElement||t instanceof HTMLObjectElement||t instanceof HTMLEmbedElement}function Hs(t,e){if(t?.nodeType!==1||Us(t)||Ds(t))return!1;let n=e.position;if(n==="absolute"||n==="fixed"||n==="sticky")return!1;let o=e.display||"";return!(o.includes("flex")||o.includes("grid")||o.startsWith("table")||e.transform&&e.transform!=="none")}function sr(t,e,n=new Map){function o(r,s){if(r?.nodeType!==1||s?.nodeType!==1)return;let i=r.childElementCount>s.childElementCount,a=n.get(r)||getComputedStyle(r);if(n.has(r)||n.set(r,a),i&&Hs(r,a)){s.style.height||(s.style.height="auto"),s.style.width||(s.style.width="auto"),s.style.removeProperty("block-size"),s.style.removeProperty("inline-size"),s.style.minHeight||(s.style.minHeight="0"),s.style.minWidth||(s.style.minWidth="0"),s.style.maxHeight||(s.style.maxHeight="none"),s.style.maxWidth||(s.style.maxWidth="none");let l=a.overflowY||a.overflowBlock||"visible",d=a.overflowX||a.overflowInline||"visible";(l!=="visible"||d!=="visible")&&(s.style.overflow="visible")}let c=Array.from(r.children),u=Array.from(s.children);for(let l=0;l<Math.min(c.length,u.length);l++)o(c[l],u[l])}o(t,e)}function zs(t){let e=getComputedStyle(t);return!(e.display==="none"||e.position==="absolute"||e.position==="fixed")}function Vs(t,e){if(t?.nodeType!==1)return!1;if(t.getAttribute("data-capture")==="exclude"&&e?.excludeMode==="remove")return!0;if(Array.isArray(e?.exclude))for(let n of e.exclude)try{if(t.matches(n))return e.excludeMode==="remove"}catch(o){_(e,"exclude selector match failed",o)}if(typeof e?.filter=="function"&&e.filterMode==="remove")try{if(!e.filter(t))return!0}catch(n){_(e,"filter function failed",n)}return!1}function ar(t,e){let n=getComputedStyle(t),o=t.getBoundingClientRect(),r=1/0,s=-1/0,i=!1,a=Array.from(t.children);for(let p of a){if(Vs(p,e)||!zs(p))continue;let m=p.getBoundingClientRect(),h=m.top-o.top,b=m.bottom-o.top;b<=h||(h<r&&(r=h),b>s&&(s=b),i=!0)}let c=i?Math.max(0,s-r):0,u=parseFloat(n.borderTopWidth)||0,l=parseFloat(n.borderBottomWidth)||0,d=parseFloat(n.paddingTop)||0,f=parseFloat(n.paddingBottom)||0;return u+l+d+f+c}var R=(t,e=3)=>Number.isFinite(t)?Math.round(t*10**e)/10**e:t,jt=.75;function cr(t,e,n,o,r,s){let i=t.ownerDocument||document,a=t.getBoundingClientRect(),c=r>0&&a.width>0?a.width/r:1,u=s>0&&a.height>0?a.height/s:1;if(Math.abs(c-u)>.02)return 0;let l=i.createElement("div");l.setAttribute("data-snapdom-internal",""),l.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;width:"+r+"px!important;overflow:visible!important;visibility:hidden!important;";let d=l.attachShadow({mode:"open"}),f=i.createElement("style");f.textContent=n,d.appendChild(f);let p=e.cloneNode(!0);d.appendChild(p),i.body.appendChild(l);let m=0,h=(b,y,w)=>{let S=N(b),g=S.boxSizing==="border-box",x=(v,k,...A)=>{let M=parseFloat(v);if(!Number.isFinite(M))return k;let F=M+(g?0:A.reduce((E,$)=>E+(parseFloat($)||0),0));return Math.abs(F-k)<=.51?F:k};return{width:x(S.width,y,S.paddingLeft,S.paddingRight,S.borderLeftWidth,S.borderRightWidth),height:x(S.height,w,S.paddingTop,S.paddingBottom,S.borderTopWidth,S.borderBottomWidth)}};try{let b=p.getBoundingClientRect(),y=p.offsetWidth||r,w=p.offsetHeight||s,S=y>0&&b.width>0?b.width/y:1,g=w>0&&b.height>0?b.height/w:1,x=(v,k,A=!1)=>{let M=v.children,F=k.children,E=Math.min(M.length,F.length);for(let $=0;$<E;$++){let W=M[$],T=F[$],I=o.get(W),O=A||tr.has(W);if(I?.nodeType===1&&W?.namespaceURI===pn&&W.style&&I.isConnected){let U=I.getBoundingClientRect();if(U.width>0&&U.height>0){let P=T.getBoundingClientRect(),z=U.width/c,j=U.height/u,tt=P.width,et=P.height,pt=I.offsetWidth||z,ft=I.offsetHeight||j,L=T.offsetWidth||tt,B=T.offsetHeight||et,D=Math.abs(z-pt)>jt||Math.abs(j-ft)>jt||Math.abs(tt-L)>jt||Math.abs(et-B)>jt;if(O){let J=h(T,L,B);z=tt>0?z*S*J.width/tt:z,j=et>0?j*g*J.height/et:j,tt=J.width,et=J.height}else if(D){let J=h(I,pt,ft),ht=h(T,L,B);z=J.width,j=J.height,tt=ht.width,et=ht.height}let V=tt-z,q=et-j;(Math.abs(V)>jt||Math.abs(q)>jt)&&(W.style.boxSizing="border-box",W.style.width=`${R(z)}px`,W.style.height=`${R(j)}px`,m++)}}x(W,T,O)}};x(e,p)}finally{l.remove()}return m}var js=/::-webkit-scrollbar(-[a-z]+)?\\b/i;function mn(t,e=new Set){let n="";if(!t)return n;for(let o=0;o<t.length;o++){let r=t[o];try{if(r.type===CSSRule.IMPORT_RULE&&r.styleSheet){n+=mn(r.styleSheet.cssRules,e);continue}if(r.type===CSSRule.MEDIA_RULE&&r.cssRules){let s=mn(r.cssRules,e);s&&(n+=`@media ${r.conditionText}{${s}}`);continue}if(r.type===CSSRule.STYLE_RULE){let s=r.selectorText||"";if(js.test(s)){let i=r.cssText;i&&!e.has(i)&&(e.add(i),n+=i)}}}catch{}}return n}var Jo=new WeakMap;function qs(t){let e="";for(let n of t.styleSheets){let o=-1;try{o=n.cssRules?n.cssRules.length:-1}catch{}e+=(n.href||"inline")+":"+o+"|"}return e}function lr(t){if(!t||!t.styleSheets)return"";let e=qs(t),n=Jo.get(t);if(n&&n.fp===e)return n.css;let o=new Set,r="";for(let s of Array.from(t.styleSheets))try{let i=s.cssRules;i&&(r+=mn(i,o))}catch{}return Jo.set(t,{fp:e,css:r}),r}Ct();var Le=new Set;async function fr(t,e={}){let n=e.__session||C.session,o={styleMap:n.styleMap,styleCache:n.styleCache,nodeMap:n.nodeMap,options:e},r=null;if(e.clip){let f=Ne(t,e.clip);if(f){o.clip={rect:f,root:t};let p=t.getBoundingClientRect();r={x:f.left-p.left,y:f.top-p.top,width:f.width,height:f.height}}}let s,i="",a="";if(Le.size){let f=(p,m)=>{for(let h=m;h;h=h.assignedSlot||h.parentElement||h.getRootNode()?.host)if(h===p)return!0;return!1};for(;;){let p=[...Le].filter(({root:m})=>f(m,t)||f(t,m)).map(({promise:m})=>m.catch(()=>{}));if(!p.length)break;await Promise.all(p)}}if(!o.clip&&t.isConnected&&t.ownerDocument?.visibilityState!=="hidden")try{let f=t.getBoundingClientRect(),p=t.ownerDocument?.defaultView||window,m=f.right<=0||f.bottom<=0||f.left>=p.innerWidth||f.top>=p.innerHeight,h=[];if(m&&(()=>{let y=[];t.shadowRoot&&y.push(t.shadowRoot);for(let w of t.querySelectorAll("*"))w.shadowRoot&&y.push(w.shadowRoot);for(;y.length;){let w=y.pop(),S=w.host?.localName==="calcite-icon";for(let g of w.querySelectorAll("*")){if(g.shadowRoot&&y.push(g.shadowRoot),!S||g.localName!=="svg")continue;let x=g.querySelectorAll("path");if(!x.length||[...x].some(k=>k.getAttribute("d")?.trim()))continue;let v=g.getBoundingClientRect();v.width&&v.height&&h.push(g)}}})(),h.length){let y=(async()=>{let S=t.style,g=t.hasAttribute("style"),x=new Map,v=(k,A)=>{x.has(k)||x.set(k,{value:S.getPropertyValue(k),priority:S.getPropertyPriority(k)}),S.setProperty(k,A,"important");let M=x.get(k);M.forcedValue=S.getPropertyValue(k),M.forcedPriority=S.getPropertyPriority(k)};try{v("left","0"),v("top","0"),v("right","auto"),v("bottom","auto"),v("margin-top","0"),v("margin-right","0"),v("margin-bottom","0"),v("margin-left","0"),v("transform","none"),v("translate","none"),v("opacity","0"),v("pointer-events","none");let k=t.getBoundingClientRect();if(k.right<=0||k.bottom<=0||k.left>=p.innerWidth||k.top>=p.innerHeight){let F=t.parentElement?.getBoundingClientRect(),E=F&&F.right>0&&F.left<p.innerWidth?Math.max(0,F.left):0,$=F&&F.bottom>0&&F.top<p.innerHeight?Math.max(0,F.top):0;v("position","fixed"),v("left",`${E}px`),v("top",`${$}px`)}await mt(100);let A=Date.now()+1500,M=()=>h.some(F=>{if([...F.querySelectorAll("path")].some($=>$.getAttribute("d")?.trim()))return!1;let E=F.getBoundingClientRect();return E.width&&E.height&&E.right>0&&E.bottom>0&&E.left<p.innerWidth&&E.top<p.innerHeight});for(;Date.now()<A&&M();)await new Promise(F=>setTimeout(F,25));await mt(100)}finally{for(let[k,A]of x)S.getPropertyValue(k)!==A.forcedValue||S.getPropertyPriority(k)!==A.forcedPriority||(A.value?S.setProperty(k,A.value,A.priority):S.removeProperty(k));!g&&!S.length&&t.removeAttribute("style"),await mt(100)}})(),w={root:t,promise:y};Le.add(w);try{await y}finally{Le.delete(w)}}}catch{}let c=Uo(t),u=o.clip?()=>{}:Do(t);try{s=await ne(t,o,e)}catch(f){throw console.warn("deepClone failed:",f),f}finally{u(),c()}try{Bo(s)}catch(f){console.warn("inlineExternal defs or symbol failed:",f)}try{await Pe(t,s,o,e)}catch(f){console.warn("inlinePseudoElements failed:",f)}await lo(s,o);try{let f=s.querySelectorAll("style[data-sd]");for(let p of f)a+=p.textContent||"",p.remove()}catch(f){_(o,"Failed to extract shadow CSS from style[data-sd]",f)}let l=Ge(o.styleMap);i=Array.from(l.entries()).map(([f,p])=>`.${p}{${f}}`).join(""),i=a+"[data-snapdom-has-after]::after,[data-snapdom-has-before]::before{content:none!important;display:none!important}"+i;for(let[f,p]of o.styleMap.entries()){if(f.tagName==="STYLE")continue;if(f.getRootNode&&f.getRootNode()instanceof ShadowRoot){f.setAttribute("style",p.replace(/;/g,"; "));continue}let m=l.get(p);m&&f.classList.add(m);let h=f.style?.backgroundImage,b=f.dataset?.snapdomHasIcon;h&&h!=="none"&&(f.style.backgroundImage=h),b&&(f.style.verticalAlign="middle",f.style.display="inline")}if((o.clip||t.scrollTop||t.scrollLeft)&&s?.nodeType===1)try{let f=o.clip&&r?{x:r.x,y:r.y}:{x:0,y:0};er(t,s,o.nodeMap,o.styleCache,f)}catch(f){_(o,"freezeViewportPositioned failed",f)}for(let[f,p]of o.nodeMap.entries()){if(o.clip&&p===t)continue;let m=p.scrollLeft,h=p.scrollTop;if((m||h)&&f?.nodeType===1&&f.namespaceURI==="http://www.w3.org/1999/xhtml"){f.style.overflow="hidden",f.style.scrollbarWidth="none",f.style.msOverflowStyle="none";try{let w=f.querySelectorAll("*");for(let S of w){if(S.nodeType!==1||S.namespaceURI!=="http://www.w3.org/1999/xhtml")continue;let g=S.style.position;if(g==="fixed"||g==="absolute"){let x=parseFloat(S.style.top)||0,v=parseFloat(S.style.left)||0;S.style.top=`${x+h}px`,S.style.left=`${v+m}px`,g==="fixed"&&(S.style.position="absolute")}}}catch{}let y=document.createElement("div");for(y.style.all="unset",y.style.transform=`translate(${-m}px, ${-h}px)`,y.style.willChange="transform",y.style.display="inline-block",y.style.width="100%";f.firstChild;)y.appendChild(f.firstChild);f.appendChild(y)}}if(t===o.nodeMap.get(s)){let f=o.styleCache.get(t)||N(t);o.styleCache.set(t,f);let p=De(f.transform);s.style.margin="0",s.style.top="auto",s.style.left="auto",s.style.right="auto",s.style.bottom="auto",s.style.animation="none",s.style.transition="none",s.style.willChange="auto",s.style.float="none",s.style.clear="none",s.style.transform=p||""}for(let[f,p]of o.nodeMap.entries())p.tagName==="PRE"&&(f.style.marginTop="0",f.style.marginBlockStart="0");return{clone:s,classCSS:i,styleCache:o.styleCache,nodeMap:o.nodeMap,reconcileRisk:o.reconcileRisk||0,clipWindow:r}}vt();rt();var ur="http://www.w3.org/1999/xlink";function Xs(t){return t.getAttribute("href")||t.getAttribute("xlink:href")||(typeof t.getAttributeNS=="function"?t.getAttributeNS(ur,"href"):null)}function Gs(t){let e=parseInt(t.dataset?.snapdomWidth||"",10)||0,n=parseInt(t.dataset?.snapdomHeight||"",10)||0,o=parseInt(t.getAttribute("width")||"",10)||0,r=parseInt(t.getAttribute("height")||"",10)||0,s=parseFloat(t.style?.width||"")||0,i=parseFloat(t.style?.height||"")||0,a=e||s||o||t.width||t.naturalWidth||100,c=n||i||r||t.height||t.naturalHeight||100;return{width:a,height:c}}async function dr(t,e={}){let n=Array.from(t.querySelectorAll("img"));t.tagName==="IMG"&&n.unshift(t);let o=async a=>{if(!a.getAttribute("src")){let m=a.currentSrc||a.src||Bt(a.getAttribute("srcset"),a)||"";m&&a.setAttribute("src",m)}a.removeAttribute("srcset"),a.removeAttribute("sizes");let c=a.src||"";if(!c)return;let u=C.image?.get(c);if(u){a.src=u,a.width||(a.width=a.naturalWidth||100),a.height||(a.height=a.naturalHeight||100);return}let l=await G(c,{as:"dataURL",useProxy:e.useProxy});if(l.ok&&typeof l.data=="string"&&l.data.startsWith("data:")){C.image?.set(c,l.data),a.src=l.data,a.width||(a.width=a.naturalWidth||100),a.height||(a.height=a.naturalHeight||100);return}let{width:d,height:f}=Gs(a),{fallbackURL:p}=e||{};if(p)try{let m=typeof p=="function"?await p({width:d,height:f,src:c,element:a}):p;if(m){let h=await G(m,{as:"dataURL",useProxy:e.useProxy});if(h?.ok&&typeof h.data=="string"){a.src=h.data,a.width||(a.width=d),a.height||(a.height=f);return}}}catch{}if(e.placeholders!==!1){let m=document.createElement("div");m.style.cssText=[`width:${d}px`,`height:${f}px`,"background:#ccc","display:inline-block","text-align:center",`line-height:${f}px`,"color:#666","font-size:12px","overflow:hidden"].join(";"),m.textContent="img",a.replaceWith(m)}else{let m=document.createElement("div");m.style.cssText=`display:inline-block;width:${d}px;height:${f}px;visibility:hidden;`,a.replaceWith(m)}},r=6;for(let a=0;a<n.length;a+=r){let c=n.slice(a,a+r).map(o);await Promise.allSettled(c)}let s=Array.from(t.querySelectorAll("image"));t.localName==="image"&&s.unshift(t);let i=async a=>{let c=Xs(a);if(!c||c.startsWith("data:")||c.startsWith("blob:"))return;let u=await G(c,{as:"dataURL",useProxy:e.useProxy});u.ok&&typeof u.data=="string"&&u.data.startsWith("data:")&&(a.setAttribute("href",u.data),a.removeAttribute("xlink:href"),typeof a.removeAttributeNS=="function"&&a.removeAttributeNS(ur,"href"))};for(let a=0;a<s.length;a+=r){let c=s.slice(a,a+r).map(i);await Promise.allSettled(c)}}at();rt();var yn=["background-image","mask","mask-image","-webkit-mask","-webkit-mask-image","mask-source","mask-box-image-source","mask-border-source","-webkit-mask-box-image-source","border-image","border-image-source"],Ys=["mask-position","mask-size","mask-repeat","mask-mode","mask-composite","-webkit-mask-position","-webkit-mask-size","-webkit-mask-repeat","-webkit-mask-composite","mask-origin","mask-clip","-webkit-mask-origin","-webkit-mask-clip","-webkit-mask-position-x","-webkit-mask-position-y"],Ks=["background-position","background-position-x","background-position-y","background-size","background-repeat","background-origin","background-clip","background-attachment","background-blend-mode"],Qs=["border-image-slice","border-image-width","border-image-outset","border-image-repeat"];async function Zs(t,e,n,o){let r=n.get(t)||N(t);n.has(t)||n.set(t,r);let s=r.getPropertyValue("border-image"),i=r.getPropertyValue("border-image-source"),a=s&&s!=="none"||i&&i!=="none",c=r.getPropertyValue("background-image"),u=r.getPropertyValue("background-color");if(c&&c!=="none"||u&&u!=="rgba(0, 0, 0, 0)"&&u!=="transparent"||/url\\s*\\(|gradient\\s*\\(/i.test(r.getPropertyValue("background")||""))for(let d of Ks){let f=r.getPropertyValue(d);f&&e.style.setProperty(d,f)}for(let d of yn){let f=r.getPropertyValue(d);if(d==="background-image"&&(!f||f==="none")){let h=r.getPropertyValue("background");h&&/url\\s*\\(/.test(h)&&(f=Ot(h).filter(b=>/url\\s*\\(/.test(b)).join(", ")||f)}if(!f||f==="none")continue;let p=Ot(f),m=await Promise.all(p.map(h=>Rt(h,o)));m.some(h=>h&&h!=="none"&&!/^url\\(undefined/.test(h))&&e.style.setProperty(d,m.join(", "))}for(let d of Ys){let f=r.getPropertyValue(d);!f||f==="initial"||e.style.setProperty(d,f)}if(a)for(let d of Qs){let f=r.getPropertyValue(d);!f||f==="initial"||e.style.setProperty(d,f)}}async function pr(t,e,n,o={},r=C.session.nodeMap){if(!e)return;let s=[];t&&tn(t)&&s.push([t,e]);let i=[e];for(;i.length;){let c=i.pop();if(c.children)for(let u of c.children){if(u.tagName==="STYLE")continue;let l=r.get(u);l&&tn(l)&&s.push([l,u]),i.push(u)}}let a=6;for(let c=0;c<s.length;c+=a)await Promise.allSettled(s.slice(c,c+a).map(([u,l])=>Zs(u,l,n,o)))}rt();at();function mr(t,e,n=C.session.nodeMap){let o=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(let a=r.currentNode;a;a=r.nextNode()){let c=n.get(a);if(c?.nodeType!==1)continue;let u=N(c),l=u.getPropertyValue("backdrop-filter")||u.getPropertyValue("-webkit-backdrop-filter");l&&l!=="none"&&a!==e&&o.push({cloneEl:a,orig:c,bf:l,path:ea(e,a)})}if(!o.length)return;let s=t.getBoundingClientRect(),i=o.map((a,c)=>{let u=e.cloneNode(!0);ta(u,e,a.orig.getBoundingClientRect(),n),na(hr(u,a.path));for(let l=0;l<c;l++){let d=hr(u,o[l].path);d&&(d.style.setProperty("backdrop-filter","none","important"),d.style.setProperty("-webkit-backdrop-filter","none","important"))}return{...a,copy:u}});for(let{cloneEl:a,orig:c,bf:u,copy:l}of i)Js(a,c,u,l,s)}function Js(t,e,n,o,r){let s=e.getBoundingClientRect();if(!s.width||!s.height)return;let i=N(e),a=e.offsetWidth?s.width/e.offsetWidth:1,c=Math.abs(a-1)>.001?1/a:1;o.style.position="absolute",o.style.left=`${(r.left-s.left)*c}px`,o.style.top=`${(r.top-s.top)*c}px`,o.style.width=`${r.width}px`,o.style.height=`${r.height}px`,o.style.margin="0",o.style.filter=n,c!==1&&(o.style.transform=`scale(${c})`,o.style.transformOrigin="top left");let u=document.createElement("div");u.style.cssText="position:absolute;inset:0;overflow:hidden;border-radius:inherit;z-index:-2",u.appendChild(o);let l=document.createElement("div");l.style.cssText="position:absolute;inset:0;border-radius:inherit;z-index:-1",l.style.backgroundColor=i.backgroundColor,l.style.backgroundImage=t.style.backgroundImage||i.backgroundImage;for(let d of["background-size","background-position","background-repeat","background-origin","background-clip"])l.style.setProperty(d,i.getPropertyValue(d));t.style.setProperty("background-color","transparent","important"),t.style.setProperty("background-image","none","important"),t.style.setProperty("backdrop-filter","none","important"),t.style.setProperty("-webkit-backdrop-filter","none","important"),i.position==="static"&&(t.style.position="relative"),t.style.isolation="isolate",t.prepend(l),t.prepend(u)}var Ie=128;function ta(t,e,n,o){let r=[[t,e]];for(;r.length;){let[s,i]=r.pop(),a=o.get(i);if(a?.nodeType===1){let l=a.getBoundingClientRect();(l.left>n.right+Ie||l.right<n.left-Ie||l.top>n.bottom+Ie||l.bottom<n.top-Ie)&&(s.tagName==="IMG"&&s.setAttribute("src","data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA="),s.style&&(s.style.backgroundImage="none"))}let c=s.children,u=i.children;for(let l=0;l<c.length;l++)r.push([c[l],u[l]])}}function ea(t,e){let n=[];for(let o=e;o!==t;o=o.parentElement){if(!o?.parentElement)return null;n.push([...o.parentElement.children].indexOf(o))}return n.reverse()}function hr(t,e){if(!e)return null;let n=t;for(let o of e)if(n=n.children[o],!n)return null;return n}function na(t){if(t)for(let e=t;e&&e.parentNode;){let n=e.parentNode;for(;e.nextSibling;)e.nextSibling.remove();e===t&&e.remove(),e=n}}at();rt();function gr(t,e){if(!t)return()=>{};let n=[],o=200;function r(s){if(e){let u=s.getBoundingClientRect();if(u.width>0||u.height>0){let l=Math.max(u.right,u.left+(s.scrollWidth||0)),d=Math.max(u.bottom,u.top+(s.scrollHeight||0));if(l<e.left-o||u.left>e.right+o||d<e.top-o||u.top>e.bottom+o)return}}let i=getComputedStyle(s),a=oa(s,i);a&&n.push(a);let c=ra(s,i);c&&n.push(c);for(let u of s.children||[])r(u)}return r(t),()=>n.forEach(s=>s())}function oa(t,e){if(!t)return()=>{};e=e||getComputedStyle(t);let n=ia(e);if(n<=0)return()=>{};if(!br(t))return()=>{};let o=yr(t),r=o.text,s=aa(e);o.write("X");let i=t.scrollHeight-s;o.restore();let a=i>0?i:sa(e),c=Math.round(a*n+s);if(t.scrollHeight<=c+.5)return()=>{};let u=0,l=r.length,d=-1;for(;u<=l;){let f=u+l>>1;o.write(r.slice(0,f)+"\\u2026"),t.scrollHeight<=c+.5?(d=f,u=f+1):l=f-1}return o.write((d>=0?r.slice(0,d):"")+"\\u2026"),()=>{o.restore()}}function ra(t,e){if(!t)return()=>{};if(e=e||getComputedStyle(t),e.textOverflow!=="ellipsis")return()=>{};if(e.whiteSpace!=="nowrap"&&e.whiteSpace!=="pre")return()=>{};if(e.overflowX!=="hidden"&&e.overflowX!=="clip")return()=>{};if(!br(t))return()=>{};if(t.scrollWidth<=t.clientWidth+.5)return()=>{};let n=yr(t),o=n.text,r=0,s=o.length,i=-1;for(;r<=s;){let a=r+s>>1;n.write(o.slice(0,a)+"\\u2026"),t.scrollWidth<=t.clientWidth+.5?(i=a,r=a+1):s=a-1}return n.write((i>=0?o.slice(0,i):"")+"\\u2026"),()=>{n.restore()}}function yr(t){let e=[];for(let o=t.firstChild;o;o=o.nextSibling)o.nodeType===Node.TEXT_NODE&&e.push(o);let n=e.map(o=>o.data);return{text:n.join(""),write(o){e[0].data=o;for(let r=1;r<e.length;r++)e[r].data=""},restore(){for(let o=0;o<e.length;o++)e[o].data=n[o]}}}function ia(t){let e=t.getPropertyValue("-webkit-line-clamp")||t.getPropertyValue("line-clamp");e=(e||"").trim();let n=parseInt(e,10);return Number.isFinite(n)&&n>0?n:0}function sa(t){let e=(t.lineHeight||"").trim(),n=parseFloat(t.fontSize)||16;return!e||e==="normal"?Math.round(n*1.2):e.endsWith("px")?parseFloat(e):/^\\d+(\\.\\d+)?$/.test(e)?Math.round(parseFloat(e)*n):e.endsWith("%")?Math.round(parseFloat(e)/100*n):Math.round(n*1.2)}function aa(t){return(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0)}function br(t){return t.childElementCount>0?!1:Array.from(t.childNodes).some(e=>e.nodeType===Node.TEXT_NODE)}var ie=[];function se(t){if(!t)return null;if(Array.isArray(t)){let[e,n]=t;return typeof e=="function"?e(n):e}if(typeof t=="object"&&"plugin"in t){let{plugin:e,options:n}=t;return typeof e=="function"?e(n):e}return typeof t=="function"?t():t}function wr(...t){let e=t.flat();for(let n of e){let o=se(n);o&&(ie.some(r=>r&&r.name&&o.name&&r.name===o.name)||ie.push(o))}}function xr(t){return t&&Array.isArray(t.plugins)?t.plugins:ie}async function gt(t,e,n){let o=n,r=xr(e);for(let s of r){let i=s&&typeof s[t]=="function"?s[t]:null;if(!i)continue;let a=await i(e,o);typeof a<"u"&&(o=a)}return o}async function Sr(t,e,n){let o=[],r=xr(e);for(let s of r){let i=s&&typeof s[t]=="function"?s[t]:null;if(!i)continue;let a=await i(e,n);typeof a<"u"&&o.push(a)}return o}function ca(t){let e=[];if(Array.isArray(t))for(let n of t){let o=se(n);if(!o||!o.name)continue;let r=e.findIndex(s=>s&&s.name===o.name);r>=0&&e.splice(r,1),e.push(o)}for(let n of ie)n&&n.name&&!e.some(o=>o.name===n.name)&&e.push(n);return Object.freeze(e)}function vr(t,e,n=!1){return!t||t.plugins&&!n||(t.plugins=ca(e)),t}function bn(){return ie.slice()}rt();var la=.92,fa=.95;async function ua(t){let e=new Image;if(e.decoding="sync",e.src=t,typeof e.decode=="function")try{return await e.decode(),e}catch{}return await new Promise((n,o)=>{e.onload=()=>n(),e.onerror=o}),e}function da(t){let e=/^data:([^;,]+)/.exec(t);return e?e[1]:""}async function wn(t,e,n){if(typeof t!="string"||!t.startsWith("data:image")||t.startsWith("data:image/svg"))return null;let o=t.length+":"+t.slice(0,64)+t.slice(-64)+":"+Math.round(e)+"x"+Math.round(n);if(C.compress.has(o))return C.compress.get(o);let r=await(async()=>{let s;try{s=await ua(t)}catch{return null}let i=s.naturalWidth||s.width,a=s.naturalHeight||s.height;if(!i||!a)return null;let c=Math.min(1,Math.max(e/i,n/a));if(!(c>0)||c>=.95)return null;let u=c*fa,l=Math.max(1,Math.round(i*u)),d=Math.max(1,Math.round(a*u)),f=document.createElement("canvas");f.width=l,f.height=d;let p=f.getContext("2d");if(!p)return null;p.imageSmoothingEnabled=!0,p.imageSmoothingQuality="high",p.drawImage(s,0,0,l,d);let m=da(t),h=m==="image/jpeg"?"image/jpeg":m==="image/webp"?"image/webp":"image/png";try{let b=f.toDataURL(h,la);if(typeof b=="string"&&b.startsWith("data:image")&&b.length<t.length)return b}catch{}return null})();return C.compress.set(o,r),r}async function pa(t,e){if(!e.compress)return{count:0,before:0,after:0};let n=(e.scale||1)*(e.dpr||1),o=Array.from(t.querySelectorAll("img"));t.tagName==="IMG"&&o.unshift(t);let r=0,s=0,i=0,a=async u=>{let l=u.getAttribute("src")||"";if(!l.startsWith("data:image")||l.startsWith("data:image/svg"))return;let d=parseFloat(u.dataset.snapdomWidth)||parseFloat(u.style.width)||u.width||0,f=parseFloat(u.dataset.snapdomHeight)||parseFloat(u.style.height)||u.height||0;if(!d||!f)return;let p=await wn(l,d*n,f*n);p&&(r++,s+=l.length,i+=p.length,u.setAttribute("src",p))},c=6;for(let u=0;u<o.length;u+=c)await Promise.allSettled(o.slice(u,u+c).map(a));return{count:r,before:s,after:i}}function ha(t){let e=t.offsetWidth||t.getBoundingClientRect().width||0,n=t.offsetHeight||t.getBoundingClientRect().height||0;return{w:e,h:n}}async function ma(t,e,n=C.session.nodeMap){if(!e.compress)return{count:0};let o=(e.scale||1)*(e.dpr||1),r=[],s=[t,...t.querySelectorAll("*")];for(let u of s){let l=u.style&&u.style.backgroundImage;l&&l.includes("data:image")&&r.push(u)}let i=0,a=async u=>{let l=n.get(u);if(!l||!l.isConnected)return;let d;try{d=getComputedStyle(l)}catch{return}if((d.backgroundRepeat||"repeat").toLowerCase().split(",").some(g=>g.trim()!=="no-repeat"))return;let{w:p,h:m}=ha(l);if(!p||!m)return;let h=p*o,b=m*o,y=u.style.backgroundImage,w=[...y.matchAll(/url\\(([\'"]?)(data:image\\/[^)\'"]+)\\1\\)/gi)],S=y;for(let g of w){let x=g[2];if(x.startsWith("data:image/svg"))continue;let v=await wn(x,h,b);v&&(S=S.split(x).join(v),i++)}S!==y&&(u.style.backgroundImage=S)},c=6;for(let u=0;u<r.length;u+=c)await Promise.allSettled(r.slice(u,u+c).map(a));return{count:i}}async function ga(t,e){if(!e.compress)return{count:0};let n=(e.scale||1)*(e.dpr||1),o=Array.from(t.querySelectorAll("image"));t.localName==="image"&&o.unshift(t);let r=0,s=async a=>{let c=a.getAttribute("href")||(typeof a.getAttributeNS=="function"?a.getAttributeNS("http://www.w3.org/1999/xlink","href"):null);if(!c||!c.startsWith("data:image")||c.startsWith("data:image/svg"))return;let u=parseFloat(a.getAttribute("width"))||0,l=parseFloat(a.getAttribute("height"))||0;if(!u||!l)return;let d=await wn(c,u*n,l*n);d&&(a.setAttribute("href",d),a.hasAttribute("xlink:href")&&a.setAttribute("xlink:href",d),r++)},i=6;for(let a=0;a<o.length;a+=i)await Promise.allSettled(o.slice(a,a+i).map(s));return{count:r}}async function Cr(t,e,n){e.compress&&(await pa(t,e),await ma(t,e,n),await ga(t,e))}function ya(t){if(Array.isArray(t.plugins)){for(let e of t.plugins)if(se(e)?.name==="picture-resolver")return!0}return bn().some(e=>e?.name==="picture-resolver")}function ba(t){let e=Array.isArray(t.plugins)?t.plugins:bn(),n=[];for(let o of e){let r=se(o);r&&typeof r.resolveNode=="function"&&n.push(r.resolveNode.bind(r))}return n.length?n:null}var wa=2e3,xa=3;function Sa(t){let e=Date.now(),n=C.burstAdvice.get(t);if(!n||e-n.firstTs>wa){C.burstAdvice.set(t,{count:1,firstTs:e,warned:!1});return}n.count++,n.count>=xa&&!n.warned&&(n.warned=!0,console.warn("[snapdom] Captured this element multiple times. Pass { burst: true } to increase the speed."))}async function Ar(t,e){if(!t)throw new Error("Element cannot be null or undefined");pe(e.cache),e.__session={styleMap:C.session.styleMap,styleCache:C.session.styleCache,nodeMap:C.session.nodeMap},e.burst||Sa(t),e.__resolveNodeHooks=ba(e);let n=e.fast,o=e.outerTransforms!==!1,r=!!e.outerShadows,s=e.clip?Ne(t,e.clip):null,i={element:t,options:e,plugins:e.plugins},a,c,u,l,d,f,p="",m="",h,b,y=null;await gt("beforeSnap",i);let w=null;e.resolvePicturePlaceholders!==!1&&!ya(e)&&(w=await Qn(i.element,i.options)),await gt("beforeClone",i);let S=gr(i.element,s);try{({clone:a,classCSS:c,styleCache:u,nodeMap:l,reconcileRisk:d,clipWindow:f}=await fr(i.element,i.options)),d>0&&!e.reconcile&&!C.warnedReconcile&&(C.warnedReconcile=!0,console.warn("[snapdom] Text in inline/table-cell elements kept its natural width and may re-wrap under font-fallback rasterization. Pass { reconcile: true } for pixel-exact layout (roughly doubles capture time).")),!o&&a&&(y=Go(i.element,a)),!r&&a&&nr(i.element,a,i.options),a&&(rr(i.element,a,l),or(i.element,a))}finally{S()}if(i={clone:a,classCSS:c,styleCache:u,nodeMap:l,...i},await gt("afterClone",i),w&&await w(),ir(i.clone),i.options?.excludeMode==="remove"||i.options?.filterMode==="remove")try{sr(i.element,i.clone,i.styleCache)}catch(E){console.warn("[snapdom] shrink pass failed:",E)}try{await yo(i.clone,i.element,i.nodeMap)}catch{}let g=E=>new Promise(($,W)=>{$t(()=>{Promise.resolve().then(E).then($,W)},{fast:n})}),x=(async()=>{await Promise.all([g(()=>dr(i.clone,i.options)),g(()=>pr(i.element,i.clone,i.styleCache,i.options,i.nodeMap))]);try{mr(i.element,i.clone,i.nodeMap)}catch(E){console.warn("[snapdom] backdrop-filter emulation failed:",E)}e.compress&&await g(()=>Cr(i.clone,i.options,i.nodeMap))})(),v=Promise.resolve();e.embedFonts&&(v=g(async()=>{let E=i.element.ownerDocument||document,$=s?I=>{try{let O=I.getBoundingClientRect();return O.right>=s.left-200&&O.left<=s.right+200&&O.bottom>=s.top-200&&O.top<=s.bottom+200}catch{return!0}}:null,{required:W,usedCodepoints:T}=oe(i.element,$);if(K()){let I=new Set(Array.from(W).map(O=>String(O).split("__")[0]).filter(Boolean));await Dt(I,1,E)}p=await Te({required:W,usedCodepoints:T,preCached:!1,exclude:i.options.excludeFonts,localFonts:i.options.localFonts,useProxy:i.options.useProxy,fontStylesheetDomains:i.options.fontStylesheetDomains,doc:E})})),await Promise.all([x,v]);let k=qe(i.clone).sort(),A=k.join(",");C.baseStyle.has(A)?m=C.baseStyle.get(A):await new Promise(E=>{$t(()=>{m=Xe(k),C.baseStyle.set(A,m),E()},{fast:n})});let M=lr(i.element?.ownerDocument||document);i={fontsCSS:p,baseCSS:m,scrollbarCSS:M,...i},await gt("beforeRender",i),await new Promise(E=>{$t(()=>{let $=N(i.element),W=i.element.getBoundingClientRect(),T=Math.max(1,R(i.element.offsetWidth||parseFloat($.width)||W.width||1)),I=Math.max(1,R(i.element.offsetHeight||parseFloat($.height)||W.height||1)),O=i.element.ownerDocument||document;if(!f&&(i.element===O.body||i.element===O.documentElement)&&!O.documentElement.hasAttribute("data-sd-pinned")){let X=Math.max(i.element.scrollHeight||0,O.documentElement?.scrollHeight||0,O.body?.scrollHeight||0),nt=Math.max(i.element.scrollWidth||0,O.documentElement?.scrollWidth||0,O.body?.scrollWidth||0);X>0&&(I=Math.max(I,R(X))),nt>0&&(T=Math.max(T,R(nt)));try{let Q=(i.scrollbarCSS||"").length+(i.baseCSS||"").length+(i.fontsCSS||"").length+(i.classCSS||"").length,ot=C.measureHints.get(i.element);if(ot&&ot.cssLen===Q&&ot.w0===T)ot.csh>0&&(I=Math.max(I,R(ot.csh))),ot.csw>0&&(T=Math.max(T,R(ot.csw)));else{let Z=O.createElement("div");Z.setAttribute("data-snapdom-internal",""),Z.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;width:"+T+"px!important;overflow:visible!important;visibility:hidden!important;";let Mt=Z.attachShadow({mode:"open"}),Ft=O.createElement("style");Ft.textContent=(i.scrollbarCSS||"")+i.baseCSS+"svg{overflow:visible;} foreignObject{overflow:visible;}"+i.classCSS,Mt.appendChild(Ft),Mt.appendChild(i.clone.cloneNode(!0)),O.body.appendChild(Z);let Xt=Z.scrollHeight,xt=Z.scrollWidth;O.body.removeChild(Z),C.measureHints.set(i.element,{cssLen:Q,w0:T,csh:Xt,csw:xt}),Xt>0&&(I=Math.max(I,R(Xt))),xt>0&&(T=Math.max(T,R(xt)))}}catch{}}if(i.options?.excludeMode==="remove"||i.options?.filterMode==="remove"){let X=ar(i.element,i.options);Number.isFinite(X)&&X>0&&(I=Math.max(1,Math.min(I,R(X+1))))}if(i.options?.reconcile)try{let X=(i.scrollbarCSS||"")+i.baseCSS+"svg{overflow:visible;} foreignObject{overflow:visible;}"+i.classCSS;cr(i.element,i.clone,X,i.nodeMap,T,I)}catch(X){console.warn("[snapdom] reconcile pass failed:",X)}let P=(X,nt=NaN)=>{let Q=typeof X=="string"?parseFloat(X):X;return Number.isFinite(Q)?Q:nt},z=P(i.options.width),j=P(i.options.height),tt=f?R(f.width):T,et=f?R(f.height):I,pt=tt,ft=et,L=Number.isFinite(z),B=Number.isFinite(j),D=et>0?tt/et:1;L&&B?(pt=Math.max(1,R(z)),ft=Math.max(1,R(j))):L?(pt=Math.max(1,R(z)),ft=Math.max(1,R(pt/(D||1)))):B&&(ft=Math.max(1,R(j)),pt=Math.max(1,R(ft*(D||1))));let V=0,q=0,J=T,ht=I;if(f){let X=0,nt=0;if(xn(i.element)){let Q=null;if(!o&&y&&Number.isFinite(y.a))Q={a:y.a,b:y.b||0,c:y.c||0,d:y.d||1,e:0,f:0};else{let ot=Vt(i.element),Z=gn($.transform&&$.transform!=="none"?$.transform:"",ot);Z&&Z.is2D&&(Q={a:Z.a,b:Z.b,c:Z.c,d:Z.d,e:0,f:0})}if(Q&&!(Q.a===1&&Q.b===0&&Q.c===0&&Q.d===1)){let{ox:ot,oy:Z}=re($,T,I),Mt=zt(T,I,Q,ot,Z);X=Mt.minX,nt=Mt.minY}}V=R(f.x+X),q=R(f.y+nt),J=R(V+f.width),ht=R(q+f.height)}else if(!o&&y&&Number.isFinite(y.a)){let X={a:y.a,b:y.b||0,c:y.c||0,d:y.d||1,e:0,f:0},nt=zt(T,I,X,0,0);V=R(nt.minX),q=R(nt.minY),J=R(nt.maxX),ht=R(nt.maxY)}else if(o&&xn(i.element)){let nt=$.transform&&$.transform!=="none"?$.transform:"",Q=Vt(i.element),ot=Yo({baseTransform:nt,rotate:Q.rotate||"0deg",scale:Q.scale,translate:Q.translate}),{ox:Z,oy:Mt}=re($,T,I),Ft=ot.is2D?ot:new DOMMatrix(ot.toString()),Xt={a:Ft.a,b:Ft.b,c:Ft.c,d:Ft.d,e:0,f:0},xt=zt(T,I,Xt,Z,Mt);V=R(xt.minX),q=R(xt.minY),J=R(xt.maxX),ht=R(xt.maxY)}let yt=Ho($),Nt=zo($),it=jo($),Lt=qo($),It=Xo($),kt=f?{top:0,right:0,bottom:0,left:0}:r?{top:R(Math.max(yt.top,Nt.top)+it.top+Lt.top+It.bleed.top),right:R(Math.max(yt.right,Nt.right)+it.right+Lt.right+It.bleed.right),bottom:R(Math.max(yt.bottom,Nt.bottom)+it.bottom+Lt.bottom+It.bleed.bottom),left:R(Math.max(yt.left,Nt.left)+it.left+Lt.left+It.bleed.left)}:{top:it.top,right:it.right,bottom:it.bottom,left:it.left};V=R(V-kt.left),q=R(q-kt.top),J=R(J+kt.right),ht=R(ht+kt.bottom);let bt=Math.max(1,R(J-V)),En=Math.max(1,R(ht-q)),Br=L||B?R(pt/tt):1,Ur=B||L?R(ft/et):1,Dr=Math.max(1,R(bt*Br)),Hr=Math.max(1,R(En*Ur)),Rn="http://www.w3.org/2000/svg",zr=xn(i.element)?2:0,_t=R(zr+(o?0:1)),ce=Math.ceil(bt+_t*2),le=Math.ceil(En+_t*2),fe=R(-(R(V)-_t)),ue=R(-(R(q)-_t)),$n=Math.max(0,fe),Tn=Math.max(0,ue),Pn=R(ce-Math.min(0,fe)),Nn=R(le-Math.min(0,ue)),wt=document.createElementNS(Rn,"foreignObject");wt.setAttribute("x",String(Math.min(0,fe))),wt.setAttribute("y",String(Math.min(0,ue))),wt.setAttribute("width",String(Pn)),wt.setAttribute("height",String(Nn)),wt.style.overflow="visible";let Ln=document.createElement("style"),Vr="svg{overflow:visible;} foreignObject{overflow:visible;} foreignObject>div{-webkit-text-size-adjust:100%!important;text-size-adjust:100%!important;}";Ln.textContent=(i.scrollbarCSS||"")+i.baseCSS+i.fontsCSS+Vr+i.classCSS,wt.appendChild(Ln);let de=document.createElement("div");de.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),de.style.cssText=`all:initial;box-sizing:border-box;display:block;overflow:visible;width:${Pn}px;height:${Nn}px`+($n!==0||Tn!==0?`;padding:${Tn}px 0 0 ${$n}px !important`:""),de.appendChild(i.clone),wt.appendChild(de);let jr=new XMLSerializer().serializeToString(wt),In=L||B,qr=Object.freeze({w0:tt,h0:et,vbW:ce,vbH:le,targetW:pt,targetH:ft,contentX:R(fe+(f?V:0)),contentY:R(ue+(f?q:0)),clip:f?Object.freeze({x:R(V),y:R(q),width:tt,height:et}):null});Object.defineProperty(e,"meta",{value:qr,enumerable:!0,writable:!1,configurable:!0});let Xr=!In||K()?ce:R(Dr+_t*2),Gr=!In||K()?le:R(Hr+_t*2),Yr=parseFloat(N(O.documentElement)?.fontSize)||16;b=`<svg xmlns="${Rn}" width="${Xr}" height="${Gr}" viewBox="0 0 ${ce} ${le}" font-size="${Yr}px">`+jr+"</svg>",h=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(b)}`,i={svgString:b,dataURL:h,...i},E()},{fast:n})}),await gt("afterRender",i);let F=document.getElementById("snapdom-sandbox");return F&&F.style.position==="absolute"&&F.remove(),i.dataURL}function xn(t){return Ko(t)}rt();function kr(t={}){let e=t.format??"png";e==="jpg"&&(e="jpeg");let n=_n(t.cache);return{debug:t.debug??!1,fast:t.fast??!0,scale:t.scale??1,exclude:t.exclude??[],excludeMode:t.excludeMode??"hide",filter:t.filter??null,filterMode:t.filterMode??"hide",placeholders:t.placeholders!==!1,embedFonts:t.embedFonts??!1,iconFonts:Array.isArray(t.iconFonts)?t.iconFonts:t.iconFonts?[t.iconFonts]:[],localFonts:Array.isArray(t.localFonts)?t.localFonts:[],excludeFonts:t.excludeFonts??void 0,fontStylesheetDomains:Array.isArray(t.fontStylesheetDomains)?t.fontStylesheetDomains:[],fallbackURL:t.fallbackURL??void 0,cache:n,useProxy:typeof t.useProxy=="string"?t.useProxy:"",width:t.width??null,height:t.height??null,format:e,type:t.type??"svg",quality:t.quality??.92,dpr:t.dpr??(window.devicePixelRatio||1),backgroundColor:t.backgroundColor??(["jpeg","webp"].includes(e)?"#ffffff":null),filename:t.filename??"snapDOM",outerTransforms:t.outerTransforms??!0,outerShadows:t.outerShadows??!1,reconcile:t.reconcile??!1,burst:t.burst??!1,invalidate:t.invalidate??!1,clip:t.clip??null,compress:t.compress!==!1,excludeStyleProps:t.excludeStyleProps??null,resolvePicturePlaceholders:t.resolvePicturePlaceholders!==!1,pictureResolver:t.pictureResolver&&typeof t.pictureResolver=="object"?t.pictureResolver:{}}}Ct();Ke();var Mr=new WeakMap;function Er(t,e,n){let o=new Set;if(t instanceof HTMLVideoElement&&o.add(t),t.querySelectorAll)for(let r of t.querySelectorAll("video"))o.add(r);for(let r of e.trackedVideos)o.has(r)||(r.removeEventListener("timeupdate",n),r.removeEventListener("seeked",n),e.trackedVideos.delete(r));for(let r of o)e.trackedVideos.has(r)||(r.addEventListener("timeupdate",n),r.addEventListener("seeked",n),e.trackedVideos.add(r))}function va(t){let e={dirty:!0,capturing:!1,last:null,inflight:Promise.resolve(),observers:[],trackedVideos:new Set},n=s=>{e.capturing||Je(s)&&(e.dirty=!0)},o=()=>{e.capturing||(e.dirty=!0)},r=t.ownerDocument||document;try{let s=new MutationObserver(n);s.observe(t,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),e.observers.push(s)}catch{}try{if(r.head){let s=new MutationObserver(n);s.observe(r.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0}),e.observers.push(s)}}catch{}return e.markDirty=n,e.onMediaDirty=o,Er(t,e,o),e}function Fr(t){let{burst:e,invalidate:n,...o}=t||{};try{return JSON.stringify(o,Object.keys(o).sort())}catch{return null}}function Rr(t,e,n,o){let r=Mr.get(t);r||(r=va(t),r.baselineSignature=Fr(e),Mr.set(t,r));let s=Fr(e),i=s===null||s!==r.baselineSignature,a=async()=>{for(let u of r.observers)r.markDirty(u.takeRecords());if(n.invalidate&&(r.dirty=!0),!i&&!r.dirty&&r.last)return r.last;r.capturing=!0,i||(r.dirty=!1);try{let u=await o();return i||(r.last=u),u}finally{for(let u of r.observers)u.takeRecords();r.capturing=!1,Er(t,r,r.onMediaDirty)}},c=r.inflight.then(a,a);return r.inflight=c.catch(()=>{}),c}at();vt();rt();async function $r(t=document,e={}){let{embedFonts:n=!0,useProxy:o=""}=e,r=e.cache??e.cacheOpt??"full";pe(r);try{await document.fonts?.ready}catch{}try{Ve()}catch{}C.session=C.session||{},C.session.styleCache||(C.session.styleCache=new WeakMap),C.image=C.image||new Y(100),C.background=C.background||new Y(100);let s=[],i=[];try{if(t&&t.nodeType===1){let c=t.querySelectorAll?Array.from(t.querySelectorAll("*")):[];i=[t,...c],s=[],t.tagName==="IMG"&&t.getAttribute("src")&&s.push(t),s.push(...Array.from(t.querySelectorAll?.("img[src]")||[]))}else t?.querySelectorAll&&(s=Array.from(t.querySelectorAll("img[src]")),i=Array.from(t.querySelectorAll("*")))}catch{}let a=[];for(let c of s){let u=c?.currentSrc||c?.src;if(u&&!C.image.has(u)){let l=Promise.resolve().then(async()=>{let d=await G(u,{as:"dataURL",useProxy:o});d?.ok&&typeof d.data=="string"&&C.image.set(u,d.data)}).catch(()=>{});a.push(l)}}for(let c of i){let u=new Set;for(let l of yn){let d="";try{d=l==="background-image"&&c?.style?.backgroundImage||N(c).getPropertyValue(l)||""}catch{}if(!d||d==="none")continue;let f=d.match(/url\\((?:[^()"\']+|"(?:[^"]*)"|\'(?:[^\']*)\')\\)/gi)||[];for(let p of f){if(u.has(p))continue;u.add(p);let m=Promise.resolve().then(()=>Rt(p,{...e,useProxy:o})).catch(()=>{});a.push(m)}}}if(n)try{let{required:c,usedCodepoints:u}=oe(t);if(typeof K=="function"?K():!!K){let d=new Set(Array.from(c).map(f=>String(f).split("__")[0]).filter(Boolean));await Dt(d,3)}await Te({required:c,usedCodepoints:u,exclude:e.excludeFonts,localFonts:e.localFonts,useProxy:e.useProxy??o,fontStylesheetDomains:e.fontStylesheetDomains})}catch{}await Promise.allSettled(a)}function Ia(...t){return wr(...t),H}var H=Object.assign(Wa,{plugins:Ia}),Fn=Symbol("snapdom.internal"),_a=Symbol("snapdom.internal.silent");async function Wa(t,e){if(!t)throw new Error("Element cannot be null or undefined");let n=kr(e);if(vr(n,e&&e.plugins),K()){if(n.embedFonts===!0)try{let r=Fo(t),s=new Set([...r].map(i=>String(i).split("__")[0]).filter(Boolean));await Dt(s,1)}catch{}let o=Array.from(t.querySelectorAll("canvas"));t.tagName==="CANVAS"&&o.unshift(t);for(let r of o)try{let s=r.getContext("2d",{willReadFrequently:!0});s&&s.getImageData(0,0,1,1)}catch(s){_(e,"safari canvas poke failed",s)}}return n.iconFonts&&n.iconFonts.length>0&&go(n.iconFonts),n.snap||(n.snap={toPng:(o,r)=>H.toPng(o,r),toSvg:(o,r)=>H.toSvg(o,r)}),n.burst?Rr(t,e,n,()=>H.capture(t,n,Fn)):H.capture(t,n,Fn)}H.capture=async(t,e,n)=>{if(n!==Fn)throw new Error("[snapdom.capture] is internal. Use snapdom(...) instead.");e.element=t;let o=await Ar(t,e),r={img:async(h,b)=>{let{toImg:y}=await Promise.resolve().then(()=>(An(),Cn));return y(o,{...h,...b||{}})},svg:async(h,b)=>{let{toSvg:y}=await Promise.resolve().then(()=>(An(),Cn));return y(o,{...h,...b||{}})},canvas:async(h,b)=>{let{toCanvas:y}=await Promise.resolve().then(()=>(qt(),Lr));return y(o,{...h,...b||{}})},blob:async(h,b)=>{let{toBlob:y}=await Promise.resolve().then(()=>(Mn(),Ir));return y(o,{...h,...b||{}})},png:async(h,b)=>{let{rasterize:y}=await Promise.resolve().then(()=>(ae(),Ue));return y(o,{...h,...b||{},format:"png"})},jpeg:async(h,b)=>{let{rasterize:y}=await Promise.resolve().then(()=>(ae(),Ue));return y(o,{...h,...b||{},format:"jpeg"})},webp:async(h,b)=>{let{rasterize:y}=await Promise.resolve().then(()=>(ae(),Ue));return y(o,{...h,...b||{},format:"webp"})},download:async(h,b)=>{let{download:y}=await Promise.resolve().then(()=>(Or(),Wr));return y(o,{...h,...b||{}})}},s={};for(let h of["img","svg","canvas","blob","png","jpeg","webp"])s[h]=async b=>r[h](e,{...b||{},[_a]:!0});s.jpg=s.jpeg;let i={...e,export:{url:o},exports:s},a=await Sr("defineExports",i),c=Object.assign({},...a.filter(h=>h&&typeof h=="object").reverse()),u={...r,...c};u.jpeg&&!u.jpg&&(u.jpg=(h,b)=>u.jpeg(h,b));function l(h,b){let y={...e,...b||{}},w=g=>g==="jpeg"||g==="jpg"||g==="webp";return[h,y.format,y.type].map(g=>typeof g=="string"?g.toLowerCase():"").find(w)&&(y.backgroundColor==null||y.backgroundColor==="transparent")&&(y.backgroundColor="#ffffff"),y}let d=!1,f=Promise.resolve();async function p(h,b){let y=Object.freeze(b&&typeof b=="object"?{...b}:{}),w=async()=>{let g=u[h];if(!g)throw new Error(`[snapdom] Unknown export type: ${h}`);let x=l(h,y),v={...e,export:{type:h,options:x,requestedOptions:y,url:o}};await gt("beforeExport",v,{format:h,options:x});let k=await g(v,x);return await gt("afterExport",v,{format:h,options:x,result:k}),d||(d=!0,await gt("afterSnap",e)),k},S=f.then(w);return f=S.catch(()=>{}),S}let m={url:o,toRaw:()=>o,to:(h,b)=>p(h,b),toImg:h=>p("img",h),toSvg:h=>p("svg",h),toCanvas:h=>p("canvas",h),toBlob:h=>p("blob",h),toPng:h=>p("png",h),toJpg:h=>p("jpg",h),toWebp:h=>p("webp",h),download:h=>p("download",h)};Object.defineProperty(m,"meta",{value:e.meta,enumerable:!0,writable:!1,configurable:!1});for(let h of Object.keys(u)){let b="to"+h.charAt(0).toUpperCase()+h.slice(1);m[b]||(m[b]=y=>p(h,y))}return m};H.toRaw=(t,e)=>H(t,e).then(n=>n.toRaw());H.toImg=(t,e)=>H(t,e).then(n=>n.toImg());H.toSvg=(t,e)=>H(t,e).then(n=>n.toSvg());H.toCanvas=(t,e)=>H(t,e).then(n=>n.toCanvas());H.toBlob=(t,e)=>H(t,e).then(n=>n.toBlob());H.toPng=(t,e)=>H(t,{...e,format:"png"}).then(n=>n.toPng());H.toJpg=(t,e)=>H(t,{...e,format:"jpeg"}).then(n=>n.toJpg());H.toWebp=(t,e)=>H(t,{...e,format:"webp"}).then(n=>n.toWebp());H.download=(t,e)=>H(t,e).then(n=>n.download());typeof window<"u"&&(window.snapdom=H,window.preCache=$r);})();\n'}function yp(){let e=process.env.CHROME_PATH?.trim();return e&&ci(e)?e:["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Chromium.app/Contents/MacOS/Chromium","/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge","/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/usr/bin/chromium","/usr/bin/chromium-browser","C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe","C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"].find(n=>ci(n))??null}async function bp(e,t){let n=rp(De.join(ip(),"gruum-capture-")),s=sp(e,[...t?[]:["--headless=new","--disable-gpu"],"--remote-debugging-port=0",`--user-data-dir=${n}`,"--no-first-run","--no-default-browser-check","--disable-extensions","--disable-background-networking","--hide-scrollbars","--window-size=1440,900","about:blank"],{stdio:["ignore","ignore","pipe"]}),r=await kp(s,cp);s.stderr?.on("data",()=>{});let o=await vp(r),i=await wp(o,t),l=(await o.send("Target.attachToTarget",{targetId:i,flatten:!0})).sessionId,c=(f,m)=>o.send(f,m,l);await c("Page.enable"),await c("Runtime.enable");let u=async f=>{try{let m=await c("Page.captureScreenshot",{format:"jpeg",quality:f?80:60,fromSurface:!0,captureBeyondViewport:!0,...f?{clip:f}:{}});return typeof m.data=="string"&&m.data?`data:image/jpeg;base64,${m.data}`:void 0}catch{return}};return{async open(f){try{await c("Page.navigate",{url:f}),await o.waitLoad(l,lp),await ui(800);let h=(await c("Page.getFrameTree")).frameTree?.frame?.url??f;return xp(f,h)?h:null}catch{return null}},async evaluate(f,m){let h=await c("Runtime.evaluate",{expression:f,awaitPromise:m,returnByValue:!0});if(!h.exceptionDetails)return h.result?.value},async screenshot(f,m){return u({x:f.x,y:f.y,width:f.width,height:f.height,scale:Math.min(2,Math.max(1,m))})},async screenshotViewport(){return u()},async location(){try{return(await c("Page.getFrameTree")).frameTree?.frame?.url??null}catch{return null}},async show(f){try{let h=(await c("Page.getFrameTree")).frameTree?.frame?.id;return h?(await c("Page.setDocumentContent",{frameId:h,html:f}),await ui(200),!0):!1}catch{return!1}},async close(){await o.close(),s.kill("SIGKILL"),op(n,{recursive:!0,force:!0})}}}async function wp(e,t){if(t){let r=(await e.send("Target.getTargets")).targetInfos?.find(o=>o.type==="page");if(r)return r.targetId}return(await e.send("Target.createTarget",{url:"about:blank"})).targetId}function xp(e,t){try{return new URL(e).host===new URL(t).host}catch{return!1}}function kp(e,t){return new Promise((n,s)=>{let r="",o=setTimeout(()=>{e.stderr?.off("data",i),s(new Error("Chrome did not open a debug port."))},t),i=a=>{r+=a.toString("utf8");let l=r.match(/DevTools listening on (ws:\/\/\S+)/);l?.[1]&&(clearTimeout(o),e.stderr?.off("data",i),n(l[1]))};e.stderr?.on("data",i),e.once("exit",()=>{clearTimeout(o),s(new Error("Chrome exited before a debug port was ready."))})})}async function vp(e){let t=new WebSocket(e);await new Promise((o,i)=>{t.addEventListener("open",()=>o(),{once:!0}),t.addEventListener("error",()=>i(new Error("Could not talk to Chrome.")),{once:!0})});let n=1,s=new Map,r=new Set;return t.addEventListener("message",o=>{let i=typeof o.data=="string"?o.data:"";if(!i)return;let a;try{a=JSON.parse(i)}catch{return}if(a.method==="Page.loadEventFired")for(let c of[...r])c(a.sessionId??a.params?.sessionId);if(typeof a.id!="number")return;let l=s.get(a.id);if(l){if(s.delete(a.id),a.error){l.reject(new Error(a.error.message||"Chrome command failed."));return}l.resolve(a.result)}}),{send(o,i,a){let l=n++,c={id:l,method:o};return i&&(c.params=i),a&&(c.sessionId=a),new Promise((u,f)=>{s.set(l,{resolve:u,reject:f}),t.send(JSON.stringify(c))})},waitLoad(o,i){return new Promise(a=>{let l=()=>{clearTimeout(c),r.delete(u),a()},c=setTimeout(l,i),u=f=>{f&&f!==o||l()};r.add(u)})},async close(){for(let o of s.values())o.reject(new Error("Chrome closed."));s.clear(),r.clear(),t.close()}}}function ui(e){return new Promise(t=>setTimeout(t,e))}function gi(e){return`/v2/projects/${encodeURIComponent(e)}`}function ns(e,t,n,s){return!(!e||e.repo!==t||!e.workspaceId||!e.host&&s||n&&!n.includes(e.id))}function mi(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 hi(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 yi="No project for this repo found. Creating\u2026";function bi(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 wi(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((o,i)=>` ${i+1} ${o}`),r=e.length===1?"Which project should this checkout use? (1): ":"Which project should this checkout use? ";return`
69
212
  ${t}
70
213
  ${s.join(`
71
214
  `)}
72
215
 
73
- ${r}`}function Vn(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 Lo(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 Oo(e,t,n){let s=[` C Create ${n}`,...t.map((r,o)=>` ${o+1} ${r.name}`)];return`
216
+ ${r}`}function ss(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 xi(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 ki(e,t,n){let s=[` C Create ${n}`,...t.map((r,o)=>` ${o+1} ${r.name}`)];return`
74
217
  Select a workspace in ${e}, or create one.
75
218
  ${s.join(`
76
219
  `)}
77
220
 
78
- Which workspace should this project live in? `}function Mo(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 No(e,t,n){let s=t.map((r,o)=>` ${o+1} ${r.name}`);return`
221
+ Which workspace should this project live in? `}function vi(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 $i(e,t,n){let s=t.map((r,o)=>` ${o+1} ${r.name}`);return`
79
222
  ${e}
80
223
  ${s.join(`
81
224
  `)}
82
225
 
83
- Which ${n} should this project live in? `}function Do(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 To(e){return`/workspace/${encodeURIComponent(e)}`}import{spawnSync as iu}from"node:child_process";var Ne="https://app.getgruum.com",Vo=()=>Wn.join(ou(),".config","gruum","credentials.json");function Gn(){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(Fo(Vo(),"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 au(e){let t=Vo();nu(Wn.dirname(t),{recursive:!0}),su(t,`${JSON.stringify(e,null,2)}
84
- `,{mode:384}),tu(t,384)}function Ot(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(`${Ot(e)}${t}`,{...n,headers:s})}function Hn(e,t){let n=iu("git",t,{cwd:e,encoding:"utf8"});return n.status!==0?null:n.stdout.trim()||null}function lu(e){let t=Hn(e,["remote","get-url","origin"]);return t?ct(t):null}function Mt(e){let t=Hn(e,["rev-parse","--abbrev-ref","HEAD"]);return t&&t!=="HEAD"?t:""}function zo(e){return Hn(e,["rev-parse","HEAD"])}function Wo(e){return Wn.join(e.stateDir,"project.json")}function cu(e){try{let t=JSON.parse(Fo(Wo(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 Kn(e,t){return`${e}${ko(t)}`}function Bo(e,t,n,s){let r=Kn(e,t.id),o=s?` in ${s}`:"",i=t.workspaceId?`${e}${To(t.workspaceId)}
226
+ Which ${n} should this project live in? `}function Ci(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 Si(e){return`/workspace/${encodeURIComponent(e)}`}import{spawnSync as _p}from"node:child_process";var Ne="https://app.getgruum.com",Ai=()=>zt.join(Ap(),".config","gruum","credentials.json");function st(){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(os(Ai(),"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 Ep(e){let t=Ai();Cp(zt.dirname(t),{recursive:!0}),Sp(t,`${JSON.stringify(e,null,2)}
227
+ `,{mode:384}),$p(t,384)}function Wt(e){return(e?.apiOrigin||Ne).replace(/\/$/,"")}async function H(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(`${Wt(e)}${t}`,{...n,headers:s})}function as(e,t){let n=_p("git",t,{cwd:e,encoding:"utf8"});return n.status!==0?null:n.stdout.trim()||null}function Pp(e){let t=as(e,["remote","get-url","origin"]);return t?yt(t):null}function Gt(e){let t=as(e,["rev-parse","--abbrev-ref","HEAD"]);return t&&t!=="HEAD"?t:""}function _i(e){return as(e,["rev-parse","HEAD"])}function Ei(e){return zt.join(e.stateDir,"project.json")}function Ip(e){try{let t=JSON.parse(os(Ei(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 ls(e,t){return`${e}${gi(t)}`}function Ri(e,t,n,s){let r=ls(e,t.id),o=s?` in ${s}`:"",i=t.workspaceId?`${e}${Si(t.workspaceId)}
85
228
  `:"";process.stderr.write(n?`Created a Gruum project for ${t.repo}${o}.
86
229
  ${i}${r}
87
230
  `:`Gruum project: ${r}
88
- ${i}`)}function uu(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 Go(e,t,n){let s=Uo({input:process.stdin,output:process.stderr});_e(s);try{for(;;){let r=t(await s.question(e));if(r!=null)return r;process.stderr.write(n)}}finally{s.close()}}async function Ho(e,t,n){return Go(e,s=>!s.trim()&&n!=null?n:Do(s,t),`gruum: enter one of the numbers.
89
- `)}async function Ko(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}).
90
- `),null;let n=await t.json();return uu(n.orgs)}async function pu(e,t,n,s){let r=s??await Ko(e);if(!r)return null;let o=null;for(;;){let i=Eo(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=Lo(i.workspaces,Vn(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 Ho(No("This account has more than one organization.",i.orgs,"organization"),i.orgs);o=i.orgs[h].id;continue}let a=Vn(n),l=await Go(Oo(i.orgName,i.workspaces,a),h=>Mo(h,i.workspaces),`gruum: enter C, or one of the numbers.
91
- `);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})`}
92
- `);continue}return{workspaceId:f,label:`${i.orgName} / ${m}`}}}function fu(e,t){let n=Co(t),s=null;for(let r of _t(e).files.values()){let o=So(r,n);if(o){if(o.startsWith("https://"))return o;s??=o}}return s}async function du(e,t){let n=fu(e,t),s=Ro(n),r=Uo({input:process.stdin,output:process.stderr});_e(r);try{for(;;){let i=(await r.question(s)).trim()||n||"",a=Ao(i);if("error"in a){process.stderr.write(`gruum: ${a.error}
93
- `);continue}return i}}finally{r.close()}}async function Jo(){let e=`Cursor on ${ru()}`,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}?
231
+ ${i}`)}function Lp(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 Pi(e,t,n){let s=is({input:process.stdin,output:process.stderr});le(s);try{for(;;){let r=t(await s.question(e));if(r!=null)return r;process.stderr.write(n)}}finally{s.close()}}async function Ii(e,t,n){return Pi(e,s=>!s.trim()&&n!=null?n:Ci(s,t),`gruum: enter one of the numbers.
232
+ `)}async function Li(e){let t=await H(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}).
233
+ `),null;let n=await t.json();return Lp(n.orgs)}async function jp(e,t,n,s){let r=s??await Li(e);if(!r)return null;let o=null;for(;;){let i=hi(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=xi(i.workspaces,ss(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 Ii($i("This account has more than one organization.",i.orgs,"organization"),i.orgs);o=i.orgs[h].id;continue}let a=ss(n),l=await Pi(ki(i.orgName,i.workspaces,a),h=>vi(h,i.workspaces),`gruum: enter C, or one of the numbers.
234
+ `);if(l!=="create"){let h=i.workspaces[l];return{workspaceId:h.id,label:`${i.orgName} / ${h.name}`}}let c=await H(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})`}
235
+ `);continue}return{workspaceId:f,label:`${i.orgName} / ${m}`}}}function Mp(e,t){let n=To(t),s=null;for(let r of Ot(e).files.values()){let o=Oo(r,n);if(o){if(o.startsWith("https://"))return o;s??=o}}return s}async function Tp(e,t,n){let s=Bo({pageUrl:n,saved:Ho(e),devServer:Op(e.repoDir),host:t,interactive:!!process.stdin.isTTY});if(s.action==="ask-agent")return{onlyPage:!1,askAgent:!0};if(s.action==="open")return s.save&&s.url&&Nt(e,s.url),{url:s.url,onlyPage:s.onlyPage};let r=is({input:process.stdin,output:process.stderr});le(r);try{for(;;){let o=s.suggested?No(s.suggested):Uo(),i=(await r.question(o)).trim();if(!i&&s.suggested)return Nt(e,s.suggested),{url:s.suggested,onlyPage:!0};if(i.includes("*")){process.stderr.write(`gruum: You may not use wildcards.
236
+ `);continue}let a=/^https?:\/\//i.test(i)?i:`http://${i}`,l=es(a);if(!l){process.stderr.write(`gruum: Enter a live URL.
237
+ `);continue}return Nt(e,l),{url:l,onlyPage:!0}}}finally{r.close()}}function Op(e){try{let t=os(zt.join(e,"package.json"),"utf8");return t.length>5e5?null:Do(t)}catch{return null}}async function Dp(e,t){let n=Mp(e,t),s=Vo(n),r=is({input:process.stdin,output:process.stderr});le(r);try{for(;;){let i=(await r.question(s)).trim()||n||"",a=zo(i);if("error"in a){process.stderr.write(`gruum: ${a.error}
238
+ `);continue}return i}}finally{r.close()}}async function cs(){let e=`Cursor on ${Rp()}`,t=await H(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}?
94
239
  `),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.
95
240
 
96
241
  Code: ${n.userCode}
97
242
  ${s}
98
243
 
99
244
  Waiting for confirmation\u2026
100
- `);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 au({token:i.token,apiOrigin:Ne}),process.stdout.write(`Signed in. This CLI can read specs for your projects.
101
- `),0}return process.stderr.write("gruum: sign-in timed out. Run `npx @gruum/cli login` again.\n"),1}function zn(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 Jn(e,t){let n=lu(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.
102
- `),null;let s=!!process.stdin.isTTY,r=cu(e),o=Ot(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 Un(r,n,null,s)?r:null;let a=await i.json(),l=Array.isArray(a.projects)?a.projects.map(zn).filter($=>$!==null):[];if(Un(r,n,l.map($=>$.id),s))return r;if(!!r&&r.repo===n&&!!r.workspaceId&&!!(r.host||!s)&&(process.stderr.write(`gruum: the saved project was not found. Do not edit .gruum/project.json.
103
- `),l.length===0&&!s))return process.stderr.write("gruum: this repo has no project this sign-in can see. Run `npx @gruum/cli check` in a terminal to choose one.\n"),null;let u=!1,f="",m;if(l.length>0&&s){let $=await Ko(t);if(!$)return null;m=$;let g=l.map(y=>jo($,y)),p=[...g.map(y=>({name:y})),{name:"Create a new one"}],d=await Ho(Po(g),p,g.length===1?0:void 0);d===g.length?(l=[],process.stderr.write(`Creating\u2026
104
- `)):l=[l[d]]}if(l.length===0){m||process.stderr.write(`${Io}
105
- `);let $=await pu(t,s,n,m);if(!$)return null;let g=await K(t,"/api/v2/cli/projects",{method:"POST",body:JSON.stringify({repo:n,rootPath:e.root,...$.workspaceId?{workspaceId:$.workspaceId}:{}})}),p=await g.json().catch(()=>({}));typeof p.place?.org=="string"&&typeof p.place.workspace=="string"?f=`${p.place.org} / ${p.place.workspace}`:f=$.label;let d=zn(p.project);if(u=p.created!==!1,!g.ok||!d){let y=typeof p.path=="string"?p.path:"";return process.stderr.write(`gruum: ${p.error||`couldn't create a project (${g.status})`}
106
- `),y&&process.stderr.write(`${o}${y}
107
- `),null}l=[d]}let h=wo(l,e.root);if(!h){let $=l.map(g=>` ${g.name}${g.rootPath?` #${g.rootPath}`:""}
108
- ${Kn(o,g.id)}`).join(`
245
+ `);let r=Date.now()+600*1e3;for(;Date.now()<r;){await new Promise(a=>setTimeout(a,2e3));let o=await H(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 Ep({token:i.token,apiOrigin:Ne}),process.stdout.write(`Signed in. This CLI can read specs for your projects.
246
+ `),0}return process.stderr.write("gruum: sign-in timed out. Run `npx @gruum/cli login` again.\n"),1}function rs(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 us(e,t){let n=Pp(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.
247
+ `),null;let s=!!process.stdin.isTTY,r=Ip(e),o=Wt(t),i=await H(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 ns(r,n,null,s)?r:null;let a=await i.json(),l=Array.isArray(a.projects)?a.projects.map(rs).filter($=>$!==null):[];if(ns(r,n,l.map($=>$.id),s))return r;if(!!r&&r.repo===n&&!!r.workspaceId&&!!(r.host||!s)&&(process.stderr.write(`gruum: the saved project was not found. Do not edit .gruum/project.json.
248
+ `),l.length===0&&!s))return process.stderr.write("gruum: this repo has no project this sign-in can see. Run `npx @gruum/cli check` in a terminal to choose one.\n"),null;let u=!1,f="",m;if(l.length>0&&s){let $=await Li(t);if(!$)return null;m=$;let g=l.map(b=>bi($,b)),p=[...g.map(b=>({name:b})),{name:"Create a new one"}],d=await Ii(wi(g),p,g.length===1?0:void 0);d===g.length?(l=[],process.stderr.write(`Creating\u2026
249
+ `)):l=[l[d]]}if(l.length===0){m||process.stderr.write(`${yi}
250
+ `);let $=await jp(t,s,n,m);if(!$)return null;let g=await H(t,"/api/v2/cli/projects",{method:"POST",body:JSON.stringify({repo:n,rootPath:e.root,...$.workspaceId?{workspaceId:$.workspaceId}:{}})}),p=await g.json().catch(()=>({}));typeof p.place?.org=="string"&&typeof p.place.workspace=="string"?f=`${p.place.org} / ${p.place.workspace}`:f=$.label;let d=rs(p.project);if(u=p.created!==!1,!g.ok||!d){let b=typeof p.path=="string"?p.path:"";return process.stderr.write(`gruum: ${p.error||`couldn't create a project (${g.status})`}
251
+ `),b&&process.stderr.write(`${o}${b}
252
+ `),null}l=[d]}let h=mi(l,e.root);if(!h){let $=l.map(g=>` ${g.name}${g.rootPath?` #${g.rootPath}`:""}
253
+ ${ls(o,g.id)}`).join(`
109
254
  `);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.
110
255
  ${$}
111
- `),null}let w=h.host??null;if(!w&&s)for(Bo(o,{...h,host:w},u,f);!w;){let $=await du(e,n),g=await K(t,`/api/v2/cli/projects/${encodeURIComponent(h.id)}/url`,{method:"POST",body:JSON.stringify({url:$})}),p=await g.json().catch(()=>({})),d=zn(p.project);if(!g.ok||!d?.host){process.stderr.write(`gruum: ${p.error||`couldn't save that URL (${g.status})`}
112
- `);continue}w=d.host,process.stderr.write(`Live URL set to ${_o(w)}.
113
- `)}else Bo(o,{...h,host:w},u,f),!w&&!s&&process.stderr.write(`No live URL yet. Add one on that page.
114
- `);let C={...h,host:w,workspaceId:h.workspaceId??null,hostDeclined:!1};return ie(Wo(e),C),C}async function Zn(e,t,n={}){if(!t)return null;let s=Gn();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 Jn(e,s);if(!r)return process.stderr.write(`This spec is only on this computer. It was not published.
115
- `),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.
116
- `),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.
117
- `),null):(ie(Re(e),a),process.stdout.write(`Published it as v${a.version}.
118
- ${Kn(Ot(s),r.id)}
256
+ `),null}let k=h.host??null;if(!k&&s)for(Ri(o,{...h,host:k},u,f);!k;){let $=await Dp(e,n),g=await H(t,`/api/v2/cli/projects/${encodeURIComponent(h.id)}/url`,{method:"POST",body:JSON.stringify({url:$})}),p=await g.json().catch(()=>({})),d=rs(p.project);if(!g.ok||!d?.host){process.stderr.write(`gruum: ${p.error||`couldn't save that URL (${g.status})`}
257
+ `);continue}k=d.host,process.stderr.write(`Live URL set to ${tt(k)}.
258
+ `)}else Ri(o,{...h,host:k},u,f),!k&&!s&&process.stderr.write(`No live URL yet. Add one on that page.
259
+ `);let C={...h,host:k,workspaceId:h.workspaceId??null,hostDeclined:!1};return re(Ei(e),C),C}async function ps(e,t,n={}){if(!t)return null;let s=st();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 us(e,s);if(!r)return process.stderr.write(`This spec is only on this computer. It was not published.
260
+ `),null;let o=await H(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.
261
+ `),await rt(e,!1),null;let a=ze(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.
262
+ `),null):(re(Ee(e),a),process.stdout.write(`Published it as v${a.version}.
263
+ ${ls(Wt(s),r.id)}
119
264
  `),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.
120
- `),null}}async function Ye(e,t){if(t)return"local";let n=Gn();if(!n)return"local";try{let s=await Jn(e,n);if(!s)return"local";let r=Mt(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(Bn(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.
121
- `),"local"}}async function qn(e){let t=Gn();if(!t)return null;let n=await Jn(e,t);return n?{credentials:t,project:n}:null}async function Zo(e,t,n,s){let r=await qn(e);if(!r)return;let o=Mt(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:zo(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.
265
+ `),null}}async function rt(e,t){if(t)return"local";let n=st();if(!n)return"local";try{let s=await us(e,n);if(!s)return"local";let r=Gt(e.repoDir),o=await H(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=ze(i.baseline);return a?(re(Ee(e),a),re(Jn(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.
266
+ `),"local"}}async function fs(e){let t=st();if(!t)return null;let n=await us(e,t);return n?{credentials:t,project:n}:null}async function ji(e,t,n,s){let r=await fs(e);if(!r)return;let o=Gt(e.repoDir);if(o)try{let i=await H(r.credentials,`/api/v2/cli/projects/${encodeURIComponent(r.project.id)}/drift`,{method:"POST",body:JSON.stringify({action:"observe",concept:"button",branch:o,commit:_i(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.
122
267
  `)}catch{process.stderr.write(`gruum: couldn't reach Gruum to report this check. The local result still stands.
123
- `)}}async function qo(e,t,n){let s=await qn(e);if(!s)return{ok:!1,text:"Sign in with gruum login before requesting an exception."};let r=Mt(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:zo(e.repoDir),reason:n,item:t})}),i=await o.json().catch(()=>({}));if(!o.ok){let c=i.error||`Request failed (${o.status}).`;return{ok:!1,text:o.status===404?`${c} Run \`npx @gruum/cli check\` so this folder points at a project that exists. Do not edit .gruum/project.json.`:c}}let a=i.reviewUrl?`${Ot(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}
124
- ${a}`:l}}catch{return{ok:!1,text:"Couldn't reach Gruum to request an exception."}}}async function Xo(e,t){let n=await qn(e);if(!n)return{ok:!1,text:"Sign in with gruum login to see exception status."};let s=Mt(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(`
125
- `)}}catch{return{ok:!1,text:"Couldn't reach Gruum to read exception status."}}}var Dt="0.2.5",Yo=`gruum ${Dt}: keep buttons on the Gruum spec
268
+ `)}}async function Mi(e,t,n,s={}){let r=await fs(e);if(!r)return{ok:!1,text:"Sign in with gruum login before requesting an exception."};let o=Gt(e.repoDir);if(!o)return{ok:!1,text:"This folder is not on a named git branch."};let i=await Tp(e,r.project.host,s.pageUrl);if(i.askAgent)return{ok:!1,text:Fo};process.stderr.write(`gruum: opening Chrome to capture the button\u2026
269
+ `);let a=await fi({item:t,host:r.project.host,pageUrl:i.url,onlyPage:i.onlyPage,result:s.result,repoDir:e.repoDir});process.stderr.write(`gruum: ${di(a)}
270
+ `);try{let l=await H(r.credentials,`/api/v2/cli/projects/${encodeURIComponent(r.project.id)}/drift`,{method:"POST",body:JSON.stringify({action:"request",concept:"button",branch:o,commit:_i(e.repoDir),reason:n,item:t,capture:a})}),c=await l.json().catch(()=>({}));if(!l.ok){let m=c.error||`Request failed (${l.status}).`;return{ok:!1,text:l.status===404?`${m} Run \`npx @gruum/cli check\` so this folder points at a project that exists. Do not edit .gruum/project.json.`:m}}let u=c.reviewUrl?`${Wt(r.credentials)}${c.reviewUrl}`:"",f=c.created?`Exception request ${c.id} is pending review.`:`An exception for this change is already pending (${c.id}).`;return{ok:!0,text:u?`${f}
271
+ ${u}`:f}}catch{return{ok:!1,text:"Couldn't reach Gruum to request an exception."}}}async function Ti(e,t){let n=await fs(e);if(!n)return{ok:!1,text:"Sign in with gruum login to see exception status."};let s=Gt(e.repoDir);try{let r=await H(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(`
272
+ `)}}catch{return{ok:!1,text:"Couldn't reach Gruum to read exception status."}}}var it="0.2.7",Oi=`gruum ${it}: keep buttons on the Gruum spec
126
273
 
127
274
  Run it as \`npx @gruum/cli <command>\`.
128
275
 
@@ -149,44 +296,50 @@ Usage:
149
296
  pre-commit line. --remove deletes exactly what init added.
150
297
  gruum hook <after-file-edit|stop|before-shell>
151
298
  Cursor hook entry points (read the event on stdin).
152
- gruum request <drift id> --reason "<why>"
153
- Ask a designer to review one drift item from \`gruum check\`. Use this
154
- when the Cursor tool is not available. Do not edit .gruum files.
299
+ gruum request <drift id> --reason "<why>" [--url <page>]
300
+ Ask a designer to review one drift item from \`gruum check\`. Captures
301
+ a screenshot and a SnapDOM of the rendered button from the live URL,
302
+ or from --url when the button is not on the site root. Use this when
303
+ the Cursor tool is not available. Do not edit .gruum files.
155
304
  gruum mcp
156
305
  Stdio MCP server: gruum_button_spec, gruum_check_buttons,
157
306
  gruum_request_exception, and gruum_exception_status.
158
- `,mu=new Set(["--baseline","--root","--out","--cli","--files","--reason"]);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 mu.has(i)&&e[s+1]!==void 0&&l.push(e[++s]);n.set(i,l)}return{positional:t,flags:n}}var B=(e,t)=>e.flags.has(t),q=(e,t)=>e.flags.get(t)?.[0];function Ae(e,t=process.cwd()){let n=Tn(t),s=q(e,"--root")??Lt(n).root??"";return Tn(t,s)}var et="No spec found. Publish one from Gruum, or draft one locally with `npx @gruum/cli baseline --write`.";function hu(e,t){let n=he(e,q(t,"--baseline"));return n||process.stderr.write(`gruum: ${et}
159
- `),n}function Qe(e,t,n){let s={...t,checkedAt:new Date().toISOString(),baselineVersion:n.baseline.version,items:n.items};return Fn(e,s),s}async function es(e,t){let n=Yn({input:process.stdin,output:process.stdout});_e(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.
160
- `)}}finally{n.close()}}function Qo(e){return!!process.stdin.isTTY&&!B(e,"--ci")&&!B(e,"--json")&&!B(e,"--staged")}async function ti(e){if(!process.stdin.isTTY||!De(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(!Ss(t,n))return;let s=De(T.join(e.repoDir,".claude"));await es(Fs(s),Us)==="yes"&&ri(Qn(["init","cursor"]))}async function ni(e,t=!1){let n=Ae(e);await Ye(n,B(e,"--baseline"));let s=he(n,q(e,"--baseline"));if(s?.version===0&&!t&&!B(e,"--baseline")){let f=await Zn(n,s,{announceLocal:!1});f&&(s=f)}if(!s){if(!t&&Qo(e)){if(await es(Bs,zs)!=="baseline")return 0;let m=["baseline","--write"],h=q(e,"--root");h&&m.push("--root",h);let w=await si(Qn(m),!1);return w!==0?w:ni(e,!0)}return process.stderr.write(`gruum: ${et}
161
- `),0}let r=Ce(n,s,{staged:B(e,"--staged")});B(e,"--staged")||Qe(n,jt(n),r);let o=(e.flags.get("--files")??[]).map(f=>T.relative(T.join(n.repoDir,n.root),T.resolve(f)).split(T.sep).join("/")),i=Gt(r.items,o),a=Pt(n);(B(e,"--ci")||B(e,"--report"))&&await Zo(n,i,s.version,B(e,"--ci")?"ci":"local"),B(e,"--json")?process.stdout.write(`${JSON.stringify({baselineVersion:s.version,items:i,exceptions:a},null,2)}
162
- `):process.stdout.write(`${ms(i,{baselineVersion:s.version,files:r.result.index.files,skipped:r.result.index.skipped},a)}
163
- `);let l=ze(i,a),c=B(e,"--ci")||B(e,"--strict")||Lt(n).block,u=0;if(c&&B(e,"--strict")){let f=i.some(m=>m.severity==="block"&&a[m.id]==="pending");u=l.length>0||f?1:0}else c&&(u=l.length>0?1:0);if(B(e,"--ci")&&l.length===0){let f=i.filter(m=>a[m.id]==="pending");f.length>0&&process.stdout.write(`${f.length} pending exception${f.length===1?"":"s"}; this run does not fail on them.
164
- `)}return Qo(e)&&await ti(n),u}async function bu(e){let t=Ae(e);await Ye(t,B(e,"--baseline"));let n=hu(t,e);return n?(process.stdout.write(`${JSON.stringify(Wt(n),null,2)}
165
- `),0):1}async function si(e,t=!0){if(!B(e,"--write"))return process.stderr.write(`gruum: pass --write to draft a spec from the working tree.
166
- `),2;let n=Ae(e),s=Et(n),r=ds(s,{version:0}),o=q(e,"--out")?T.resolve(q(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.
307
+ `,Fp=new Set(["--baseline","--root","--out","--cli","--files","--reason","--url"]);function gs(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 Fp.has(i)&&e[s+1]!==void 0&&l.push(e[++s]);n.set(i,l)}return{positional:t,flags:n}}var U=(e,t)=>e.flags.has(t),q=(e,t)=>e.flags.get(t)?.[0];function Pe(e,t=process.cwd()){let n=Hn(t),s=q(e,"--root")??Bt(n).root??"";return Hn(t,s)}var at="No spec found. Publish one from Gruum, or draft one locally with `npx @gruum/cli baseline --write`.";function Bp(e,t){let n=ye(e,q(t,"--baseline"));return n||process.stderr.write(`gruum: ${at}
308
+ `),n}function ot(e,t,n){let s={...t,checkedAt:new Date().toISOString(),baselineVersion:n.baseline.version,items:n.items};return Zn(e,s),s}async function ms(e,t){let n=Ui({input:process.stdin,output:process.stdout});le(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.
309
+ `)}}finally{n.close()}}function Di(e){return!!process.stdin.isTTY&&!U(e,"--ci")&&!U(e,"--json")&&!U(e,"--staged")}async function Fi(e){if(!process.stdin.isTTY||!Ue(N.join(e.repoDir,".cursor")))return;let t=_e(N.join(e.repoDir,".cursor/hooks.json")),n=_e(N.join(e.repoDir,".cursor/mcp.json"));if(!Us(t,n))return;let s=Ue(N.join(e.repoDir,".claude"));await ms(nr(s),sr)==="yes"&&zi(gs(["init","cursor"]))}async function Bi(e,t=!1){let n=Pe(e);await rt(n,U(e,"--baseline"));let s=ye(n,q(e,"--baseline"));if(s?.version===0&&!t&&!U(e,"--baseline")){let f=await ps(n,s,{announceLocal:!1});f&&(s=f)}if(!s){if(!t&&Di(e)){if(await ms(tr,or)!=="baseline")return 0;let m=["baseline","--write"],h=q(e,"--root");h&&m.push("--root",h);let k=await Vi(gs(m),!1);return k!==0?k:Bi(e,!0)}return process.stderr.write(`gruum: ${at}
310
+ `),0}let r=Ae(n,s,{staged:U(e,"--staged")});U(e,"--staged")||ot(n,Ut(n),r);let o=(e.flags.get("--files")??[]).map(f=>N.relative(N.join(n.repoDir,n.root),N.resolve(f)).split(N.sep).join("/")),i=en(r.items,o),a=Ft(n);(U(e,"--ci")||U(e,"--report"))&&await ji(n,i,s.version,U(e,"--ci")?"ci":"local"),U(e,"--json")?process.stdout.write(`${JSON.stringify({baselineVersion:s.version,items:i,exceptions:a},null,2)}
311
+ `):process.stdout.write(`${Es(i,{baselineVersion:s.version,files:r.result.index.files,skipped:r.result.index.skipped},a)}
312
+ `);let l=Ge(i,a),c=U(e,"--ci")||U(e,"--strict")||Bt(n).block,u=0;if(c&&U(e,"--strict")){let f=i.some(m=>m.severity==="block"&&a[m.id]==="pending");u=l.length>0||f?1:0}else c&&(u=l.length>0?1:0);if(U(e,"--ci")&&l.length===0){let f=i.filter(m=>a[m.id]==="pending");f.length>0&&process.stdout.write(`${f.length} pending exception${f.length===1?"":"s"}; this run does not fail on them.
313
+ `)}return Di(e)&&await Fi(n),u}async function Vp(e){let t=Pe(e);await rt(t,U(e,"--baseline"));let n=Bp(t,e);return n?(process.stdout.write(`${JSON.stringify(Qt(n),null,2)}
314
+ `),0):1}async function Vi(e,t=!0){if(!U(e,"--write"))return process.stderr.write(`gruum: pass --write to draft a spec from the working tree.
315
+ `),2;let n=Pe(e),s=Dt(n),r=As(s,{version:0}),o=q(e,"--out")?N.resolve(q(e,"--out")):Ee(n);re(o,r);let i=N.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.
167
316
  Wrote ${i}.
168
- `);let a=await Zn(n,r);return a&&o!==Re(n)&&ie(o,a),a&&t&&await ti(n),0}function ei(e,t,n,s){if(!n.ok)return process.stderr.write(`gruum: ${n.error}
169
- `),!1;if(!n.changed)return s.push(`unchanged ${t}`),!0;let r=T.join(e.repoDir,t);return n.text===""?(Xn(r,{force:!0}),s.push(`removed ${t}`)):(me(r,n.text),s.push(`wrote ${t}`)),!0}function ri(e){if(e.positional[1]!=="cursor")return process.stderr.write(`gruum: usage: gruum init cursor [--remove] [--force] [--cli "<command>"]
170
- `),2;let t=Ae(e),n=q(e,"--cli"),s=n??We,r=n??Cs,o=n??qt,i=B(e,"--remove"),a=d=>Se(T.join(t.repoDir,d)),l=[],c=i?Rs(a(".cursor/hooks.json")):Xt(a(".cursor/hooks.json"),s),u=i?As(a(".cursor/mcp.json")):Yt(a(".cursor/mcp.json"),o);for(let d of[c,u])if(!d.ok)return process.stderr.write(`gruum: ${d.error}
171
- `),1;ei(t,".cursor/hooks.json",c,l),ei(t,".cursor/mcp.json",u,l);let f=a(Y);if(i)f!==null&&en(f)&&(Xn(T.join(t.repoDir,Y)),l.push(`removed ${Y}`));else if(f===null||B(e,"--force")){let d=he(t,q(e,"--baseline")),y=Is(d?null:yu(t)),k=d?[...new Set(d.styles.map(x=>x.path))].sort():[];me(T.join(t.repoDir,Y),Qt(k.length?k:y)),l.push(`wrote ${Y}`)}else if(en(f)){let d=js(f);d.changed?(me(T.join(t.repoDir,Y),d.text),l.push(`wrote ${Y}`)):l.push(`unchanged ${Y}`)}else l.push(`kept ${Y} (exists; --force replaces it)`);let m=i?Ps(a(".gitignore")):ot(a(".gitignore"));m.changed&&(me(T.join(t.repoDir,".gitignore"),m.text),l.push("wrote .gitignore"));let h=De(T.join(t.repoDir,".husky")),w=["lefthook.yml","lefthook.yaml",".lefthook.yml"].some(d=>De(T.join(t.repoDir,d))),C=bo(t),$=h?".husky/pre-commit":C?`${C}/pre-commit`:null,g=$?T.resolve(t.repoDir,$):null,p=g?Se(g):null;if(i){if(g&&p!==null){let d=Ms(p);d.changed&&d.text===""?(Xn(g,{force:!0}),l.push(`removed ${$}`)):d.changed&&(me(g,d.text),l.push(`edited ${$}`))}}else{let d=Ls({husky:h,lefthook:w,hookText:p,gitHooksDir:C},r);if(d.kind==="print")l.push(`pre-commit ${d.reason}:
172
- ${d.snippet}`);else if(d.changed&&g){if(me(g,d.text),d.kind==="git")try{gu(g,493)}catch{}l.push(`wrote ${$}${d.kind==="git"?" (local only; not shared through git)":""}`)}else l.push(`unchanged ${$}`)}return process.stdout.write(`${l.join(`
317
+ `);let a=await ps(n,r);return a&&o!==Ee(n)&&re(o,a),a&&t&&await Fi(n),0}function Ni(e,t,n,s){if(!n.ok)return process.stderr.write(`gruum: ${n.error}
318
+ `),!1;if(!n.changed)return s.push(`unchanged ${t}`),!0;let r=N.join(e.repoDir,t);return n.text===""?(ds(r,{force:!0}),s.push(`removed ${t}`)):(he(r,n.text),s.push(`wrote ${t}`)),!0}function zi(e){if(e.positional[1]!=="cursor")return process.stderr.write(`gruum: usage: gruum init cursor [--remove] [--force] [--cli "<command>"]
319
+ `),2;let t=Pe(e),n=q(e,"--cli"),s=n??Ke,r=n??Ns,o=n??rn,i=U(e,"--remove"),a=d=>_e(N.join(t.repoDir,d)),l=[],c=i?Fs(a(".cursor/hooks.json")):on(a(".cursor/hooks.json"),s),u=i?Bs(a(".cursor/mcp.json")):an(a(".cursor/mcp.json"),o);for(let d of[c,u])if(!d.ok)return process.stderr.write(`gruum: ${d.error}
320
+ `),1;Ni(t,".cursor/hooks.json",c,l),Ni(t,".cursor/mcp.json",u,l);let f=a(Y);if(i)f!==null&&cn(f)&&(ds(N.join(t.repoDir,Y)),l.push(`removed ${Y}`));else if(f===null||U(e,"--force")){let d=ye(t,q(e,"--baseline")),b=Ws(d?null:zp(t)),x=d?[...new Set(d.styles.map(w=>w.path))].sort():[];he(N.join(t.repoDir,Y),ln(x.length?x:b)),l.push(`wrote ${Y}`)}else if(cn(f)){let d=Gs(f);d.changed?(he(N.join(t.repoDir,Y),d.text),l.push(`wrote ${Y}`)):l.push(`unchanged ${Y}`)}else l.push(`kept ${Y} (exists; --force replaces it)`);let m=i?Ks(a(".gitignore")):dt(a(".gitignore"));m.changed&&(he(N.join(t.repoDir,".gitignore"),m.text),l.push("wrote .gitignore"));let h=Ue(N.join(t.repoDir,".husky")),k=["lefthook.yml","lefthook.yaml",".lefthook.yml"].some(d=>Ue(N.join(t.repoDir,d))),C=Io(t),$=h?".husky/pre-commit":C?`${C}/pre-commit`:null,g=$?N.resolve(t.repoDir,$):null,p=g?_e(g):null;if(i){if(g&&p!==null){let d=Js(p);d.changed&&d.text===""?(ds(g,{force:!0}),l.push(`removed ${$}`)):d.changed&&(he(g,d.text),l.push(`edited ${$}`))}}else{let d=Hs({husky:h,lefthook:k,hookText:p,gitHooksDir:C},r);if(d.kind==="print")l.push(`pre-commit ${d.reason}:
321
+ ${d.snippet}`);else if(d.changed&&g){if(he(g,d.text),d.kind==="git")try{Np(g,493)}catch{}l.push(`wrote ${$}${d.kind==="git"?" (local only; not shared through git)":""}`)}else l.push(`unchanged ${$}`)}return process.stdout.write(`${l.join(`
173
322
  `)}
174
323
  `),i||process.stdout.write(`
175
324
  Commit the .cursor/ files so teammates get the same guardrails. Tokens never go in the repository.
176
- `),0}function yu(e){try{return Et(e)}catch{return null}}async function xu(){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 ku(e){let t=e.workspace_roots,n=Array.isArray(t)&&typeof t[0]=="string"&&De(t[0])?t[0]:typeof e.cwd=="string"&&De(e.cwd)?e.cwd:process.cwd();return Ae({positional:[],flags:new Map},n)}async function wu(e){let t=e.positional[1],n=await xu(),s=t==="before-shell"?{permission:"allow"}:{};try{let r=ku(n),o=Lt(r),i={...o.hooks,exceptions:!0},a=he(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=rn(T.relative(r.repoDir,T.resolve(r.repoDir,f)).split(T.sep).join("/"),r.root);a&&m!==null&&Js(m)&&Qe(r,l,Ce(r,a))}else if(t==="stop"){if(a){let f=Qe(r,l,Ce(r,a)),m=ws(f,n,i,c);Fn(r,m.ledger),u=m.output}}else if(t==="before-shell"){let f=typeof n.command=="string"?n.command:"",m=Jt(f).some(h=>o.hooks.denyGit.includes(h));if(a&&m){let h=Qe(r,l,Ce(r,a));u=vs(h,n,i,c)}}else return process.stderr.write(`gruum: unknown hook ${String(t)}
325
+ `),0}function zp(e){try{return Dt(e)}catch{return null}}async function Wp(){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 Gp(e){let t=e.workspace_roots,n=Array.isArray(t)&&typeof t[0]=="string"&&Ue(t[0])?t[0]:typeof e.cwd=="string"&&Ue(e.cwd)?e.cwd:process.cwd();return Pe({positional:[],flags:new Map},n)}async function Kp(e){let t=e.positional[1],n=await Wp(),s=t==="before-shell"?{permission:"allow"}:{};try{let r=Gp(n),o=Bt(r),i={...o.hooks,exceptions:!0},a=ye(r),l=Ut(r),c=Ft(r),u=s;if(t==="after-file-edit"){let f=typeof n.file_path=="string"?n.file_path:"",m=gn(N.relative(r.repoDir,N.resolve(r.repoDir,f)).split(N.sep).join("/"),r.root);a&&m!==null&&cr(m)&&ot(r,l,Ae(r,a))}else if(t==="stop"){if(a){let f=ot(r,l,Ae(r,a)),m=Ts(f,n,i,c);Zn(r,m.ledger),u=m.output}}else if(t==="before-shell"){let f=typeof n.command=="string"?n.command:"",m=nn(f).some(h=>o.hooks.denyGit.includes(h));if(a&&m){let h=ot(r,l,Ae(r,a));u=Os(h,n,i,c)}}else return process.stderr.write(`gruum: unknown hook ${String(t)}
177
326
  `),2;process.stdout.write(`${JSON.stringify(u)}
178
327
  `)}catch(r){process.stderr.write(`gruum hook ${t}: ${r instanceof Error?r.message:String(r)}
179
328
  `),process.stdout.write(`${JSON.stringify(s)}
180
- `)}return 0}async function oi(e,t,n){await Ye(e,!1);let s=he(e);if(!s)return{ok:!1,text:et};let o=Ce(e,s).items.find(i=>i.id===t);return o?qo(e,o,n):{ok:!1,text:`No drift item ${t}. Run gruum_check_buttons or \`npx @gruum/cli check\` and use an id from that list. Do not edit .gruum files.`}}async function vu(e){let t=e.positional[1]??"",n=q(e,"--reason")?.trim()??"";if(!t||!n)return process.stderr.write(`Usage: npx @gruum/cli request <drift id> --reason "why this button should stay"
181
- `),2;let s=await oi(Ae(e),t,n);return(s.ok?process.stdout:process.stderr).write(`${s.text}
182
- `),s.ok?0:1}async function $u(e){let t=Ae(e),n=Gs({spec:async()=>{let o=he(t,q(e,"--baseline"));return o?{text:JSON.stringify(Wt(o),null,2)}:{text:et,isError:!0}},check:async o=>{let i=he(t,q(e,"--baseline"));if(!i)return{text:et,isError:!0};let a=Ce(t,i);Qe(t,jt(t),a);let l=Gt(a.items,o);return{text:JSON.stringify({baselineVersion:i.version,blocking:ze(l,Pt(t)).length,items:l},null,2)}},request:async(o,i)=>{let a=await oi(t,o,i);return{text:a.text,isError:!a.ok}},status:async o=>{let i=await Xo(t,o);return{text:i.text,isError:!i.ok}}}),s={name:"gruum",version:Dt},r=Yn({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"}})}
183
- `);continue}let a=await Hs(i,n,s);a&&process.stdout.write(`${JSON.stringify(a)}
184
- `)}return 0}async function Cu(){if(process.stdout.write(Ns(Dt)),!process.stdin.isTTY)return process.stdout.write(`
185
- ${Ee.map(n=>n.usage).join(`
329
+ `)}return 0}async function Wi(e,t,n,s){await rt(e,!1);let r=ye(e);if(!r)return{ok:!1,text:at};let o=Ae(e,r),i=o.items.find(a=>a.id===t);return i?Mi(e,i,n,{pageUrl:s,result:o.result}):{ok:!1,text:`No drift item ${t}. Run gruum_check_buttons or \`npx @gruum/cli check\` and use an id from that list. Do not edit .gruum files.`}}async function Hp(e){let t=e.positional[1]??"",n=q(e,"--reason")?.trim()??"";if(!t||!n)return process.stderr.write(`Usage: npx @gruum/cli request <drift id> --reason "why this button should stay" [--url http://localhost:3000/]
330
+ `),2;let s=await Wi(Pe(e),t,n,q(e,"--url"));return(s.ok?process.stdout:process.stderr).write(`${s.text}
331
+ `),s.ok?0:1}async function qp(e){let t=Pe(e),n=ir({spec:async()=>{let o=ye(t,q(e,"--baseline"));return o?{text:JSON.stringify(Qt(o),null,2)}:{text:at,isError:!0}},check:async o=>{let i=ye(t,q(e,"--baseline"));if(!i)return{text:at,isError:!0};let a=Ae(t,i);ot(t,Ut(t),a);let l=en(a.items,o);return{text:JSON.stringify({baselineVersion:i.version,blocking:Ge(l,Ft(t)).length,items:l},null,2)}},request:async(o,i,a)=>{let l=await Wi(t,o,i,a);return{text:l.text,isError:!l.ok}},status:async o=>{let i=await Ti(t,o);return{text:i.text,isError:!i.ok}}}),s={name:"gruum",version:it},r=Ui({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"}})}
332
+ `);continue}let a=await ar(i,n,s);a&&process.stdout.write(`${JSON.stringify(a)}
333
+ `)}return 0}function Jp(){let e=process.stdin;return new Promise(t=>{let n=(s,r)=>{e.off("keypress",n),t({name:r?.name,ctrl:r?.ctrl,sequence:r?.sequence??s})};e.on("keypress",n)})}async function Zp(e){let t=process.stdin;Up(t);let n=!1,s=()=>{n||(n=!0,process.off("exit",s),t.isTTY&&t.isRaw&&t.setRawMode(!1),t.pause(),process.stdout.write("\x1B[?25h"))};process.on("exit",s),t.isTTY&&t.setRawMode(!0),t.resume(),process.stdout.write("\x1B[?25l");let r=0,o=0;try{for(;;){let i=Ys(e,r),a=i.endsWith(`
334
+ `)?i.split(`
335
+ `).length-1:i.split(`
336
+ `).length;o>0&&process.stdout.write(`\x1B[${o}A`),process.stdout.write(i),o=a;let l=Qs(r,await Jp());if(l.type==="interrupt"&&(process.stderr.write(`
337
+ `),process.exit(130)),l.type==="quit")return"quit";if(l.type==="select")return we[l.index];l.type==="move"&&(r=l.index)}}finally{s()}}async function Xp(){if(!process.stdin.isTTY)return process.stdout.write(Xs(it)),process.stdout.write(`
338
+ ${we.map(t=>t.usage).join(`
186
339
  `)}
187
- `),0;let e=Yn({input:process.stdin,output:process.stdout});_e(e);let t=null;try{for(;;){let n=await new Promise(s=>{e.question(Ds,s)});if(t=Ws(n),t==="quit"||t)break;process.stdout.write(`Enter 1, 2, or 3.
188
- `)}}finally{e.close()}return!t||t==="quit"?0:Nt([t.name,...t.args])}async function Nt(e){let t=Qn(e),n=t.positional[0];if(B(t,"--version"))return process.stdout.write(`${Dt}
189
- `),0;if(B(t,"--help")||n==="help")return process.stdout.write(Yo),0;switch(n){case"login":{let s=await Jo();if(s!==0||!process.stdin.isTTY)return s;let r=await es(Ts,Vs);return r==="check"?Nt(["check"]):r==="baseline"?Nt(["baseline","--write"]):0}case"check":return ni(t);case"request":return vu(t);case"spec":return bu(t);case"baseline":return si(t);case"init":return ri(t);case"hook":return wu(t);case"mcp":return $u(t);case void 0:return Cu();default:return process.stderr.write(`gruum: unknown command ${n}
340
+ `),0;if(!st()){let t=await cs();if(t!==0)return t;process.stdout.write(`
341
+ `)}let e=await Zp(it);return e==="quit"?0:Kt([e.name,...e.args])}async function Kt(e){let t=gs(e),n=t.positional[0];if(U(t,"--version"))return process.stdout.write(`${it}
342
+ `),0;if(U(t,"--help")||n==="help")return process.stdout.write(Oi),0;switch(n){case"login":{let s=await cs();if(s!==0||!process.stdin.isTTY)return s;let r=await ms(er,rr);return r==="check"?Kt(["check"]):r==="baseline"?Kt(["baseline","--write"]):0}case"check":return Bi(t);case"request":return Hp(t);case"spec":return Vp(t);case"baseline":return Vi(t);case"init":return zi(t);case"hook":return Kp(t);case"mcp":return qp(t);case void 0:return Xp();default:return process.stderr.write(`gruum: unknown command ${n}
190
343
 
191
- ${Yo}`),2}}Nt(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)}
344
+ ${Oi}`),2}}Kt(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)}
192
345
  `),process.exitCode=1});