@grum-os/cli 0.3.28 → 0.3.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content.md5 +1 -1
- package/grum.mjs +58 -58
- package/package.json +2 -2
package/grum.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
globalThis.__GRUM_VERSION__="0.3.
|
|
2
|
+
globalThis.__GRUM_VERSION__="0.3.29";
|
|
3
3
|
import{chmodSync as _R,existsSync as ft,readdirSync as ny,rmSync as po}from"node:fs";import{homedir as cy}from"node:os";import{fileURLToPath as jR}from"node:url";import ee from"node:path";import{createInterface as OR,emitKeypressEvents as MR}from"node:readline";var yo=(e,t,n)=>Math.min(n,Math.max(t,e)),go=e=>yo(Math.round(e),0,255).toString(16).padStart(2,"0").toUpperCase();function bo({r:e,g:t,b:n,a:r}){let o=`#${go(e)}${go(t)}${go(n)}`,s=Math.round(yo(r,0,1)*255);return s>=255?o:`${o}${go(s)}`}function wy(e){let t=e.replace(/^#/,"");if(!/^[0-9a-f]+$/i.test(t)||![3,4,6,8].includes(t.length))return null;let n=t.length<=4?[...t].map(s=>s+s).join(""):t,r=parseInt(n.slice(0,6),16),o=n.length===8?parseInt(n.slice(6,8),16)/255:1;return{r:r>>16&255,g:r>>8&255,b:r&255,a:o}}function ho(e,t){let n=e.trim();return n.endsWith("%")?parseFloat(n)/100*t:parseFloat(n)}function ky(e,t,n){let r=s=>(s+e/30)%12,o=s=>n-t*Math.min(n,1-n)*Math.max(-1,Math.min(r(s)-3,9-r(s),1));return[o(0)*255,o(8)*255,o(4)*255]}function mo(e,t){return e==="none"?0:ho(e,t)}function Fc(e,t,n){let r=(e+.3963377774*t+.2158037573*n)**3,o=(e-.1055613458*t-.0638541728*n)**3,s=(e-.0894841775*t-1.291485548*n)**3,i=[4.0767416621*r-3.3077115913*o+.2309699292*s,-1.2684380046*r+2.6097574011*o-.3413193965*s,-.0041960863*r-.7034186147*o+1.707614701*s],[l,a,c]=i.map(u=>{let p=yo(u,0,1);return(p<=.0031308?12.92*p:1.055*p**(1/2.4)-.055)*255});return[l,a,c]}function gt(e){let t=e.trim().toLowerCase();if(t.startsWith("#"))return wy(t);let n=t.match(/^(rgba?|hsla?|oklch|oklab)\(([^)]*)\)$/);if(!n?.[1]||n[2]==null)return null;let r=n[2].split(/[\s,/]+/).filter(Boolean);if(r.length<3)return null;let o=r[3]!=null?mo(r[3],1):1;if(n[1].startsWith("ok")){let p=yo(mo(r[0],1),0,1),d=mo(r[1],.4);if(n[1]==="oklab"){let b=mo(r[2],.4);if([p,d,b,o].some(Number.isNaN))return null;let[k,y,x]=Fc(p,d,b);return{r:k,g:y,b:x,a:o}}let f=r[2];if(f!=="none"&&!/^-?[\d.]+(deg)?$/.test(f))return null;let m=(f==="none"?0:parseFloat(f))*Math.PI/180;if([p,d,m,o].some(Number.isNaN))return null;let[g,S,h]=Fc(p,d*Math.cos(m),d*Math.sin(m));return{r:g,g:S,b:h,a:o}}if(n[1].startsWith("rgb")){let[p,d,f]=r.slice(0,3).map(m=>ho(m,255));return[p,d,f,o].some(Number.isNaN)?null:{r:p,g:d,b:f,a:o}}let s=parseFloat(r[0]),i=ho(r[1],1),l=ho(r[2],1);if([s,i,l,o].some(Number.isNaN))return null;let[a,c,u]=ky((s%360+360)%360,i,l);return{r:a,g:c,b:u,a:o}}function ce(e){let t=gt(e);return t?bo(t):null}function Uc({r:e,g:t,b:n}){let r=p=>{let d=p/255;return d<=.04045?d/12.92:((d+.055)/1.055)**2.4},[o,s,i]=[r(e),r(t),r(n)],l=(o*.4124+s*.3576+i*.1805)/.95047,a=o*.2126+s*.7152+i*.0722,c=(o*.0193+s*.1192+i*.9505)/1.08883,u=p=>p>.008856?Math.cbrt(p):7.787*p+16/116;return[116*u(a)-16,500*(u(l)-u(a)),200*(u(a)-u(c))]}function fi(e){return`--color-${e.replace(/^#/,"").slice(0,6).toLowerCase()}`}function wo(e,t){let n=gt(e),r=gt(t);if(!n||!r)return 1/0;let[o,s,i]=Uc(n),[l,a,c]=Uc(r);return Math.hypot(o-l,s-a,i-c)}var lr=/#(?:[0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{3,4})\b|\b(?:rgba?|hsla?|oklch|oklab)\([^)]*\)/gi;var gi={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 zc(e){let t=e.lastIndexOf("-");return t<=0?null:gi[e.slice(0,t)]?.[e.slice(t+1)]??null}function Rn(e){let t=[],n=0,r=0;for(let o=0;o<e.length;o++){let s=e[o];s==="("||s==="["?n++:s===")"||s==="]"?n=Math.max(0,n-1):s===","&&n===0&&(t.push(e.slice(r,o).trim()),r=o+1)}return t.push(e.slice(r).trim()),t.filter(Boolean)}function xy(e,t){if(!e)return t;let n=Rn(e);return Rn(t).flatMap(r=>n.map(o=>r.includes("&")?r.replaceAll("&",o):`${o} ${r}`)).join(", ")}var vy=/^@(?:-\w+-)?(?:keyframes|font-face|property)\b/i;function ko(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,i=>i.replace(/[^\n]/g," ")),n=[],r=[],o=0,s=1;for(let i=0;i<t.length;i++){let l=t[i];if(l===`
|
|
4
4
|
`&&s++,l==="{"){let a=t.slice(o,i).trim(),c=r[r.length-1];c&&(c.own+=t.slice(c.segStart,o));let u=/^@theme\b/i.test(a),p=a.startsWith("@")&&!u,d=[...r].reverse().find(f=>!f.isAt)??null;r.push({raw:a,resolved:p?a:u?":root":xy(d?.resolved??null,a),isAt:p,skip:(c?.skip??!1)||p&&vy.test(a),line:s,own:"",segStart:i+1}),o=i+1}else if(l==="}"){let a=r.pop();if(a){a.own+=t.slice(a.segStart,i),!a.isAt&&!a.skip&&n.push({selector:a.resolved,body:a.own,line:a.line,context:r.filter(u=>u.isAt).map(u=>u.raw.replace(/\s+/g," ")).join(" \xB7 ")});let c=r[r.length-1];c&&(c.segStart=i+1)}o=i+1}else l===";"&&(o=i+1)}return n}function xo(e){let t=[],n=0,r=0,o=s=>{let i=s.indexOf(":");if(i<=0)return;let l=s.slice(0,i).trim(),a=s.slice(i+1).replace(/\s+/g," ").trim();/^-{0,2}[a-z][\w-]*$/i.test(l)&&a&&t.push({property:l,value:a})};for(let s=0;s<e.length;s++){let i=e[s];i==="("?n++:i===")"?n=Math.max(0,n-1):i===";"&&n===0&&(o(e.slice(r,s)),r=s+1)}return o(e.slice(r)),t}var Gc=e=>e.replace(/\\(.)/g,"$1");function Sy(e){let t=e;for(;;){let n=/:(?:global|local)\(/i.exec(t);if(!n)break;let r=0,o=-1;for(let i=n.index+n[0].length-1;i<t.length;i++){let l=t[i];if(l==="(")r++;else if(l===")"&&--r===0){o=i;break}}if(o<0)break;let s=t.slice(n.index+n[0].length,o).trim();t=`${t.slice(0,n.index)}${s}${t.slice(o+1)}`}return t.replace(/:(?:global|local)(?=\s|$)/gi,"").trim()}var mi=/\*|[a-z][\w-]*|\.((?:\\.|[\w-])+)|#((?:\\.|[\w-])+)|\[\s*([\w-]+)\s*(?:([~|^$*]?=)\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*[is]?\s*\]|::([\w-]+)|:([\w-]+)(\((?:[^()]|\([^()]*\))*\))?/giy;function tt(e){let t=[];mi.lastIndex=0;let n=0;for(;n<e.length;){mi.lastIndex=n;let r=mi.exec(e);if(!r||r.index!==n)return null;let o=r[0];if(n+=o.length,o==="*")t.push({kind:"universal",raw:o});else if(r[1]!==void 0)t.push({kind:"class",raw:o,name:Gc(r[1])});else if(r[2]!==void 0)t.push({kind:"id",raw:o,name:Gc(r[2])});else if(r[3]!==void 0)t.push({kind:"attr",raw:o,name:r[3],op:r[4]??null,value:r[4]?r[5]??r[6]??r[7]??"":null});else if(r[8]!==void 0)t.push({kind:"pseudoElement",raw:o,name:r[8].toLowerCase()});else if(r[9]!==void 0){let s=r[9].toLowerCase();/^(?:before|after|first-line|first-letter)$/.test(s)?t.push({kind:"pseudoElement",raw:o,name:s}):t.push({kind:"pseudo",raw:o,name:s,args:r[10]?r[10].slice(1,-1).trim():null})}else if(t.length===0)t.push({kind:"tag",raw:o,name:o.toLowerCase()});else return null}return t.length?t:null}function ue(e){let t=Sy(e),n=[],r=0,o=0,s=null,i=!0,l=a=>{let c=t.slice(o,a).trim();if(!c)return!0;let u=tt(c);return u?(n.push({combinator:i?null:s??" ",simples:u}),i=!1,s=null,!0):!1};for(let a=0;a<t.length;a++){let c=t[a];if(c==="("||c==="[")r++;else if(c===")"||c==="]")r=Math.max(0,r-1);else if(r===0&&(c===">"||c==="+"||c==="~")){if(!l(a)||s)return null;s=c,o=a+1}else if(r===0&&/\s/.test(c)){if(!l(a))return null;o=a+1}}return!l(t.length)||s?null:n.length?n:null}function An(e){return e.map(t=>t.raw).join("")}function cr(e){return e.map((t,n)=>{let r=An(t.simples);return n===0?r:t.combinator===" "?` ${r}`:` ${t.combinator} ${r}`}).join("")}function re(e){let t=[],n=0,r=0;for(let o=0;o<e.length;o++){let s=e[o];s==="("||s==="["?n++:s===")"||s==="]"?n=Math.max(0,n-1):s===","&&n===0&&(t.push(e.slice(r,o).trim()),r=o+1)}return t.push(e.slice(r).trim()),t.filter(Boolean)}var Hc=e=>e.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(t=>t.toLowerCase());function Bc(e,t){let n=e.toLowerCase();return t.some(r=>n.includes(r.toLowerCase()))}function hi(e,t){let n=t.excludeClassKeywords;if(!n?.length)return!1;let r=new Set(n.flatMap(o=>[o.toLowerCase(),`${o.toLowerCase()}s`]));return e.some(o=>o.kind==="class"&&Hc(o.name).some(s=>r.has(s)))}var $y=new Set(["html","body"]),Cy=new Set(["svg","path","use","img","picture","video","i","em","strong","b","small","kbd","sup","sub"]);function So(e,t){for(let n of e)switch(n.kind){case"tag":if(t.elements.includes(n.name))return!0;break;case"class":if(Bc(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&&Bc(n.value,t.classKeywords))return!0;break;case"pseudo":if((n.name==="is"||n.name==="where")&&n.args){let r=re(n.args).map(ue);if(r.length>0&&r.every(o=>o!==null&&So(o[o.length-1].simples,t)))return!0}break;default:break}return!1}function Vc(e){return e.some(n=>n.kind==="universal")?e.length===1:e.some(n=>n.kind==="tag"&&$y.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 qc(e){return e.some(t=>t.kind==="tag"&&Cy.has(t.name))}var vo=["hover","focus","active","selected","current","loading","disabled"],Ry={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"},Ay={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",checked:"selected",disabled:"disabled"},Iy={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"},Ey=new Set(["active","selected","pressed","checked","loading","busy","disabled","open","current","hover","focus","show","expanded","collapsed"]),Wc=e=>Ry[e.toLowerCase()]??e.toLowerCase(),At={hover:"__gs-hover",focus:"__gs-focus",active:"__gs-active"};function Jc(e){if(e.kind==="pseudo"){let t=Ay[e.name];if(!t)return null;let n=At[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:Wc(e.value),marker:{classes:[],attrs:{"data-state":e.value}}};let t=Iy[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]:Ey.has(e.name.toLowerCase())?e.name:null;return n?{state:Wc(n),marker:{classes:[e.name],attrs:{}}}:null}return null}function Ty(e){return e.kind!=="pseudo"||e.name!=="not"||!e.args?!1:re(e.args).every(t=>{let n=tt(t);return n!==null&&n.every(r=>Jc(r)!==null)})}function mt(e){let t=[],n=new Map;for(let s of e){if(Ty(s))continue;let i=Jc(s);if(!i){t.push(s);continue}let l=n.get(i.state)??{classes:[],attrs:{}};for(let a of i.marker.classes)l.classes.includes(a)||l.classes.push(a);Object.assign(l.attrs,i.marker.attrs),n.set(i.state,l)}let r=[...n.keys()].sort((s,i)=>Me(s)-Me(i)||s.localeCompare(i)),o={classes:[],attrs:{}};for(let s of r){let i=n.get(s);o.classes.push(...i.classes),Object.assign(o.attrs,i.attrs)}return{identity:t,states:r,marker:o}}function Me(e){if(e==="default")return-1;let t=vo.indexOf(e);return t===-1?vo.length:t}function nt(e){return e.length?e.join(" + "):"default"}function yi(e){return e.replace(/:hover\b/g,`.${At.hover}`).replace(/:focus(?:-visible|-within)?\b/g,`.${At.focus}`).replace(/:active\b/g,`.${At.active}`)}var _y=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"]),jy=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"]),Oy=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 ur(e){let t=e.toLowerCase();return _y.has(t)?"paint":jy.has(t)?"layout":Oy.has(t)?"hint":"box"}var My={shadow:/^box-shadow$/,cursor:/^cursor$/,rounded:/^border(?:-[a-z]+)*-radius$/,radius:/^border(?:-[a-z]+)*-radius$/};function Kc(e,t){let n=e.filter(s=>s.kind==="class");if(n.length!==1||e.length!==1)return!1;let r=Hc(n[0].name)[0],o=r?My[r]:void 0;return o?t.length>0&&t.every(s=>o.test(s.property.toLowerCase())):!1}function pr(e){let t=[],n=/var\(\s*(--[\w-]+)\s*(,)?/g;for(let r of e.matchAll(n)){let o=null;if(r[2]){let s=1,i=r.index+r[0].length,l=i;for(;l<e.length;l++)if(e[l]==="(")s++;else if(e[l]===")"&&--s===0)break;o=e.slice(i,l).trim()}t.push({name:r[1],fallback:o,index:r.index})}return t}function Dy(e){let t="",n=0;for(;n<e.length;){let r=e.indexOf("var(",n);if(r<0)return t+e.slice(n);t+=e.slice(n,r);let o=0,s=r+3;for(;s<e.length;s++)if(e[s]==="(")o++;else if(e[s]===")"&&--o===0)break;n=s+1}return t}var Py=/(?<![\w#-])-?\d*\.?\d+(?:px|rem|em|vw|vh|vmin|vmax|ch|ex|%)/gi;function $o(e){let t=Dy(e);return new RegExp(lr.source,"i").test(t)?!0:[...t.matchAll(Py)].some(n=>parseFloat(n[0])!==0)}function Xc(e,t){let n=ce(e),r=ce(t);return n||r?n===r:e.trim().toLowerCase()===t.trim().toLowerCase()}function Ly(e){let t=ue(e);if(!t)return null;let n=o=>new Set(t[o].simples.flatMap(s=>s.kind==="class"?[s.name]:[])),r=[n(t.length-1)];for(let o=t.length-2;o>=0;o--){let s=t[o+1].combinator;(s===" "||s===">")&&r.push(n(o))}for(let o of[...r])for(let s of o){let i=s.match(/^(.+?)__/)?.[1];i&&r.push(new Set([i]))}return r}var Ny=(e,t)=>[...t].some(n=>e.startsWith(`${n}--`));function Fy(e,t,n){let r="no";for(let o of re(e.selector)){let s=ue(o);if(!s)return"possible";let i=s[s.length-1].simples,l=i.flatMap(u=>u.kind==="class"?[u.name]:[]),a=s.length>1||e.context!==""||i.some(u=>u.kind!=="class"&&u.kind!=="tag"),c="no";if(l.length?t.some(u=>l.every(p=>u.has(p)))?c=a?"possible":"proven":(t.some(u=>l.every(p=>u.has(p)||Ny(p,u)))||n.some(u=>l.every(p=>u.includes(p))&&t.some(p=>u.some(d=>p.has(d)))))&&(c="possible"):c="possible",c==="proven")return c;c==="possible"&&(r=c)}return r}function Zc(e){let t=[];for(let n of e.matchAll(/\bclass(?:Name)?\s*=\s*\{?\s*["'`]([^"'`]+)["'`]/g)){let r=n[1].split(/\s+/).filter(o=>/^[\w-]+$/.test(o));r.length>1&&t.push(r)}return t}function Yc(e,t,n){let r=new Map;for(let a of e)r.set(a.name,[...r.get(a.name)??[],a]);let o=()=>({covered:!0,tokens:[],through:[],failing:[],reason:null}),s=(a,c)=>{a.tokens.push(...c.tokens.filter(u=>!a.tokens.includes(u))),a.through.push(...c.through.filter(u=>!a.through.includes(u))),a.failing.push(...c.failing.filter(u=>!a.failing.includes(u))),c.covered||(a.covered=!1,a.reason??=c.reason)};function i(a,c,u){let p=o();for(let d of pr(a))s(p,l(d.name,d.fallback,c,u));return $o(a)&&(p.covered=!1,p.reason??="set to a hard-coded value"),p}function l(a,c,u,p){if(p.has(a))return{...o(),covered:!1,reason:"refers to itself"};let d=new Set([...p,a]),f=[],m=[];for(let h of r.get(a)??[]){let b=Fy(h,u,t);b==="proven"?f.push(h):b==="possible"&&m.push(h)}let g=n.get(a),S=o();f.length||(g!==void 0?S.tokens.push(a):c==null?(S.covered=!1,S.reason="no declaration is proven to apply here"):s(S,i(c,u,d)));for(let h of[...f,...m]){if(g!==void 0&&Xc(h.value,g)){S.through.push(h),S.tokens.includes(a)||S.tokens.push(a);continue}let b=i(h.value,u,d);S.through.push(h),!b.covered&&($o(h.value)||!b.failing.length)&&b.failing.unshift(h),s(S,b)}return S}return(a,c,u)=>{let p=o();if(u==null)return p.covered=n.has(a),p.covered?p.tokens.push(a):p.reason="read outside a stylesheet rule",p;for(let d of re(u)){let f=Ly(d);if(!f){s(p,{...o(),covered:!1,reason:"selector Grum can't read"});continue}s(p,l(a,c,f,new Set))}return p}}var Qc={color:"Color",typography:"Typography",spacing:"Spacing",radius:"Radius",shadow:"Shadows",other:"Other"},Uy=/\.(css|scss|sass|less|pcss)$/i,zy=/^(?::root|html|body|:host)?(?:\[data-[\w-]+(?:[~|^$*]?=[^\]]*)?\]|\.(?:(?:light|dark)(?:-mode)?|theme-[\w-]+))*$/i;function eu(e){let t=e.split(",").map(n=>n.trim());return t.length>0&&t.every(n=>n!==""&&zy.test(n))}function Kt(e){return Uy.test(e)}function Gy(...e){let t=e.map(r=>r??"").join("\0"),n=5381;for(let r=0;r<t.length;r++)n=(n*33^t.charCodeAt(r))>>>0;return n.toString(36)}function It(e){let t=n=>(n??"").replace(/\s+/g," ").trim();return Gy(e.file,t(e.selector),t(e.context),e.property.toLowerCase(),t(e.value).toLowerCase())}function bi(e){let t=e.evidence;return t?t.observed.length?"observed":t.definitions.some(n=>n.useCount>0)?"implemented":"defined":"unverified"}var By=200,ou=/\.html?$/i,Wy=/\.(m?[jt]sx?|vue|svelte|astro)$/i,Hy=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Vy=new Set(["script","style","textarea","title"]),qy=new Set(["li","p","option","tr","td","th","dt","dd"]),Co=/\{\{|\$\{|<%|\{%/;function Jy(e){return`/${e}`.replace(/^\/(?:public|static|dist|site|docs)\//,"/").replace(/(^|\/)index\.html?$/i,"$1")}function Ky(e){let t=e.split(`
|
|
5
5
|
`),n={tag:"#document",id:null,classes:[],attrs:{},line:0,snippet:"",parent:null,children:[],dynamic:!1},r=[],o="",s=n,i=1,l=0,a=c=>{for(let u=l;u<c&&u<e.length;u++)e[u]===`
|
|
6
6
|
`&&i++;l=c};for(;l<e.length;){let c=e.indexOf("<",l);if(c<0)break;if(a(c),e.startsWith("<!--",l)){let x=e.indexOf("-->",l+4);a(x<0?e.length:x+3);continue}if(e[l+1]==="!"||e[l+1]==="?"){let x=e.indexOf(">",l);a(x<0?e.length:x+1);continue}let u=/^<\/([a-zA-Z][\w:-]*)\s*>/.exec(e.slice(l,l+80));if(u){let x=u[1].toLowerCase();for(let v=s;v&&v!==n;v=v.parent)if(v.tag===x){s=v.parent??n;break}a(l+u[0].length);continue}let p=/^<([a-zA-Z][\w:-]*)/.exec(e.slice(l,l+80));if(!p){a(l+1);continue}let d=i,f=l+p[0].length,m=null;for(;f<e.length;f++){let x=e[f];if(m)x===m&&(m=null);else if(x==='"'||x==="'")m=x;else if(x===">")break}let g=e.slice(l+p[0].length,f),S=p[1].toLowerCase(),h={},b=!1;for(let x of g.matchAll(/([^\s"'=<>/`]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g)){let v=x[1].toLowerCase(),$=x[2]??x[3]??x[4]??"";/^(?::class|v-bind:class|\[class\]|\[ngclass\]|classname)$/.test(v)&&(b=!0),!(v in h)&&(h[v]=$)}Co.test(h.class??"")&&(b=!0),qy.has(S)&&s.tag===S&&(s=s.parent??n);let k={tag:S,id:h.id&&!Co.test(h.id)?h.id:null,classes:(h.class??"").split(/\s+/).filter(x=>x&&!Co.test(x)),attrs:h,line:d,snippet:ht(t[d-1]??""),parent:s,children:[],dynamic:b};s.children.push(k),r.push(k),a(f+1);let y=g.trimEnd().endsWith("/");if(Vy.has(S)){let x=e.toLowerCase().indexOf(`</${S}`,l),v=x<0?e.length:x;S==="script"&&(o+=`
|
|
7
7
|
${e.slice(l,v)}`),a(v);continue}!Hy.has(S)&&!y&&(s=k)}return{elements:r,scripts:o}}var Xy=e=>e.replace(/[?#].*$/,"");function ki(e,t,n){let r=Xy(t.trim());if(!r||/^(?:[a-z]+:)?\/\//i.test(r)||/^data:/i.test(r))return null;let o=r.startsWith("/")?r.slice(1).split("/"):[...e.split("/").slice(0,-1),...r.split("/")],s=[];for(let l of o)!l||l==="."||(l===".."?s.pop():s.push(l));let i=s.join("/");for(let l of[i,`public/${i}`,`static/${i}`,`src/${i}`])if(n.has(l))return l;return null}function xi(e,t,n=new Set){if(n.has(e))return[];n.add(e);let r=t.get(e)??"",o=[];for(let s of r.matchAll(/@import\s+(?:url\(\s*)?["']?([^"')\s;]+)["']?\s*\)?/g)){let i=ki(e,s[1],t);i&&Kt(i)&&o.push(...xi(i,t,n))}return o.push(e),o}var wi=(e,t)=>{let n=new Map;for(let r of e)for(let o of t(r))n.set(o,[...n.get(o)??[],r]);return n};function tu(e,t){for(let n of e.matchAll(/(?:classList\.(?:add|toggle|replace)|(?:add|toggle)Class)\(([^)]*)\)/g))for(let r of n[1].matchAll(/["'`]([\w\s-]+)["'`]/g))for(let o of r[1].split(/\s+/))o&&t.add(o);for(let n of e.matchAll(/class(?:Name)?\s*[=:]\s*["'`]([^"'`]+)["'`]/g))for(let r of n[1].split(/\s+/))/^[\w-]+$/.test(r)&&t.add(r)}function su(e,t){let n=[],r=new Set,o=!1,s=new Map;for(let[l,a]of e){if(t?.test(l))continue;if(Wy.test(l)){tu(a,r);for(let d of a.matchAll(/(?:import\s+(?:[^'"]*?from\s+)?|require\(\s*)["']([^"']+\.(?:css|scss|sass|less|pcss))["']/g)){let f=ki(l,d[1],e);f&&!s.has(f)&&s.set(f,l)}continue}if(!ou.test(l))continue;if(n.length>=By){o=!0;continue}let{elements:c,scripts:u}=Ky(a);tu(u,r);let p=[];for(let d of c){if(d.tag!=="link"||!/(^|\s)stylesheet(\s|$)/i.test(d.attrs.rel??""))continue;let f=ki(l,d.attrs.href??"",e);if(f&&Kt(f))for(let m of xi(f,e))p.includes(m)||p.push(m)}n.push({file:l,path:Jy(l),elements:c,byClass:wi(c,d=>d.classes),byId:wi(c,d=>d.id?[d.id]:[]),byTag:wi(c,d=>[d.tag]),sheets:p,dynamic:c.some(d=>d.dynamic)})}let i=new Map;for(let l of n)for(let a of l.sheets)i.set(a,[...i.get(a)??[],l]);for(let[l,a]of[...s])for(let c of xi(l,e))s.has(c)||s.set(c,a);return{pages:n,sheetPages:i,scriptClasses:r,codeSheets:s,truncated:o}}function iu(e){return e.pages.filter(t=>t.sheets.length).map(t=>t.path)}var Zy={hover:"hover",focus:"focus","focus-visible":"focus-visible","focus-within":"focus-within",active:"active",visited:"visited",checked:"checked",disabled:"disabled",enabled:"enabled",target:"target","placeholder-shown":"placeholder-shown",invalid:"invalid",valid:"valid"},Et=e=>e!==null&&"unknown"in e;function nu(e){let t=e.parent?.children??[];return t.slice(0,t.indexOf(e))}function Yy(e,t,n){switch(e.kind){case"universal":return!0;case"tag":return t.tag===e.name;case"id":return t.id===e.name;case"class":return t.classes.includes(e.name);case"attr":{let r=t.attrs[e.name.toLowerCase()];if(r===void 0)return!1;if(e.op===null||e.value===null)return!0;if(Co.test(r))return`[${e.name}] is set at runtime`;let o=e.value;switch(e.op){case"=":return r===o;case"~=":return r.split(/\s+/).includes(o);case"|=":return r===o||r.startsWith(`${o}-`);case"^=":return r.startsWith(o);case"$=":return r.endsWith(o);case"*=":return r.includes(o);default:return`${e.raw} isn't evaluated`}}case"pseudoElement":return n.pseudoElement=e.name,!0;case"pseudo":{let r=Zy[e.name];if(r)return n.states.push(r),!0;let o=t.parent?.children??[t];switch(e.name){case"root":return t.tag==="html";case"link":case"any-link":return t.tag==="a"&&"href"in t.attrs;case"first-child":return o[0]===t;case"last-child":return o[o.length-1]===t;case"only-child":return o.length===1;case"first-of-type":return o.find(s=>s.tag===t.tag)===t;case"last-of-type":return o.findLast(s=>s.tag===t.tag)===t;case"not":case"is":case"where":case"matches":{let s=Rn(e.args??"").map(tt);if(!s.length||s.some(c=>!c))return`${e.raw} isn't evaluated`;let i=s.map(c=>au(c,t)),l=i.find(Et);if(e.name==="not")return i.some(c=>c&&!Et(c)&&c.states.length)?!0:l?l.unknown:i.every(c=>c===null);let a=i.find(c=>c!==null&&!Et(c));return a?(n.states.push(...a.states),!0):l?l.unknown:!1}default:return`${e.raw} isn't evaluated`}}}}function au(e,t){let n={states:[]},r=null;for(let o of e){let s=Yy(o,t,n);if(s===!1)return null;typeof s=="string"&&(r=s)}return r?{unknown:r}:n}function Si(e,t,n){let r=au(e[t].simples,n);if(r===null||t===0)return r;let o=a=>a===null?null:Et(r)?r:Et(a)?a:{states:[...a.states,...r.states],...r.pseudoElement&&{pseudoElement:r.pseudoElement}},s=e[t].combinator,i=s===">"?[n.parent]:s==="+"?[nu(n).at(-1)]:s==="~"?nu(n).reverse():(()=>{let a=[];for(let c=n.parent;c;c=c.parent)a.push(c);return a})(),l=null;for(let a of i){if(!a||a.tag==="#document")continue;let c=o(Si(e,t-1,a));if(c&&!Et(c))return c;c&&(l=c)}return l}function Qy(e,t){let n=t[t.length-1].simples,r=n.find(i=>i.kind==="id");if(r?.kind==="id")return e.byId.get(r.name)??[];let o=n.find(i=>i.kind==="class");if(o?.kind==="class")return e.byClass.get(o.name)??[];let s=n.find(i=>i.kind==="tag");return s?.kind==="tag"?e.byTag.get(s.name)??[]:e.elements}function lu(e){let t=0,n=0,r=0;for(let{simples:o}of e)for(let s of o)s.kind==="id"?t++:s.kind==="class"||s.kind==="attr"||s.kind==="pseudo"&&s.name!=="where"?n++:(s.kind==="tag"||s.kind==="pseudoElement")&&r++;return t*1e4+n*100+r}function cu(e,t,n){let r=[],o=null,s=new Set;for(let i of Rn(n)){let l=ue(i);if(!l){o??=`Grum can't read the selector ${i}`;continue}let a=lu(l),c=!1;for(let d of t)for(let f of Qy(d,l)){let m=Si(l,l.length-1,f);if(m!==null){if(Et(m)){o??=m.unknown;continue}c=!0,!s.has(f)&&(s.add(f),r.push({el:f,page:d,hit:m,specificity:a}))}}if(c)continue;let p=l.flatMap(d=>d.simples.flatMap(f=>f.kind==="class"?[f.name]:[])).find(d=>e.scriptClasses.has(d));p?o??=`a script adds .${p} at runtime`:t.some(d=>d.dynamic)&&(o??="some markup builds its classes at runtime")}return{matched:r,unknown:o}}function eb(e,t){let n=[...new Set(e.hit.states)].join(" + ");return{file:e.page.file,line:e.el.line,snippet:e.el.snippet,page:e.page.path,...n&&{state:n},...t&&{context:t}}}function vi(e,t){if(e.sheetPages.has(t))return null;let n=e.codeSheets.get(t);return n?`${n} loads the stylesheet; Grum doesn't trace which pages render it`:e.pages.length?e.truncated?"Grum read only the first 200 pages":null:"no static page in the repository loads the stylesheet, and Grum doesn't trace how the app loads it"}function $i(e,t,n,r=""){let o=vi(e,t);if(o)return{uses:[],count:0,unknown:o};let{matched:s,unknown:i}=cu(e,e.sheetPages.get(t)??[],n),l=s.find(c=>c.hit.pseudoElement)?.hit.pseudoElement,a=s.filter(c=>!c.hit.pseudoElement);return!a.length&&l?{uses:[],count:0,unknown:`it styles ::${l}, which renders only with content`}:{uses:a.slice(0,12).map(c=>eb(c,r)),count:a.length,...!a.length&&i?{unknown:i}:{}}}function uu(e,t,n){let r=e.pages.find(s=>s.file===t);if(!r)return{uses:[],count:0,unknown:ou.test(t)?"Grum read only the first 200 pages":"it is in a component; Grum doesn't trace which pages render it"};let o=r.elements.findLast(s=>s.line<=n);return!o||o.tag==="script"||o.tag==="style"?{uses:[],count:0,unknown:"it is in a script or <style> block, not on an element"}:{uses:[{file:t,line:o.line,snippet:o.snippet,page:r.path}],count:1}}function pu(e,t,n){let r=new Map,o=new Map,s=new Map,i=t.map(l=>Rn(l.selector).map(a=>ue(a)));for(let l of n){let a=vi(e,l.file),c=e.sheetPages.get(l.file)??[],{matched:u,unknown:p}=a?{matched:[],unknown:a}:cu(e,c,l.selector);p&&t.forEach((d,f)=>{d.name===l.name&&!s.has(f)&&s.set(f,p)});for(let d of u){if(d.hit.pseudoElement)continue;let f=m=>{let g=d.page.sheets.indexOf(m.file);return(g<0?-1:g)*1e6+m.line};for(let m=d.el;m&&m.tag!=="#document";){let g=[];t.forEach((b,k)=>{if(!(b.name!==l.name||!d.page.sheets.includes(b.file)))for(let y of i[k]){if(!y){s.has(k)||s.set(k,`Grum can't read the selector ${b.selector}`);continue}let x=Si(y,y.length-1,m);if(x!==null){if(Et(x)){s.has(k)||s.set(k,x.unknown);continue}if(!x.pseudoElement){g.push({i:k,spec:lu(y),conditional:!!b.context||x.states.length>0,states:x.states});break}}}});let S=b=>b.spec*1e9+f(t[b.i]),h=g.filter(b=>!b.conditional).sort((b,k)=>S(k)-S(b))[0];for(let b of g){if(b!==h&&(!b.conditional||h&&S(b)<S(h)))continue;let k=o.get(b.i)??new Map,y=[...new Set([...d.hit.states,...b.states])],x=[l.context,t[b.i].context].filter(Boolean).join(" \xB7 ");k.set(d.el,{file:d.page.file,line:d.el.line,snippet:d.el.snippet,page:d.page.path,...y.length&&{state:y.join(" + ")},...x&&{context:x}}),o.set(b.i,k)}if(h)break;m=m.parent}}}return t.forEach((l,a)=>{let c=[...o.get(a)?.values()??[]],u=s.get(a)??vi(e,t[a].file);r.set(a,{uses:c.slice(0,12),count:c.length,...!c.length&&u?{unknown:u}:{}})}),r}var Ti=["color","typography","spacing","radius","border","button","input"],_i={color:"Color",typography:"Typography",spacing:"Spacing",radius:"Radius",border:"Border width",button:"Buttons",input:"Inputs"},nb=new Set(["button","input"]),rb=e=>nb.has(e),ob=["color","typography","spacing","radius"],ji={raw:"Hard-coded value",near:"Near-identical colors",undefined:"Token not in contract","look-new":"Button not in contract","look-changed":"Button look changed","state-missing":"Button state missing","native-button":"Raw <button>","native-input":"Raw <input>","prop-unknown":"Unknown button variant"},sb={"look-new":"Input not in contract","look-changed":"Input look changed","state-missing":"Input state missing","prop-unknown":"Unknown input variant"};function Oi(e){return(e.area==="input"?sb[e.kind]:void 0)??ji[e.kind]}function ib(e){let t=[];for(let[s,i]of e)if(!(dr.test(s)||!Kt(s))){for(let l of ko(i))if(/^(?::root|html)$/i.test(l.selector.trim()))for(let a of xo(l.body))a.property==="font-size"&&t.push({value:a.value.trim(),context:l.context})}if(!t.length)return{px:16,declared:!1};let[n]=t;if(t.length>1||n.context)return{px:null,declared:!0};let r=n.value.match(/^(\d*\.?\d+)(px|%|rem|em)$/);if(!r)return{px:null,declared:!0};let o=parseFloat(r[1]);return{px:r[2]==="px"?o:r[2]==="%"?o/100*16:o*16,declared:!0}}var du=/\.(tsx|jsx|ts|js|mjs|vue|svelte|astro|html)$/i,dr=/(^|\/)(tests?|__tests__|__mocks__|fixtures|stories)\/|\.(test|spec|stories)\.|(^|\/)(tailwind|postcss|vite|next|webpack|eslint)\.config\.|\.d\.ts$/i,ab=[[/^(color|background(-color)?|border(-(top|right|bottom|left))?(-color)?|outline(-color)?|fill|stroke|caret-color|accent-color|text-decoration-color|box-shadow)$/i,"color"],[/^(font-size|line-height|letter-spacing|font)$/i,"typography"],[/^(padding|margin)(-(top|right|bottom|left|inline|block)(-(start|end))?)?$|^(gap|row-gap|column-gap)$/i,"spacing"],[/^border(-(top|bottom)-(left|right))?-radius$/i,"radius"]];function lb(e){return ab.find(([t])=>t.test(e))?.[1]??null}var cb=/^(border(-(top|right|bottom|left))?|outline)$/i,ub=/^(border(-(top|right|bottom|left))?-width|outline-width)$/i,pb=/^(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/i,db=/(?<![\w.#-])(\d*\.?\d+)(px|rem)\b/g,fb=[[/\b(?:p|px|py|pt|pr|pb|pl|ps|pe|m|mx|my|mt|mr|mb|ml|gap|gap-x|gap-y|space-x|space-y)-\[(\d*\.?\d+(?:px|rem))\]/g,"spacing","spacing"],[/\btext-\[(\d*\.?\d+(?:px|rem))\]/g,"typography","font-size"],[/\bleading-\[(\d*\.?\d+(?:px|rem))\]/g,"typography","line-height"],[/\brounded(?:-[trblse]{1,2})?-\[(\d*\.?\d+(?:px|rem))\]/g,"radius","border-radius"]],gb=[[/(?<![\w[-])(?:p|px|py|pt|pr|pb|pl|m|mx|my|mt|mr|mb|ml|gap|gap-x|gap-y|space-x|space-y)-(?:\d+(?:\.5)?|px)(?![\w[])/g,"spacing"],[/(?<![\w[-])text-(?:xs|sm|base|lg|[2-9]?xl)(?![\w[-])/g,"typography"],[/(?<![\w[-])rounded(?:-[trblse]{1,2})?(?:-(?:none|sm|md|lg|[2-3]?xl|full))?(?![\w[-])/g,"radius"]],mb=/(?<![\w-])(bg|text|border|ring|fill|stroke|outline|from|via|to|divide|placeholder|decoration)-([a-z][\w-]*)/g,hb={bg:"background",from:"background",via:"background",to:"background",border:"border-color",ring:"border-color",outline:"border-color",divide:"border-color"};function yb(e){if(e==="white")return"#FFFFFF";if(e==="black")return"#000000";let t=e.match(/^([a-z]+)-(\d{2,3})$/);return t?gi[t[1]]?.[t[2]]?.toUpperCase()??null:null}function ht(e){let t=e.trim();return t.length>140?`${t.slice(0,137)}\u2026`:t}function bb(e,t){return!e.startsWith("#")||e.length>5?!0:/[a-f]/i.test(e)||/[:'"`[(]\s*$/.test(t)}var wb=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function kb(e,t,n,r,o){let s=t.split(`
|
|
8
8
|
`);for(let i of ko(t)){let l=eu(i.selector),a=i.line-1,c=(u,p)=>{let d=new RegExp(`(?:^|[\\s;{])${wb(u)}\\s*:`),f=i.line;for(let m=a;m<s.length;m++)if(d.test(s[m])){a=m,f=m+1;break}return{file:e,line:f,snippet:ht(s[f-1]??`${u}: ${p}`)}};for(let u of xo(i.body)){if(u.property.startsWith("--")){let g=c(u.property,u.value);l||o.push({name:u.property,value:u.value,selector:i.selector,context:i.context,place:g});continue}if(u.property.startsWith("$"))continue;if(ub.test(u.property)){let g=c(u.property,u.value);for(let S of pr(u.value))r.push({area:"border",name:S.name,property:u.property,place:g,selector:i.selector,context:i.context,declared:u.value,fallback:S.fallback,channel:!1});continue}let p=lb(u.property);if(!p)continue;let d=c(u.property,u.value);for(let g of pr(u.value))r.push({area:p,name:g.name,property:u.property,place:d,selector:i.selector,context:i.context,declared:u.value,fallback:g.fallback,channel:/rgba?\(\s*$/i.test(u.value.slice(0,g.index)),...cb.test(u.property)&&{shorthand:!0}});let f=u.value.replace(/var\([^)]*\)/g,""),m={selector:i.selector,context:i.context,value:u.value};if(p==="color")for(let g of f.matchAll(lr))n.push({area:p,value:g[0],property:u.property,place:d,decl:m});else for(let g of f.matchAll(db))parseFloat(g[1])!==0&&n.push({area:p,value:`${g[1]}${g[2]}`,property:u.property,place:d,decl:m})}}}function xb(e,t,n,r,o,s){t.split(`
|
|
9
|
-
`).forEach((i,l)=>{let a={file:e,line:l+1,snippet:ht(i)};for(let c of i.matchAll(lr)){if(!bb(c[0],i.slice(0,c.index)))continue;let u=i.slice(0,c.index).toLowerCase(),p=/(bg-\[|background)\S*$/.test(u)?"background":/border\S*$/.test(u)?"border-color":"color";n.push({area:"color",value:c[0],property:p,place:a,attr:Ci(i,c.index)})}for(let c of pr(i))r.push({area:"color",name:c.name,property:"var()",place:a,selector:null,fallback:c.fallback,channel:!1});for(let[c,u,p]of fb)for(let d of i.matchAll(c))n.push({area:u,value:d[1],property:p,place:a,attr:Ci(i,d.index)});for(let[c,u]of gb){let p=i.match(c)?.length??0;p&&s.set(u,(s.get(u)??0)+p)}for(let[,c,u]of i.matchAll(mb)){if(o.has(`--color-${u}`)){s.set("color",(s.get("color")??0)+1);continue}let p=yb(u);p&&n.push({area:"color",value:p,property:hb[c]??"color",place:a,attr:Ci(i,i.indexOf(`${c}-${u}`))})}})}function Ci(e,t){let n=e.slice(0,Math.max(0,t)),r=/([\w:-]+)\s*=\s*\{?\s*(["'`])([^"'`]*)$/.exec(n);return r?r[1].toLowerCase():null}function fr(e){let t=e.match(/^(\d*\.?\d+)(px|rem)$/);return t?parseFloat(t[1])*(t[2]==="rem"?16:1):null}function Ri(e){return e>=10?"high":e>=4?"medium":"low"}function fu(e,t){let n=null;for(let r of t){if(r.category!=="color")continue;let o=wo(e,r.resolved);(!n||o<n.distance)&&(n={token:r,distance:o})}return n}function vb(e,t){return t<=Math.max(4,e*.25)}function Sb(e){return fi(e)}function Ai(e,t){let n=new Map;for(let r of e){let o=t(r),s=n.get(o);s?s.push(r):n.set(o,[r])}return n}function Ro(e){let t=new Set,n=[];for(let r of e){let o=`${r.place.file}:${r.place.line}`;if(!t.has(o)&&(t.add(o),n.push(r.place),n.length>=12))break}return n}function wu(e,t,n,r=new Set){if(r.has(e))return null;let o=t.get(e),s=o!==void 0?[o]:n.filter(l=>l.name===e).map(l=>l.value),i=new Set(s.map(l=>{let a=l.trim(),c=a.match(/^var\(\s*(--[\w-]+)\s*\)$/)?.[1];return c?wu(c,t,n,new Set([...r,e])):ce(a)?"color":pb.test(a)?"style":/^(\d*\.?\d+(px|rem|em)|thin|medium|thick)$/i.test(a)?"width":null}));return i.size===1?[...i][0]:null}function ku(e){return e.area==="typography"?`typography:${Mi(e.property)}`:e.area}function xu(e,t){let n=[],r=[],o=[],s=[],i=new Map,l=new Set(t.map(w=>w.name)),a=0;for(let[w,A]of e)dr.test(w)||((Kt(w)||du.test(w))&&a++,Kt(w)?kb(w,A,n,r,o):du.test(w)&&(xb(w,A,n,r,l,i),s.push(...Zc(A))));let c=new Map(t.map(w=>[w.name,w])),u=new Map(t.map(w=>[w.name,w.resolved])),p=r.flatMap(w=>{if(!w.shorthand)return[w];let A=wu(w.name,u,o);return A==="style"?[]:A==="width"?[{...w,area:"border",keyArea:w.area}]:[w]}),d=new Map(i),f=w=>d.set(w,(d.get(w)??0)+1),m=new Map,g=Yc(o,s,u),S=new Set(o.map(w=>w.name)),h=new Map,b=[];for(let w of p){if(w.name.startsWith("--tw-"))continue;let A=c.get(w.name);if(A&&!S.has(w.name)){if(f(Ti.includes(A.category)?A.category:w.area),w.selector!=null){let N=m.get(w.name)??new Set;N.add(w.channel?"color-channel":ku(w)),m.set(w.name,N)}continue}let E=g(w.name,w.fallback,w.selector);if(E.covered){f(w.area);let N=h.get(w.name);N?N.uses.push(w):h.set(w.name,{uses:[w],how:E})}else b.push({...w,how:E})}let k=[...h].filter(([w])=>!b.some(A=>A.name===w)).map(([w,{uses:A,how:E}])=>({name:w,uses:A.length,tokens:E.tokens,through:[...new Set(E.through.map(N=>N.selector))],places:Ro(A)})),y=[],x=t.filter(w=>w.category==="color"),v=su(e,dr),$=n.filter(w=>w.area==="color");for(let[w,A]of Ai($,E=>ce(E.value)??E.value.toUpperCase())){if(!ce(w))continue;let E=fu(w,x),N=A[0].property,F=E!=null&&E.distance>.5&&E.distance<=2.5,_=E!=null&&E.distance<=8;y.push({key:`color:${F?"near":"raw"}:${w}`,area:"color",kind:F?"near":"raw",title:F?`${w} is nearly ${E.token.name} (${E.token.resolved})`:Ei("color",w,_?E.token.name:null),found:w,foundColor:w,property:N,uses:A.length,severity:Ri(A.length),suggestion:_?{token:E.token.name,value:E.token.resolved,exists:!0}:{token:Sb(w),value:w,exists:!1},action:F?"Merge":_?"Replace":"Create token",places:Ro(A),evidence:mu(A,v)})}for(let w=0;w<x.length;w++)for(let A=w+1;A<x.length;A++){let E=x[w],N=x[A];E.resolved!==N.resolved&&(wo(E.resolved,N.resolved)>2.5||y.push({key:`color:near:${E.name}|${N.name}`,area:"color",kind:"near",title:`${E.name} and ${N.name} are near-identical`,found:`${E.name} ${E.resolved} \xB7 ${N.name} ${N.resolved}`,foundColor:N.resolved,property:"token",uses:2,severity:"low",suggestion:{token:E.name,value:E.resolved,exists:!0},action:"Merge",places:[{file:E.file,line:E.line,snippet:`${E.name}: ${E.value}`},{file:N.file,line:N.line,snippet:`${N.name}: ${N.value}`}],evidence:Ao([E,N].map(F=>({fingerprint:It({file:F.file,selector:":root",context:"",property:F.name,value:F.value}),place:{file:F.file,line:F.line,snippet:`${F.name}: ${F.value}`},origin:"contract",selector:null,context:"",property:F.name,value:F.value,uses:[],useCount:0,unknown:"it compares two contract tokens; using either is not drift on the site"})))}))}for(let[w,A]of Ai(b,E=>E.name)){let N=[...new Set(A.flatMap(te=>te.how.failing))].filter(te=>te.name===w).filter(te=>$o(te.value)),F=o.find(te=>te.name===w)?.value??null,_=N[0]?.value??F,P=_?ce(_):null,T=P?fu(P,x):null,B=F?ce(F):null,Y=B?"color":A[0].area,me=B?"color":A[0].keyArea??Y,J=[...new Set(N.map(te=>te.value))];y.push({key:`${me}:undefined:${w}`,area:Y,kind:"undefined",title:c.has(w)?`${w} is set to ${J.join(", ")||"another value"} locally, but the contract has ${c.get(w).resolved}`:J.length?`${w} holds hard-coded ${J.join(", ")} instead of ${J.length===1?"a contract token":"contract tokens"}`:`${w} is used but not in the contract`,found:w,foundColor:P,local:_,...N.length&&{declarations:N.map(te=>({selector:te.selector,value:te.value,place:te.place}))},property:A[0].property,uses:A.length,severity:Ri(A.length),suggestion:T&&T.distance<=8?{token:T.token.name,value:T.token.resolved,exists:!0}:{token:w,value:_??"",exists:!1},action:T&&T.distance<=8?"Replace":"Add to contract",places:Ro([...N,...A]),evidence:$b(w,N,A,o,v)})}for(let[,w]of Ai(n.filter(A=>A.area!=="color"),A=>`${A.area}|${A.value}`)){let{area:A,value:E,property:N}=w[0];y.push({key:`${A}:raw:${E}`,area:A,kind:"raw",title:Ei(A,E,null),found:E,foundColor:null,property:N,uses:w.length,severity:Ri(w.length),suggestion:null,action:"Create token",places:Ro(w),evidence:mu(w,v)})}let R=Object.fromEntries([...m].map(([w,A])=>[w,[...A].sort()]));for(let w=0;w<y.length;w++)y[w]=_b(y[w],t,void 0,R);let I={high:0,medium:1,low:2};y.sort((w,A)=>I[w.severity]-I[A.severity]||A.uses-w.uses||w.key.localeCompare(A.key));let O=new Map;for(let w of n)O.set(w.area,(O.get(w.area)??0)+1);for(let w of b)O.set(w.area,(O.get(w.area)??0)+1);let L=ob.map(w=>{let A=d.get(w)??0,E=O.get(w)??0;return{area:w,label:_i[w],tokenized:A,raw:E,score:A+E?Math.round(A/(A+E)*100):null}}),D=L.filter(w=>w.score!=null);return{score:D.length?Math.round(D.reduce((w,A)=>w+A.score,0)/D.length):null,areas:L,issues:y,covered:k,usage:R,rootFontSize:ib(e),files:a,evidence:{version:1,revision:null,sourcePages:iu(v),capture:null}}}function Ao(e){return{definitions:e.slice(0,40),definitionCount:e.length,observed:[],gaps:[]}}function Io(e,t){return{fingerprint:It({file:e.place.file,...e}),...e,uses:t.uses,useCount:t.count,...t.unknown&&{unknown:t.unknown}}}var gu=/\.html?$/i;function mu(e,t){let n=new Map;for(let r of e){let{file:o}=r.place;if(r.decl){let a=Io({place:r.place,origin:"stylesheet",selector:r.decl.selector,context:r.decl.context,property:r.property,value:r.decl.value},n.size<40?$i(t,o,r.decl.selector,r.decl.context):{uses:[],count:0,unknown:"not analyzed"});n.has(a.fingerprint)||n.set(a.fingerprint,a);continue}let s=gu.test(o)&&(r.attr==="style"||r.attr==="class"),i=s?uu(t,o,r.place.line):{uses:[],count:0,unknown:gu.test(o)?"it isn't in an element's style or class":"it is in a component; Grum doesn't trace which pages render it"},l=Io({place:r.place,origin:r.attr==="style"?"inline-style":s?"markup":"code",selector:null,context:"",property:r.property,value:`${r.place.line}:${r.value}`},i);n.has(l.fingerprint)||n.set(l.fingerprint,{...l,value:r.value})}return Ao([...n.values()])}function $b(e,t,n,r,o){let s=n.flatMap(u=>u.selector!=null?[{name:e,selector:u.selector,context:u.context??"",file:u.place.file}]:[]);if(!t.length){let u=new Map;for(let p of n){let d=Io({place:p.place,origin:p.selector!=null?"stylesheet":"code",selector:p.selector,context:p.context??"",property:p.property,value:p.place.snippet},p.selector!=null?$i(o,p.place.file,p.selector,p.context??""):{uses:[],count:0,unknown:"it is read in a component; Grum doesn't trace which pages render it"});u.has(d.fingerprint)||u.set(d.fingerprint,d)}return Ao([...u.values()])}let i=r.filter(u=>u.name===e),l=pu(o,i.map(u=>({name:e,selector:u.selector,context:u.context,file:u.place.file,line:u.place.line})),s),a={uses:[],count:0,unknown:"it is read only in components; Grum doesn't trace which pages render them"},c=[...new Map(n.flatMap(u=>u.selector!=null&&u.declared?[[`${u.place.file}|${u.selector}|${u.property}|${u.declared}`,{file:u.place.file,selector:u.selector,property:u.property,value:u.declared,context:u.context??""}]]:[])).values()].slice(0,12);return Ao(t.map(u=>({...Io({place:u.place,origin:"stylesheet",selector:u.selector,context:u.context,property:e,value:u.value},s.length?l.get(i.indexOf(u)):a),...c.length&&{readBy:c}})))}var Cb={typography:"--font-size-",spacing:"--space-",radius:"--radius-",border:"--border-width-"};function Mi(e){return/line-height|leading/i.test(e)?"line height":/letter-spacing|tracking/i.test(e)?"letter spacing":"font size"}function Rb(e){return/leading|line-height/i.test(e)?"line height":/tracking|letter/i.test(e)?"letter spacing":"font size"}function vu(e){return e.area==="typography"?Mi(e.property):_i[e.area].toLowerCase()}var Xt=e=>`${Math.round(e*100)}%`,Ab=e=>{let t=Math.round(e*100)/100;return`${t>0?"+":""}${t}px`};function hu(e,t,n=!1){let r=gt(e),o=gt(n?`rgb(${t.resolved})`:t.resolved);if(!r||!o)return null;let s=bo(o),i=wo(e,s);if(n)return{token:t,d:i,opacityLost:!1,channels:!0,byUsage:!0,...r.a<1&&{alpha:Math.round(r.a*100)/100},...i>.5&&{change:`Changes the color from ${e} to ${bo({...o,a:r.a})}${i<=2.3?" (barely visible)":""}.`}};let l=i<=.5;return Math.abs(r.a-o.a)<.005?{token:t,d:i,opacityLost:!1,...!l&&{change:`Changes the color from ${e} to ${t.resolved}${i<=2.3?" (barely visible)":""}.`}}:l&&o.a>=1?{token:t,d:i,opacityLost:!1,alpha:Math.round(r.a*100)/100}:{token:t,d:i,opacityLost:!0,change:`Changes ${e} (${Xt(r.a)} opacity) to ${t.resolved} (${Xt(o.a)} opacity).`}}function Ib(e,t,n,r,o){if(!o&&e.area==="typography"&&Rb(r.name)!==Mi(e.property))return null;let s=fr(r.resolved.trim());if(s==null)return null;let i=Math.abs(s-n);return{token:r,d:i,opacityLost:!1,...i>=.01&&{change:`Changes the ${vu(e)} from ${t} to ${r.resolved} (${Ab(s-n)}).`}}}function Su(e){return e.kind!=="undefined"?e.found:e.area==="color"?e.foundColor:e.local!==void 0?e.local:e.suggestion&&!e.suggestion.exists?e.suggestion.value:null}function $u(e,t,n){let r=Su(e);if(!r)return null;let o=n?.[t.name]??[];if(e.area==="color")return t.category==="color"?hu(r,t):o.includes("color-channel")?hu(r,t,!0):null;let s=o.includes(ku(e));if(t.category!==e.area&&!s)return null;let i=fr(r.trim()),l=i==null?null:Ib(e,r,i,t,s);return l&&t.category!==e.area?{...l,byUsage:!0}:l}function Ii(e){return{token:e.token.name,value:e.channels?ce(`rgb(${e.token.resolved})`)??e.token.resolved:e.token.resolved,...e.channels&&{channels:!0},...e.token.origin==="grum"&&{pending:!0},...e.alpha!=null&&{alpha:e.alpha},...e.change&&{change:e.change}}}function yu(e,t,n){if(rb(e.area)||e.property==="token")return null;let r=e.area,o=r==="color",s=Su(e),i=new Set(e.declarations?.map(h=>h.value)),l=t.flatMap(h=>{let b=i.size>1?null:$u(e,h,n);return b?[b]:[]}).sort((h,b)=>Number(h.opacityLost)-Number(b.opacityLost)||h.d-b.d),a=l[0],c=!o&&s?fr(s.trim()):null,u=a!=null&&!a.opacityLost&&(!a.byUsage||!a.change)&&(o?a.d<=8:c!=null&&vb(c,a.d)),p=e.kind==="undefined"?{token:e.found,value:s??""}:{token:Eb(e.found,r,t),value:e.found},d=vu(e),f=new Set(e.places.map(h=>h.file)).size,m=o&&s?(gt(s)?.a??1)<1:!1,g,S;if(i.size>1)g={kind:"add",...p},S=`It is declared with ${i.size} values (${[...i].join(", ")}) for different variants. Point each declaration at a contract token with its value, or add the missing values to the contract.`;else if(a&&u){g={kind:"replace",...Ii(a)};let h=a.token.name;S=a.change?o?`${h} is the closest contract color. Using it changes the shade.`:`${h} (${a.token.resolved}) is only a few pixels off. Using it changes the ${d}.`:a.alpha!=null?`${h} is the same color. The fix keeps its ${Xt(a.alpha)} opacity.`:o?`${h} is the same color.`:`${h} is the same ${d} (${a.token.resolved}).`}else a?e.kind==="undefined"?(g={kind:"add",...p},S="Nothing in the contract is close, so declare it with the other tokens."):o?(g={kind:"add",...p},S=m?`No contract color matches it at ${Xt(gt(s).a)} opacity. Keep it and add it to the palette, or pick a color knowing it changes the look.`:"No contract color is close. If it's intentional, add it to the palette."):e.uses<2?(g={kind:"add",...p},S=`Used once, and nothing on the ${d} scale is close. Keep ${e.found} and add it as a token, or pick a token knowing it changes the ${d}.`):(g={kind:"add",...p},S=`Used ${e.uses} times across ${f} file${f===1?"":"s"} with no close token: looks like a step missing from the ${d} scale.`):(g={kind:"add",...p},S=s?o?"The contract has no colors yet.":`The contract has no ${d} tokens yet.`:"Grum couldn't read its value to compare with the contract, so declare it with the other tokens.");return g.kind==="add"&&a?.byUsage&&(S+=` ${a.token.name} (${a.token.resolved}) is an option, since code reads it for the ${d}, but it is not the same value.`),{recommended:g,why:S,tokens:l.slice(0,8).map(Ii),add:p}}function Eb(e,t,n){if(t==="color")return fi(ce(e)??e);let r=n.filter(d=>d.category===t&&d.name.startsWith("--")),o=new Map;for(let d of r){let f=d.name.replace(/[^-]+$/,"");f!=="--"&&o.set(f,(o.get(f)??0)+1)}let s=[...o].sort((d,f)=>f[1]-d[1])[0]?.[0]??Cb[t],i=fr(e);if(i==null)return`${s}new`;let l=String(i).replace(".","_"),a=`${s}${l}px`,c=d=>n.some(f=>f.name===s+d)?a:s+d,u=r.flatMap(d=>{let f=Number(d.name.slice(s.length)),m=fr(d.resolved.trim());return d.name.startsWith(s)&&f>0&&m!=null?[m/f]:[]});if(!u.length)return c(l);let p=u[0];return u.every(d=>Math.abs(d-p)<.01)&&Number.isInteger(i/p)?c(String(i/p)):a}function Tb(e,t){let n=t.kind==="replace";return{...e,title:e.kind==="raw"?Ei(e.area,e.found,n?t.alpha!=null?`${t.token} at ${Xt(t.alpha)}`:t.token:null):e.title,suggestion:{token:t.token,value:t.value,exists:n,...t.pending&&{pending:!0},...n&&t.alpha!=null&&{alpha:t.alpha},...n&&t.change&&{change:t.change},...n&&t.channels&&{channels:!0}},action:t.kind==="replace"?e.kind==="near"?"Merge":"Replace":e.kind==="undefined"?"Add to contract":"Create token"}}function _b(e,t,n,r){let o=yu(e,t,r);if(!o)return e;let s=n?t.find(u=>u.name===n):null,i=jb(e),l=s&&i.length<=1?$u(e,s,r):null,a=Tb(e,l?{kind:"replace",...Ii(l)}:o.recommended);if(i.length<=1)return a;let c=new Map(i.map(u=>{let p=yu(Ob(e,u),t,r)?.recommended;return[u,p?.kind==="replace"&&!p.change?Mb({...p,exists:!0}):void 0]}));return{...a,declarations:e.declarations.map(({use:u,...p})=>{let d=c.get(p.value);return d?{...p,use:d}:p})}}function jb(e){return[...new Set(e.declarations?.map(t=>t.value))]}function Ob(e,t){let n=(e.declarations??[]).filter(r=>r.value===t);return{...e,local:t,foundColor:e.area==="color"?ce(t):null,declarations:n}}function Ei(e,t,n){if(e==="color")return n?`Hard-coded ${t} instead of ${n}`:`Hard-coded ${t} has no matching token`;let r=_i[e].toLowerCase();return n?`${t} ${r} instead of ${n}`:`${t} is not on the ${r} scale`}function Mb(e){return e.channels?e.alpha!=null?`rgb(var(${e.token}) / ${Xt(e.alpha)})`:`rgb(var(${e.token}))`:e.alpha!=null?`color-mix(in srgb, var(${e.token}) ${Xt(e.alpha)}, transparent)`:`var(${e.token})`}var Db=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"]),Pb=new Set(["page","index","layout","route","default"]);function Zt(e){return Db.has(e.property)||/^(margin|transition|grid-)/.test(e.property)?!0:(e.property==="width"||e.property==="height")&&/^(100%|auto)$/.test(e.value)}function gr(e){return e.flatMap(t=>t.declarations.filter(n=>!Zt(n)).map(n=>`${t.state}|${t.context}|${n.property}:${n.value}`)).sort().join(";")}function Lb(e){return gr(e.states)}function Nb(e){return e.states.filter(t=>t.state==="default"&&t.context==="").flatMap(t=>t.declarations)}function Cu(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Fb(e){let t=e.via?/^bg-([\w-]+?)(?:\/(\d+))?$/.exec(e.via):null;if(t){let r=t[1].replace(/-/g," ");return Cu(t[2]?`${r} ${t[2]}%`:r)}let n=/var\(\s*--(?:color-)?([\w-]+)/.exec(e.value)?.[1];return Cu((n??e.value).replace(/-/g," "))}function Au(e){let t=Nb(e),n=u=>t.findLast(p=>p.property===u),r=n("background-color")??n("background"),o=r!==void 0&&!/^(transparent|none|initial|inherit)\b/.test(r.value),s=n("border-width")?.value,i=s!==void 0&&!/^0(px)?$/.test(s)&&n("border-style")?.value!=="none",l=n("width")?.value,a=l!==void 0&&l===n("height")?.value&&!/^(auto|100%|fit-content)$/.test(l);return n("inset")?.value==="0"?"Overlay":i?a?"Outline icon":"Outline":o?`${Fb(r)} ${a?"icon":"fill"}`:a?"Icon":t.some(u=>u.property.startsWith("padding")||u.property==="border-radius"||u.property==="height"&&u.value!=="auto")?"Ghost":"Text"}function Ub(e){let t=e.split("/"),n=(t.pop()??e).replace(/\.[^.]+$/,""),r=t.pop();return Pb.has(n)&&r?`${r}/${n}`:n}function zb(e){let t=[...new Set(e.map(r=>Ub(r.path)))],n=t.slice(0,2).join(", ");return t.length>2?`${n} +${t.length-2}`:n}var Ru=(e,t)=>e.path.localeCompare(t.path)||e.line-t.line;function Iu(e){let t=new Map;for(let o of e){let s=Au(o.variant),i=t.get(s)??new Map,l=Lb(o.variant),a=i.get(l)??{looks:[],sites:[]};a.looks.push(o.variant),a.sites.push(...o.sites),i.set(l,a),t.set(s,i)}let n=[],r=new Map;for(let[o,s]of t){let i=[...s.values()];for(let f of i)f.sites.sort(Ru);i.sort((f,m)=>m.sites.length-f.sites.length||Ru(f.sites[0],m.sites[0]));let[l,...a]=i,c=l.looks[0],u=a.map(f=>zb(f.sites)),p=a.map((f,m)=>{let g=f.looks[0],h={title:u.filter(b=>b===u[m]).length>1?`${u[m]} \xB7 line ${f.sites[0].line}`:u[m],selector:g.selector,path:f.sites[0].path,line:f.sites[0].line,element:g.element,usage:g.usage,states:g.states,alike:!0};return r.set(h,f.sites),h}),d={...c,title:o,axis:null,base:!1,path:l.sites[0].path,line:l.sites[0].line,markup:!0,places:l.sites.map(f=>({path:f.path,line:f.line})),...p.length?{modifiers:p}:{}};r.set(d,l.sites),n.push(d)}return{variants:n,sites:r}}var Gb=1,Bb=new Set([".cursor/rules/grum.mdc"]);function Wb(e){return Bb.has(e)}var Eu=["style.new","state.changed","state.missing","token.unknown","value.hardcoded","native.element","prop.unknown"],Tu={"style.new":"block","state.changed":"block","state.missing":"block","token.unknown":"block","value.hardcoded":"block","native.element":"block","prop.unknown":"block"};function _u(e){let t=0;for(let n=0;n<e.length;n++)t=t*33+e.charCodeAt(n)>>>0;return t.toString(36)}function Eo(e){let t=`${e.path}::${e.selector}`;return`button-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48)}-${_u(t)}`}function Tt(e){return e.context?`${e.state} @ ${e.context}`:e.state}var Hb=/var\(\s*(--[\w-]+)/g;function Vb(e){let t=new Set;for(let n of e)for(let r of n.declarations)for(let o of r.value.matchAll(Hb))t.add(o[1]);return[...t].sort()}function qb(e){let t=new Map;for(let n of e)t.set(n.property,n.value.trim());return[...t].map(([n,r])=>({property:n,value:r})).sort((n,r)=>n.property.localeCompare(r.property))}function Jb(e){let t=new Map;for(let n of e){let r=Tt(n),o=t.get(r),s=qb([...o?.declarations??[],...n.declarations]);t.set(r,{state:n.state,context:n.context,declarations:s})}return[...t.values()]}function Kb(e){let t=[{path:e.path,line:e.line},...e.places??[]],n=new Set;return t.filter(r=>{let o=`${r.path}:${r.line}`;return n.has(o)?!1:(n.add(o),!0)})}function Xb(e){let t=new Map,n=(r,o,s)=>{let i=Eo(r),l=t.get(i),a=Jb([...l?Zb(l.states):[],...o]),c=l?.stateLines??new Map;for(let u of o)c.has(Tt(u))||c.set(Tt(u),u.line);t.set(i,{...l??r,id:i,states:a,tokens:Vb(a),line:l?.line??s,stateLines:c})};for(let r of e){let o=Eo(r);if(n({kind:"look",title:r.title,selector:r.selector,path:r.path,axis:r.axis,...r.usage.via?{selectedBy:r.usage.via}:r.select?{selectedBy:`via ${r.select.prop}="${r.select.value}"`}:{},...r.select?{select:r.select}:{},...r.element?{element:r.element.tag}:{},...r.markup?{markup:!0}:{}},r.states,r.line),r.places?.length){let s=t.get(o);s&&(s.places=r.places)}for(let s of r.modifiers??[])n({kind:"modifier",title:`${r.title} \xB7 ${s.title}`,selector:s.selector,path:s.path,hostId:o,...s.usage.via?{selectedBy:s.usage.via}:{},...s.element?{element:s.element.tag}:{},...s.alike?{markup:!0}:{}},s.states,s.line);for(let s of r.contexts??[])n({kind:"context",title:`${r.title} in ${s.selector}`,selector:s.selector,path:s.path,hostId:o,role:s.role,...s.element?{element:s.element.tag}:{}},s.states,s.line)}return t}function Zb(e){return e.map(t=>({state:t.state,context:t.context,line:0,declarations:t.declarations}))}var Pi=/^(\d+) native /;function Yb(e,t){if(e==="native")return`native:${t.refs[0]?.path??""}`;if(t.styles?.length){let n=[...new Set(t.refs.map(r=>r.path))].sort().join(",");return`${e}:${[...t.styles].sort().join(",")}:${n}`}return`${e}:${t.refs.map(n=>n.path).join(",")}:${t.message}`}var Li={hardcoded:"value.hardcoded",native:"native.element",props:"prop.unknown"},Qb=new Set(Object.values(Li));function ju(e){let t=e.find(n=>n.toLowerCase()==="button");return t||(e.length===1?e[0]:null)}var ew={"value.hardcoded":()=>"Replace each literal with the Design Contract token named, or with a Design Contract token for that property.","native.element":e=>{let t=ju(e.components);return t?`Render ${t} instead of a raw <button>, or ask for an exception.`:"Use a Design Contract 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 tw(e){let t=[];for(let n of e.audit)if(n.status==="attention")for(let r of n.findings)t.push({check:n.id,finding:r,key:Yb(n.id,r)});return t}function nw(e,t){let n=new Map(e.map(s=>[s.property,s.value])),r=new Map(t.map(s=>[s.property,s.value])),o=[];for(let[s,i]of r){let l=n.get(s);l===void 0?o.push(`added ${s}: ${i}`):l!==i&&o.push(`${s}: ${l} \u2192 ${i}`)}for(let[s,i]of n)r.has(s)||o.push(`removed ${s}: ${i}`);return o}function Ni(e){return e.map(t=>`${t.property}: ${t.value}`).join("; ")}function Di(e,t){return e.length>t?`${e.slice(0,t).join(", ")}, and ${e.length-t} more`:e.join(", ")}function rw(e,t){let n=e.replace(/^--/,"").split("-")[0]??"",r=n?t.filter(o=>o.startsWith(`--${n}`)):[];return(r.length?r:t).slice(0,3)}function Ou(e,t){let n={...Tu,...t.settings.severity},r=[],o=(g,S="")=>{r.push({id:`${g.kind}:${_u(`${g.styleId??""}|${g.state??""}|${S}`)}`,severity:n[g.kind],...g})},s=Xb(e.variants),i=new Map(t.styles.map(g=>[g.id,g])),l=t.styles.filter(g=>g.kind==="look"),a=new Set([...t.tokens.map(g=>g.name),...t.styles.flatMap(g=>g.tokens)]),c=[...a],u=new Map;for(let g of t.styles)g.markup&&u.set(gr(g.states),g);let p=new Map;for(let g of s.values()){if(!g.markup)continue;let S=u.get(gr(g.states));S&&p.set(g.id,S)}let d=g=>g.markup?`${g.title} (as in ${g.path})`:g.select?`${g.title} (${g.select.prop}="${g.select.value}")`:g.selector.length>40?g.title:g.selector;for(let g of s.values()){if(i.has(g.id)||p.has(g.id))continue;let S=g.hostId?i.get(g.hostId):void 0,h=g.markup?l.filter($=>$.markup):l,b=h.filter($=>$.path===g.path),k=(b.length?b:h).map(d),y=g.markup?`This one-off ${g.element??"button"} (${Di((g.states[0]?.declarations??[]).map($=>`${$.property}: ${$.value}`),3)})`:g.selector,x=ju(t.components),v=g.markup?x?`render ${x} with a Design Contract look,`:k.length?`copy ${Di(k,3)},`:"use a Design Contract style,":S?`restyle ${S.selector} only through Design Contract modifiers`:k.length?`use ${Di(k,3)},`:"use a Design Contract style,";o({kind:"style.new",styleId:g.id,title:`${g.title} is not in the Design Contract`,baseline:null,observed:{declarations:g.states[0]?.declarations??[],states:g.states,...g.markup?{markup:!0}:{}},refs:Kb(g),fix:`${y} is not in the Design Contract; ${v} or ask for an exception.`},g.markup?gr(g.states):g.selector)}for(let g of s.values()){let S=i.get(g.id);if(!S)continue;let h=new Map(S.states.map(b=>[Tt(b),b]));for(let b of g.states){let k=Tt(b),y=h.get(k),x=nw(y?.declarations??[],b.declarations);x.length!==0&&o({kind:"state.changed",styleId:g.id,title:y?`${g.title}: ${k} changed`:`${g.title}: new ${k} state`,state:k,baseline:y?{declarations:y.declarations}:null,observed:{declarations:b.declarations},refs:[{path:g.path,line:g.stateLines.get(k)??g.line}],fix:y?`Restore ${g.selector} ${k} to the Design Contract (${x.slice(0,3).join("; ")}), or ask for an exception.`:`${k} is not a Design Contract state of ${g.selector}; remove it, or ask for an exception.`},Ni(b.declarations))}}for(let g of s.values()){let S=i.get(g.id);if(!S)continue;let h=new Set(g.states.map(Tt));for(let b of S.states){let k=Tt(b);h.has(k)||o({kind:"state.missing",styleId:g.id,title:`${g.title}: ${k} state is missing`,state:k,baseline:{declarations:b.declarations},observed:null,refs:[{path:g.path,line:g.line}],fix:`Define ${g.selector} ${k} again: ${Ni(b.declarations)||"as in the Design Contract"}.`})}}for(let g of s.values())for(let S of g.tokens){if(a.has(S))continue;let h=rw(S,c);o({kind:"token.unknown",styleId:g.id,title:`${g.title} reads ${S}, which is not a Design Contract token`,baseline:null,observed:{token:S},refs:[{path:g.path,line:g.line}],fix:h.length?`Use a Design Contract token such as ${h.join(", ")} instead of ${S}, or ask for an exception.`:`${S} is not a Design Contract token; ask for an exception to add it.`},S)}let f=new Map;for(let g of t.acceptedFindings)f.set(g.key,[...f.get(g.key)??[],g]);let m=tw(e).filter(({check:g})=>g in Li);for(let g of Eu)if(Qb.has(g))for(let{check:S,finding:h,key:b}of m){if(Li[S]!==g)continue;let k=f.get(b)??[];if(k.some($=>!ow(S,$.message,h.message)))continue;let y=k[0],x=h.styles?.[0],v=x?[...s.values()].find($=>$.title===x):void 0;if(g==="native.element"){let $=h.refs[0]?.path??"",R=Number(Pi.exec(h.message)?.[1]??"1");if(r.filter(O=>O.kind==="style.new"&&O.observed?.markup===!0&&O.refs.some(L=>L.path===$)).length>=R)continue}o({kind:g,styleId:v?.id??null,title:h.message,baseline:y?{message:y.message}:null,observed:{message:h.message,...g==="native.element"?{element:"button"}:{}},waiverKey:b,refs:h.refs.map(({path:$,line:R})=>({path:$,line:R})),fix:ew[g](t)},b)}return r}function ow(e,t,n){if(t===n)return!1;if(e==="native"){let r=Pi.exec(t)?.[1],o=Pi.exec(n)?.[1];if(r&&o)return Number(o)>Number(r)}return!0}var sw=`This design isn't in your project's Design Contract.
|
|
9
|
+
`).forEach((i,l)=>{let a={file:e,line:l+1,snippet:ht(i)};for(let c of i.matchAll(lr)){if(!bb(c[0],i.slice(0,c.index)))continue;let u=i.slice(0,c.index).toLowerCase(),p=/(bg-\[|background)\S*$/.test(u)?"background":/border\S*$/.test(u)?"border-color":"color";n.push({area:"color",value:c[0],property:p,place:a,attr:Ci(i,c.index)})}for(let c of pr(i))r.push({area:"color",name:c.name,property:"var()",place:a,selector:null,fallback:c.fallback,channel:!1});for(let[c,u,p]of fb)for(let d of i.matchAll(c))n.push({area:u,value:d[1],property:p,place:a,attr:Ci(i,d.index)});for(let[c,u]of gb){let p=i.match(c)?.length??0;p&&s.set(u,(s.get(u)??0)+p)}for(let[,c,u]of i.matchAll(mb)){if(o.has(`--color-${u}`)){s.set("color",(s.get("color")??0)+1);continue}let p=yb(u);p&&n.push({area:"color",value:p,property:hb[c]??"color",place:a,attr:Ci(i,i.indexOf(`${c}-${u}`))})}})}function Ci(e,t){let n=e.slice(0,Math.max(0,t)),r=/([\w:-]+)\s*=\s*\{?\s*(["'`])([^"'`]*)$/.exec(n);return r?r[1].toLowerCase():null}function fr(e){let t=e.match(/^(\d*\.?\d+)(px|rem)$/);return t?parseFloat(t[1])*(t[2]==="rem"?16:1):null}function Ri(e){return e>=10?"high":e>=4?"medium":"low"}function fu(e,t){let n=null;for(let r of t){if(r.category!=="color")continue;let o=wo(e,r.resolved);(!n||o<n.distance)&&(n={token:r,distance:o})}return n}function vb(e,t){return t<=Math.max(4,e*.25)}function Sb(e){return fi(e)}function Ai(e,t){let n=new Map;for(let r of e){let o=t(r),s=n.get(o);s?s.push(r):n.set(o,[r])}return n}function Ro(e){let t=new Set,n=[];for(let r of e){let o=`${r.place.file}:${r.place.line}`;if(!t.has(o)&&(t.add(o),n.push(r.place),n.length>=12))break}return n}function wu(e,t,n,r=new Set){if(r.has(e))return null;let o=t.get(e),s=o!==void 0?[o]:n.filter(l=>l.name===e).map(l=>l.value),i=new Set(s.map(l=>{let a=l.trim(),c=a.match(/^var\(\s*(--[\w-]+)\s*\)$/)?.[1];return c?wu(c,t,n,new Set([...r,e])):ce(a)?"color":pb.test(a)?"style":/^(\d*\.?\d+(px|rem|em)|thin|medium|thick)$/i.test(a)?"width":null}));return i.size===1?[...i][0]:null}function ku(e){return e.area==="typography"?`typography:${Mi(e.property)}`:e.area}function xu(e,t){let n=[],r=[],o=[],s=[],i=new Map,l=new Set(t.map(w=>w.name)),a=0;for(let[w,R]of e)dr.test(w)||((Kt(w)||du.test(w))&&a++,Kt(w)?kb(w,R,n,r,o):du.test(w)&&(xb(w,R,n,r,l,i),s.push(...Zc(R))));let c=new Map(t.map(w=>[w.name,w])),u=new Map(t.map(w=>[w.name,w.resolved])),p=r.flatMap(w=>{if(!w.shorthand)return[w];let R=wu(w.name,u,o);return R==="style"?[]:R==="width"?[{...w,area:"border",keyArea:w.area}]:[w]}),d=new Map(i),f=w=>d.set(w,(d.get(w)??0)+1),m=new Map,g=Yc(o,s,u),S=new Set(o.map(w=>w.name)),h=new Map,b=[];for(let w of p){if(w.name.startsWith("--tw-"))continue;let R=c.get(w.name);if(R&&!S.has(w.name)){if(f(Ti.includes(R.category)?R.category:w.area),w.selector!=null){let N=m.get(w.name)??new Set;N.add(w.channel?"color-channel":ku(w)),m.set(w.name,N)}continue}let I=g(w.name,w.fallback,w.selector);if(I.covered){f(w.area);let N=h.get(w.name);N?N.uses.push(w):h.set(w.name,{uses:[w],how:I})}else b.push({...w,how:I})}let k=[...h].filter(([w])=>!b.some(R=>R.name===w)).map(([w,{uses:R,how:I}])=>({name:w,uses:R.length,tokens:I.tokens,through:[...new Set(I.through.map(N=>N.selector))],places:Ro(R)})),y=[],x=t.filter(w=>w.category==="color"),v=su(e,dr),$=n.filter(w=>w.area==="color");for(let[w,R]of Ai($,I=>ce(I.value)??I.value.toUpperCase())){if(!ce(w))continue;let I=fu(w,x),N=R[0].property,F=I!=null&&I.distance>.5&&I.distance<=2.5,_=I!=null&&I.distance<=8;y.push({key:`color:${F?"near":"raw"}:${w}`,area:"color",kind:F?"near":"raw",title:F?`${w} is nearly ${I.token.name} (${I.token.resolved})`:Ei("color",w,_?I.token.name:null),found:w,foundColor:w,property:N,uses:R.length,severity:Ri(R.length),suggestion:_?{token:I.token.name,value:I.token.resolved,exists:!0}:{token:Sb(w),value:w,exists:!1},action:F?"Merge":_?"Replace":"Create token",places:Ro(R),evidence:mu(R,v)})}for(let w=0;w<x.length;w++)for(let R=w+1;R<x.length;R++){let I=x[w],N=x[R];I.resolved!==N.resolved&&(wo(I.resolved,N.resolved)>2.5||y.push({key:`color:near:${I.name}|${N.name}`,area:"color",kind:"near",title:`${I.name} and ${N.name} are near-identical`,found:`${I.name} ${I.resolved} \xB7 ${N.name} ${N.resolved}`,foundColor:N.resolved,property:"token",uses:2,severity:"low",suggestion:{token:I.name,value:I.resolved,exists:!0},action:"Merge",places:[{file:I.file,line:I.line,snippet:`${I.name}: ${I.value}`},{file:N.file,line:N.line,snippet:`${N.name}: ${N.value}`}],evidence:Ao([I,N].map(F=>({fingerprint:It({file:F.file,selector:":root",context:"",property:F.name,value:F.value}),place:{file:F.file,line:F.line,snippet:`${F.name}: ${F.value}`},origin:"contract",selector:null,context:"",property:F.name,value:F.value,uses:[],useCount:0,unknown:"it compares two contract tokens; using either is not drift on the site"})))}))}for(let[w,R]of Ai(b,I=>I.name)){let N=[...new Set(R.flatMap(te=>te.how.failing))].filter(te=>te.name===w).filter(te=>$o(te.value)),F=o.find(te=>te.name===w)?.value??null,_=N[0]?.value??F,P=_?ce(_):null,T=P?fu(P,x):null,B=F?ce(F):null,Y=B?"color":R[0].area,me=B?"color":R[0].keyArea??Y,J=[...new Set(N.map(te=>te.value))];y.push({key:`${me}:undefined:${w}`,area:Y,kind:"undefined",title:c.has(w)?`${w} is set to ${J.join(", ")||"another value"} locally, but the contract has ${c.get(w).resolved}`:J.length?`${w} holds hard-coded ${J.join(", ")} instead of ${J.length===1?"a contract token":"contract tokens"}`:`${w} is used but not in the contract`,found:w,foundColor:P,local:_,...N.length&&{declarations:N.map(te=>({selector:te.selector,value:te.value,place:te.place}))},property:R[0].property,uses:R.length,severity:Ri(R.length),suggestion:T&&T.distance<=8?{token:T.token.name,value:T.token.resolved,exists:!0}:{token:w,value:_??"",exists:!1},action:T&&T.distance<=8?"Replace":"Add to contract",places:Ro([...N,...R]),evidence:$b(w,N,R,o,v)})}for(let[,w]of Ai(n.filter(R=>R.area!=="color"),R=>`${R.area}|${R.value}`)){let{area:R,value:I,property:N}=w[0];y.push({key:`${R}:raw:${I}`,area:R,kind:"raw",title:Ei(R,I,null),found:I,foundColor:null,property:N,uses:w.length,severity:Ri(w.length),suggestion:null,action:"Create token",places:Ro(w),evidence:mu(w,v)})}let A=Object.fromEntries([...m].map(([w,R])=>[w,[...R].sort()]));for(let w=0;w<y.length;w++)y[w]=_b(y[w],t,void 0,A);let E={high:0,medium:1,low:2};y.sort((w,R)=>E[w.severity]-E[R.severity]||R.uses-w.uses||w.key.localeCompare(R.key));let O=new Map;for(let w of n)O.set(w.area,(O.get(w.area)??0)+1);for(let w of b)O.set(w.area,(O.get(w.area)??0)+1);let L=ob.map(w=>{let R=d.get(w)??0,I=O.get(w)??0;return{area:w,label:_i[w],tokenized:R,raw:I,score:R+I?Math.round(R/(R+I)*100):null}}),D=L.filter(w=>w.score!=null);return{score:D.length?Math.round(D.reduce((w,R)=>w+R.score,0)/D.length):null,areas:L,issues:y,covered:k,usage:A,rootFontSize:ib(e),files:a,evidence:{version:1,revision:null,sourcePages:iu(v),capture:null}}}function Ao(e){return{definitions:e.slice(0,40),definitionCount:e.length,observed:[],gaps:[]}}function Io(e,t){return{fingerprint:It({file:e.place.file,...e}),...e,uses:t.uses,useCount:t.count,...t.unknown&&{unknown:t.unknown}}}var gu=/\.html?$/i;function mu(e,t){let n=new Map;for(let r of e){let{file:o}=r.place;if(r.decl){let a=Io({place:r.place,origin:"stylesheet",selector:r.decl.selector,context:r.decl.context,property:r.property,value:r.decl.value},n.size<40?$i(t,o,r.decl.selector,r.decl.context):{uses:[],count:0,unknown:"not analyzed"});n.has(a.fingerprint)||n.set(a.fingerprint,a);continue}let s=gu.test(o)&&(r.attr==="style"||r.attr==="class"),i=s?uu(t,o,r.place.line):{uses:[],count:0,unknown:gu.test(o)?"it isn't in an element's style or class":"it is in a component; Grum doesn't trace which pages render it"},l=Io({place:r.place,origin:r.attr==="style"?"inline-style":s?"markup":"code",selector:null,context:"",property:r.property,value:`${r.place.line}:${r.value}`},i);n.has(l.fingerprint)||n.set(l.fingerprint,{...l,value:r.value})}return Ao([...n.values()])}function $b(e,t,n,r,o){let s=n.flatMap(u=>u.selector!=null?[{name:e,selector:u.selector,context:u.context??"",file:u.place.file}]:[]);if(!t.length){let u=new Map;for(let p of n){let d=Io({place:p.place,origin:p.selector!=null?"stylesheet":"code",selector:p.selector,context:p.context??"",property:p.property,value:p.place.snippet},p.selector!=null?$i(o,p.place.file,p.selector,p.context??""):{uses:[],count:0,unknown:"it is read in a component; Grum doesn't trace which pages render it"});u.has(d.fingerprint)||u.set(d.fingerprint,d)}return Ao([...u.values()])}let i=r.filter(u=>u.name===e),l=pu(o,i.map(u=>({name:e,selector:u.selector,context:u.context,file:u.place.file,line:u.place.line})),s),a={uses:[],count:0,unknown:"it is read only in components; Grum doesn't trace which pages render them"},c=[...new Map(n.flatMap(u=>u.selector!=null&&u.declared?[[`${u.place.file}|${u.selector}|${u.property}|${u.declared}`,{file:u.place.file,selector:u.selector,property:u.property,value:u.declared,context:u.context??""}]]:[])).values()].slice(0,12);return Ao(t.map(u=>({...Io({place:u.place,origin:"stylesheet",selector:u.selector,context:u.context,property:e,value:u.value},s.length?l.get(i.indexOf(u)):a),...c.length&&{readBy:c}})))}var Cb={typography:"--font-size-",spacing:"--space-",radius:"--radius-",border:"--border-width-"};function Mi(e){return/line-height|leading/i.test(e)?"line height":/letter-spacing|tracking/i.test(e)?"letter spacing":"font size"}function Rb(e){return/leading|line-height/i.test(e)?"line height":/tracking|letter/i.test(e)?"letter spacing":"font size"}function vu(e){return e.area==="typography"?Mi(e.property):_i[e.area].toLowerCase()}var Xt=e=>`${Math.round(e*100)}%`,Ab=e=>{let t=Math.round(e*100)/100;return`${t>0?"+":""}${t}px`};function hu(e,t,n=!1){let r=gt(e),o=gt(n?`rgb(${t.resolved})`:t.resolved);if(!r||!o)return null;let s=bo(o),i=wo(e,s);if(n)return{token:t,d:i,opacityLost:!1,channels:!0,byUsage:!0,...r.a<1&&{alpha:Math.round(r.a*100)/100},...i>.5&&{change:`Changes the color from ${e} to ${bo({...o,a:r.a})}${i<=2.3?" (barely visible)":""}.`}};let l=i<=.5;return Math.abs(r.a-o.a)<.005?{token:t,d:i,opacityLost:!1,...!l&&{change:`Changes the color from ${e} to ${t.resolved}${i<=2.3?" (barely visible)":""}.`}}:l&&o.a>=1?{token:t,d:i,opacityLost:!1,alpha:Math.round(r.a*100)/100}:{token:t,d:i,opacityLost:!0,change:`Changes ${e} (${Xt(r.a)} opacity) to ${t.resolved} (${Xt(o.a)} opacity).`}}function Ib(e,t,n,r,o){if(!o&&e.area==="typography"&&Rb(r.name)!==Mi(e.property))return null;let s=fr(r.resolved.trim());if(s==null)return null;let i=Math.abs(s-n);return{token:r,d:i,opacityLost:!1,...i>=.01&&{change:`Changes the ${vu(e)} from ${t} to ${r.resolved} (${Ab(s-n)}).`}}}function Su(e){return e.kind!=="undefined"?e.found:e.area==="color"?e.foundColor:e.local!==void 0?e.local:e.suggestion&&!e.suggestion.exists?e.suggestion.value:null}function $u(e,t,n){let r=Su(e);if(!r)return null;let o=n?.[t.name]??[];if(e.area==="color")return t.category==="color"?hu(r,t):o.includes("color-channel")?hu(r,t,!0):null;let s=o.includes(ku(e));if(t.category!==e.area&&!s)return null;let i=fr(r.trim()),l=i==null?null:Ib(e,r,i,t,s);return l&&t.category!==e.area?{...l,byUsage:!0}:l}function Ii(e){return{token:e.token.name,value:e.channels?ce(`rgb(${e.token.resolved})`)??e.token.resolved:e.token.resolved,...e.channels&&{channels:!0},...e.token.origin==="grum"&&{pending:!0},...e.alpha!=null&&{alpha:e.alpha},...e.change&&{change:e.change}}}function yu(e,t,n){if(rb(e.area)||e.property==="token")return null;let r=e.area,o=r==="color",s=Su(e),i=new Set(e.declarations?.map(h=>h.value)),l=t.flatMap(h=>{let b=i.size>1?null:$u(e,h,n);return b?[b]:[]}).sort((h,b)=>Number(h.opacityLost)-Number(b.opacityLost)||h.d-b.d),a=l[0],c=!o&&s?fr(s.trim()):null,u=a!=null&&!a.opacityLost&&(!a.byUsage||!a.change)&&(o?a.d<=8:c!=null&&vb(c,a.d)),p=e.kind==="undefined"?{token:e.found,value:s??""}:{token:Eb(e.found,r,t),value:e.found},d=vu(e),f=new Set(e.places.map(h=>h.file)).size,m=o&&s?(gt(s)?.a??1)<1:!1,g,S;if(i.size>1)g={kind:"add",...p},S=`It is declared with ${i.size} values (${[...i].join(", ")}) for different variants. Point each declaration at a contract token with its value, or add the missing values to the contract.`;else if(a&&u){g={kind:"replace",...Ii(a)};let h=a.token.name;S=a.change?o?`${h} is the closest contract color. Using it changes the shade.`:`${h} (${a.token.resolved}) is only a few pixels off. Using it changes the ${d}.`:a.alpha!=null?`${h} is the same color. The fix keeps its ${Xt(a.alpha)} opacity.`:o?`${h} is the same color.`:`${h} is the same ${d} (${a.token.resolved}).`}else a?e.kind==="undefined"?(g={kind:"add",...p},S="Nothing in the contract is close, so declare it with the other tokens."):o?(g={kind:"add",...p},S=m?`No contract color matches it at ${Xt(gt(s).a)} opacity. Keep it and add it to the palette, or pick a color knowing it changes the look.`:"No contract color is close. If it's intentional, add it to the palette."):e.uses<2?(g={kind:"add",...p},S=`Used once, and nothing on the ${d} scale is close. Keep ${e.found} and add it as a token, or pick a token knowing it changes the ${d}.`):(g={kind:"add",...p},S=`Used ${e.uses} times across ${f} file${f===1?"":"s"} with no close token: looks like a step missing from the ${d} scale.`):(g={kind:"add",...p},S=s?o?"The contract has no colors yet.":`The contract has no ${d} tokens yet.`:"Grum couldn't read its value to compare with the contract, so declare it with the other tokens.");return g.kind==="add"&&a?.byUsage&&(S+=` ${a.token.name} (${a.token.resolved}) is an option, since code reads it for the ${d}, but it is not the same value.`),{recommended:g,why:S,tokens:l.slice(0,8).map(Ii),add:p}}function Eb(e,t,n){if(t==="color")return fi(ce(e)??e);let r=n.filter(d=>d.category===t&&d.name.startsWith("--")),o=new Map;for(let d of r){let f=d.name.replace(/[^-]+$/,"");f!=="--"&&o.set(f,(o.get(f)??0)+1)}let s=[...o].sort((d,f)=>f[1]-d[1])[0]?.[0]??Cb[t],i=fr(e);if(i==null)return`${s}new`;let l=String(i).replace(".","_"),a=`${s}${l}px`,c=d=>n.some(f=>f.name===s+d)?a:s+d,u=r.flatMap(d=>{let f=Number(d.name.slice(s.length)),m=fr(d.resolved.trim());return d.name.startsWith(s)&&f>0&&m!=null?[m/f]:[]});if(!u.length)return c(l);let p=u[0];return u.every(d=>Math.abs(d-p)<.01)&&Number.isInteger(i/p)?c(String(i/p)):a}function Tb(e,t){let n=t.kind==="replace";return{...e,title:e.kind==="raw"?Ei(e.area,e.found,n?t.alpha!=null?`${t.token} at ${Xt(t.alpha)}`:t.token:null):e.title,suggestion:{token:t.token,value:t.value,exists:n,...t.pending&&{pending:!0},...n&&t.alpha!=null&&{alpha:t.alpha},...n&&t.change&&{change:t.change},...n&&t.channels&&{channels:!0}},action:t.kind==="replace"?e.kind==="near"?"Merge":"Replace":e.kind==="undefined"?"Add to contract":"Create token"}}function _b(e,t,n,r){let o=yu(e,t,r);if(!o)return e;let s=n?t.find(u=>u.name===n):null,i=jb(e),l=s&&i.length<=1?$u(e,s,r):null,a=Tb(e,l?{kind:"replace",...Ii(l)}:o.recommended);if(i.length<=1)return a;let c=new Map(i.map(u=>{let p=yu(Ob(e,u),t,r)?.recommended;return[u,p?.kind==="replace"&&!p.change?Mb({...p,exists:!0}):void 0]}));return{...a,declarations:e.declarations.map(({use:u,...p})=>{let d=c.get(p.value);return d?{...p,use:d}:p})}}function jb(e){return[...new Set(e.declarations?.map(t=>t.value))]}function Ob(e,t){let n=(e.declarations??[]).filter(r=>r.value===t);return{...e,local:t,foundColor:e.area==="color"?ce(t):null,declarations:n}}function Ei(e,t,n){if(e==="color")return n?`Hard-coded ${t} instead of ${n}`:`Hard-coded ${t} has no matching token`;let r=_i[e].toLowerCase();return n?`${t} ${r} instead of ${n}`:`${t} is not on the ${r} scale`}function Mb(e){return e.channels?e.alpha!=null?`rgb(var(${e.token}) / ${Xt(e.alpha)})`:`rgb(var(${e.token}))`:e.alpha!=null?`color-mix(in srgb, var(${e.token}) ${Xt(e.alpha)}, transparent)`:`var(${e.token})`}var Db=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"]),Pb=new Set(["page","index","layout","route","default"]);function Zt(e){return Db.has(e.property)||/^(margin|transition|grid-)/.test(e.property)?!0:(e.property==="width"||e.property==="height")&&/^(100%|auto)$/.test(e.value)}function gr(e){return e.flatMap(t=>t.declarations.filter(n=>!Zt(n)).map(n=>`${t.state}|${t.context}|${n.property}:${n.value}`)).sort().join(";")}function Lb(e){return gr(e.states)}function Nb(e){return e.states.filter(t=>t.state==="default"&&t.context==="").flatMap(t=>t.declarations)}function Cu(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Fb(e){let t=e.via?/^bg-([\w-]+?)(?:\/(\d+))?$/.exec(e.via):null;if(t){let r=t[1].replace(/-/g," ");return Cu(t[2]?`${r} ${t[2]}%`:r)}let n=/var\(\s*--(?:color-)?([\w-]+)/.exec(e.value)?.[1];return Cu((n??e.value).replace(/-/g," "))}function Au(e){let t=Nb(e),n=u=>t.findLast(p=>p.property===u),r=n("background-color")??n("background"),o=r!==void 0&&!/^(transparent|none|initial|inherit)\b/.test(r.value),s=n("border-width")?.value,i=s!==void 0&&!/^0(px)?$/.test(s)&&n("border-style")?.value!=="none",l=n("width")?.value,a=l!==void 0&&l===n("height")?.value&&!/^(auto|100%|fit-content)$/.test(l);return n("inset")?.value==="0"?"Overlay":i?a?"Outline icon":"Outline":o?`${Fb(r)} ${a?"icon":"fill"}`:a?"Icon":t.some(u=>u.property.startsWith("padding")||u.property==="border-radius"||u.property==="height"&&u.value!=="auto")?"Ghost":"Text"}function Ub(e){let t=e.split("/"),n=(t.pop()??e).replace(/\.[^.]+$/,""),r=t.pop();return Pb.has(n)&&r?`${r}/${n}`:n}function zb(e){let t=[...new Set(e.map(r=>Ub(r.path)))],n=t.slice(0,2).join(", ");return t.length>2?`${n} +${t.length-2}`:n}var Ru=(e,t)=>e.path.localeCompare(t.path)||e.line-t.line;function Iu(e){let t=new Map;for(let o of e){let s=Au(o.variant),i=t.get(s)??new Map,l=Lb(o.variant),a=i.get(l)??{looks:[],sites:[]};a.looks.push(o.variant),a.sites.push(...o.sites),i.set(l,a),t.set(s,i)}let n=[],r=new Map;for(let[o,s]of t){let i=[...s.values()];for(let f of i)f.sites.sort(Ru);i.sort((f,m)=>m.sites.length-f.sites.length||Ru(f.sites[0],m.sites[0]));let[l,...a]=i,c=l.looks[0],u=a.map(f=>zb(f.sites)),p=a.map((f,m)=>{let g=f.looks[0],h={title:u.filter(b=>b===u[m]).length>1?`${u[m]} \xB7 line ${f.sites[0].line}`:u[m],selector:g.selector,path:f.sites[0].path,line:f.sites[0].line,element:g.element,usage:g.usage,states:g.states,alike:!0};return r.set(h,f.sites),h}),d={...c,title:o,axis:null,base:!1,path:l.sites[0].path,line:l.sites[0].line,markup:!0,places:l.sites.map(f=>({path:f.path,line:f.line})),...p.length?{modifiers:p}:{}};r.set(d,l.sites),n.push(d)}return{variants:n,sites:r}}var Gb=1,Bb=new Set([".cursor/rules/grum.mdc"]);function Wb(e){return Bb.has(e)}var Eu=["style.new","state.changed","state.missing","token.unknown","value.hardcoded","native.element","prop.unknown"],Tu={"style.new":"block","state.changed":"block","state.missing":"block","token.unknown":"block","value.hardcoded":"block","native.element":"block","prop.unknown":"block"};function _u(e){let t=0;for(let n=0;n<e.length;n++)t=t*33+e.charCodeAt(n)>>>0;return t.toString(36)}function Eo(e){let t=`${e.path}::${e.selector}`;return`button-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,48)}-${_u(t)}`}function Tt(e){return e.context?`${e.state} @ ${e.context}`:e.state}var Hb=/var\(\s*(--[\w-]+)/g;function Vb(e){let t=new Set;for(let n of e)for(let r of n.declarations)for(let o of r.value.matchAll(Hb))t.add(o[1]);return[...t].sort()}function qb(e){let t=new Map;for(let n of e)t.set(n.property,n.value.trim());return[...t].map(([n,r])=>({property:n,value:r})).sort((n,r)=>n.property.localeCompare(r.property))}function Jb(e){let t=new Map;for(let n of e){let r=Tt(n),o=t.get(r),s=qb([...o?.declarations??[],...n.declarations]);t.set(r,{state:n.state,context:n.context,declarations:s})}return[...t.values()]}function Kb(e){let t=[{path:e.path,line:e.line},...e.places??[]],n=new Set;return t.filter(r=>{let o=`${r.path}:${r.line}`;return n.has(o)?!1:(n.add(o),!0)})}function Xb(e){let t=new Map,n=(r,o,s)=>{let i=Eo(r),l=t.get(i),a=Jb([...l?Zb(l.states):[],...o]),c=l?.stateLines??new Map;for(let u of o)c.has(Tt(u))||c.set(Tt(u),u.line);t.set(i,{...l??r,id:i,states:a,tokens:Vb(a),line:l?.line??s,stateLines:c})};for(let r of e){let o=Eo(r);if(n({kind:"look",title:r.title,selector:r.selector,path:r.path,axis:r.axis,...r.usage.via?{selectedBy:r.usage.via}:r.select?{selectedBy:`via ${r.select.prop}="${r.select.value}"`}:{},...r.select?{select:r.select}:{},...r.element?{element:r.element.tag}:{},...r.markup?{markup:!0}:{}},r.states,r.line),r.places?.length){let s=t.get(o);s&&(s.places=r.places)}for(let s of r.modifiers??[])n({kind:"modifier",title:`${r.title} \xB7 ${s.title}`,selector:s.selector,path:s.path,hostId:o,...s.usage.via?{selectedBy:s.usage.via}:{},...s.element?{element:s.element.tag}:{},...s.alike?{markup:!0}:{}},s.states,s.line);for(let s of r.contexts??[])n({kind:"context",title:`${r.title} in ${s.selector}`,selector:s.selector,path:s.path,hostId:o,role:s.role,...s.element?{element:s.element.tag}:{}},s.states,s.line)}return t}function Zb(e){return e.map(t=>({state:t.state,context:t.context,line:0,declarations:t.declarations}))}var Pi=/^(\d+) native /;function Yb(e,t){if(e==="native")return`native:${t.refs[0]?.path??""}`;if(t.styles?.length){let n=[...new Set(t.refs.map(r=>r.path))].sort().join(",");return`${e}:${[...t.styles].sort().join(",")}:${n}`}return`${e}:${t.refs.map(n=>n.path).join(",")}:${t.message}`}var Li={hardcoded:"value.hardcoded",native:"native.element",props:"prop.unknown"},Qb=new Set(Object.values(Li));function ju(e){let t=e.find(n=>n.toLowerCase()==="button");return t||(e.length===1?e[0]:null)}var ew={"value.hardcoded":()=>"Replace each literal with the Design Contract token named, or with a Design Contract token for that property.","native.element":e=>{let t=ju(e.components);return t?`Render ${t} instead of a raw <button>, or ask for an exception.`:"Use a Design Contract 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 tw(e){let t=[];for(let n of e.audit)if(n.status==="attention")for(let r of n.findings)t.push({check:n.id,finding:r,key:Yb(n.id,r)});return t}function nw(e,t){let n=new Map(e.map(s=>[s.property,s.value])),r=new Map(t.map(s=>[s.property,s.value])),o=[];for(let[s,i]of r){let l=n.get(s);l===void 0?o.push(`added ${s}: ${i}`):l!==i&&o.push(`${s}: ${l} \u2192 ${i}`)}for(let[s,i]of n)r.has(s)||o.push(`removed ${s}: ${i}`);return o}function Ni(e){return e.map(t=>`${t.property}: ${t.value}`).join("; ")}function Di(e,t){return e.length>t?`${e.slice(0,t).join(", ")}, and ${e.length-t} more`:e.join(", ")}function rw(e,t){let n=e.replace(/^--/,"").split("-")[0]??"",r=n?t.filter(o=>o.startsWith(`--${n}`)):[];return(r.length?r:t).slice(0,3)}function Ou(e,t){let n={...Tu,...t.settings.severity},r=[],o=(g,S="")=>{r.push({id:`${g.kind}:${_u(`${g.styleId??""}|${g.state??""}|${S}`)}`,severity:n[g.kind],...g})},s=Xb(e.variants),i=new Map(t.styles.map(g=>[g.id,g])),l=t.styles.filter(g=>g.kind==="look"),a=new Set([...t.tokens.map(g=>g.name),...t.styles.flatMap(g=>g.tokens)]),c=[...a],u=new Map;for(let g of t.styles)g.markup&&u.set(gr(g.states),g);let p=new Map;for(let g of s.values()){if(!g.markup)continue;let S=u.get(gr(g.states));S&&p.set(g.id,S)}let d=g=>g.markup?`${g.title} (as in ${g.path})`:g.select?`${g.title} (${g.select.prop}="${g.select.value}")`:g.selector.length>40?g.title:g.selector;for(let g of s.values()){if(i.has(g.id)||p.has(g.id))continue;let S=g.hostId?i.get(g.hostId):void 0,h=g.markup?l.filter($=>$.markup):l,b=h.filter($=>$.path===g.path),k=(b.length?b:h).map(d),y=g.markup?`This one-off ${g.element??"button"} (${Di((g.states[0]?.declarations??[]).map($=>`${$.property}: ${$.value}`),3)})`:g.selector,x=ju(t.components),v=g.markup?x?`render ${x} with a Design Contract look,`:k.length?`copy ${Di(k,3)},`:"use a Design Contract style,":S?`restyle ${S.selector} only through Design Contract modifiers`:k.length?`use ${Di(k,3)},`:"use a Design Contract style,";o({kind:"style.new",styleId:g.id,title:`${g.title} is not in the Design Contract`,baseline:null,observed:{declarations:g.states[0]?.declarations??[],states:g.states,...g.markup?{markup:!0}:{}},refs:Kb(g),fix:`${y} is not in the Design Contract; ${v} or ask for an exception.`},g.markup?gr(g.states):g.selector)}for(let g of s.values()){let S=i.get(g.id);if(!S)continue;let h=new Map(S.states.map(b=>[Tt(b),b]));for(let b of g.states){let k=Tt(b),y=h.get(k),x=nw(y?.declarations??[],b.declarations);x.length!==0&&o({kind:"state.changed",styleId:g.id,title:y?`${g.title}: ${k} changed`:`${g.title}: new ${k} state`,state:k,baseline:y?{declarations:y.declarations}:null,observed:{declarations:b.declarations},refs:[{path:g.path,line:g.stateLines.get(k)??g.line}],fix:y?`Restore ${g.selector} ${k} to the Design Contract (${x.slice(0,3).join("; ")}), or ask for an exception.`:`${k} is not a Design Contract state of ${g.selector}; remove it, or ask for an exception.`},Ni(b.declarations))}}for(let g of s.values()){let S=i.get(g.id);if(!S)continue;let h=new Set(g.states.map(Tt));for(let b of S.states){let k=Tt(b);h.has(k)||o({kind:"state.missing",styleId:g.id,title:`${g.title}: ${k} state is missing`,state:k,baseline:{declarations:b.declarations},observed:null,refs:[{path:g.path,line:g.line}],fix:`Define ${g.selector} ${k} again: ${Ni(b.declarations)||"as in the Design Contract"}.`})}}for(let g of s.values())for(let S of g.tokens){if(a.has(S))continue;let h=rw(S,c);o({kind:"token.unknown",styleId:g.id,title:`${g.title} reads ${S}, which is not a Design Contract token`,baseline:null,observed:{token:S},refs:[{path:g.path,line:g.line}],fix:h.length?`Use a Design Contract token such as ${h.join(", ")} instead of ${S}, or ask for an exception.`:`${S} is not a Design Contract token; ask for an exception to add it.`},S)}let f=new Map;for(let g of t.acceptedFindings)f.set(g.key,[...f.get(g.key)??[],g]);let m=tw(e).filter(({check:g})=>g in Li);for(let g of Eu)if(Qb.has(g))for(let{check:S,finding:h,key:b}of m){if(Li[S]!==g)continue;let k=f.get(b)??[];if(k.some($=>!ow(S,$.message,h.message)))continue;let y=k[0],x=h.styles?.[0],v=x?[...s.values()].find($=>$.title===x):void 0;if(g==="native.element"){let $=h.refs[0]?.path??"",A=Number(Pi.exec(h.message)?.[1]??"1");if(r.filter(O=>O.kind==="style.new"&&O.observed?.markup===!0&&O.refs.some(L=>L.path===$)).length>=A)continue}o({kind:g,styleId:v?.id??null,title:h.message,baseline:y?{message:y.message}:null,observed:{message:h.message,...g==="native.element"?{element:"button"}:{}},waiverKey:b,refs:h.refs.map(({path:$,line:A})=>({path:$,line:A})),fix:ew[g](t)},b)}return r}function ow(e,t,n){if(t===n)return!1;if(e==="native"){let r=Pi.exec(t)?.[1],o=Pi.exec(n)?.[1];if(r&&o)return Number(o)>Number(r)}return!0}var sw=`This design isn't in your project's Design Contract.
|
|
10
10
|
|
|
11
11
|
1. Use an existing style.
|
|
12
12
|
2. Keep it and request review.`,iw=`If the contract has no button for the job, ask the user once: "${sw}" Do not write that look or request review until they answer. If they already answered in this conversation, follow that choice; do not ask again. After they choose review, keep the requested look and call grum_request_review once with all drift keys from grum_check that render on the same page, their reason and that page URL, or run \`npx @grum-os/cli request <key> [<key>...] --reason "..." --url "<page>"\` once. If it fails, report the error and its next step, then stop; a failed request is not approval and does not revoke their choice. Never edit .grum files to make a check pass.`,aw={product:"Grum Design Contract",what:"The designer-published Design Contract 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.",iw]};function Mu(e){let t=(n,r)=>e.styles.filter(o=>o.hostId===n&&o.kind===r).map(o=>o.selector);return{about:{...aw,drift:Eu.map(n=>({kind:n,severity:e.settings.severity[n]??Tu[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}:{},...n.select?{select:n.select}:{},tokens:n.tokens,states:Object.fromEntries(n.states.map(r=>[Tt(r),Ni(r.declarations)])),modifiers:t(n.id,"modifier"),contexts:t(n.id,"context")})),tokens:e.tokens,rules:e.rules.filter(n=>!Wb(n.path)).map(n=>({path:n.path,under:n.headings.join(" > "),text:n.text}))}}}function Du(e){if(!e||typeof e!="object")return null;let t=e;return t.schema!==Gb||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}var PA={hover:{classes:[At.hover],attrs:{}},focus:{classes:[At.focus],attrs:{}},active:{classes:[At.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 lw="data-gs-sheet";function Lu(e){return`[${lw}="${e.replace(/["\\]/g,"")}"]`}function Pu(e){return/\.module\.[a-z]+$/i.test(e)}var cw=new Set(["button","a","div","span","input","summary","label"]);function Yt(e){let t=0,n=0;for(let r=0;r<e.length;r++){let o=e[r];o==="("||o==="["?t++:o===")"||o==="]"?t=Math.max(0,t-1):t===0&&/[\s>+~]/.test(o)&&(n=r+1)}return n}function uw(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 To(e,t){let n=ue(e);if(!n||n.some(c=>c.combinator==="+"||c.combinator==="~"))return null;let r=n.map(c=>uw(c.simples));if(r.some(c=>c===null))return null;let o=r,s=o[o.length-1],i=s.tag&&s.tag!=="*"?s.tag:"button";if(!cw.has(i)||s.classes.length===0&&Object.keys(s.attrs).length===0&&!s.tag)return null;let l=[...new Set([...t,...s.classes])],a=o.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:l,attrs:s.attrs,ancestors:a}}function Fi(e,t){let n="";for(let r of e)r.property.toLowerCase()===t&&(n=r.value.replace(/!important\s*$/i,"").trim());return n}function _o(e){let t=Fi(e,"display");if(/^none\b/i.test(t))return"display: none";let n=Fi(e,"visibility");if(/^(hidden|collapse)\b/i.test(n))return`visibility: ${n.split(/\s+/)[0].toLowerCase()}`;let r=Fi(e,"opacity");return/^(0|0\.0+)$/.test(r)?"opacity: 0":null}function Ui(e,t){return e===t||!Pu(e)&&!Pu(t)}function zi(e,t){let n=new Set(e.element?.classes??[]);return t.filter(r=>{if(r===e)return!0;if(!r.base||!Ui(r.path,e.path))return!1;let o=/^\.([\w-]+)$/.exec(r.selector)?.[1];return!!(o&&n.has(o))})}function ae(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 Nu=new Set(["tone","size","variant","kind","type","style","theme","color","colour","appearance","intent","emphasis","shape","level"]),pw=new Set(["is","has","js","c","component","comp","el","ui","the","root"]),dw={xs:["extra","small"],sm:["small"],md:["medium"],lg:["large"],xl:["extra","large"],xxl:["extra","extra","large"]},fw=new Set(["cta","ui","ux","faq","cms","api","url","ios"]);function Bi(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 gw(e){return new Set(e.flatMap(t=>[t,`${t}s`]))}function Gi(e){let t=e.map(n=>fw.has(n)?n.toUpperCase():n).join(" ");return t.charAt(0).toUpperCase()+t.slice(1)}function In(e,t){let n=Bi(e).filter(o=>!t.has(o)&&!pw.has(o)),r=null;return n.length>1&&Nu.has(n[0])&&(r=n[0],n=n.slice(1)),{words:n.flatMap(o=>dw[o]??[o]),axis:r}}var Fu=/\.((?:\\.|[\w-])+)/g,mw=/\[\s*([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*))\s*\]/g;function hw(e,t){let n=e.split("/"),r=(n.pop()??"").replace(/(\.module)?\.[a-z]+$/i,""),o=n.pop()??"";return Bi(r).some(l=>t.has(l))||Bi(o).some(l=>t.has(l))?In(r,t).words:[]}function yw(e,t){let n=[];for(let r of e.split(/[\s>+~]+/).filter(Boolean)){let o=[...r.matchAll(Fu)].map(s=>s[1]);if(o.length)for(let s of o)n.push(...In(s,t).words);else{let s=/^[a-z][\w-]*/i.exec(r)?.[0]?.toLowerCase();s&&!["div","span","html","body"].includes(s)&&n.push(...In(s,t).words)}}return n}function Qt(e,t){let n=gw(t),r=Yt(e.selector),o=e.selector.slice(0,r),s=e.selector.slice(r),i=[...s.matchAll(Fu)].map(u=>In(u[1],n));for(let u of s.matchAll(mw)){let p=u[1].replace(/^data-/,"").toLowerCase();if(!Nu.has(p))continue;let d=u[2]??u[3]??u[4]??"",f=In(d,n);i.push({words:f.words,axis:p})}let l=i.filter(u=>u.words.length>0);if(l.length>0)return{title:l.map(u=>Gi(u.words)).join(" + "),axis:l.length===1?l[0].axis:null};let a=yw(o,n);if(a.length>0)return{title:`In ${a.join(" ")}`,axis:null};let c=hw(e.path,n);if(c.length>0)return{title:Gi(c),axis:null};if(e.base){let u=bw(e.path,n);return u.length>0?{title:`${Gi(u)} Base`,axis:null}:{title:"Base",axis:null}}return{title:"Unnamed",axis:null}}function bw(e,t){let n=e.split("/").pop()??"";if(!/\.module\.[a-z]+$/i.test(n))return[];let r=n.replace(/\.module\.[a-z]+$/i,"");return In(r,t).words}var ww=/\.(erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,Uu=/^<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/,kw=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),xw=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),vw=new Set(["classNames","classnames","clsx","cn","cx"]),Sw=/^(?:ref|key|style|dangerouslySetInnerHTML)$/i;function Bu(e,t){let n=1;for(let r=0;r<t&&r<e.length;r++)e[r]===`
|
|
@@ -15,44 +15,44 @@ ${e.slice(l,v)}`),a(v);continue}!Hy.has(S)&&!y&&(s=k)}return{elements:r,scripts:
|
|
|
15
15
|
`).slice(0,12),l=e.slice(r,o).split(`
|
|
16
16
|
`).length>12;return{source:Wu(i)+(l?`
|
|
17
17
|
\u2026`:""),startLine:s}}function Cw(e,t){let n=Bu(e,Math.max(0,t)),r=e.split(`
|
|
18
|
-
`),o=Math.max(0,n-1);return{source:Wu(r.slice(o,o+12)),startLine:o+1}}function Gu(e,t){return{kind:"other",...Cw(e,t)}}function Do(e,t){let n=Uu.exec(e.slice(t));if(!n)return null;let r=n[1],o=n[2]??"",s=t+n[0].length;if(/\/\s*$/.test(o)||kw.has(r.toLowerCase()))return{tag:r,attrs:o,openStart:t,openEnd:s,closeEnd:s,body:""};let l=1,a=s,c=Math.min(e.length,t+4e3);for(;a<c;){if(e[a]!=="<"){a++;continue}if(e.startsWith("</",a)){let p=/^<\/([A-Za-z][\w.-]*)\s*>/.exec(e.slice(a));if(p&&p[1].toLowerCase()===r.toLowerCase()){if(l--,l===0){let d=a+p[0].length;return{tag:r,attrs:o,openStart:t,openEnd:s,closeEnd:d,body:e.slice(s,a)}}a+=p?p[0].length:2;continue}a+=p?p[0].length:2;continue}let u=Uu.exec(e.slice(a));if(u&&u[1].toLowerCase()===r.toLowerCase()&&!/\/\s*$/.test(u[2]??"")&&(l++,l>6))return"too-big";a+=u?u[0].length:1}return a>=c&&s+(c-t)>=4e3?"too-big":null}function Vi(e,t){let n=Math.max(0,t-8e3),r=Math.min(t,e.length-1);for(;r>=n;){let o=e.lastIndexOf("<",r);if(o<n)return null;if(e[o+1]==="/"||e[o+1]==="!"||e[o+1]==="?"){r=o-1;continue}let s=Do(e,o);if(s==="too-big")return"too-big";if(s&&t>=s.openStart&&t<s.closeEnd)return s;r=o-1}return null}function Hu(e){return e.replace(/([a-z\d])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function Tn(e){return e.split(/\s+/).filter(Boolean)}function yt(e,t){let n=e[t];if(n!=='"'&&n!=="'"&&n!=="`")return null;let r="";for(let o=t+1;o<e.length;o++){let s=e[o];if(s==="\\"){r+=e[o+1]??"",o++;continue}if(n==="`"&&s==="$"&&e[o+1]==="{")return null;if(s===n)return{value:r,end:o+1};r+=s}return null}function Vu(e){let t=[],n="",r=0,o=null;for(let s=0;s<e.length;s++){let i=e[s];if(o){if(n+=i,i==="\\"){n+=e[s+1]??"",s++;continue}i===o&&(o=null);continue}if(i==='"'||i==="'"||i==="`"){o=i,n+=i;continue}if(i==="("||i==="["||i==="{")r++;else if(i===")"||i==="]"||i==="}")r=Math.max(0,r-1);else if(i===","&&r===0){n.trim()&&t.push(n.trim()),n="";continue}n+=i}return n.trim()&&t.push(n.trim()),t}function Oo(e=new Map,t=new Map){return{values:e,aliases:t,flags:new Set,strings:new Set,prefixes:new Map}}var Wi=/^[A-Za-z_$][\w$]*$/;function qi(e,t){let n=0,r=null;for(let o=0;o<e.length;o++){let s=e[o];if(r){s==="\\"?o++:s===r&&(r=null);continue}if(s==='"'||s==="'"||s==="`"){r=s;continue}if(s==="("||s==="["||s==="{")n++;else if(s===")"||s==="]"||s==="}")n--;else if(n===0&&e.startsWith(t,o))return o}return-1}function Ji(e){let t=e.trim();for(;t.startsWith("(")&&t.endsWith(")");){let n=0,r=!0;for(let o=0;o<t.length-1&&r;o++)t[o]==="("?n++:t[o]===")"&&n--,n===0&&(r=!1);if(!r)break;t=t.slice(1,-1).trim()}return t}function qu(e,t,n){if(e==="true")return!0;if(e==="false"||e==="undefined"||e==="null")return!1;let r=t.aliases.get(e);return r!==void 0&&!t.values.has(e)?_n(r,t,n+1):(t.flags.add(e),!!t.values.get(e))}function _n(e,t,n=0){if(n>4)return null;let r=Ji(e);for(let c of["||","&&"]){let u=qi(r,c);if(u<0)continue;let p=_n(r.slice(0,u),t,n+1),d=_n(r.slice(u+2),t,n+1);return p===null||d===null?null:c==="||"?p||d:p&&d}let o=/^(!\s*)?([A-Za-z_$][\w$]*)$/.exec(r);if(o){let c=qu(o[2],t,n);return c===null?null:o[1]?!c:c}let s=/^([A-Za-z_$][\w$]*)\s*(===|==|!==|!=)\s*(["'])(.*?)\3$/.exec(r);if(!s)return null;let i=t.values.get(s[1]);typeof i=="string"&&t.strings.add(s[1]);let l=typeof i=="string"?i:"";return s[2]==="==="||s[2]==="=="?l===s[4]:l!==s[4]}function Ju(e){let t=0,n=null,r=-1;for(let o=0;o<e.length;o++){let s=e[o];if(n){s==="\\"?o++:s===n&&(n=null);continue}if(s==='"'||s==="'"||s==="`"){n=s;continue}if(s==="("||s==="["||s==="{")t++;else if(s===")"||s==="]"||s==="}")t--;else if(s==="?"&&t===0){r=o;break}}if(r<0)return null;t=0,n=null;for(let o=r+1;o<e.length;o++){let s=e[o];if(n){s==="\\"?o++:s===n&&(n=null);continue}if(s==='"'||s==="'"||s==="`"){n=s;continue}if(s==="("||s==="["||s==="{")t++;else if(s===")"||s==="]"||s==="}")t--;else if(s===":"&&t===0)return{condition:e.slice(0,r),yes:e.slice(r+1,o),no:e.slice(o+1)}}return null}function En(e,t=Oo()){let n=Ji(e);if(!n)return{classes:[],dynamic:!1};let r=Ju(n);if(r){let c=_n(r.condition,t);return c===null?{classes:[],dynamic:!0}:En(c?r.yes:r.no,t)}let o=qi(n,"&&");if(o>=0){let c=_n(n.slice(0,o),t);return c===null?{classes:[],dynamic:!0}:c?En(n.slice(o+2),t):{classes:[],dynamic:!1}}if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))return{classes:Tn(n.slice(1,-1)),dynamic:!1};if(n.startsWith("`")&&n.endsWith("`")){let c=n.slice(1,-1),u="",p=0;for(;p<c.length;){let d=c.indexOf("${",p);if(d<0){u+=c.slice(p);break}u+=c.slice(p,d);let f=c.indexOf("}",d+2);if(f<0)return{classes:[],dynamic:!0};let m=c.slice(d+2,f).trim();if(Wi.test(m)){let g=t.values.get(m);if(typeof g!="string")return{classes:[],dynamic:!0};t.strings.add(m);let S=/[\w-]*$/.exec(u)?.[0];S&&t.prefixes.set(m,S),u+=g}else{let g=En(m,t);if(g.dynamic)return{classes:[],dynamic:!0};u+=g.classes.join(" ")}p=f+1}return{classes:Tn(u),dynamic:!1}}if(Wi.test(n)&&t.values.has(n)){let c=t.values.get(n);return typeof c!="string"?{classes:[],dynamic:!1}:(t.strings.add(n),{classes:Tn(c),dynamic:!1})}let s=/^(?:styles?|classes|css|cls)\.([A-Za-z_]\w*)$/.exec(n);if(s)return{classes:[Hu(s[1])],dynamic:!1};let i=/^(?:styles?|classes|css|cls)\[\s*["']([\w-]+)["']\s*\]$/.exec(n);if(i)return{classes:[i[1]],dynamic:!1};let l=/^(?:styles?|classes|css|cls)\[\s*(`[^`]*`)\s*\]$/.exec(n);if(l){let c=En(l[1],t);return c.dynamic||c.classes.length!==1?{classes:[],dynamic:!0}:c}let a=/^([A-Za-z_][\w]*)\s*\(([\s\S]*)\)$/.exec(n);if(a&&vw.has(a[1])){let c=[];for(let u of Vu(a[2])){let p=En(u,t);if(p.dynamic)return{classes:[],dynamic:!0};c.push(...p.classes)}return{classes:c,dynamic:!1}}return{classes:[],dynamic:!0}}function Po(e){let t=[],n=!1,r=0;for(;r<e.length;){if(/\s/.test(e[r])){r++;continue}if(e[r]==="{"){let i=0,l=r;for(let a=r;a<e.length;a++)if(e[a]==="{")i++;else if(e[a]==="}"&&(i--,i===0)){r=a+1;break}r===l&&(r=e.length),/^\{\s*\.\.\./.test(e.slice(l))&&(n=!0);continue}let o=/^([A-Za-z_:][\w:.-]*)/.exec(e.slice(r));if(!o){r++;continue}for(r+=o[0].length;r<e.length&&/\s/.test(e[r]);)r++;if(e[r]!=="="){t.push({name:o[1]});continue}for(r++;r<e.length&&/\s/.test(e[r]);)r++;let s=yt(e,r);if(s){t.push({name:o[1],value:s.value}),r=s.end;continue}if(e[r]==="{"){let i=0,l=r;for(let u=r;u<e.length;u++)if(e[u]==="{")i++;else if(e[u]==="}"&&(i--,i===0)){r=u+1;break}r===l&&(r=e.length);let a=e.slice(l+1,r-1).trim(),c=yt(a,0);c&&c.end===a.length?t.push({name:o[1],value:c.value}):t.push({name:o[1],expr:a});continue}r++}return{list:t,spread:n}}function Ki(e,t){let n=Po(e).list.find(r=>r.name==="class"||r.name==="className");return n?n.value!==void 0?{classes:Tn(n.value),dynamic:!1}:n.expr===void 0?{classes:[],dynamic:!0}:En(n.expr,t):null}function Ku(e,t){return/[<>]/.test(t)?!1:e==="href"||e==="src"||e==="action"?/^(?:https?:|mailto:|\/|#)/i.test(t):!0}function Rw(e){return e==="class"||e==="className"?!1:!Sw.test(e)&&!/^on/i.test(e)}function Xu(e){let t={};for(let n of Po(e).list){if(!Rw(n.name)||n.expr!==void 0)continue;let r=n.value??"";Ku(n.name,r)&&(t[n.name]=r)}return t}var Aw=/^(?:data-[\w-]+|aria-[\w-]+|disabled|hidden)$/,Iw=new Set(["disabled","hidden"]);function jo(e,t,n=0){if(n>4)return null;let r=Ji(e),o=yt(r,0);if(o&&o.end===r.length)return o.value;let s=Ju(r);if(s){let a=_n(s.condition,t);return a===null?null:jo(a?s.yes:s.no,t,n+1)}let i=qi(r,"||");if(i>=0){let a=jo(r.slice(0,i),t,n+1);return a===null?null:a!==void 0?a:jo(r.slice(i+2),t,n+1)}if(r==="undefined"||r==="null"||r==="false")return;if(r==="true")return"true";if(!Wi.test(r))return null;let l=t.values.get(r);if(typeof l=="string")return t.strings.add(r),l;if(typeof l=="boolean"||t.aliases.has(r)){let a=qu(r,t,n);return a===null?null:a?"true":void 0}return t.values.has(r)?void 0:null}function Ew(e,t){let n={};for(let r of Po(e).list){if(r.expr===void 0||!Aw.test(r.name))continue;let o=jo(r.expr,t);if(o!=null){if(Iw.has(r.name)){o!=="false"&&(n[r.name]="");continue}Ku(r.name,o)&&(n[r.name]=o)}}return n}function Tw(e,t){let n=/([A-Za-z_][\w-]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*["']([^"']*)["']\s*\})/g;for(let r of e.matchAll(n)){let o=r.index??0;if(t>=o&&t<o+r[0].length){let s=r[1];return s==="class"||s==="className"?{}:{prop:s,value:r[2]??r[3]??r[4]}}}return{}}function Mo(e,t=0){if(t>6)return"";let n="",r=0;for(;r<e.length;){if(e[r]==="{"){let i=0,l=r;for(let u=r;u<e.length;u++)if(e[u]==="{")i++;else if(e[u]==="}"&&(i--,i===0)){l=u+1;break}if(l===r)break;let a=e.slice(r+1,l-1).trim();/^[A-Za-z_$][\w$]*$/.exec(a)?.[0]&&(n+='<span class="__gs-slot">Text</span>'),r=l;continue}if(e[r]==="<"){if(e.startsWith("<!--",r)){let a=e.indexOf("-->",r);r=a===-1?e.length:a+3;continue}if(e.startsWith("</",r)){let a=/^<\/[A-Za-z][\w.-]*\s*>/.exec(e.slice(r));r+=a?a[0].length:1;continue}let i=Do(e,r);if(!i||i==="too-big"){r++;continue}let l=i.tag.toLowerCase();if(/^[A-Z]/.test(i.tag))n+=Mo(i.body,t+1);else if(xw.has(l)){let a=Ki(i.attrs),c=a&&!a.dynamic&&a.classes.length?` class="${zu(a.classes.join(" "))}"`:"",u=Mo(i.body,t+1);n+=`<${l}${c}>${u}</${l}>`}r=i.closeEnd;continue}let o=e.slice(r).search(/[<{}]/),s=o===-1?e.length:r+o;n+=zu(e.slice(r,s)),r=s}return n}function _w(e){let t=Ki(e.attrs);return!t||t.dynamic||t.classes.length===0?null:{tag:e.tag.toLowerCase(),classes:t.classes,attrs:Xu(e.attrs)}}function Zu(e,t){let n=[],r=t-1;for(;n.length<3&&r>=0;){let o=Vi(e,r);if(!o||o==="too-big"||/^[A-Z]/.test(o.tag))break;let s=_w(o);if(!s)break;n.push(s),r=o.openStart-1}return n.reverse()}var jw=8;function Ow(e){let t=e.trim(),n=yt(t,0);return n&&n.end===t.length?n.value:t==="true"?!0:t==="false"?!1:/^-?\d+(?:\.\d+)?$/.test(t)?t:null}function Mw(e,t){let n=0,r=-1;for(let i=t;i<e.length&&i<t+2e3;i++){let l=e[i];if(l==='"'||l==="'"||l==="`"){let a=yt(e,i);if(!a)return null;i=a.end-1;continue}if(l==="{")n++;else if(l==="}"&&(n--,n===0)){r=i;break}}if(r<0)return null;let o=e.slice(r+1).trimStart()[0];if(o!==")"&&o!==":")return null;let s=new Map;for(let i of Vu(e.slice(t+1,r))){if(i.startsWith("..."))continue;let l=/^([A-Za-z_$][\w$]*)(?:\s*:\s*([A-Za-z_$][\w$]*))?(?:\s*=\s*([\s\S]+))?$/.exec(i);if(!l)continue;let a=l[2]??l[1];if(l[3]===void 0){s.set(a,void 0);continue}let c=Ow(l[3]);c!==null&&s.set(a,c)}return{values:s,end:r}}function Dw(e,t){let n=new Set(t.attrs.match(/[A-Za-z_$][\w$]*/g)??[]),r=Math.max(0,t.openStart-8e3),s=[...e.slice(r,t.openStart).matchAll(/\(\s*\{/g)].reverse();for(let i of s){let l=r+(i.index??0)+i[0].length-1,a=Mw(e,l);if(!a||![...a.values.keys()].some(p=>n.has(p)))continue;let c=new Map,u=e.slice(a.end,t.openStart);for(let p of u.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*([^;\n]+);/g))n.has(p[1])&&c.set(p[1],p[2].trim());return Oo(a.values,c)}return Oo()}function Pw(e,t){let n=new Map;for(let r of e.matchAll(/([\w-]+)\$\{\s*([A-Za-z_$][\w$]*)\s*\}/g)){let o=r[1],s=t.find(i=>i.startsWith(o)&&i.length>o.length);s&&n.set(r[2],s.slice(o.length))}return n}function Lw(e,t,n,r){let o=$w(e,t.openStart,t.closeEnd);if(/^[A-Z]/.test(t.tag)){let d=Tw(e.slice(t.openStart,t.openEnd),n-t.openStart);return{kind:"component",...o,component:{tag:t.tag,...d}}}let s=Dw(e,t);for(let[d,f]of Pw(t.attrs,r))s.values.set(d,f);let i={};for(let[d,f]of s.values)i[d]=f??null;let l={attrs:t.attrs,values:i,aliases:Object.fromEntries(s.aliases)},a=Oo(new Map(s.values),s.aliases),c=Nw(l.attrs,a);if(!c)return{kind:"dynamic",...o};let u={tag:t.tag.toLowerCase(),...c,ancestors:Zu(e,t.openStart),bodyHtml:Mo(t.body)},p=[...[...a.strings].filter(d=>typeof s.values.get(d)=="string").map(d=>({name:d,kind:"text",...a.prefixes.has(d)?{prefix:a.prefixes.get(d)}:{}})),...[...a.flags].slice(0,jw).map(d=>({name:d,kind:"flag"}))];return p.length===0?{kind:"markup",...o,element:u}:{kind:"markup",...o,element:u,params:p,redraw:l}}function Nw(e,t){let n=Ki(e,t);return n?.dynamic?null:{classes:n?.classes??[],attrs:{...Xu(e),...Ew(e,t)}}}function _t(e,t,n,r){if(ww.test(r))return Gu(e,t);let o=Vi(e,t);return o==="too-big"||!o?Gu(e,t):Lw(e,o,t,n)}function Fw(e){let t={},n=new Set,{list:r,spread:o}=Po(e);for(let s of r)s.expr===void 0?t[s.name]=s.value??"true":s.expr==="true"||s.expr==="false"?t[s.name]=s.expr:n.add(s.name);return{literals:t,dynamic:n,spread:o}}function Hi(e,t){let n=Fw(t),r=new Map,o=[],s=[],i=[],l=n.spread;for(let a of e.axes){if(a.opaque){l=!0;continue}if(!a.locked&&n.dynamic.has(a.prop)){l=!0;continue}let c=a.locked?a.defaultValue:n.literals[a.prop]??(n.spread?void 0:a.defaultValue);if(c===void 0)continue;r.set(a.prop,c);let u=!a.locked&&n.literals[a.prop]===c;if(a.prefix){s.push(`${a.prefix}${c}`),u&&c!==a.defaultValue&&i.push({prop:a.prop,value:c,known:a.defaultValue?[a.defaultValue]:[],cls:`${a.prefix}${c}`});continue}let p=a.values.find(d=>d.value===c);if(!p){l=!0,u&&a.values.length>0&&i.push({prop:a.prop,value:c,known:a.values.map(d=>d.value)});continue}for(let d of p.classes)d.startsWith("__gs-recipe-")&&o.push(d),s.push(d)}if(!l){for(let a of e.compounds)if(a.when.every(u=>r.get(u.prop)===u.value))for(let u of a.classes)u.startsWith("__gs-recipe-")&&o.push(u),s.push(u)}return e.classNameProp&&(n.dynamic.has("className")?l=!0:n.literals.className&&s.push(...Tn(n.literals.className))),{draw:l?null:[...e.staticClasses,...s],selects:o,unknown:i}}function Xi(e){let t=[],n=/import\s*\{([^}]+)\}\s*from\s*["']([^"']+)["']/g;for(let r of e.matchAll(n)){let o=r[2];for(let s of r[1].split(",")){let i=s.trim().split(/\s+as\s+/),l=i[0]?.trim(),a=(i[1]??i[0])?.trim();l&&a&&t.push({local:a,imported:l,spec:o})}}return t}function Uw(e,t,n,r,o){for(let s of Xi(t)){if(s.local!==n)continue;let i=o(e,s.spec),l=r.find(a=>a.path===i&&a.component===s.imported);if(l)return l}return r.find(s=>s.path===e&&s.component===n)}function Yu(e,t,n,r,o,s){if(e.kind!=="component"||!e.component||o.length===0)return e;let i=Uw(r,t,e.component.tag,o,s);if(!i)return e;let l=Vi(t,n),a=e.component.tag;if(!l||l==="too-big"||l.tag!==a&&l.tag!==i.component)return e;let c=Hi(i,l.attrs);return c.draw?{kind:"markup",source:e.source,startLine:e.startLine,component:e.component,element:{tag:i.rootTag,classes:c.draw,attrs:{},ancestors:Zu(t,l.openStart),bodyHtml:Mo(l.body)}}:e}function zw(e,t){let n=new RegExp(`\\b${t}\\s*=\\s*`).exec(e);if(!n)return e;let r=n.index+n[0].length,o=yt(e,r);if(o)return e.slice(0,n.index)+e.slice(o.end);if(e[r]!=="{")return e;let s=0;for(let i=r;i<e.length;i++)if(e[i]==="{")s++;else if(e[i]==="}"&&--s===0)return e.slice(0,n.index)+e.slice(i+1);return e}function mr(e,t,n,r){let o=[],s=new Set,i=(a,c)=>{let u=`${a}\0${c.path}`;s.has(u)||(s.add(u),o.push({local:a,binding:c}))};for(let a of Xi(t)){let c=r(e,a.spec),u=n.find(p=>p.path===c&&p.component===a.imported);u&&i(a.local,u)}for(let a of n)a.path===e&&i(a.component,a);let l=[];for(let{local:a,binding:c}of o){let u=0,p=`<${a}`;for(;u<t.length;){let d=t.indexOf(p,u);if(d<0)break;let f=t[d+p.length];if(f&&/[\w.]/.test(f)){u=d+p.length;continue}let m=Do(t,d);if(!m||m==="too-big"){u=d+p.length;continue}let g=Hi(c,m.attrs),S=Hi(c,zw(m.attrs,"className"));l.push({offset:d,component:a,selects:g.selects,unknown:g.unknown,attrs:m.attrs,body:m.body,rootTag:c.rootTag,recipe:S.draw?.filter(h=>h.startsWith("__gs-recipe-"))??null}),u=Math.max(m.closeEnd,d+p.length)}}return l}function Gw(e,t){let n=e.slice(t,t+700),r=n.indexOf("{");if(r<0)return{};let o=n.indexOf("}",r),s=n.slice(r,o<0?r+400:o+1),i={};for(let l of s.matchAll(/([A-Za-z_$][\w$]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))i[l[1]]=l[2]??l[3]??"";return i}function Bw(e){let t=/\bclassName\s*=\s*/.exec(e);if(!t)return null;let n=t.index+t[0].length,r=yt(e,n);if(r)return r.value;if(e[n]!=="{")return null;let o=0;for(let s=n;s<e.length;s++)if(e[s]==="{")o++;else if(e[s]==="}"&&(o--,o===0))return e.slice(n+1,s);return null}function Ww(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 r={rename:{},fixed:{},opaque:[]};for(n++;n<e.length;){for(;n<e.length&&/[\s,]/.test(e[n]);)n++;if(e[n]==="}")return r;if(e.startsWith("...",n))return null;let o=/^[A-Za-z_$][\w$]*/.exec(e.slice(n));if(!o)return null;for(n+=o[0].length;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]===","||e[n]==="}"){r.rename[o[0]]=o[0];continue}if(e[n]!==":")return null;for(n++;n<e.length&&/\s/.test(e[n]);)n++;let s=yt(e,n);if(s){r.fixed[o[0]]=s.value,n=s.end;continue}let i=/^[A-Za-z_$][\w$]*/.exec(e.slice(n));if(i){r.rename[o[0]]=i[0],n+=i[0].length;continue}r.opaque.push(o[0]);let l=0;for(;n<e.length;){let a=e[n];if(a==='"'||a==="'"||a==="`"){let c=yt(e,n);if(!c)return null;n=c.end;continue}if(a==="("||a==="["||a==="{")l++;else if(a===")"||a==="]"||a==="}"){if(l===0)break;l--}else if(a===","&&l===0)break;n++}}return null}function Hw(e,t,n,r){let o=[];for(let s of Xi(e)){let i=r(t,s.spec),l=n.find(a=>a.path===i&&a.name===s.imported);l&&o.push({local:s.local,recipe:l})}for(let s of n)s.path===t&&s.name&&o.push({local:s.name,recipe:s});return o}function Vw(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:Hu(c[1])});let r=/(?:styles?|classes|css|cls)\s*\[\s*["']([^"']+)["']\s*\]/g;for(let c of e.matchAll(r))t.push({at:c.index??0,kind:"static",text:c[1]});let o=/(?:styles?|classes|css|cls)\s*\[\s*`([^`$]*)\$\{\s*([A-Za-z_$][\w$]*)\s*\}`\s*\]/g;for(let c of e.matchAll(o))t.push({at:c.index??0,kind:"prefix",text:c[1],prop:c[2]});let s=/(?:styles?|classes|css|cls)\s*\[\s*["']([^"']+)["']\s*\+\s*([A-Za-z_$][\w$]*)\s*\]/g;for(let c of e.matchAll(s))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=[],l=[];for(let c of t)c.kind==="prefix"&&c.prop?l.push({prop:c.prop,prefix:c.text}):i.push(...Tn(c.text));let a=/(?:^|[(,\s])className\s*(?:[,)]|$)/.test(e);return{staticClasses:i,prefixes:l,classNameProp:a}}function qw(e,t,n,r,o){let s=a=>t.rename[a]??a,i=e.axes.map(a=>{let c=t.fixed[a.prop],u=s(a.prop);return{prop:u,values:c?a.values.filter(p=>p.value===c):a.values,defaultValue:c??n[u]??a.defaultValue,opaque:t.opaque.includes(a.prop),locked:!!c}}),l=e.compounds.map(a=>({classes:a.classes,when:a.when.map(c=>({prop:s(c.prop),value:t.fixed[c.prop]??c.value}))}));return{staticClasses:[...e.staticClasses,...r],axes:i,compounds:l,classNameProp:o}}function Qu(e,t,n){let r=[];for(let o of e){let s=Hw(o.source,o.path,t,n);for(let i of o.names){let l=new RegExp(`(?:function\\s+${i}\\b|(?:const|let|var)\\s+${i}\\b)`,"g"),a=[...o.source.matchAll(l)],c=null;for(let u of a){let p=u.index??0,f=o.source.slice(p+u[0].length).search(/\nexport\s/),m=o.source.slice(p,p+u[0].length+(f<0?8e3:f)),g=Gw(o.source,p),S=0;for(;S<m.length;){if(m[S]!=="<"||m[S+1]==="/"||m[S+1]==="!"){S++;continue}let h=Do(m,S);if(!h||h==="too-big"){S++;continue}if(S=h.openEnd,/^[A-Z]/.test(h.tag))continue;let b=Bw(h.attrs);if(!b)continue;let k=Vw(b),y=k.prefixes.length?2:k.staticClasses.length?1:0,x=null,v=s.find($=>new RegExp(`(?:^|[^\\w$])${$.local}\\s*\\(`).test(b));if(v){let $=new RegExp(`(?:^|[^\\w$])${v.local}\\s*\\(`).exec(b),R=$?$.index+$[0].length-1:-1,I=R<0?null:Ww(b,R);if(I){y=3,x=qw(v.recipe,I,g,k.staticClasses,k.classNameProp);for(let O of k.prefixes)x.axes.push({prop:O.prop,values:[],prefix:O.prefix,defaultValue:g[O.prop]})}}!x&&(k.prefixes.length||k.staticClasses.length)&&(x={staticClasses:k.staticClasses,axes:k.prefixes.map($=>({prop:$.prop,values:[],prefix:$.prefix,defaultValue:g[$.prop]})),compounds:[],classNameProp:k.classNameProp}),x&&(!c||y>c.score)&&(c={score:y,tag:h.tag.toLowerCase(),body:x})}}c&&r.push({component:i,path:o.path,rootTag:c.tag,...c.body})}}return r}function Jw(e,t){if(!e)return t;let n=re(e);return re(t).flatMap(r=>n.map(o=>r.includes("&")?r.replaceAll("&",o):`${o} ${r}`)).join(", ")}var Kw=/^@(?:-\w+-)?(?:keyframes|font-face|property)\b/i;function Ge(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,i=>i.replace(/[^\n]/g," ")),n=[],r=[],o=0,s=1;for(let i=0;i<t.length;i++){let l=t[i];if(l===`
|
|
18
|
+
`),o=Math.max(0,n-1);return{source:Wu(r.slice(o,o+12)),startLine:o+1}}function Gu(e,t){return{kind:"other",...Cw(e,t)}}function Do(e,t){let n=Uu.exec(e.slice(t));if(!n)return null;let r=n[1],o=n[2]??"",s=t+n[0].length;if(/\/\s*$/.test(o)||kw.has(r.toLowerCase()))return{tag:r,attrs:o,openStart:t,openEnd:s,closeEnd:s,body:""};let l=1,a=s,c=Math.min(e.length,t+4e3);for(;a<c;){if(e[a]!=="<"){a++;continue}if(e.startsWith("</",a)){let p=/^<\/([A-Za-z][\w.-]*)\s*>/.exec(e.slice(a));if(p&&p[1].toLowerCase()===r.toLowerCase()){if(l--,l===0){let d=a+p[0].length;return{tag:r,attrs:o,openStart:t,openEnd:s,closeEnd:d,body:e.slice(s,a)}}a+=p?p[0].length:2;continue}a+=p?p[0].length:2;continue}let u=Uu.exec(e.slice(a));if(u&&u[1].toLowerCase()===r.toLowerCase()&&!/\/\s*$/.test(u[2]??"")&&(l++,l>6))return"too-big";a+=u?u[0].length:1}return a>=c&&s+(c-t)>=4e3?"too-big":null}function Vi(e,t){let n=Math.max(0,t-8e3),r=Math.min(t,e.length-1);for(;r>=n;){let o=e.lastIndexOf("<",r);if(o<n)return null;if(e[o+1]==="/"||e[o+1]==="!"||e[o+1]==="?"){r=o-1;continue}let s=Do(e,o);if(s==="too-big")return"too-big";if(s&&t>=s.openStart&&t<s.closeEnd)return s;r=o-1}return null}function Hu(e){return e.replace(/([a-z\d])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function Tn(e){return e.split(/\s+/).filter(Boolean)}function yt(e,t){let n=e[t];if(n!=='"'&&n!=="'"&&n!=="`")return null;let r="";for(let o=t+1;o<e.length;o++){let s=e[o];if(s==="\\"){r+=e[o+1]??"",o++;continue}if(n==="`"&&s==="$"&&e[o+1]==="{")return null;if(s===n)return{value:r,end:o+1};r+=s}return null}function Vu(e){let t=[],n="",r=0,o=null;for(let s=0;s<e.length;s++){let i=e[s];if(o){if(n+=i,i==="\\"){n+=e[s+1]??"",s++;continue}i===o&&(o=null);continue}if(i==='"'||i==="'"||i==="`"){o=i,n+=i;continue}if(i==="("||i==="["||i==="{")r++;else if(i===")"||i==="]"||i==="}")r=Math.max(0,r-1);else if(i===","&&r===0){n.trim()&&t.push(n.trim()),n="";continue}n+=i}return n.trim()&&t.push(n.trim()),t}function Oo(e=new Map,t=new Map){return{values:e,aliases:t,flags:new Set,strings:new Set,prefixes:new Map}}var Wi=/^[A-Za-z_$][\w$]*$/;function qi(e,t){let n=0,r=null;for(let o=0;o<e.length;o++){let s=e[o];if(r){s==="\\"?o++:s===r&&(r=null);continue}if(s==='"'||s==="'"||s==="`"){r=s;continue}if(s==="("||s==="["||s==="{")n++;else if(s===")"||s==="]"||s==="}")n--;else if(n===0&&e.startsWith(t,o))return o}return-1}function Ji(e){let t=e.trim();for(;t.startsWith("(")&&t.endsWith(")");){let n=0,r=!0;for(let o=0;o<t.length-1&&r;o++)t[o]==="("?n++:t[o]===")"&&n--,n===0&&(r=!1);if(!r)break;t=t.slice(1,-1).trim()}return t}function qu(e,t,n){if(e==="true")return!0;if(e==="false"||e==="undefined"||e==="null")return!1;let r=t.aliases.get(e);return r!==void 0&&!t.values.has(e)?_n(r,t,n+1):(t.flags.add(e),!!t.values.get(e))}function _n(e,t,n=0){if(n>4)return null;let r=Ji(e);for(let c of["||","&&"]){let u=qi(r,c);if(u<0)continue;let p=_n(r.slice(0,u),t,n+1),d=_n(r.slice(u+2),t,n+1);return p===null||d===null?null:c==="||"?p||d:p&&d}let o=/^(!\s*)?([A-Za-z_$][\w$]*)$/.exec(r);if(o){let c=qu(o[2],t,n);return c===null?null:o[1]?!c:c}let s=/^([A-Za-z_$][\w$]*)\s*(===|==|!==|!=)\s*(["'])(.*?)\3$/.exec(r);if(!s)return null;let i=t.values.get(s[1]);typeof i=="string"&&t.strings.add(s[1]);let l=typeof i=="string"?i:"";return s[2]==="==="||s[2]==="=="?l===s[4]:l!==s[4]}function Ju(e){let t=0,n=null,r=-1;for(let o=0;o<e.length;o++){let s=e[o];if(n){s==="\\"?o++:s===n&&(n=null);continue}if(s==='"'||s==="'"||s==="`"){n=s;continue}if(s==="("||s==="["||s==="{")t++;else if(s===")"||s==="]"||s==="}")t--;else if(s==="?"&&t===0){r=o;break}}if(r<0)return null;t=0,n=null;for(let o=r+1;o<e.length;o++){let s=e[o];if(n){s==="\\"?o++:s===n&&(n=null);continue}if(s==='"'||s==="'"||s==="`"){n=s;continue}if(s==="("||s==="["||s==="{")t++;else if(s===")"||s==="]"||s==="}")t--;else if(s===":"&&t===0)return{condition:e.slice(0,r),yes:e.slice(r+1,o),no:e.slice(o+1)}}return null}function En(e,t=Oo()){let n=Ji(e);if(!n)return{classes:[],dynamic:!1};let r=Ju(n);if(r){let c=_n(r.condition,t);return c===null?{classes:[],dynamic:!0}:En(c?r.yes:r.no,t)}let o=qi(n,"&&");if(o>=0){let c=_n(n.slice(0,o),t);return c===null?{classes:[],dynamic:!0}:c?En(n.slice(o+2),t):{classes:[],dynamic:!1}}if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))return{classes:Tn(n.slice(1,-1)),dynamic:!1};if(n.startsWith("`")&&n.endsWith("`")){let c=n.slice(1,-1),u="",p=0;for(;p<c.length;){let d=c.indexOf("${",p);if(d<0){u+=c.slice(p);break}u+=c.slice(p,d);let f=c.indexOf("}",d+2);if(f<0)return{classes:[],dynamic:!0};let m=c.slice(d+2,f).trim();if(Wi.test(m)){let g=t.values.get(m);if(typeof g!="string")return{classes:[],dynamic:!0};t.strings.add(m);let S=/[\w-]*$/.exec(u)?.[0];S&&t.prefixes.set(m,S),u+=g}else{let g=En(m,t);if(g.dynamic)return{classes:[],dynamic:!0};u+=g.classes.join(" ")}p=f+1}return{classes:Tn(u),dynamic:!1}}if(Wi.test(n)&&t.values.has(n)){let c=t.values.get(n);return typeof c!="string"?{classes:[],dynamic:!1}:(t.strings.add(n),{classes:Tn(c),dynamic:!1})}let s=/^(?:styles?|classes|css|cls)\.([A-Za-z_]\w*)$/.exec(n);if(s)return{classes:[Hu(s[1])],dynamic:!1};let i=/^(?:styles?|classes|css|cls)\[\s*["']([\w-]+)["']\s*\]$/.exec(n);if(i)return{classes:[i[1]],dynamic:!1};let l=/^(?:styles?|classes|css|cls)\[\s*(`[^`]*`)\s*\]$/.exec(n);if(l){let c=En(l[1],t);return c.dynamic||c.classes.length!==1?{classes:[],dynamic:!0}:c}let a=/^([A-Za-z_][\w]*)\s*\(([\s\S]*)\)$/.exec(n);if(a&&vw.has(a[1])){let c=[];for(let u of Vu(a[2])){let p=En(u,t);if(p.dynamic)return{classes:[],dynamic:!0};c.push(...p.classes)}return{classes:c,dynamic:!1}}return{classes:[],dynamic:!0}}function Po(e){let t=[],n=!1,r=0;for(;r<e.length;){if(/\s/.test(e[r])){r++;continue}if(e[r]==="{"){let i=0,l=r;for(let a=r;a<e.length;a++)if(e[a]==="{")i++;else if(e[a]==="}"&&(i--,i===0)){r=a+1;break}r===l&&(r=e.length),/^\{\s*\.\.\./.test(e.slice(l))&&(n=!0);continue}let o=/^([A-Za-z_:][\w:.-]*)/.exec(e.slice(r));if(!o){r++;continue}for(r+=o[0].length;r<e.length&&/\s/.test(e[r]);)r++;if(e[r]!=="="){t.push({name:o[1]});continue}for(r++;r<e.length&&/\s/.test(e[r]);)r++;let s=yt(e,r);if(s){t.push({name:o[1],value:s.value}),r=s.end;continue}if(e[r]==="{"){let i=0,l=r;for(let u=r;u<e.length;u++)if(e[u]==="{")i++;else if(e[u]==="}"&&(i--,i===0)){r=u+1;break}r===l&&(r=e.length);let a=e.slice(l+1,r-1).trim(),c=yt(a,0);c&&c.end===a.length?t.push({name:o[1],value:c.value}):t.push({name:o[1],expr:a});continue}r++}return{list:t,spread:n}}function Ki(e,t){let n=Po(e).list.find(r=>r.name==="class"||r.name==="className");return n?n.value!==void 0?{classes:Tn(n.value),dynamic:!1}:n.expr===void 0?{classes:[],dynamic:!0}:En(n.expr,t):null}function Ku(e,t){return/[<>]/.test(t)?!1:e==="href"||e==="src"||e==="action"?/^(?:https?:|mailto:|\/|#)/i.test(t):!0}function Rw(e){return e==="class"||e==="className"?!1:!Sw.test(e)&&!/^on/i.test(e)}function Xu(e){let t={};for(let n of Po(e).list){if(!Rw(n.name)||n.expr!==void 0)continue;let r=n.value??"";Ku(n.name,r)&&(t[n.name]=r)}return t}var Aw=/^(?:data-[\w-]+|aria-[\w-]+|disabled|hidden)$/,Iw=new Set(["disabled","hidden"]);function jo(e,t,n=0){if(n>4)return null;let r=Ji(e),o=yt(r,0);if(o&&o.end===r.length)return o.value;let s=Ju(r);if(s){let a=_n(s.condition,t);return a===null?null:jo(a?s.yes:s.no,t,n+1)}let i=qi(r,"||");if(i>=0){let a=jo(r.slice(0,i),t,n+1);return a===null?null:a!==void 0?a:jo(r.slice(i+2),t,n+1)}if(r==="undefined"||r==="null"||r==="false")return;if(r==="true")return"true";if(!Wi.test(r))return null;let l=t.values.get(r);if(typeof l=="string")return t.strings.add(r),l;if(typeof l=="boolean"||t.aliases.has(r)){let a=qu(r,t,n);return a===null?null:a?"true":void 0}return t.values.has(r)?void 0:null}function Ew(e,t){let n={};for(let r of Po(e).list){if(r.expr===void 0||!Aw.test(r.name))continue;let o=jo(r.expr,t);if(o!=null){if(Iw.has(r.name)){o!=="false"&&(n[r.name]="");continue}Ku(r.name,o)&&(n[r.name]=o)}}return n}function Tw(e,t){let n=/([A-Za-z_][\w-]*)\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*["']([^"']*)["']\s*\})/g;for(let r of e.matchAll(n)){let o=r.index??0;if(t>=o&&t<o+r[0].length){let s=r[1];return s==="class"||s==="className"?{}:{prop:s,value:r[2]??r[3]??r[4]}}}return{}}function Mo(e,t=0){if(t>6)return"";let n="",r=0;for(;r<e.length;){if(e[r]==="{"){let i=0,l=r;for(let u=r;u<e.length;u++)if(e[u]==="{")i++;else if(e[u]==="}"&&(i--,i===0)){l=u+1;break}if(l===r)break;let a=e.slice(r+1,l-1).trim();/^[A-Za-z_$][\w$]*$/.exec(a)?.[0]&&(n+='<span class="__gs-slot">Text</span>'),r=l;continue}if(e[r]==="<"){if(e.startsWith("<!--",r)){let a=e.indexOf("-->",r);r=a===-1?e.length:a+3;continue}if(e.startsWith("</",r)){let a=/^<\/[A-Za-z][\w.-]*\s*>/.exec(e.slice(r));r+=a?a[0].length:1;continue}let i=Do(e,r);if(!i||i==="too-big"){r++;continue}let l=i.tag.toLowerCase();if(/^[A-Z]/.test(i.tag))n+=Mo(i.body,t+1);else if(xw.has(l)){let a=Ki(i.attrs),c=a&&!a.dynamic&&a.classes.length?` class="${zu(a.classes.join(" "))}"`:"",u=Mo(i.body,t+1);n+=`<${l}${c}>${u}</${l}>`}r=i.closeEnd;continue}let o=e.slice(r).search(/[<{}]/),s=o===-1?e.length:r+o;n+=zu(e.slice(r,s)),r=s}return n}function _w(e){let t=Ki(e.attrs);return!t||t.dynamic||t.classes.length===0?null:{tag:e.tag.toLowerCase(),classes:t.classes,attrs:Xu(e.attrs)}}function Zu(e,t){let n=[],r=t-1;for(;n.length<3&&r>=0;){let o=Vi(e,r);if(!o||o==="too-big"||/^[A-Z]/.test(o.tag))break;let s=_w(o);if(!s)break;n.push(s),r=o.openStart-1}return n.reverse()}var jw=8;function Ow(e){let t=e.trim(),n=yt(t,0);return n&&n.end===t.length?n.value:t==="true"?!0:t==="false"?!1:/^-?\d+(?:\.\d+)?$/.test(t)?t:null}function Mw(e,t){let n=0,r=-1;for(let i=t;i<e.length&&i<t+2e3;i++){let l=e[i];if(l==='"'||l==="'"||l==="`"){let a=yt(e,i);if(!a)return null;i=a.end-1;continue}if(l==="{")n++;else if(l==="}"&&(n--,n===0)){r=i;break}}if(r<0)return null;let o=e.slice(r+1).trimStart()[0];if(o!==")"&&o!==":")return null;let s=new Map;for(let i of Vu(e.slice(t+1,r))){if(i.startsWith("..."))continue;let l=/^([A-Za-z_$][\w$]*)(?:\s*:\s*([A-Za-z_$][\w$]*))?(?:\s*=\s*([\s\S]+))?$/.exec(i);if(!l)continue;let a=l[2]??l[1];if(l[3]===void 0){s.set(a,void 0);continue}let c=Ow(l[3]);c!==null&&s.set(a,c)}return{values:s,end:r}}function Dw(e,t){let n=new Set(t.attrs.match(/[A-Za-z_$][\w$]*/g)??[]),r=Math.max(0,t.openStart-8e3),s=[...e.slice(r,t.openStart).matchAll(/\(\s*\{/g)].reverse();for(let i of s){let l=r+(i.index??0)+i[0].length-1,a=Mw(e,l);if(!a||![...a.values.keys()].some(p=>n.has(p)))continue;let c=new Map,u=e.slice(a.end,t.openStart);for(let p of u.matchAll(/\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*([^;\n]+);/g))n.has(p[1])&&c.set(p[1],p[2].trim());return Oo(a.values,c)}return Oo()}function Pw(e,t){let n=new Map;for(let r of e.matchAll(/([\w-]+)\$\{\s*([A-Za-z_$][\w$]*)\s*\}/g)){let o=r[1],s=t.find(i=>i.startsWith(o)&&i.length>o.length);s&&n.set(r[2],s.slice(o.length))}return n}function Lw(e,t,n,r){let o=$w(e,t.openStart,t.closeEnd);if(/^[A-Z]/.test(t.tag)){let d=Tw(e.slice(t.openStart,t.openEnd),n-t.openStart);return{kind:"component",...o,component:{tag:t.tag,...d}}}let s=Dw(e,t);for(let[d,f]of Pw(t.attrs,r))s.values.set(d,f);let i={};for(let[d,f]of s.values)i[d]=f??null;let l={attrs:t.attrs,values:i,aliases:Object.fromEntries(s.aliases)},a=Oo(new Map(s.values),s.aliases),c=Nw(l.attrs,a);if(!c)return{kind:"dynamic",...o};let u={tag:t.tag.toLowerCase(),...c,ancestors:Zu(e,t.openStart),bodyHtml:Mo(t.body)},p=[...[...a.strings].filter(d=>typeof s.values.get(d)=="string").map(d=>({name:d,kind:"text",...a.prefixes.has(d)?{prefix:a.prefixes.get(d)}:{}})),...[...a.flags].slice(0,jw).map(d=>({name:d,kind:"flag"}))];return p.length===0?{kind:"markup",...o,element:u}:{kind:"markup",...o,element:u,params:p,redraw:l}}function Nw(e,t){let n=Ki(e,t);return n?.dynamic?null:{classes:n?.classes??[],attrs:{...Xu(e),...Ew(e,t)}}}function _t(e,t,n,r){if(ww.test(r))return Gu(e,t);let o=Vi(e,t);return o==="too-big"||!o?Gu(e,t):Lw(e,o,t,n)}function Fw(e){let t={},n=new Set,{list:r,spread:o}=Po(e);for(let s of r)s.expr===void 0?t[s.name]=s.value??"true":s.expr==="true"||s.expr==="false"?t[s.name]=s.expr:n.add(s.name);return{literals:t,dynamic:n,spread:o}}function Hi(e,t){let n=Fw(t),r=new Map,o=[],s=[],i=[],l=n.spread;for(let a of e.axes){if(a.opaque){l=!0;continue}if(!a.locked&&n.dynamic.has(a.prop)){l=!0;continue}let c=a.locked?a.defaultValue:n.literals[a.prop]??(n.spread?void 0:a.defaultValue);if(c===void 0)continue;r.set(a.prop,c);let u=!a.locked&&n.literals[a.prop]===c;if(a.prefix){s.push(`${a.prefix}${c}`),u&&c!==a.defaultValue&&i.push({prop:a.prop,value:c,known:a.defaultValue?[a.defaultValue]:[],cls:`${a.prefix}${c}`});continue}let p=a.values.find(d=>d.value===c);if(!p){l=!0,u&&a.values.length>0&&i.push({prop:a.prop,value:c,known:a.values.map(d=>d.value)});continue}for(let d of p.classes)d.startsWith("__gs-recipe-")&&o.push(d),s.push(d)}if(!l){for(let a of e.compounds)if(a.when.every(u=>r.get(u.prop)===u.value))for(let u of a.classes)u.startsWith("__gs-recipe-")&&o.push(u),s.push(u)}return e.classNameProp&&(n.dynamic.has("className")?l=!0:n.literals.className&&s.push(...Tn(n.literals.className))),{draw:l?null:[...e.staticClasses,...s],selects:o,unknown:i}}function Xi(e){let t=[],n=/import\s*\{([^}]+)\}\s*from\s*["']([^"']+)["']/g;for(let r of e.matchAll(n)){let o=r[2];for(let s of r[1].split(",")){let i=s.trim().split(/\s+as\s+/),l=i[0]?.trim(),a=(i[1]??i[0])?.trim();l&&a&&t.push({local:a,imported:l,spec:o})}}return t}function Uw(e,t,n,r,o){for(let s of Xi(t)){if(s.local!==n)continue;let i=o(e,s.spec),l=r.find(a=>a.path===i&&a.component===s.imported);if(l)return l}return r.find(s=>s.path===e&&s.component===n)}function Yu(e,t,n,r,o,s){if(e.kind!=="component"||!e.component||o.length===0)return e;let i=Uw(r,t,e.component.tag,o,s);if(!i)return e;let l=Vi(t,n),a=e.component.tag;if(!l||l==="too-big"||l.tag!==a&&l.tag!==i.component)return e;let c=Hi(i,l.attrs);return c.draw?{kind:"markup",source:e.source,startLine:e.startLine,component:e.component,element:{tag:i.rootTag,classes:c.draw,attrs:{},ancestors:Zu(t,l.openStart),bodyHtml:Mo(l.body)}}:e}function zw(e,t){let n=new RegExp(`\\b${t}\\s*=\\s*`).exec(e);if(!n)return e;let r=n.index+n[0].length,o=yt(e,r);if(o)return e.slice(0,n.index)+e.slice(o.end);if(e[r]!=="{")return e;let s=0;for(let i=r;i<e.length;i++)if(e[i]==="{")s++;else if(e[i]==="}"&&--s===0)return e.slice(0,n.index)+e.slice(i+1);return e}function mr(e,t,n,r){let o=[],s=new Set,i=(a,c)=>{let u=`${a}\0${c.path}`;s.has(u)||(s.add(u),o.push({local:a,binding:c}))};for(let a of Xi(t)){let c=r(e,a.spec),u=n.find(p=>p.path===c&&p.component===a.imported);u&&i(a.local,u)}for(let a of n)a.path===e&&i(a.component,a);let l=[];for(let{local:a,binding:c}of o){let u=0,p=`<${a}`;for(;u<t.length;){let d=t.indexOf(p,u);if(d<0)break;let f=t[d+p.length];if(f&&/[\w.]/.test(f)){u=d+p.length;continue}let m=Do(t,d);if(!m||m==="too-big"){u=d+p.length;continue}let g=Hi(c,m.attrs),S=Hi(c,zw(m.attrs,"className"));l.push({offset:d,component:a,selects:g.selects,unknown:g.unknown,attrs:m.attrs,body:m.body,rootTag:c.rootTag,recipe:S.draw?.filter(h=>h.startsWith("__gs-recipe-"))??null}),u=Math.max(m.closeEnd,d+p.length)}}return l}function Gw(e,t){let n=e.slice(t,t+700),r=n.indexOf("{");if(r<0)return{};let o=n.indexOf("}",r),s=n.slice(r,o<0?r+400:o+1),i={};for(let l of s.matchAll(/([A-Za-z_$][\w$]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))i[l[1]]=l[2]??l[3]??"";return i}function Bw(e){let t=/\bclassName\s*=\s*/.exec(e);if(!t)return null;let n=t.index+t[0].length,r=yt(e,n);if(r)return r.value;if(e[n]!=="{")return null;let o=0;for(let s=n;s<e.length;s++)if(e[s]==="{")o++;else if(e[s]==="}"&&(o--,o===0))return e.slice(n+1,s);return null}function Ww(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 r={rename:{},fixed:{},opaque:[]};for(n++;n<e.length;){for(;n<e.length&&/[\s,]/.test(e[n]);)n++;if(e[n]==="}")return r;if(e.startsWith("...",n))return null;let o=/^[A-Za-z_$][\w$]*/.exec(e.slice(n));if(!o)return null;for(n+=o[0].length;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]===","||e[n]==="}"){r.rename[o[0]]=o[0];continue}if(e[n]!==":")return null;for(n++;n<e.length&&/\s/.test(e[n]);)n++;let s=yt(e,n);if(s){r.fixed[o[0]]=s.value,n=s.end;continue}let i=/^[A-Za-z_$][\w$]*/.exec(e.slice(n));if(i){r.rename[o[0]]=i[0],n+=i[0].length;continue}r.opaque.push(o[0]);let l=0;for(;n<e.length;){let a=e[n];if(a==='"'||a==="'"||a==="`"){let c=yt(e,n);if(!c)return null;n=c.end;continue}if(a==="("||a==="["||a==="{")l++;else if(a===")"||a==="]"||a==="}"){if(l===0)break;l--}else if(a===","&&l===0)break;n++}}return null}function Hw(e,t,n,r){let o=[];for(let s of Xi(e)){let i=r(t,s.spec),l=n.find(a=>a.path===i&&a.name===s.imported);l&&o.push({local:s.local,recipe:l})}for(let s of n)s.path===t&&s.name&&o.push({local:s.name,recipe:s});return o}function Vw(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:Hu(c[1])});let r=/(?:styles?|classes|css|cls)\s*\[\s*["']([^"']+)["']\s*\]/g;for(let c of e.matchAll(r))t.push({at:c.index??0,kind:"static",text:c[1]});let o=/(?:styles?|classes|css|cls)\s*\[\s*`([^`$]*)\$\{\s*([A-Za-z_$][\w$]*)\s*\}`\s*\]/g;for(let c of e.matchAll(o))t.push({at:c.index??0,kind:"prefix",text:c[1],prop:c[2]});let s=/(?:styles?|classes|css|cls)\s*\[\s*["']([^"']+)["']\s*\+\s*([A-Za-z_$][\w$]*)\s*\]/g;for(let c of e.matchAll(s))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=[],l=[];for(let c of t)c.kind==="prefix"&&c.prop?l.push({prop:c.prop,prefix:c.text}):i.push(...Tn(c.text));let a=/(?:^|[(,\s])className\s*(?:[,)]|$)/.test(e);return{staticClasses:i,prefixes:l,classNameProp:a}}function qw(e,t,n,r,o){let s=a=>t.rename[a]??a,i=e.axes.map(a=>{let c=t.fixed[a.prop],u=s(a.prop);return{prop:u,values:c?a.values.filter(p=>p.value===c):a.values,defaultValue:c??n[u]??a.defaultValue,opaque:t.opaque.includes(a.prop),locked:!!c}}),l=e.compounds.map(a=>({classes:a.classes,when:a.when.map(c=>({prop:s(c.prop),value:t.fixed[c.prop]??c.value}))}));return{staticClasses:[...e.staticClasses,...r],axes:i,compounds:l,classNameProp:o}}function Qu(e,t,n){let r=[];for(let o of e){let s=Hw(o.source,o.path,t,n);for(let i of o.names){let l=new RegExp(`(?:function\\s+${i}\\b|(?:const|let|var)\\s+${i}\\b)`,"g"),a=[...o.source.matchAll(l)],c=null;for(let u of a){let p=u.index??0,f=o.source.slice(p+u[0].length).search(/\nexport\s/),m=o.source.slice(p,p+u[0].length+(f<0?8e3:f)),g=Gw(o.source,p),S=0;for(;S<m.length;){if(m[S]!=="<"||m[S+1]==="/"||m[S+1]==="!"){S++;continue}let h=Do(m,S);if(!h||h==="too-big"){S++;continue}if(S=h.openEnd,/^[A-Z]/.test(h.tag))continue;let b=Bw(h.attrs);if(!b)continue;let k=Vw(b),y=k.prefixes.length?2:k.staticClasses.length?1:0,x=null,v=s.find($=>new RegExp(`(?:^|[^\\w$])${$.local}\\s*\\(`).test(b));if(v){let $=new RegExp(`(?:^|[^\\w$])${v.local}\\s*\\(`).exec(b),A=$?$.index+$[0].length-1:-1,E=A<0?null:Ww(b,A);if(E){y=3,x=qw(v.recipe,E,g,k.staticClasses,k.classNameProp);for(let O of k.prefixes)x.axes.push({prop:O.prop,values:[],prefix:O.prefix,defaultValue:g[O.prop]})}}!x&&(k.prefixes.length||k.staticClasses.length)&&(x={staticClasses:k.staticClasses,axes:k.prefixes.map($=>({prop:$.prop,values:[],prefix:$.prefix,defaultValue:g[$.prop]})),compounds:[],classNameProp:k.classNameProp}),x&&(!c||y>c.score)&&(c={score:y,tag:h.tag.toLowerCase(),body:x})}}c&&r.push({component:i,path:o.path,rootTag:c.tag,...c.body})}}return r}function Jw(e,t){if(!e)return t;let n=re(e);return re(t).flatMap(r=>n.map(o=>r.includes("&")?r.replaceAll("&",o):`${o} ${r}`)).join(", ")}var Kw=/^@(?:-\w+-)?(?:keyframes|font-face|property)\b/i;function ze(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,i=>i.replace(/[^\n]/g," ")),n=[],r=[],o=0,s=1;for(let i=0;i<t.length;i++){let l=t[i];if(l===`
|
|
19
19
|
`&&s++,l==="{"){let a=t.slice(o,i).trim(),c=r[r.length-1];c&&(c.own+=t.slice(c.segStart,o));let u=/^@theme\b/i.test(a),p=a.startsWith("@")&&!u,d=[...r].reverse().find(f=>!f.isAt)??null;r.push({selector:a,resolved:p?a:u?":root":Jw(d?.resolved??null,a),isAt:p,skip:(c?.skip??!1)||p&&Kw.test(a),start:i+1,line:s,own:"",segStart:i+1}),o=i+1}else if(l==="}"){let a=r.pop();if(a){a.own+=t.slice(a.segStart,i),!a.isAt&&!a.skip&&n.push({selector:a.resolved,body:t.slice(a.start,i),ownBody:a.own,line:a.line,context:r.filter(u=>u.isAt).map(u=>u.selector.replace(/\s+/g," ")).join(" \xB7 ")});let c=r[r.length-1];c&&(c.segStart=i+1)}o=i+1}else l===";"&&(o=i+1)}return n}function we(e){let t=[],n=0,r=0,o=s=>{let i=s.indexOf(":");if(i<=0)return;let l=s.slice(0,i).trim(),a=s.slice(i+1).replace(/\s+/g," ").trim();/^-{0,2}[a-z][\w-]*$/i.test(l)&&a&&l!=="composes"&&t.push({property:l,value:a})};for(let s=0;s<e.length;s++){let i=e[s];i==="("?n++:i===")"?n=Math.max(0,n-1):i===";"&&n===0&&(o(e.slice(r,s)),r=s+1)}return o(e.slice(r)),t}function Lo(e){let t=new Map,n=e.match(/:root\{([^}]*)\}/);if(!n?.[1])return t;for(let r of n[1].split(";")){let o=r.indexOf(":");if(o<=0)continue;let s=r.slice(0,o).trim(),i=r.slice(o+1).trim();s.startsWith("--")&&i&&t.set(s,i)}return t}function en(e,t,n=0){if(n>4)return e;let r="",o=0;for(;;){let s=e.indexOf("var(",o);if(s<0)return r+e.slice(o);let i=1,l=-1,a=s+4;for(;a<e.length&&i>0;a++){let f=e[a];f==="("?i++:f===")"?i--:f===","&&i===1&&l<0&&(l=a)}if(i>0)return r+e.slice(o);let c=e.slice(s+4,a-1),u=(l<0?c:e.slice(s+4,l)).trim(),p=l<0?void 0:e.slice(l+1,a-1),d=t.get(u)??p?.trim();r+=e.slice(o,s)+(d?en(d,t,n+1):`var(${u})`),o=a}}function Yi(e,t){return mt([...t]).identity.every(n=>{if(n.kind==="tag")return e.tag===n.name;if(n.kind==="class")return e.classes.includes(n.name);if(n.kind==="id")return e.attrs.id===n.name;if(n.kind==="universal"||n.kind==="pseudoElement")return!0;if(n.kind==="attr"){let r=e.attrs[n.name];if(r===void 0)return!1;let o=n.value??"";return n.op?n.op==="="?r===o:n.op==="~="?r.split(/\s+/).includes(o):n.op==="^="?o!==""&&r.startsWith(o):n.op==="$="?o!==""&&r.endsWith(o):n.op==="*="?o!==""&&r.includes(o):n.op==="|="?r===o||r.startsWith(`${o}-`):!1:!0}if(n.kind==="pseudo"){if(n.name==="root")return e.tag==="html";let r=n.args?re(n.args).map(tt):[];if(r.some(o=>o===null))return!1;if(/^(is|where|matches|any)$/.test(n.name))return r.some(o=>Yi(e,o));if(n.name==="not")return r.length>0&&!r.some(o=>Yi(e,o))}return!1})}function hr(e,t,n,r=n.length-1){if(t<0||!Yi(e[t],n[r].simples))return!1;if(r===0)return!0;let o=n[r].combinator;if(o==="+"||o==="~")return!1;let s=e[t].parent;if(o===">")return hr(e,s,n,r-1);for(;s>=0;){if(hr(e,s,n,r-1))return!0;s=e[s].parent}return!1}var Xw=/^(area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)$/;function Zw(e){let t=/<!--[\s\S]*?-->|<(\/)?([a-zA-Z][\w.:-]*)((?:[^>"'{]|"[^"]*"|'[^']*'|\{[^}]*\})*?)(\/)?>/g,n=[],r=0;return o=>{t.lastIndex=r;for(let s=t.exec(e);s&&s.index<o;s=t.exec(e)){if(r=t.lastIndex,!s[2])continue;let i=s[2].toLowerCase();if(s[1]){let c=n.findLastIndex(u=>u.tag===i);c>=0&&(n.length=c);continue}if(s[4]||Xw.test(i))continue;if(i==="script"||i==="style"){let c=e.indexOf(`</${i}`,r);r=t.lastIndex=c===-1?e.length:c;continue}let l={};for(let c of s[3].matchAll(/([\w:-]+)=(?:"([^"]*)"|'([^']*)')/g))l[c[1]]=c[2]??c[3]??"";let a=(l.class??l.className??"").split(/\s+/).filter(Boolean);n.push({tag:i,classes:a,attrs:l})}return[...n]}}function Yw(e,t,n=[]){let r=[{...e,parent:-1,target:""}],o=[0],s=t.replace(/<\/?([a-z][\w-]*)\b[^>]*>/gi,(u,p)=>{if(u.startsWith("</"))return o.length>1&&o.pop(),u;let d={};for(let m of u.matchAll(/([\w:-]+)="([^"]*)"/g))d[m[1]]=m[2];let f=r.length;return r.push({tag:p.toLowerCase(),classes:(d.class??"").split(/\s+/).filter(Boolean),attrs:d,parent:o[o.length-1],target:` [data-gs-part="${f}"]`}),!/^(img|input|br|hr|source|wbr)$/i.test(p)&&!u.endsWith("/>")&&o.push(f),u.replace(/\/?\s*>$/,` data-gs-part="${f}">`)}),l=[...s.matchAll(/(^|>)([^<]+)(?=<|$)/g)].filter(u=>u[2].trim()).sort((u,p)=>p[2].trim().length-u[2].trim().length)[0],a=l?s.slice(0,l.index+l[1].length)+"__gs_label__"+s.slice(l.index+l[0].length):s,c=r.length;return n.forEach((u,p)=>{r.push({...u,parent:p?r.length-1:-1,target:""})}),n.length&&(r[0].parent=r.length-1),{nodes:r,size:c,bodyHtml:a}}function Qw(e){let t=/\sstyle=(?:"([^"]*)"|'([^']*)')/.exec(e);if(t)return we(t[1]??t[2]??"");let n=/\sstyle=\{\{([^{}]*)\}\}/.exec(e);return n?[...n[1].matchAll(/(?:^|,)\s*(?:"([^"]+)"|'([^']+)'|([\w$]+))\s*:\s*(?:"([^"]*)"|'([^']*)'|(-?[\d.]+))/g)].map(r=>{let o=r[1]??r[2]??r[3];return{property:o.startsWith("--")?o:o.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`),value:r[4]??r[5]??(r[6]==="0"?"0":`${r[6]}px`)}}):[]}function ek(e,t){let n=new Map,r=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",o=t.matchAll(/<link\b[^>]*\brel=["']?stylesheet["']?[^>]*>|<style\b/gi);for(let s of o){if(s[0].toLowerCase().startsWith("<style")){n.has(`${e}${tn}`)||n.set(`${e}${tn}`,n.size);continue}let i=/\bhref=["']?([^"'\s>]+)/i.exec(s[0])?.[1];if(!i||/^(?:[a-z]+:)?\/\//i.test(i))continue;let l=(i.startsWith("/")?i.slice(1):`${r}/${i}`).split(/[?#]/)[0].split("/"),a=[];for(let c of l)c===".."?a.pop():c&&c!=="."&&a.push(c);n.set(a.join("/"),n.size)}return n}var tk=4e3,tn="#style.css";function tp(e,t,n){let r=new Map,o=new Set,s=new Set(n.filter(a=>!a.borrowed).flatMap(a=>a.declarations.flatMap(c=>[...c.value.matchAll(/var\(\s*(--[\w-]+)/g)].map(u=>u[1])))),i=n.flatMap((a,c)=>re(a.selector).flatMap(u=>{let p=ue(u);if(!p)return[];let d=p.reduce((g,S)=>g+S.simples.reduce((h,b)=>h+(b.kind==="id"?100:b.kind==="tag"?1:10),0),0),f=p.at(-1).simples.some(g=>g.kind==="class"||g.kind==="id"),m=a.borrowed?a.declarations.filter(g=>g.property.startsWith("--")?s.has(g.property):f&&!Zt(g)):a.declarations;return m.length?[{...a,declarations:m,compounds:p,order:c,specificity:d}]:[]})).sort((a,c)=>a.specificity-c.specificity||a.order-c.order),l=new Map;for(let a of i)if(a.context===""&&a.compounds.length===1&&/^(:root|html)$/.test(An(a.compounds[0].simples)))for(let c of a.declarations)c.property.startsWith("--")&&l.set(c.property,c.value);for(let[a,c]of e){if(!/\.(html?|tsx?|jsx?|vue|svelte|astro|mdx)$/i.test(a)||/(^|\/)(tests?|__tests__)\/|\.(test|spec)\./i.test(a))continue;let u=Zw(c),p=ek(a,c),d=f=>p.get(f)??-1;for(let f of c.matchAll(/<(button|a|div|span)\b/gi)){if(r.size>=100)break;let m=_t(c,f.index+1,[],a),g=m.element;if(!g||g.tag!=="button"&&g.tag!=="a"&&g.attrs.role!=="button")continue;let S=g.bodyHtml.includes("<");if(!S&&g.tag!=="button"&&g.attrs.role!=="button")continue;let{nodes:h,size:b,bodyHtml:k}=Yw(g,g.bodyHtml,u(f.index)),y=h.slice(0,b),x=t.filter(_=>{if(_.select||_.markup||!_.path.endsWith("css"))return!1;let P=ue(_.selector);return P&&y.some((T,B)=>hr(h,B,P))});if(S?!x.length:x.length)continue;let v=i.flatMap(_=>/\.module\./.test(_.path)&&!x.some(P=>P.path===_.path)?[]:y.flatMap((P,T)=>hr(h,T,_.compounds)?[{..._,i:T}]:[])).sort((_,P)=>_.specificity-P.specificity||d(_.path)-d(P.path)||_.order-P.order),$=[...c.slice(f.index,f.index+tk).matchAll(/<(\/)?([a-zA-Z][\w.-]*)\b(?:[^>"'{]|"[^"]*"|'[^']*'|\{\{[^}]*\}\}|\{[^}]*\})*?>/g)].filter(_=>!_[1]).slice(0,b);y.forEach((_,P)=>{let T=$[P];if(!T||T[2].toLowerCase()!==_.tag)return;let B=Qw(T[0]).filter(Y=>ae(Y.property,Y.value));B.length&&v.push({path:a,selector:"",line:c.slice(0,f.index).split(`
|
|
20
|
-
`).length,context:"",borrowed:!0,declarations:B,compounds:[{combinator:null,simples:[]}],order:1/0,specificity:1e3,i:P})});let
|
|
21
|
-
`).length,N={path:a,line:E,example:m},F=r.get(A);if(F)F.places.push({path:a,line:E}),F.usage.files.some(_=>_.path===a)||F.usage.files.push(N),F.usage.fileCount=new Set(F.places.map(_=>_.path)).size;else{let _=v.findLast(T=>T.i===0&&I(T)),P=x.find(T=>T.element?.classes.some(B=>z.includes(B)))??x[0]??{title:"Button",path:_?.path??a,line:_?.line??E};r.set(A,{title:g.bodyHtml.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()||P.title,axis:null,element:{...g,classes:z,ancestors:[]},usage:{status:"used",files:[N],fileCount:1},selector:w,path:P.path,line:P.line,base:!1,places:[{path:a,line:E}],states:D,render:{element:{...g,classes:z,attrs:Object.fromEntries(Object.entries(g.attrs).filter(([T])=>!/^(href|target)$/i.test(T))),ancestors:[]},bodyHtml:k}})}for(let _ of x)o.add(_);for(let _ of t)_.path===x[0]?.path&&_.states.every(P=>P.declarations.every(T=>T.property.startsWith("--")))&&z.some(P=>_.selector.startsWith(`.${P.split("--")[0]}--`))&&o.add(_)}}return[...t.filter(a=>!o.has(a)),...r.values()]}var nk=60;function jn(e,t,n){let r=ue(e);if(!r)return null;let o=r.length-1,s=r[o].simples;if(Vc(s)||hi(s,t))return null;if(So(s,t))return{compounds:r,at:o};for(let i=o-1;i>=0;i--){let l=r[i].simples;if(So(l,t)&&!hi(l,t))return{compounds:r,at:i}}return!n||o===0&&qc(s)?null:{compounds:r,at:0}}function ep(e,t,n){return cr([...e,{combinator:e.length?t.combinator:null,simples:n}])}function np(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 rk(e,t){return e.length>=t.length?!1:e.every(n=>t.some(r=>np(n,r)))}function ok(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(r=>r.toLowerCase()===n.name.toLowerCase()):!1}function rp(e,t){for(let n of t.classes)e.classes.includes(n)||e.classes.push(n);Object.assign(e.attrs,t.attrs)}function op(e){let t=new Set(e.map(n=>ur(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 sk(e){let t=e.filter(s=>s.context===""),n=t.length?t:e;if(n.some(s=>s.state==="default"))return null;let o=[...n.map(s=>new Set(s.state.split(" + "))).reduce((s,i)=>s?new Set([...s].filter(l=>i.has(l))):i,null)??[]].filter(s=>Me(s)===vo.length);return o.length===1?o[0]:null}function Zi(e){return e.sort((t,n)=>+(t.context!=="")-+(n.context!=="")||Me(t.state.split(" + ")[0])-Me(n.state.split(" + ")[0])||t.state.localeCompare(n.state))}function sp(e,t,n,r,o={parts:new Set,controls:new Set}){let s=new Map,i=[];for(let h of t)if(h.declarations.length!==0)for(let b of re(h.selector)){let k=jn(b,n,r);if(!k)continue;let{compounds:y,at:x}=k,v=y[x],$=mt(v.simples);if($.identity.length===0)continue;let R=y.slice(0,x),I=ep(R,v,$.identity),O=nt($.states);if(x<y.length-1){i.push({hostKey:I,part:{selector:cr(y),path:e,line:h.line,state:O}});continue}if(Kc($.identity,h.declarations))continue;let L=s.get(I);if(!L){if(s.size>=nk)continue;L={key:I,prefix:R,identity:$.identity,line:h.line,states:[],modifiers:[],contexts:[],parts:[],movedInto:null},s.set(I,L)}let D=L.states.find(z=>z.state===O&&z.context===h.context);D||(D={state:O,context:h.context,line:h.line,declarations:[]},$.states.length&&(D.marker={classes:[],attrs:{}}),L.states.push(D)),D.marker&&rp(D.marker,$.marker),D.declarations.push(...h.declarations)}for(let[h,b]of s){let k=b.states.flatMap(v=>v.declarations),y=b.states.every(v=>_o(v.declarations)),x=k.every(v=>ur(v.property)==="hint");(y||x)&&s.delete(h)}let l=new Map;for(let h of s.values()){let b=An(h.identity);l.set(b,[...l.get(b)??[],h])}for(let h of l.values()){let b=h.map(v=>sk(v.states)),k=b[0];if(!k||b.some(v=>v!==k))continue;let y=h.flatMap(v=>v.states).find(v=>v.marker&&v.state.split(" + ").includes(k))?.marker;if(!y)continue;let x=[...y.classes.map(v=>({kind:"class",raw:`.${v}`,name:v})),...Object.entries(y.attrs).map(([v,$])=>({kind:"attr",raw:`[${v}="${$}"]`,name:v,op:"=",value:$}))];for(let v of h){let $=[...v.identity,...x],R={combinator:v.prefix.length?" ":null,simples:$},I=ep(v.prefix,R,$);for(let O of v.states){let L=O.state.split(" + ").filter(D=>D!==k);if(O.state=nt(L),L.length===0)delete O.marker;else if(O.marker){O.marker.classes=O.marker.classes.filter(D=>!y.classes.includes(D));for(let D of Object.keys(y.attrs))delete O.marker.attrs[D]}}s.delete(v.key),s.set(I,{...v,key:I,identity:$})}}let a=()=>[...s.values()].filter(h=>h.prefix.length===0),c=h=>h.states.filter(b=>b.state==="default").reduce((b,k)=>b+k.declarations.length,0),u=a().find(h=>ok(h.identity,n))??(r?a().filter(h=>{let b=h.identity.length===1?h.identity[0]:null;return b?.kind==="class"&&o.controls.has(b.name)}).sort((h,b)=>c(b)-c(h)||h.line-b.line)[0]??null:null),p=u&&u.identity[0].kind==="class"?[u.identity[0].name]:[],d=(h,b,k)=>{b[k].push(h),h.movedInto=b,s.delete(h.key)},f=[...s.values()],m=h=>{let b=f.find(k=>k.key===h)??null;for(;b?.movedInto;)b=b.movedInto;return b};for(let h of a()){let b=h.identity.length===1?h.identity[0]:null;if(!(b?.kind!=="class"||!o.parts.has(b.name))&&(s.delete(h.key),u&&h!==u)){h.movedInto=u;for(let k of h.states)u.parts.push({selector:h.key,path:e,line:k.line,state:k.state})}}let g=a().filter(h=>h.identity.filter(b=>b.kind!=="tag"&&b.kind!=="universal").length>=2).sort((h,b)=>h.identity.length-b.identity.length);for(let h of g){let b=f.filter(y=>y!==h&&y!==u&&y.prefix.length===0&&rk(y.identity,h.identity));if(b.length===0)continue;b.sort((y,x)=>x.identity.length-y.identity.length||c(x)-c(y)||y.line-x.line);let k=m(b[0].key);k&&k!==h&&d(h,k,"modifiers")}for(let{hostKey:h,part:b}of i){let k=m(h)??(r?u:null);k&&s.has(k.key)&&k.parts.push(b)}let S=h=>{let b=h===u,k=To(h.key,p);return{...Qt({selector:h.key,path:e,base:b},n.classKeywords),element:k,usage:{status:"unknown",files:[],fileCount:0},selector:h.key,path:e,line:h.line,base:b,states:Zi(h.states),modifiers:h.modifiers.length?h.modifiers.map(y=>{let x=y.identity.filter(v=>!h.identity.some($=>np($,v)));return{title:Qt({selector:x.map(v=>v.raw).join(""),path:e,base:!1},n.classKeywords).title,selector:y.key,path:e,line:y.line,element:To(y.key,p),usage:{status:"unknown",files:[],fileCount:0},states:Zi(y.states)}}):void 0,contexts:h.contexts.length?h.contexts.map(y=>{let x=op(y.states.flatMap(v=>v.declarations));return{selector:y.key,path:e,line:y.line,role:x,element:x==="override"?To(y.key,p):null,states:Zi(y.states)}}):void 0,parts:h.parts.length?h.parts:void 0}};return[...s.values()].map(S)}function ip(e){let t=new Map;for(let i of e){let l=i.base?/^\.([\w-]+)$/.exec(i.selector):null;l&&t.set(i.path,[...t.get(i.path)??[],l[1]])}let n=i=>{let l=ue(i.selector);if(!l)return null;let a=l[l.length-1].simples,c=t.get(i.path)??[],u=a.filter(p=>!(p.kind==="class"&&c.includes(p.name)));return{depth:l.length-1,subject:An(a),bareTag:!a.some(p=>p.kind==="class"||p.kind==="attr"||p.kind==="id"),bare:u.length&&u.length<a.length?An(u):null}},r=new Map(e.map(i=>[i,n(i)])),o=new Set,s=i=>{let l=r.get(i);if(!l||l.depth===0)return null;let a=e.filter(c=>{if(c===i||o.has(c))return!1;let u=r.get(c);return u!=null&&u.depth<l.depth&&(!l.bareTag||u.depth===0)&&(u.subject===l.subject||l.bare!==null&&u.subject===l.bare)});return a.sort((c,u)=>+(u.path===i.path)-+(c.path===i.path)||r.get(c).depth-r.get(u).depth),a[0]??null};for(let i of[...e].sort((l,a)=>(r.get(a)?.depth??0)-(r.get(l)?.depth??0))){let l=s(i);if(!l)continue;for(;o.has(l);)l=s(l)??l;let a=op(i.states.flatMap(c=>c.declarations));l.contexts=[...l.contexts??[],{selector:i.selector,path:i.path,line:i.line,role:a,element:a==="override"?i.element:null,states:i.states}],i.parts?.length&&(l.parts=[...l.parts??[],...i.parts]),i.modifiers?.length&&(l.modifiers=[...l.modifiers??[],...i.modifiers]),o.add(i)}return e.filter(i=>!o.has(i))}var ik=40,rt=(e,t)=>({path:e,line:t});function ot(e,t,n,r){return{...e,status:t.length===0?"ok":"attention",summary:t.length===0?n:r(t.length),findings:t.slice(0,ik)}}function nn(e,t){return{...e,status:"na",summary:t,findings:[]}}var Qi=e=>e.state.split(" + ");function pp(e,t){if(!e.element||!t.element||e!==t&&!Ui(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(r=>n.has(r))?Object.entries(e.element.attrs).every(([r,o])=>t.element.attrs[r]===o):!1}function dp(e,t){return t.filter(n=>pp(n,e)).flatMap(n=>n.states)}function ak(e,t,n){return dp(e,t).some(r=>Qi(r).includes(n))||t.filter(r=>pp(r,e)).some(r=>(r.parts??[]).some(o=>o.state.split(" + ").includes(n)))}var lk=[{state:"hover",severity:"issue"},{state:"focus",severity:"issue"},{state:"disabled",severity:"issue"},{state:"active",severity:"note"}];function ck(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(o=>o.element&&o.element.ancestors.length===0);if(n.length===0)return nn(t,"No styles that can be drawn on their own.");let r=[];for(let{state:o,severity:s}of lk){let i=n.filter(l=>!ak(l,e.variants,o));i.length!==0&&r.push({severity:s,message:i.length===n.length?`No style defines a ${o} state.`:`${i.length} of ${n.length} styles have no ${o} state.`,styles:i.length===n.length?void 0:i.map(l=>l.title),refs:i.slice(0,6).map(l=>rt(l.path,l.line))})}return ot(t,r,"Every style has hover, focus, disabled, and active rules.",o=>`${o} state${o===1?"":"s"} missing on some styles.`)}var ap=new Set(["outline","outline-style","outline-width"]),lp=/^(?:none|0|0px)(?:\s+(?:none|0|0px))*$/i,uk=/^(?:outline(?:-color|-width|-style)?|box-shadow|border(?:-[a-z]+)*|background(?:-color)?|text-decoration(?:-[a-z]+)?|color)$/;function pk(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(o=>o.element&&o.element.ancestors.length===0);if(n.length===0)return nn(t,"No styles that can be drawn on their own.");let r=[];for(let o of n){let s=dp(o,e.variants),i=s.filter(a=>{let c=Qi(a);return c.includes("default")||c.includes("focus")}).flatMap(a=>a.declarations.map(c=>({s:a,d:c}))).find(({d:a})=>ap.has(a.property)&&lp.test(a.value.replace(/\s*!important/i,"")));!i||s.filter(a=>Qi(a).includes("focus")).some(a=>a.declarations.some(c=>uk.test(c.property)&&!(ap.has(c.property)&&lp.test(c.value))&&!/^(?:none|0|0px)$/i.test(c.value)&&!(c.property==="box-shadow"&&/^none$/i.test(c.value))))||r.push({severity:"issue",message:`${o.title} removes the outline (${i.d.property}: ${i.d.value}) and no focus rule replaces it.`,styles:[o.title],refs:[rt(o.path,i.s.line)]})}return ot(t,r,"No style removes the outline without a focus replacement.",o=>`${o} style${o===1?"":"s"} lose the focus indicator.`)}function dk(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 nn(t,`The ${e.noun} styles read no custom properties.`);let r=e.tokens.filter(o=>o.definedIn.length===0&&!o.name.startsWith("--tw-")).map(o=>{let s=e.variants.filter(i=>i.states.some(l=>l.declarations.some(a=>a.value.includes(`var(${o.name}`)||new RegExp(`var\\(\\s*${o.name}\\b`).test(a.value))));return{severity:"note",message:`${o.name} is read but never defined here. It may be set outside the scanned files (a framework, a theme provider).`,styles:s.slice(0,8).map(i=>i.title),refs:s.slice(0,3).map(i=>rt(i.path,i.line))}});return ot(t,r,`All ${e.tokens.length} tokens read are defined.`,o=>`${o} token${o===1?"":"s"} with no definition.`)}var fk=/var\((?:[^()]|\([^()]*\))*\)/g,cp=/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?)\([^)]*\)/gi,gk=/^(?:padding|margin|gap|row-gap|column-gap|height|min-height|max-height|border-radius|font-size|letter-spacing)(?:-[a-z]+)*$/,mk=/(?<![\w.-])(\d+(?:\.\d+)?)px\b/g;function up(e){let t=e.trim().toLowerCase().replace(/\s+/g,""),n=/^#([0-9a-f]{3})$/.exec(t);return n?`#${[...n[1]].map(r=>r+r).join("")}`:t}function ea(e,t,n=0){return n>6?e:e.replace(/var\(\s*(--[\w-]+)\s*(?:,\s*([^)]*))?\)/g,(r,o,s)=>{let i=t.get(o);return i!==void 0?ea(i,t,n+1):s!==void 0?ea(s.trim(),t,n+1):r})}var hk=[[/^(?: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 yk(e,t){if(!t)return null;let n=hk.find(([r])=>r.test(e))?.[1];return t.find(r=>!n||n.test(r))??null}function bk(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,r=new Map;for(let[s,i]of e.tokenValues){let l=ea(i,e.tokenValues).trim();if(new RegExp(`^(?:${cp.source})$`,"i").test(l)){let a=up(l);n.set(a,[...n.get(a)??[],s])}else/^\d+(?:\.\d+)?px$/.test(l)&&r.set(l,[...r.get(l)??[],s])}if(n.size===0&&r.size===0)return nn(t,"No color or size tokens were found to compare against.");let o=[];for(let s of e.variants){let i=[],l=null;for(let c of s.states)for(let u of c.declarations){if(u.via)continue;let p=u.value.replace(fk," ");for(let d of p.matchAll(cp)){let f=n.get(up(d[0]));i.push(f?`${d[0]} in ${u.property} is the value of ${f[0]}`:`${d[0]} in ${u.property} is not a token`),l??=c}if(gk.test(u.property))for(let d of p.matchAll(mk)){let f=yk(u.property,r.get(`${d[1]}px`));!f||Number(d[1])<=1||(i.push(`${d[1]}px in ${u.property} is the value of ${f}`),l??=c)}}if(i.length===0||!l)continue;let a=[...new Set(i)];o.push({severity:"issue",message:`${s.title}: ${a.slice(0,4).join("; ")}${a.length>4?`; and ${a.length-4} more`:""}.`,styles:[s.title],refs:[rt(s.path,l.line)]})}return ot(t,o,`No ${e.noun} style hard-codes a value a token already has.`,s=>`${s} style${s===1?"":"s"} hard-code values.`)}function wk(e){let t={id:"unused",title:"Unused styles",description:"Styles defined in CSS that no component, page, or template references."},n=e.variants.filter(o=>o.element&&o.usage.status!=="unknown");if(n.length===0)return nn(t,"No styles with a class name to look for.");let r=[];for(let o of n)o.usage.status==="unreferenced"?r.push({severity:"issue",message:`${o.title} (${o.selector}) is defined but no reference to it was found.`,styles:[o.title],refs:[rt(o.path,o.line)]}):o.usage.status==="dynamic"&&r.push({severity:"note",message:`${o.title} (${o.selector}) is built at runtime and nothing selects it by value.`,styles:[o.title],refs:[rt(o.path,o.line),...o.usage.files.slice(0,2)]});return r.sort((o,s)=>+(s.severity==="issue")-+(o.severity==="issue")),ot(t,r,`All ${n.length} styles are referenced.`,o=>`${o} style${o===1?"":"s"} unreferenced or unconfirmed.`)}function kk(e){let t={id:"duplicates",title:"Duplicate styles",description:"Different styles whose default declarations are identical."},n=new Map;for(let o of e.variants){if(!o.element)continue;let s=o.states.filter(l=>l.state==="default"&&l.context==="").flatMap(l=>l.declarations).map(l=>`${l.property}:${l.value.replace(/\s+/g," ").trim()}`);if(s.length<2)continue;let i=[...new Set(s)].sort().join(";");n.set(i,[...n.get(i)??[],o])}let r=[...n.values()].filter(o=>o.length>1).map(o=>({severity:"issue",message:`${o.map(s=>s.title).join(", ")} declare the same default styles (${o.map(s=>s.selector).join(", ")}).`,styles:o.map(s=>s.title),refs:o.map(s=>rt(s.path,s.line))}));return ot(t,r,"No two styles share the same default declarations.",o=>`${o} group${o===1?"":"s"} of identical styles.`)}function xk(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 nn(t,`No shared ${e.element} component was found, so native elements are expected.`);let n=e.nativeUses.map(r=>({severity:"issue",message:`${r.count} native <${e.element}> element${r.count===1?"":"s"} in ${r.path}.`,refs:[rt(r.path,r.line)]}));return ot(t,n,`Every <${e.element}> goes through the component.`,r=>`${r} file${r===1?"":"s"} bypass the component.`)}function vk(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 nn(t,`No shared ${e.element} component was found.`);let n=(e.unknownProps??[]).map(r=>({severity:"issue",message:`<${r.component} ${r.prop}="${r.value}"> in ${r.path}: ${r.component} has no ${r.prop} "${r.value}" (it has ${r.known.join(", ")}).`,refs:[rt(r.path,r.line)]}));return ot(t,n,"Every literal prop value picks a look the component has.",r=>`${r} call${r===1?"":"s"} ask for a look the component does not have.`)}function Sk(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 ot(t,[],"Every style is named in written guidance.",()=>"");let r=e.variants.filter(o=>o.element&&n.undocumented.includes(o.title));return ot(t,[{severity:"note",message:`${n.undocumented.length} of ${n.documented.length+n.undocumented.length} styles are named in no guidance.`,styles:n.undocumented,refs:r.slice(0,6).map(o=>rt(o.path,o.line))}],"",o=>`${o} finding${o===1?"":"s"}.`)}function fp(e){return[ck(e),pk(e),wk(e),kk(e),dk(e),bk(e),xk(e),vk(e),Sk(e)]}var $k=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,Ck=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,Rk=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),Ak=new Set(["icon","glyph","svg"]),Ik=new Set(["label","text","title","caption"]),Ek=e=>e.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(t=>t.toLowerCase());function mp(e){let t=e.flatMap(Ek);return t.some(n=>Ak.has(n))?"icon":t.some(n=>Ik.has(n))?"label":null}function Tk(e){let t=e.replace(/\{\s*\/\*[\s\S]*?\*\/\s*\}/g," "),n=[];for(let r of t.matchAll($k)){let o=r[1];if(!Rk.has(o.toLowerCase())||o!==o.toLowerCase())continue;let s=[...r[2].matchAll(Ck)].map(l=>l[1]??l[2]),i=mp(s);i&&n.push({index:r.index??0,role:i,tag:o.toLowerCase(),classes:s})}return n}function _k(e,t,n){if(!t.some(o=>o.property.toLowerCase()==="display"&&/^none\b/i.test(o.value.trim()))||n.size===0)return null;for(let o of re(e)){let s=ue(o);if(!s||s.length<2)continue;let i=s[s.length-1];if(i.combinator!==" "&&i.combinator!==">")continue;let l=i.simples.filter(d=>d.kind==="class");if(l.length!==1||l[0].kind!=="class"||!n.has(l[0].name))continue;let a=s[s.length-2];if(a.simples.filter(d=>d.kind!=="class"&&d.kind!=="attr"&&d.kind!=="tag").length>0)continue;let u=a.simples.filter(d=>d.kind==="class"),p=a.simples.filter(d=>d.kind==="attr");if(u.length===1&&p.length===0&&u[0].kind==="class"&&!/^(?:is|has)-/.test(u[0].name))return{classes:[u[0].name],attrs:{}};if(u.length===0&&p.length===1&&p[0].kind==="attr"&&p[0].value)return{classes:[],attrs:{[p[0].name]:p[0].value}}}return null}var jk=["text","icon-start","icon-end","icon"],gp={text:"Text","icon-start":"Icon left","icon-end":"Icon right",icon:"Icon"};function Ok(e,t){let n=null,r=null;for(let i of t)i.index<e.index?n=i:r||(r=i);if(!n&&!r)return null;let o=n?e.index-n.index:1/0;return(r?r.index-e.index:1/0)<=o?"start":"end"}function On(e){return{role:e.role,tag:e.tag,classes:e.classes}}function hp(e){let t=new Map,n=(r,o)=>{let s=t.get(r)??[];s.some(i=>i.path===o.path)||s.push(o),t.set(r,s)};for(let r of e){let o=r.sources.flatMap(Tk),s=o.filter(f=>f.role==="label"),i=o.filter(f=>f.role==="icon"),l=s[0];l&&n("text",{path:r.sheet,slots:[On(l)],classes:[],attrs:{}});let a=new Set(s.flatMap(f=>f.classes.filter(m=>mp([m])==="label"))),c=null,u=null;for(let f of i){let m=Ok(f,s),g=s.reduce((S,h)=>{let b=Math.abs(h.index-f.index);return!S||b<S.dist?{hit:h,dist:b}:S},null);m==="start"&&g&&!c&&(c={icon:f,label:g.hit}),m==="end"&&g&&!u&&(u={icon:f,label:g.hit})}c&&n("icon-start",{path:r.sheet,slots:[On(c.icon),On(c.label)],classes:[],attrs:{}}),u&&n("icon-end",{path:r.sheet,slots:[On(u.label),On(u.icon)],classes:[],attrs:{}});let p=null;for(let f of r.rules)if(p=_k(f.selector,f.declarations,a),p)break;let d=c?.icon??u?.icon??i[0]??null;p&&d&&n("icon",{path:r.sheet,slots:[On(d)],classes:p.classes,attrs:p.attrs})}return[{id:"text",label:gp.text,sheets:t.get("text")??[]},...jk.filter(r=>r!=="text"&&t.has(r)).map(r=>({id:r,label:gp[r],sheets:t.get(r)??[]}))]}var Mk=25,Dk=12,yp=700,Pk=/\b(?:must(?: not)?|never|always|should(?: not|n't)?|do not|don't|avoid|prefer|forbidden|not allowed|no more than)\b/i,bt=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Lk(e){let t=e.split(`
|
|
20
|
+
`).length,context:"",borrowed:!0,declarations:B,compounds:[{combinator:null,simples:[]}],order:1/0,specificity:1e3,i:P})});let A=new Map;for(let _=b;_<h.length;_++)if(h[_].tag!=="html"){for(let P of i)if(P.context===""&&!P.compounds.some(T=>mt(T.simples).states.length)&&hr(h,_,P.compounds))for(let T of P.declarations)T.property.startsWith("--")&&s.has(T.property)&&l.get(T.property)!==T.value&&A.set(T.property,T.value)}let E=_=>_.declarations.some(P=>/^(background(?:-color)?|border(?:-(?:color|width|style))?|box-shadow)$/.test(P.property)&&!/^(none|transparent|0|inherit|initial|unset)\b/.test(P.value)),O=_=>_.declarations.some(P=>/^padding(?:-(?:inline|block|left|right|top|bottom))?$/.test(P.property)&&!/^0(?:px)?$/.test(P.value.trim()));if(!S&&!(v.some(_=>_.i===0&&E(_))&&v.some(_=>_.i===0&&O(_)))||S&&!v.some(_=>_.i>0&&!_.borrowed&&_.declarations.some(P=>/^(background(?:-color)?|border(?:-.+)?|box-shadow|transform)$/.test(P.property))))continue;let L=new Map;for(let _ of v){let P=_.compounds.map(C=>mt(C.simples)),T=nt([...new Set(P.flatMap(C=>C.states))]),B=_.compounds.at(-1).simples.find(C=>C.kind==="pseudoElement"),Y=h[_.i].target+(B?.raw??""),me=`${Y}|${T}|${_.context}`,J=L.get(me)??{state:T,context:_.context,line:_.line,declarations:[],...Y?{target:Y}:{}},te=new Map(J.declarations.map(C=>[C.property,C]));for(let C of _.declarations)if(!(_.i===0&&Zt(C)&&C.property!=="display"||te.get(C.property)?.value.endsWith("!important")&&!C.value.endsWith("!important"))&&(te.set(C.property,C),C.property==="border")){let M=C.value.match(/(?:[^\s()]+|\([^)]*\))+/g)??[];if(M.length>=3)for(let[U,K]of[["border-width",M[0]],["border-style",M[1]],["border-color",M.slice(2).join(" ")]])te.set(U,{property:U,value:K})}if(J.declarations=[...te.values()],T!=="default"){let C={classes:[],attrs:{}};for(let j of P)rp(C,j.marker);J.marker=C}L.set(me,J)}let D=[...L.values()];for(let _ of D){let P=new Map(A);for(let T of D)if(!(T.context!==_.context&&T.context!=="")&&!(T.target&&T.target!==_.target)&&!(T.state!=="default"&&T.state!==_.state))for(let B of T.declarations)B.property.startsWith("--")&&P.set(B.property,B.value);_.declarations=_.declarations.map(T=>({...T,value:T.property.startsWith("--")?T.value:en(T.value,P)}))}let z=g.classes.filter(_=>v.some(P=>P.compounds.some(T=>T.simples.some(B=>B.kind==="class"&&B.name===_))&&P.declarations.some(T=>!Zt(T)))||/(?:^|[-_])(primary|secondary|destructive|danger|ghost|link|icon)(?:$|[-_])/.test(_)),w=z.map(_=>`.${_}`).join("");if(!w)continue;let R=`${w}|${k}|${JSON.stringify(D)}`,I=c.slice(0,f.index).split(`
|
|
21
|
+
`).length,N={path:a,line:I,example:m},F=r.get(R);if(F)F.places.push({path:a,line:I}),F.usage.files.some(_=>_.path===a)||F.usage.files.push(N),F.usage.fileCount=new Set(F.places.map(_=>_.path)).size;else{let _=v.findLast(T=>T.i===0&&E(T)),P=x.find(T=>T.element?.classes.some(B=>z.includes(B)))??x[0]??{title:"Button",path:_?.path??a,line:_?.line??I};r.set(R,{title:g.bodyHtml.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()||P.title,axis:null,element:{...g,classes:z,ancestors:[]},usage:{status:"used",files:[N],fileCount:1},selector:w,path:P.path,line:P.line,base:!1,places:[{path:a,line:I}],states:D,render:{element:{...g,classes:z,attrs:Object.fromEntries(Object.entries(g.attrs).filter(([T])=>!/^(href|target)$/i.test(T))),ancestors:[]},bodyHtml:k}})}for(let _ of x)o.add(_);for(let _ of t)_.path===x[0]?.path&&_.states.every(P=>P.declarations.every(T=>T.property.startsWith("--")))&&z.some(P=>_.selector.startsWith(`.${P.split("--")[0]}--`))&&o.add(_)}}return[...t.filter(a=>!o.has(a)),...r.values()]}var nk=60;function jn(e,t,n){let r=ue(e);if(!r)return null;let o=r.length-1,s=r[o].simples;if(Vc(s)||hi(s,t))return null;if(So(s,t))return{compounds:r,at:o};for(let i=o-1;i>=0;i--){let l=r[i].simples;if(So(l,t)&&!hi(l,t))return{compounds:r,at:i}}return!n||o===0&&qc(s)?null:{compounds:r,at:0}}function ep(e,t,n){return cr([...e,{combinator:e.length?t.combinator:null,simples:n}])}function np(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 rk(e,t){return e.length>=t.length?!1:e.every(n=>t.some(r=>np(n,r)))}function ok(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(r=>r.toLowerCase()===n.name.toLowerCase()):!1}function rp(e,t){for(let n of t.classes)e.classes.includes(n)||e.classes.push(n);Object.assign(e.attrs,t.attrs)}function op(e){let t=new Set(e.map(n=>ur(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 sk(e){let t=e.filter(s=>s.context===""),n=t.length?t:e;if(n.some(s=>s.state==="default"))return null;let o=[...n.map(s=>new Set(s.state.split(" + "))).reduce((s,i)=>s?new Set([...s].filter(l=>i.has(l))):i,null)??[]].filter(s=>Me(s)===vo.length);return o.length===1?o[0]:null}function Zi(e){return e.sort((t,n)=>+(t.context!=="")-+(n.context!=="")||Me(t.state.split(" + ")[0])-Me(n.state.split(" + ")[0])||t.state.localeCompare(n.state))}function sp(e,t,n,r,o={parts:new Set,controls:new Set}){let s=new Map,i=[];for(let h of t)if(h.declarations.length!==0)for(let b of re(h.selector)){let k=jn(b,n,r);if(!k)continue;let{compounds:y,at:x}=k,v=y[x],$=mt(v.simples);if($.identity.length===0)continue;let A=y.slice(0,x),E=ep(A,v,$.identity),O=nt($.states);if(x<y.length-1){i.push({hostKey:E,part:{selector:cr(y),path:e,line:h.line,state:O}});continue}if(Kc($.identity,h.declarations))continue;let L=s.get(E);if(!L){if(s.size>=nk)continue;L={key:E,prefix:A,identity:$.identity,line:h.line,states:[],modifiers:[],contexts:[],parts:[],movedInto:null},s.set(E,L)}let D=L.states.find(z=>z.state===O&&z.context===h.context);D||(D={state:O,context:h.context,line:h.line,declarations:[]},$.states.length&&(D.marker={classes:[],attrs:{}}),L.states.push(D)),D.marker&&rp(D.marker,$.marker),D.declarations.push(...h.declarations)}for(let[h,b]of s){let k=b.states.flatMap(v=>v.declarations),y=b.states.every(v=>_o(v.declarations)),x=k.every(v=>ur(v.property)==="hint");(y||x)&&s.delete(h)}let l=new Map;for(let h of s.values()){let b=An(h.identity);l.set(b,[...l.get(b)??[],h])}for(let h of l.values()){let b=h.map(v=>sk(v.states)),k=b[0];if(!k||b.some(v=>v!==k))continue;let y=h.flatMap(v=>v.states).find(v=>v.marker&&v.state.split(" + ").includes(k))?.marker;if(!y)continue;let x=[...y.classes.map(v=>({kind:"class",raw:`.${v}`,name:v})),...Object.entries(y.attrs).map(([v,$])=>({kind:"attr",raw:`[${v}="${$}"]`,name:v,op:"=",value:$}))];for(let v of h){let $=[...v.identity,...x],A={combinator:v.prefix.length?" ":null,simples:$},E=ep(v.prefix,A,$);for(let O of v.states){let L=O.state.split(" + ").filter(D=>D!==k);if(O.state=nt(L),L.length===0)delete O.marker;else if(O.marker){O.marker.classes=O.marker.classes.filter(D=>!y.classes.includes(D));for(let D of Object.keys(y.attrs))delete O.marker.attrs[D]}}s.delete(v.key),s.set(E,{...v,key:E,identity:$})}}let a=()=>[...s.values()].filter(h=>h.prefix.length===0),c=h=>h.states.filter(b=>b.state==="default").reduce((b,k)=>b+k.declarations.length,0),u=a().find(h=>ok(h.identity,n))??(r?a().filter(h=>{let b=h.identity.length===1?h.identity[0]:null;return b?.kind==="class"&&o.controls.has(b.name)}).sort((h,b)=>c(b)-c(h)||h.line-b.line)[0]??null:null),p=u&&u.identity[0].kind==="class"?[u.identity[0].name]:[],d=(h,b,k)=>{b[k].push(h),h.movedInto=b,s.delete(h.key)},f=[...s.values()],m=h=>{let b=f.find(k=>k.key===h)??null;for(;b?.movedInto;)b=b.movedInto;return b};for(let h of a()){let b=h.identity.length===1?h.identity[0]:null;if(!(b?.kind!=="class"||!o.parts.has(b.name))&&(s.delete(h.key),u&&h!==u)){h.movedInto=u;for(let k of h.states)u.parts.push({selector:h.key,path:e,line:k.line,state:k.state})}}let g=a().filter(h=>h.identity.filter(b=>b.kind!=="tag"&&b.kind!=="universal").length>=2).sort((h,b)=>h.identity.length-b.identity.length);for(let h of g){let b=f.filter(y=>y!==h&&y!==u&&y.prefix.length===0&&rk(y.identity,h.identity));if(b.length===0)continue;b.sort((y,x)=>x.identity.length-y.identity.length||c(x)-c(y)||y.line-x.line);let k=m(b[0].key);k&&k!==h&&d(h,k,"modifiers")}for(let{hostKey:h,part:b}of i){let k=m(h)??(r?u:null);k&&s.has(k.key)&&k.parts.push(b)}let S=h=>{let b=h===u,k=To(h.key,p);return{...Qt({selector:h.key,path:e,base:b},n.classKeywords),element:k,usage:{status:"unknown",files:[],fileCount:0},selector:h.key,path:e,line:h.line,base:b,states:Zi(h.states),modifiers:h.modifiers.length?h.modifiers.map(y=>{let x=y.identity.filter(v=>!h.identity.some($=>np($,v)));return{title:Qt({selector:x.map(v=>v.raw).join(""),path:e,base:!1},n.classKeywords).title,selector:y.key,path:e,line:y.line,element:To(y.key,p),usage:{status:"unknown",files:[],fileCount:0},states:Zi(y.states)}}):void 0,contexts:h.contexts.length?h.contexts.map(y=>{let x=op(y.states.flatMap(v=>v.declarations));return{selector:y.key,path:e,line:y.line,role:x,element:x==="override"?To(y.key,p):null,states:Zi(y.states)}}):void 0,parts:h.parts.length?h.parts:void 0}};return[...s.values()].map(S)}function ip(e){let t=new Map;for(let i of e){let l=i.base?/^\.([\w-]+)$/.exec(i.selector):null;l&&t.set(i.path,[...t.get(i.path)??[],l[1]])}let n=i=>{let l=ue(i.selector);if(!l)return null;let a=l[l.length-1].simples,c=t.get(i.path)??[],u=a.filter(p=>!(p.kind==="class"&&c.includes(p.name)));return{depth:l.length-1,subject:An(a),bareTag:!a.some(p=>p.kind==="class"||p.kind==="attr"||p.kind==="id"),bare:u.length&&u.length<a.length?An(u):null}},r=new Map(e.map(i=>[i,n(i)])),o=new Set,s=i=>{let l=r.get(i);if(!l||l.depth===0)return null;let a=e.filter(c=>{if(c===i||o.has(c))return!1;let u=r.get(c);return u!=null&&u.depth<l.depth&&(!l.bareTag||u.depth===0)&&(u.subject===l.subject||l.bare!==null&&u.subject===l.bare)});return a.sort((c,u)=>+(u.path===i.path)-+(c.path===i.path)||r.get(c).depth-r.get(u).depth),a[0]??null};for(let i of[...e].sort((l,a)=>(r.get(a)?.depth??0)-(r.get(l)?.depth??0))){let l=s(i);if(!l)continue;for(;o.has(l);)l=s(l)??l;let a=op(i.states.flatMap(c=>c.declarations));l.contexts=[...l.contexts??[],{selector:i.selector,path:i.path,line:i.line,role:a,element:a==="override"?i.element:null,states:i.states}],i.parts?.length&&(l.parts=[...l.parts??[],...i.parts]),i.modifiers?.length&&(l.modifiers=[...l.modifiers??[],...i.modifiers]),o.add(i)}return e.filter(i=>!o.has(i))}var ik=40,rt=(e,t)=>({path:e,line:t});function ot(e,t,n,r){return{...e,status:t.length===0?"ok":"attention",summary:t.length===0?n:r(t.length),findings:t.slice(0,ik)}}function nn(e,t){return{...e,status:"na",summary:t,findings:[]}}var Qi=e=>e.state.split(" + ");function pp(e,t){if(!e.element||!t.element||e!==t&&!Ui(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(r=>n.has(r))?Object.entries(e.element.attrs).every(([r,o])=>t.element.attrs[r]===o):!1}function dp(e,t){return t.filter(n=>pp(n,e)).flatMap(n=>n.states)}function ak(e,t,n){return dp(e,t).some(r=>Qi(r).includes(n))||t.filter(r=>pp(r,e)).some(r=>(r.parts??[]).some(o=>o.state.split(" + ").includes(n)))}var lk=[{state:"hover",severity:"issue"},{state:"focus",severity:"issue"},{state:"disabled",severity:"issue"},{state:"active",severity:"note"}];function ck(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(o=>o.element&&o.element.ancestors.length===0);if(n.length===0)return nn(t,"No styles that can be drawn on their own.");let r=[];for(let{state:o,severity:s}of lk){let i=n.filter(l=>!ak(l,e.variants,o));i.length!==0&&r.push({severity:s,message:i.length===n.length?`No style defines a ${o} state.`:`${i.length} of ${n.length} styles have no ${o} state.`,styles:i.length===n.length?void 0:i.map(l=>l.title),refs:i.slice(0,6).map(l=>rt(l.path,l.line))})}return ot(t,r,"Every style has hover, focus, disabled, and active rules.",o=>`${o} state${o===1?"":"s"} missing on some styles.`)}var ap=new Set(["outline","outline-style","outline-width"]),lp=/^(?:none|0|0px)(?:\s+(?:none|0|0px))*$/i,uk=/^(?:outline(?:-color|-width|-style)?|box-shadow|border(?:-[a-z]+)*|background(?:-color)?|text-decoration(?:-[a-z]+)?|color)$/;function pk(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(o=>o.element&&o.element.ancestors.length===0);if(n.length===0)return nn(t,"No styles that can be drawn on their own.");let r=[];for(let o of n){let s=dp(o,e.variants),i=s.filter(a=>{let c=Qi(a);return c.includes("default")||c.includes("focus")}).flatMap(a=>a.declarations.map(c=>({s:a,d:c}))).find(({d:a})=>ap.has(a.property)&&lp.test(a.value.replace(/\s*!important/i,"")));!i||s.filter(a=>Qi(a).includes("focus")).some(a=>a.declarations.some(c=>uk.test(c.property)&&!(ap.has(c.property)&&lp.test(c.value))&&!/^(?:none|0|0px)$/i.test(c.value)&&!(c.property==="box-shadow"&&/^none$/i.test(c.value))))||r.push({severity:"issue",message:`${o.title} removes the outline (${i.d.property}: ${i.d.value}) and no focus rule replaces it.`,styles:[o.title],refs:[rt(o.path,i.s.line)]})}return ot(t,r,"No style removes the outline without a focus replacement.",o=>`${o} style${o===1?"":"s"} lose the focus indicator.`)}function dk(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 nn(t,`The ${e.noun} styles read no custom properties.`);let r=e.tokens.filter(o=>o.definedIn.length===0&&!o.name.startsWith("--tw-")).map(o=>{let s=e.variants.filter(i=>i.states.some(l=>l.declarations.some(a=>a.value.includes(`var(${o.name}`)||new RegExp(`var\\(\\s*${o.name}\\b`).test(a.value))));return{severity:"note",message:`${o.name} is read but never defined here. It may be set outside the scanned files (a framework, a theme provider).`,styles:s.slice(0,8).map(i=>i.title),refs:s.slice(0,3).map(i=>rt(i.path,i.line))}});return ot(t,r,`All ${e.tokens.length} tokens read are defined.`,o=>`${o} token${o===1?"":"s"} with no definition.`)}var fk=/var\((?:[^()]|\([^()]*\))*\)/g,cp=/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?)\([^)]*\)/gi,gk=/^(?:padding|margin|gap|row-gap|column-gap|height|min-height|max-height|border-radius|font-size|letter-spacing)(?:-[a-z]+)*$/,mk=/(?<![\w.-])(\d+(?:\.\d+)?)px\b/g;function up(e){let t=e.trim().toLowerCase().replace(/\s+/g,""),n=/^#([0-9a-f]{3})$/.exec(t);return n?`#${[...n[1]].map(r=>r+r).join("")}`:t}function ea(e,t,n=0){return n>6?e:e.replace(/var\(\s*(--[\w-]+)\s*(?:,\s*([^)]*))?\)/g,(r,o,s)=>{let i=t.get(o);return i!==void 0?ea(i,t,n+1):s!==void 0?ea(s.trim(),t,n+1):r})}var hk=[[/^(?: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 yk(e,t){if(!t)return null;let n=hk.find(([r])=>r.test(e))?.[1];return t.find(r=>!n||n.test(r))??null}function bk(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,r=new Map;for(let[s,i]of e.tokenValues){let l=ea(i,e.tokenValues).trim();if(new RegExp(`^(?:${cp.source})$`,"i").test(l)){let a=up(l);n.set(a,[...n.get(a)??[],s])}else/^\d+(?:\.\d+)?px$/.test(l)&&r.set(l,[...r.get(l)??[],s])}if(n.size===0&&r.size===0)return nn(t,"No color or size tokens were found to compare against.");let o=[];for(let s of e.variants){let i=[],l=null;for(let c of s.states)for(let u of c.declarations){if(u.via)continue;let p=u.value.replace(fk," ");for(let d of p.matchAll(cp)){let f=n.get(up(d[0]));i.push(f?`${d[0]} in ${u.property} is the value of ${f[0]}`:`${d[0]} in ${u.property} is not a token`),l??=c}if(gk.test(u.property))for(let d of p.matchAll(mk)){let f=yk(u.property,r.get(`${d[1]}px`));!f||Number(d[1])<=1||(i.push(`${d[1]}px in ${u.property} is the value of ${f}`),l??=c)}}if(i.length===0||!l)continue;let a=[...new Set(i)];o.push({severity:"issue",message:`${s.title}: ${a.slice(0,4).join("; ")}${a.length>4?`; and ${a.length-4} more`:""}.`,styles:[s.title],refs:[rt(s.path,l.line)]})}return ot(t,o,`No ${e.noun} style hard-codes a value a token already has.`,s=>`${s} style${s===1?"":"s"} hard-code values.`)}function wk(e){let t={id:"unused",title:"Unused styles",description:"Styles defined in CSS that no component, page, or template references."},n=e.variants.filter(o=>o.element&&o.usage.status!=="unknown");if(n.length===0)return nn(t,"No styles with a class name to look for.");let r=[];for(let o of n)o.usage.status==="unreferenced"?r.push({severity:"issue",message:`${o.title} (${o.selector}) is defined but no reference to it was found.`,styles:[o.title],refs:[rt(o.path,o.line)]}):o.usage.status==="dynamic"&&r.push({severity:"note",message:`${o.title} (${o.selector}) is built at runtime and nothing selects it by value.`,styles:[o.title],refs:[rt(o.path,o.line),...o.usage.files.slice(0,2)]});return r.sort((o,s)=>+(s.severity==="issue")-+(o.severity==="issue")),ot(t,r,`All ${n.length} styles are referenced.`,o=>`${o} style${o===1?"":"s"} unreferenced or unconfirmed.`)}function kk(e){let t={id:"duplicates",title:"Duplicate styles",description:"Different styles whose default declarations are identical."},n=new Map;for(let o of e.variants){if(!o.element)continue;let s=o.states.filter(l=>l.state==="default"&&l.context==="").flatMap(l=>l.declarations).map(l=>`${l.property}:${l.value.replace(/\s+/g," ").trim()}`);if(s.length<2)continue;let i=[...new Set(s)].sort().join(";");n.set(i,[...n.get(i)??[],o])}let r=[...n.values()].filter(o=>o.length>1).map(o=>({severity:"issue",message:`${o.map(s=>s.title).join(", ")} declare the same default styles (${o.map(s=>s.selector).join(", ")}).`,styles:o.map(s=>s.title),refs:o.map(s=>rt(s.path,s.line))}));return ot(t,r,"No two styles share the same default declarations.",o=>`${o} group${o===1?"":"s"} of identical styles.`)}function xk(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 nn(t,`No shared ${e.element} component was found, so native elements are expected.`);let n=e.nativeUses.map(r=>({severity:"issue",message:`${r.count} native <${e.element}> element${r.count===1?"":"s"} in ${r.path}.`,refs:[rt(r.path,r.line)]}));return ot(t,n,`Every <${e.element}> goes through the component.`,r=>`${r} file${r===1?"":"s"} bypass the component.`)}function vk(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 nn(t,`No shared ${e.element} component was found.`);let n=(e.unknownProps??[]).map(r=>({severity:"issue",message:`<${r.component} ${r.prop}="${r.value}"> in ${r.path}: ${r.component} has no ${r.prop} "${r.value}" (it has ${r.known.join(", ")}).`,refs:[rt(r.path,r.line)]}));return ot(t,n,"Every literal prop value picks a look the component has.",r=>`${r} call${r===1?"":"s"} ask for a look the component does not have.`)}function Sk(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 ot(t,[],"Every style is named in written guidance.",()=>"");let r=e.variants.filter(o=>o.element&&n.undocumented.includes(o.title));return ot(t,[{severity:"note",message:`${n.undocumented.length} of ${n.documented.length+n.undocumented.length} styles are named in no guidance.`,styles:n.undocumented,refs:r.slice(0,6).map(o=>rt(o.path,o.line))}],"",o=>`${o} finding${o===1?"":"s"}.`)}function fp(e){return[ck(e),pk(e),wk(e),kk(e),dk(e),bk(e),xk(e),vk(e),Sk(e)]}var $k=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,Ck=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,Rk=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),Ak=new Set(["icon","glyph","svg"]),Ik=new Set(["label","text","title","caption"]),Ek=e=>e.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(t=>t.toLowerCase());function mp(e){let t=e.flatMap(Ek);return t.some(n=>Ak.has(n))?"icon":t.some(n=>Ik.has(n))?"label":null}function Tk(e){let t=e.replace(/\{\s*\/\*[\s\S]*?\*\/\s*\}/g," "),n=[];for(let r of t.matchAll($k)){let o=r[1];if(!Rk.has(o.toLowerCase())||o!==o.toLowerCase())continue;let s=[...r[2].matchAll(Ck)].map(l=>l[1]??l[2]),i=mp(s);i&&n.push({index:r.index??0,role:i,tag:o.toLowerCase(),classes:s})}return n}function _k(e,t,n){if(!t.some(o=>o.property.toLowerCase()==="display"&&/^none\b/i.test(o.value.trim()))||n.size===0)return null;for(let o of re(e)){let s=ue(o);if(!s||s.length<2)continue;let i=s[s.length-1];if(i.combinator!==" "&&i.combinator!==">")continue;let l=i.simples.filter(d=>d.kind==="class");if(l.length!==1||l[0].kind!=="class"||!n.has(l[0].name))continue;let a=s[s.length-2];if(a.simples.filter(d=>d.kind!=="class"&&d.kind!=="attr"&&d.kind!=="tag").length>0)continue;let u=a.simples.filter(d=>d.kind==="class"),p=a.simples.filter(d=>d.kind==="attr");if(u.length===1&&p.length===0&&u[0].kind==="class"&&!/^(?:is|has)-/.test(u[0].name))return{classes:[u[0].name],attrs:{}};if(u.length===0&&p.length===1&&p[0].kind==="attr"&&p[0].value)return{classes:[],attrs:{[p[0].name]:p[0].value}}}return null}var jk=["text","icon-start","icon-end","icon"],gp={text:"Text","icon-start":"Icon left","icon-end":"Icon right",icon:"Icon"};function Ok(e,t){let n=null,r=null;for(let i of t)i.index<e.index?n=i:r||(r=i);if(!n&&!r)return null;let o=n?e.index-n.index:1/0;return(r?r.index-e.index:1/0)<=o?"start":"end"}function On(e){return{role:e.role,tag:e.tag,classes:e.classes}}function hp(e){let t=new Map,n=(r,o)=>{let s=t.get(r)??[];s.some(i=>i.path===o.path)||s.push(o),t.set(r,s)};for(let r of e){let o=r.sources.flatMap(Tk),s=o.filter(f=>f.role==="label"),i=o.filter(f=>f.role==="icon"),l=s[0];l&&n("text",{path:r.sheet,slots:[On(l)],classes:[],attrs:{}});let a=new Set(s.flatMap(f=>f.classes.filter(m=>mp([m])==="label"))),c=null,u=null;for(let f of i){let m=Ok(f,s),g=s.reduce((S,h)=>{let b=Math.abs(h.index-f.index);return!S||b<S.dist?{hit:h,dist:b}:S},null);m==="start"&&g&&!c&&(c={icon:f,label:g.hit}),m==="end"&&g&&!u&&(u={icon:f,label:g.hit})}c&&n("icon-start",{path:r.sheet,slots:[On(c.icon),On(c.label)],classes:[],attrs:{}}),u&&n("icon-end",{path:r.sheet,slots:[On(u.label),On(u.icon)],classes:[],attrs:{}});let p=null;for(let f of r.rules)if(p=_k(f.selector,f.declarations,a),p)break;let d=c?.icon??u?.icon??i[0]??null;p&&d&&n("icon",{path:r.sheet,slots:[On(d)],classes:p.classes,attrs:p.attrs})}return[{id:"text",label:gp.text,sheets:t.get("text")??[]},...jk.filter(r=>r!=="text"&&t.has(r)).map(r=>({id:r,label:gp[r],sheets:t.get(r)??[]}))]}var Mk=25,Dk=12,yp=700,Pk=/\b(?:must(?: not)?|never|always|should(?: not|n't)?|do not|don't|avoid|prefer|forbidden|not allowed|no more than)\b/i,bt=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Lk(e){let t=e.split(`
|
|
22
22
|
`),n=[],r=[],o=null,s=null,i=0;if(t[0]?.trim()==="---"){let a=t.findIndex((c,u)=>u>0&&c.trim()==="---");a>0&&(i=a+1)}let l=a=>{o&&(n.push({start:o.start,end:a,text:o.lines.join(`
|
|
23
|
-
`).trimEnd(),headings:o.headings}),o=null)};for(;i<t.length;i++){let a=t[i],c=i+1,u=/^\s*(```|~~~)/.exec(a)?.[1];if(s){o.lines.push(a),u===s&&(s=null,l(c));continue}if(u){l(c-1),s=u,o={start:c,lines:[a],headings:[...r]};continue}let p=/^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(a);if(p){l(c-1),r=[...r.slice(0,p[1].length-1),p[2]];continue}if(a.trim()===""){l(c-1);continue}o??={start:c,lines:[],headings:[...r]},o.lines.push(a)}return l(t.length),n}function Nk(e,t){let n=e.map(bt).join("|"),r=e.map(o=>bt(o.charAt(0).toUpperCase()+o.slice(1))).join("|");return new RegExp(`${t.source}|\\b(?:${n})s?\\b|[a-z](?:${r})s?\\b|\\b(?:${n})[-_]|[-_](?:${n})\\b`,"i")}function Fk(e,t){let n=t.map(bt).join("|"),r=new Map;for(let o of e){if(o.base||o.title==="Unnamed"||o.title.startsWith("In ")||!o.element)continue;let i=r.get(o.title)??{title:o.title,tests:[],heading:null},l=o.selector.slice(Yt(o.selector));for(let a of l.matchAll(/\.((?:\\.|[\w-])+)/g)){let c=a[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-])${bt(c)}(?![\\w-])`:`(?:\\.|["'\`])${bt(c)}(?![\\w-])`))}if(!o.title.includes(" + ")){let a=o.title.toLowerCase().split(/\s+/).map(bt).join("[\\s_-]+");i.tests.push(new RegExp(`\\b${a}[\\s_-]+(?:${n})s?\\b|\\b(?:${n})s?[_-]+${a}\\b`,"i")),o.axis&&/^[a-z]+$/i.test(o.title)&&i.tests.push(new RegExp(`\\b${bt(o.axis)}\\s*[=:]\\s*\\{?\\s*["'\`]${bt(o.title.toLowerCase())}["'\`]`,"i")),i.heading=o.title.toLowerCase()}r.set(o.title,i)}return[...r.values()]}function Uk(e,t){return e.toLowerCase().replace(new RegExp(`\\b(?:${t.map(bt).join("|")})s?\\b`,"g")," ").replace(/[^a-z0-9]+/g," ").trim()}function zk(e){return e.length>yp?`${e.slice(0,yp).trimEnd()}\u2026`:e}function No(e,t,n,r){let o=Nk(n.classKeywords,n.prose),s=Fk(r,n.classKeywords),i=new Set,l=[];for(let u of t){let p=e.get(u.path);if(p===void 0)continue;let d=[];for(let f of Lk(p)){if(!o.test(f.text)&&!f.headings.some(S=>o.test(S)))continue;let m=f.headings.length?Uk(f.headings[f.headings.length-1],n.classKeywords):"",g=s.filter(S=>S.tests.some(h=>h.test(f.text))||m!==""&&S.heading===m).map(S=>S.title);for(let S of g)i.add(S);d.push({path:u.path,line:f.start,endLine:f.end,headings:f.headings,text:zk(f.text),rule:Pk.test(f.text),styles:g})}d.length!==0&&l.push({path:u.path,kind:u.kind,passages:d.slice(0,Dk),total:d.length,rules:d.filter(f=>f.rule).length})}let a={instruction:0,documentation:1,record:2};l.sort((u,p)=>a[u.kind]-a[p.kind]||p.rules-u.rules||p.total-u.total||u.path.localeCompare(p.path));let c=new Map;for(let u of r)u.element&&!u.base&&u.title!=="Unnamed"&&!u.title.startsWith("In ")&&c.set(u.title,!0);return{files:l.slice(0,Mk).map(({rules:u,...p})=>p),documented:[...i].sort(),undocumented:[...c.keys()].filter(u=>!i.has(u))}}var G=(e,t)=>({property:e,value:t});function sa(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 oa(e){let t=sa(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 r=Math.round(n*2);if(Math.abs(n*2-r)>1e-6)return null;if(r===0)return"0";let o=Math.floor(r/8),s=["",".125",".25",".375",".5",".625",".75",".875"][r%8];return o===0?`0${s}rem`:`${o}${s}rem`}function Gk(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 bp(e,t){return{full:"100%",screen:t==="w"?"100vw":"100vh",auto:"auto",fit:"fit-content",min:"min-content",max:"max-content"}[e]??Gk(e)??sa(e)??oa(e)}var Bk={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"}},Wk={thin:"100",extralight:"200",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"},Hk={none:"1",tight:"1.25",snug:"1.375",normal:"1.5",relaxed:"1.625",loose:"2"},Vk=new Set,qk=new Set(["sm","md","lg","xl","2xl","3xl"]),Jk={none:"0",sm:"0.125rem","":"0.25rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem","3xl":"1.5rem",full:"9999px"},Kk={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"},Xk={"":"3px",0:"0px",1:"1px",2:"2px",4:"4px",8:"8px"},Zk={bg:"background-color",text:"text-color",border:"border-color",outline:"outline-color",ring:"ring-color"};function ta(e,t,n=Vk,r){let o=null;if(e.startsWith("[")&&e.endsWith("]")){let i=e.slice(1,-1).replace(/_/g," ").trim().replace(/^color:\s*/,"");if(i.startsWith("--"))o=`var(${i})`;else if(/^var\(\s*--[\w-]+\s*\)$/.test(i))o=i.replace(/\s+/g,"");else if(/^#[0-9a-f]{3,8}$/i.test(i)||/^(?:rgb|hsl|oklch|oklab|color|color-mix)\(/i.test(i))o=i;else return null}else if(e==="white")o="#fff";else if(e==="black")o="#000";else if(e==="transparent")o="transparent";else if(e==="current")o="currentColor";else if(e==="inherit")o="inherit";else{let i=r?Zk[r]:void 0;o=(i&&n.has(`--${i}-${e}`)?`var(--${i}-${e})`:null)??zc(e)??(/^[a-z][\w-]*$/i.test(e)?`var(--${e}, var(--color-${e}))`:null)}if(!o)return null;if(!t)return o;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?o:`color-mix(in srgb, ${o} ${s}%, transparent)`}function Yk(e){let t=0,n=-1;for(let r=0;r<e.length;r++){let o=e[r];o==="["?t++:o==="]"?t=Math.max(0,t-1):o==="/"&&t===0&&(n=r)}return n<0?{body:e,opacity:null}:{body:e.slice(0,n),opacity:e.slice(n+1)}}function na(){return G("box-shadow","var(--gs-ring-inset, ) 0 0 0 var(--gs-ring-w, 3px) var(--gs-ring-c, currentColor)")}var Qk={flex:"flex","inline-flex":"inline-flex",block:"block","inline-block":"inline-block",inline:"inline",grid:"grid","inline-grid":"inline-grid",hidden:"none",contents:"contents"},ra={start:"flex-start",end:"flex-end",center:"center",baseline:"baseline",stretch:"stretch",between:"space-between",around:"space-around",evenly:"space-evenly"};function yr(e,t){let n=e.startsWith("-"),r=n?e.slice(1):e,{body:o,opacity:s}=Yk(r),i=Qk[o];if(i&&!n&&!s)return[G("display",i)];let l=/^flex-(row|col|row-reverse|col-reverse)$/.exec(o);if(l&&!n&&!s){let w=l[1]==="col"?"column":l[1]==="col-reverse"?"column-reverse":l[1];return[G("flex-direction",w)]}if(o==="flex-wrap"&&!n)return[G("flex-wrap","wrap")];if(o==="flex-nowrap"&&!n)return[G("flex-wrap","nowrap")];if(o==="flex-1"&&!n)return[G("flex","1 1 0%")];if(o==="shrink-0"&&!n)return[G("flex-shrink","0")];if(o==="grow-0"&&!n)return[G("flex-grow","0")];if(o==="grow"&&!n)return[G("flex-grow","1")];let a=/^items-(start|end|center|baseline|stretch)$/.exec(o);if(a&&!n)return[G("align-items",ra[a[1]])];let c=/^justify-(start|end|center|between|around|evenly)$/.exec(o);if(c&&!n)return[G("justify-content",ra[c[1]])];let u=/^self-(start|end|center|stretch|auto)$/.exec(o);if(u&&!n)return[G("align-self",u[1]==="auto"?"auto":ra[u[1]])];if(o==="whitespace-nowrap")return[G("white-space","nowrap")];if(o==="whitespace-normal")return[G("white-space","normal")];if(o==="truncate")return[G("overflow","hidden"),G("text-overflow","ellipsis"),G("white-space","nowrap")];if(o==="underline")return[G("text-decoration-line","underline")];if(o==="no-underline")return[G("text-decoration-line","none")];if(o==="line-through")return[G("text-decoration-line","line-through")];let p=/^(uppercase|lowercase|capitalize|normal-case)$/.exec(o);if(p)return[G("text-transform",p[1]==="normal-case"?"none":p[1])];let d=/^text-(left|center|right|justify|start|end)$/.exec(o);if(d&&!s)return[G("text-align",d[1])];let f=Bk[o.replace(/^text-/,"")];if(o.startsWith("text-")&&f&&!s&&!n)return[G("font-size",f.size),G("line-height",f.leading)];let m=Wk[o.replace(/^font-/,"")];if(o.startsWith("font-")&&m&&!s)return[G("font-weight",m)];if(o.startsWith("leading-")&&!s){let w=o.slice(8),E=Hk[w]??oa(w);if(E)return[G("line-height",E)]}let g=/^cursor-(pointer|default|not-allowed|wait|text|move)$/.exec(o);if(g)return[G("cursor",g[1])];if(o==="pointer-events-none")return[G("pointer-events","none")];if(o==="pointer-events-auto")return[G("pointer-events","auto")];if(o==="select-none")return[G("user-select","none")];let S=/^opacity-(\d+)$/.exec(o);if(S&&!n)return[G("opacity",String(Number(S[1])/100))];if(o==="transition"||o==="transition-colors"||o==="transition-all")return[G("transition-property",o==="transition-colors"?"color, background-color, border-color, text-decoration-color, fill, stroke":o==="transition-all"?"all":"color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter"),G("transition-timing-function","cubic-bezier(0.4, 0, 0.2, 1)"),G("transition-duration","150ms")];let h=/^duration-(\d+)$/.exec(o);if(h)return[G("transition-duration",`${h[1]}ms`)];let b={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(o.startsWith("ease-")&&b[o.slice(4)])return[G("transition-timing-function",b[o.slice(4)])];if(o==="outline-none")return[G("outline","2px solid transparent"),G("outline-offset","2px")];if(o==="outline")return[G("outline-style","solid")];let k=/^outline-(\d+)$/.exec(o);if(k)return[G("outline-width",`${k[1]}px`)];let y=/^outline-offset-(\d+)$/.exec(o);if(y)return[G("outline-offset",`${y[1]}px`)];let x=/^outline-(dashed|dotted|double)$/.exec(o);if(x)return[G("outline-style",x[1])];if(o==="shadow"||o.startsWith("shadow-")){let w=o==="shadow"?"":o.slice(7);if(w&&t.has(`--shadow-${w}`))return[G("box-shadow",`var(--shadow-${w})`)];let A=Kk[w];if(A)return[G("box-shadow",A)]}if(o==="ring-inset")return[G("--gs-ring-inset","inset")];if(o==="ring"||/^ring(?:-(?:0|1|2|4|8))?$/.test(o)){let w=o==="ring"?"":o.slice(5),A=Xk[w];if(A)return[G("--gs-ring-w",A),na()]}if(o.startsWith("ring-")&&s===null){let w=ta(o.slice(5),null,t,"ring");if(w)return[G("--gs-ring-c",w),na()]}if(o.startsWith("ring-")&&s){let w=ta(o.slice(5),s,t,"ring");if(w)return[G("--gs-ring-c",w),na()]}let v=o==="rounded"?"":o.startsWith("rounded-")?o.slice(8):null;if(v!==null&&!n){let w=/^(t|r|b|l|s|e|tl|tr|bl|br|ss|se)(?:-(.+))?$/.exec(v),A=w?w[2]??"":v,E=Jk[A];if(!E)return null;let N=qk.has(A)&&t.has(`--radius-${A}`)?`var(--radius-${A}, ${E})`:E;if(!w)return[G("border-radius",N)];let _={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"]}[w[1]];return _?_.map(P=>G(P,N)):null}if(/^border(?:-[trblxy])?$/.test(o)&&!s)return[G("border-width","1px"),G("border-style","solid")];let $=/^border-(\d+)$/.exec(o);if($&&!s)return[G("border-width",`${$[1]}px`),G("border-style","solid")];let R=/^border-(solid|dashed|dotted|double|none|hidden)$/.exec(o);if(R)return[G("border-style",R[1])];let I=/^(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(o),O=I?.[1],L=I?.[2];if(O&&L&&!s){let w=O==="w"||O==="min-w"||O==="max-w"?bp(L,"w"):O==="h"||O==="min-h"||O==="max-h"?bp(L,"h"):oa(L);if(!w)return null;let A=n?w==="0"?"0":`-${w}`:w,N={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"]}[O];return N?N.map(F=>G(F,A)):null}let D={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[w,A]of Object.entries(D))if(o===w||o.startsWith(`${w}-`)){let E=o===w?"":o.slice(w.length+1);if(!E||/^(?:gradient|clip|ellipsis|wrap|nowrap|balance|pretty|opacity)/.test(E))return null;if(w==="text"&&!n){let F=sa(E);if(F)return[G("font-size",F)]}let N=ta(E,s,t,w);return!N||n?null:[G(A,N)]}let z=/^\[([a-z-]+):(.+)\]$/i.exec(o);if(z&&!n&&!s){let w=z[1].toLowerCase(),A=z[2].replace(/_/g," ").trim();if(/^[a-z][\w-]*$/.test(w)&&A&&!/[<>]/.test(A))return[G(w,A)]}return null}var ex=48,tx={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",disabled:"disabled"},nx=new Set(["cn","clsx","classNames","classnames","cx","twMerge"]);function st(e,t){let n=1;for(let r=0;r<t&&r<e.length;r++)e[r]===`
|
|
23
|
+
`).trimEnd(),headings:o.headings}),o=null)};for(;i<t.length;i++){let a=t[i],c=i+1,u=/^\s*(```|~~~)/.exec(a)?.[1];if(s){o.lines.push(a),u===s&&(s=null,l(c));continue}if(u){l(c-1),s=u,o={start:c,lines:[a],headings:[...r]};continue}let p=/^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(a);if(p){l(c-1),r=[...r.slice(0,p[1].length-1),p[2]];continue}if(a.trim()===""){l(c-1);continue}o??={start:c,lines:[],headings:[...r]},o.lines.push(a)}return l(t.length),n}function Nk(e,t){let n=e.map(bt).join("|"),r=e.map(o=>bt(o.charAt(0).toUpperCase()+o.slice(1))).join("|");return new RegExp(`${t.source}|\\b(?:${n})s?\\b|[a-z](?:${r})s?\\b|\\b(?:${n})[-_]|[-_](?:${n})\\b`,"i")}function Fk(e,t){let n=t.map(bt).join("|"),r=new Map;for(let o of e){if(o.base||o.title==="Unnamed"||o.title.startsWith("In ")||!o.element)continue;let i=r.get(o.title)??{title:o.title,tests:[],heading:null},l=o.selector.slice(Yt(o.selector));for(let a of l.matchAll(/\.((?:\\.|[\w-])+)/g)){let c=a[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-])${bt(c)}(?![\\w-])`:`(?:\\.|["'\`])${bt(c)}(?![\\w-])`))}if(!o.title.includes(" + ")){let a=o.title.toLowerCase().split(/\s+/).map(bt).join("[\\s_-]+");i.tests.push(new RegExp(`\\b${a}[\\s_-]+(?:${n})s?\\b|\\b(?:${n})s?[_-]+${a}\\b`,"i")),o.axis&&/^[a-z]+$/i.test(o.title)&&i.tests.push(new RegExp(`\\b${bt(o.axis)}\\s*[=:]\\s*\\{?\\s*["'\`]${bt(o.title.toLowerCase())}["'\`]`,"i")),i.heading=o.title.toLowerCase()}r.set(o.title,i)}return[...r.values()]}function Uk(e,t){return e.toLowerCase().replace(new RegExp(`\\b(?:${t.map(bt).join("|")})s?\\b`,"g")," ").replace(/[^a-z0-9]+/g," ").trim()}function zk(e){return e.length>yp?`${e.slice(0,yp).trimEnd()}\u2026`:e}function No(e,t,n,r){let o=Nk(n.classKeywords,n.prose),s=Fk(r,n.classKeywords),i=new Set,l=[];for(let u of t){let p=e.get(u.path);if(p===void 0)continue;let d=[];for(let f of Lk(p)){if(!o.test(f.text)&&!f.headings.some(S=>o.test(S)))continue;let m=f.headings.length?Uk(f.headings[f.headings.length-1],n.classKeywords):"",g=s.filter(S=>S.tests.some(h=>h.test(f.text))||m!==""&&S.heading===m).map(S=>S.title);for(let S of g)i.add(S);d.push({path:u.path,line:f.start,endLine:f.end,headings:f.headings,text:zk(f.text),rule:Pk.test(f.text),styles:g})}d.length!==0&&l.push({path:u.path,kind:u.kind,passages:d.slice(0,Dk),total:d.length,rules:d.filter(f=>f.rule).length})}let a={instruction:0,documentation:1,record:2};l.sort((u,p)=>a[u.kind]-a[p.kind]||p.rules-u.rules||p.total-u.total||u.path.localeCompare(p.path));let c=new Map;for(let u of r)u.element&&!u.base&&u.title!=="Unnamed"&&!u.title.startsWith("In ")&&c.set(u.title,!0);return{files:l.slice(0,Mk).map(({rules:u,...p})=>p),documented:[...i].sort(),undocumented:[...c.keys()].filter(u=>!i.has(u))}}var G=(e,t)=>({property:e,value:t});function sa(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 oa(e){let t=sa(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 r=Math.round(n*2);if(Math.abs(n*2-r)>1e-6)return null;if(r===0)return"0";let o=Math.floor(r/8),s=["",".125",".25",".375",".5",".625",".75",".875"][r%8];return o===0?`0${s}rem`:`${o}${s}rem`}function Gk(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 bp(e,t){return{full:"100%",screen:t==="w"?"100vw":"100vh",auto:"auto",fit:"fit-content",min:"min-content",max:"max-content"}[e]??Gk(e)??sa(e)??oa(e)}var Bk={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"}},Wk={thin:"100",extralight:"200",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"},Hk={none:"1",tight:"1.25",snug:"1.375",normal:"1.5",relaxed:"1.625",loose:"2"},Vk=new Set,qk=new Set(["sm","md","lg","xl","2xl","3xl"]),Jk={none:"0",sm:"0.125rem","":"0.25rem",md:"0.375rem",lg:"0.5rem",xl:"0.75rem","2xl":"1rem","3xl":"1.5rem",full:"9999px"},Kk={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"},Xk={"":"3px",0:"0px",1:"1px",2:"2px",4:"4px",8:"8px"},Zk={bg:"background-color",text:"text-color",border:"border-color",outline:"outline-color",ring:"ring-color"};function ta(e,t,n=Vk,r){let o=null;if(e.startsWith("[")&&e.endsWith("]")){let i=e.slice(1,-1).replace(/_/g," ").trim().replace(/^color:\s*/,"");if(i.startsWith("--"))o=`var(${i})`;else if(/^var\(\s*--[\w-]+\s*\)$/.test(i))o=i.replace(/\s+/g,"");else if(/^#[0-9a-f]{3,8}$/i.test(i)||/^(?:rgb|hsl|oklch|oklab|color|color-mix)\(/i.test(i))o=i;else return null}else if(e==="white")o="#fff";else if(e==="black")o="#000";else if(e==="transparent")o="transparent";else if(e==="current")o="currentColor";else if(e==="inherit")o="inherit";else{let i=r?Zk[r]:void 0;o=(i&&n.has(`--${i}-${e}`)?`var(--${i}-${e})`:null)??zc(e)??(/^[a-z][\w-]*$/i.test(e)?`var(--${e}, var(--color-${e}))`:null)}if(!o)return null;if(!t)return o;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?o:`color-mix(in srgb, ${o} ${s}%, transparent)`}function Yk(e){let t=0,n=-1;for(let r=0;r<e.length;r++){let o=e[r];o==="["?t++:o==="]"?t=Math.max(0,t-1):o==="/"&&t===0&&(n=r)}return n<0?{body:e,opacity:null}:{body:e.slice(0,n),opacity:e.slice(n+1)}}function na(){return G("box-shadow","var(--gs-ring-inset, ) 0 0 0 var(--gs-ring-w, 3px) var(--gs-ring-c, currentColor)")}var Qk={flex:"flex","inline-flex":"inline-flex",block:"block","inline-block":"inline-block",inline:"inline",grid:"grid","inline-grid":"inline-grid",hidden:"none",contents:"contents"},ra={start:"flex-start",end:"flex-end",center:"center",baseline:"baseline",stretch:"stretch",between:"space-between",around:"space-around",evenly:"space-evenly"};function yr(e,t){let n=e.startsWith("-"),r=n?e.slice(1):e,{body:o,opacity:s}=Yk(r),i=Qk[o];if(i&&!n&&!s)return[G("display",i)];let l=/^flex-(row|col|row-reverse|col-reverse)$/.exec(o);if(l&&!n&&!s){let w=l[1]==="col"?"column":l[1]==="col-reverse"?"column-reverse":l[1];return[G("flex-direction",w)]}if(o==="flex-wrap"&&!n)return[G("flex-wrap","wrap")];if(o==="flex-nowrap"&&!n)return[G("flex-wrap","nowrap")];if(o==="flex-1"&&!n)return[G("flex","1 1 0%")];if(o==="shrink-0"&&!n)return[G("flex-shrink","0")];if(o==="grow-0"&&!n)return[G("flex-grow","0")];if(o==="grow"&&!n)return[G("flex-grow","1")];let a=/^items-(start|end|center|baseline|stretch)$/.exec(o);if(a&&!n)return[G("align-items",ra[a[1]])];let c=/^justify-(start|end|center|between|around|evenly)$/.exec(o);if(c&&!n)return[G("justify-content",ra[c[1]])];let u=/^self-(start|end|center|stretch|auto)$/.exec(o);if(u&&!n)return[G("align-self",u[1]==="auto"?"auto":ra[u[1]])];if(o==="whitespace-nowrap")return[G("white-space","nowrap")];if(o==="whitespace-normal")return[G("white-space","normal")];if(o==="truncate")return[G("overflow","hidden"),G("text-overflow","ellipsis"),G("white-space","nowrap")];if(o==="underline")return[G("text-decoration-line","underline")];if(o==="no-underline")return[G("text-decoration-line","none")];if(o==="line-through")return[G("text-decoration-line","line-through")];let p=/^(uppercase|lowercase|capitalize|normal-case)$/.exec(o);if(p)return[G("text-transform",p[1]==="normal-case"?"none":p[1])];let d=/^text-(left|center|right|justify|start|end)$/.exec(o);if(d&&!s)return[G("text-align",d[1])];let f=Bk[o.replace(/^text-/,"")];if(o.startsWith("text-")&&f&&!s&&!n)return[G("font-size",f.size),G("line-height",f.leading)];let m=Wk[o.replace(/^font-/,"")];if(o.startsWith("font-")&&m&&!s)return[G("font-weight",m)];if(o.startsWith("leading-")&&!s){let w=o.slice(8),I=Hk[w]??oa(w);if(I)return[G("line-height",I)]}let g=/^cursor-(pointer|default|not-allowed|wait|text|move)$/.exec(o);if(g)return[G("cursor",g[1])];if(o==="pointer-events-none")return[G("pointer-events","none")];if(o==="pointer-events-auto")return[G("pointer-events","auto")];if(o==="select-none")return[G("user-select","none")];let S=/^opacity-(\d+)$/.exec(o);if(S&&!n)return[G("opacity",String(Number(S[1])/100))];if(o==="transition"||o==="transition-colors"||o==="transition-all")return[G("transition-property",o==="transition-colors"?"color, background-color, border-color, text-decoration-color, fill, stroke":o==="transition-all"?"all":"color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter"),G("transition-timing-function","cubic-bezier(0.4, 0, 0.2, 1)"),G("transition-duration","150ms")];let h=/^duration-(\d+)$/.exec(o);if(h)return[G("transition-duration",`${h[1]}ms`)];let b={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(o.startsWith("ease-")&&b[o.slice(4)])return[G("transition-timing-function",b[o.slice(4)])];if(o==="outline-none")return[G("outline","2px solid transparent"),G("outline-offset","2px")];if(o==="outline")return[G("outline-style","solid")];let k=/^outline-(\d+)$/.exec(o);if(k)return[G("outline-width",`${k[1]}px`)];let y=/^outline-offset-(\d+)$/.exec(o);if(y)return[G("outline-offset",`${y[1]}px`)];let x=/^outline-(dashed|dotted|double)$/.exec(o);if(x)return[G("outline-style",x[1])];if(o==="shadow"||o.startsWith("shadow-")){let w=o==="shadow"?"":o.slice(7);if(w&&t.has(`--shadow-${w}`))return[G("box-shadow",`var(--shadow-${w})`)];let R=Kk[w];if(R)return[G("box-shadow",R)]}if(o==="ring-inset")return[G("--gs-ring-inset","inset")];if(o==="ring"||/^ring(?:-(?:0|1|2|4|8))?$/.test(o)){let w=o==="ring"?"":o.slice(5),R=Xk[w];if(R)return[G("--gs-ring-w",R),na()]}if(o.startsWith("ring-")&&s===null){let w=ta(o.slice(5),null,t,"ring");if(w)return[G("--gs-ring-c",w),na()]}if(o.startsWith("ring-")&&s){let w=ta(o.slice(5),s,t,"ring");if(w)return[G("--gs-ring-c",w),na()]}let v=o==="rounded"?"":o.startsWith("rounded-")?o.slice(8):null;if(v!==null&&!n){let w=/^(t|r|b|l|s|e|tl|tr|bl|br|ss|se)(?:-(.+))?$/.exec(v),R=w?w[2]??"":v,I=Jk[R];if(!I)return null;let N=qk.has(R)&&t.has(`--radius-${R}`)?`var(--radius-${R}, ${I})`:I;if(!w)return[G("border-radius",N)];let _={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"]}[w[1]];return _?_.map(P=>G(P,N)):null}if(/^border(?:-[trblxy])?$/.test(o)&&!s)return[G("border-width","1px"),G("border-style","solid")];let $=/^border-(\d+)$/.exec(o);if($&&!s)return[G("border-width",`${$[1]}px`),G("border-style","solid")];let A=/^border-(solid|dashed|dotted|double|none|hidden)$/.exec(o);if(A)return[G("border-style",A[1])];let E=/^(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(o),O=E?.[1],L=E?.[2];if(O&&L&&!s){let w=O==="w"||O==="min-w"||O==="max-w"?bp(L,"w"):O==="h"||O==="min-h"||O==="max-h"?bp(L,"h"):oa(L);if(!w)return null;let R=n?w==="0"?"0":`-${w}`:w,N={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"]}[O];return N?N.map(F=>G(F,R)):null}let D={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[w,R]of Object.entries(D))if(o===w||o.startsWith(`${w}-`)){let I=o===w?"":o.slice(w.length+1);if(!I||/^(?:gradient|clip|ellipsis|wrap|nowrap|balance|pretty|opacity)/.test(I))return null;if(w==="text"&&!n){let F=sa(I);if(F)return[G("font-size",F)]}let N=ta(I,s,t,w);return!N||n?null:[G(R,N)]}let z=/^\[([a-z-]+):(.+)\]$/i.exec(o);if(z&&!n&&!s){let w=z[1].toLowerCase(),R=z[2].replace(/_/g," ").trim();if(/^[a-z][\w-]*$/.test(w)&&R&&!/[<>]/.test(R))return[G(w,R)]}return null}var ex=48,tx={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",disabled:"disabled"},nx=new Set(["cn","clsx","classNames","classnames","cx","twMerge"]);function st(e,t){let n=1;for(let r=0;r<t&&r<e.length;r++)e[r]===`
|
|
24
24
|
`&&n++;return n}function rx(e){let t=n=>n.replace(/[^\n]/g," ");return e.replace(/\/\*[\s\S]*?\*\//g,t).replace(/(^|\s)\/\/[^\n]*/g,(n,r)=>r+t(n.slice(r.length)))}function $e(e,t){for(;t<e.length&&/\s/.test(e[t]);)t++;return t}function Uo(e,t){let n=e[t];if(n!=='"'&&n!=="'"&&n!=="`")return null;let r="",o=!1;for(let s=t+1;s<e.length;s++){let i=e[s];if(i==="\\"){let l=e[s+1];if(l===void 0)return null;r+=l==="n"?`
|
|
25
25
|
`:l,s++;continue}if(n==="`"&&i==="$"&&e[s+1]==="{"){o=!0;let l=1;for(s+=2;s<e.length&&l>0;s++)e[s]==="{"?l++:e[s]==="}"&&l--;s--;continue}if(i===n)return{v:o?null:r,end:s+1};r+=i}return null}function zo(e,t,n,r){let o=0;for(let s=t;s<e.length;s++){let i=e[s];if(i==='"'||i==="'"||i==="`"){let l=Uo(e,s);if(!l)return e.length;s=l.end-1;continue}if(i===n)o++;else if(i===r&&(o--,o===0))return s+1}return e.length}function ox(e,t){let n=$e(e,t),r=/^\.join\s*\(/.exec(e.slice(n,n+12));return r?zo(e,n+r[0].length-1,"(",")"):t}function sx(e,t){let n=0;for(let r=t;r<e.length;r++){let o=e[r];if(o==='"'||o==="'"||o==="`"){let s=Uo(e,r);if(!s)return e.length;r=s.end-1;continue}if(o==="("||o==="["||o==="{")n++;else if(o===")"||o==="]"||o==="}"){if(n===0)return r;n--}else if(o===","&&n===0)return r}return e.length}function kp(e){if(e.t==="str")return e.v;if(e.t==="arr"){let t=[];for(let n of e.items){let r=kp(n);r&&t.push(r)}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 ix(e,t){let n=t+1,r=[];for(;n<e.length;){if(n=$e(e,n),e[n]===")")return{v:r.join(" ").replace(/\s+/g," ").trim()||null,end:n+1};if(e[n]===","){n++;continue}let o=Ee(e,n);if(!o)return null;let s=$e(e,o.end);if(e[s]===","||e[s]===")"){let i=kp(o.val);i&&r.push(i),n=o.end;continue}n=sx(e,n)}return null}function Ee(e,t){if(t=$e(e,t),t>=e.length)return null;let n=e[t];if(n==='"'||n==="'"||n==="`"){let o=Uo(e,t);return o?{val:{t:"str",v:o.v,at:t},end:o.end}:null}if(n==="["){let o=t+1,s=[];for(;o<e.length;){if(o=$e(e,o),e[o]==="]")return{val:{t:"arr",items:s,at:t},end:ox(e,o+1)};if(e[o]===","){o++;continue}let i=Ee(e,o);if(!i)return null;s.push(i.val),o=i.end}return null}if(n==="{"){let o=t+1,s=[];for(;o<e.length;){if(o=$e(e,o),e[o]==="}")return{val:{t:"obj",entries:s,at:t},end:o+1};if(e[o]===","){o++;continue}if(e.slice(o,o+3)==="..."){let c=Ee(e,o+3);if(!c)return null;o=c.end;continue}let i="",l=o;if(e[o]==='"'||e[o]==="'"||e[o]==="`"){let c=Uo(e,o);if(!c||c.v===null)return null;i=c.v,o=c.end}else if(/[\w$]/.test(e[o])){for(l=o;o<e.length&&/[\w$]/.test(e[o]);)o++;i=e.slice(l,o)}else return null;if(o=$e(e,o),e[o]!==":"){e[o]==="("&&(o=zo(e,o,"(",")"));continue}let a=Ee(e,o+1);if(!a)return null;s.push({key:i,at:l,value:a.val}),o=a.end}return null}let r=t;if(n==="."||n==="-"||/\d/.test(n)){let o=t+1;for(;o<e.length&&/[\d.]/.test(e[o]);)o++;let s=e.slice(t,o);if(/^-?\d+(?:\.\d+)?$/.test(s))return{val:{t:"num",v:Number(s),at:r},end:o};for(;o<e.length&&/[\w$.+-]/.test(e[o]);)o++;return{val:{t:"other",at:r},end:o}}if(/[\w$]/.test(n)){let o=t;for(;o<e.length&&/[\w$]/.test(e[o]);)o++;let s=e.slice(t,o),i=$e(e,o);if(e[i]==="("){if(nx.has(s)){let l=ix(e,i);return l?{val:{t:"str",v:l.v,at:r},end:l.end}:null}return{val:{t:"other",at:r},end:zo(e,i,"(",")")}}return s==="true"||s==="false"?{val:{t:"bool",v:s==="true",at:r},end:o}:{val:{t:"other",at:r},end:i}}return null}function jt(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 Te(e){let t=[],n="",r=0;for(let o of e)o==="["?r++:o==="]"&&(r=Math.max(0,r-1)),/\s/.test(o)&&r===0?(n&&t.push(n),n=""):(!/\s/.test(o)||r>0)&&(n+=o);return n&&t.push(n),t}var ia={sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"};function ax(e,t,n,r){let o=tx[e];if(o)return t.includes(o)||t.push(o),!0;if(e==="dark")return r.on=!0,!0;if(ia[e])return n.min.push(ia[e]),!0;let s=/^max-(sm|md|lg|xl|2xl)$/.exec(e);if(s)return n.below.push(ia[s[1]]),!0;let i=/^min-\[([\d.]+(?:px|rem|em))\]$/.exec(e);if(i)return n.min.push(i[1]),!0;let l=/^max-\[([\d.]+(?:px|rem|em))\]$/.exec(e);return l?(n.max.push(l[1]),!0):!1}function lx(e,t){let n=[];for(let r of e.min)n.push(`(min-width: ${r})`);for(let r of e.max)n.push(`(max-width: ${r})`);for(let r of e.below)n.push(`not all and (min-width: ${r})`);return t&&n.push("(prefers-color-scheme: dark)"),n.length?`@media ${n.join(" and ")}`:""}function ca(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 r=[],o="",s=0;for(let p of t)p==="["?s++:p==="]"&&(s=Math.max(0,s-1)),p===":"&&s===0?(r.push(o),o=""):o+=p;r.push(o);let i=r.pop()??"";if(!i)return null;let l=[],a={min:[],max:[],below:[]},c={on:!1};for(let p of r)if(!p||!ax(p,l,a,c))return null;l.sort((p,d)=>Me(p)-Me(d));let u=/^[\w-]+$/.test(i)?i:null;return{token:e,state:nt(l),context:lx(a,c.on),utility:i,important:n,stem:u}}function ua(e,t){let n=yr(e.utility,t);return n?n.map(r=>({property:r.property,value:e.important?`${r.value} !important`:r.value,via:e.token})):[]}function cx(e){return e.some(t=>ur(t.property)!=="hint")}function Go(e,t){let n=[];for(let r of e.matchAll(/@apply\s+([^;{}]+)/g))for(let o of Te(r[1])){let s=ca(o);if(!s)continue;let i=ua(s,t).filter(l=>ae(l.property,l.value));i.length!==0&&n.push({state:s.state,context:s.context,declarations:i})}return n}function xp(e){return e==="default"?"":e.split(" + ").map(t=>t==="hover"?":hover":t==="focus"?":focus":t==="active"?":active":t==="disabled"?":disabled":"").join("")}function pa(e,t,n){let r=t.map(p=>`${p.property}:${p.value}`).join(";");if(!r)return[];let o=yi(e),s=`${o}{${r}}`,i=n.split(" \xB7 ").map(p=>p.trim()).filter(p=>p&&!/^@layer\b/i.test(p));if(i.length===0)return[s];if(i.length!==1||!i[0].startsWith("@media"))return[];let l=i[0],a=[`${l}{${s}}`];if(!l.includes("prefers-color-scheme: dark"))return a;let c=l.replace(/^@media\s+/,"").split(/\s+and\s+/).filter(p=>!p.includes("prefers-color-scheme")).join(" and "),u=`html[data-theme="dark"] ${o}{${r}}`;return a.push(c?`@media ${c}{${u}}`:u),a}function wp(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 ux(e){if(e.t!=="obj")return{};let t=e.entries.find(r=>r.key==="defaultVariants")?.value;if(!t||t.t!=="obj")return{};let n={};for(let r of t.entries)r.value.t==="str"&&r.value.v?n[r.key]=r.value.v:r.value.t==="bool"&&(n[r.key]=r.value.v?"true":"false");return n}function px(e,t,n,r,o){let s=Ee(e,t),i={slots:[],defaults:{}};if(!s)return i;let l=jt(s.val)??"",a=$e(e,s.end);if(e[a]!==",")return l.trim()?{slots:[Fo(l,st(e,t),o)],defaults:{}}:i;let c=Ee(e,a+1);if(!c||c.val.t!=="obj")return l.trim()?{slots:[Fo(l,st(e,t),o)],defaults:{}}:i;let u=c.val.entries.find(f=>f.key==="variants")?.value,p=[],d=new Map;if(l.trim()&&p.push(Fo(l,st(e,t),o)),u&&u.t==="obj"){for(let f of u.entries)if(f.value.t==="obj")for(let m of f.value.entries){let g=jt(m.value);if(!g||!g.trim()||m.key==="false")continue;d.set(`${f.key}\0${m.key}`,g);let S=m.key==="true"?`.${f.key}`:`.${f.key}-${m.key}`,h=Qt({selector:S,path:r,base:!1},n.classKeywords);p.push({title:h.title,axis:m.key==="true"?f.key:h.axis??f.key,base:!1,classes:`${l} ${g}`.trim(),line:st(e,m.at),group:o,prop:f.key,value:m.key})}}return p.push(...fx(c.val,l,d,n,r,e,o)),{slots:p,defaults:ux(c.val)}}function dx(e,t,n,r,o){let s=Ee(e,t);if(!s||s.val.t!=="obj")return[];let i=u=>{if(u.t!=="obj")return null;let p=u.entries.find(d=>d.key==="root")?.value;return p?jt(p):null},l=s.val.entries.find(u=>u.key==="common")?.value,a=(l&&i(l))??"",c=[];a.trim()&&c.push(Fo(a,st(e,t),o));for(let u of s.val.entries){if(u.key==="common"||u.value.t!=="obj")continue;let p=u.key.replace(/s$/,"");for(let d of u.value.entries){let f=i(d.value);if(!f||!f.trim())continue;let m=Qt({selector:`.${p}-${d.key}`,path:r,base:!1},n.classKeywords);c.push({title:m.title,axis:m.axis??p,base:!1,classes:`${a} ${f}`.trim(),line:st(e,d.at),group:o,prop:p,value:d.key})}}return c}function vp(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 r=vp(n);if(!r||r.length!==1)return null;t.push(r[0])}return t.length?t:null}return null}function fx(e,t,n,r,o,s,i){let l=e.entries.find(c=>c.key==="compoundVariants")?.value;if(!l||l.t!=="arr")return[];let a=[];for(let c of l.items){if(c.t!=="obj")continue;let u=[],p="",d=c.at,f=!1;for(let g of c.entries){if(g.key==="class"||g.key==="className"){p=jt(g.value)??"",d=g.at,g.value.t!=="str"&&g.value.t!=="arr"&&p===""&&(f=!0);continue}let S=vp(g.value);if(!S){f=!0;break}u.push({axis:g.key,values:S})}if(f)continue;let m=[[]];for(let g of u){let S=[];for(let h of m){for(let b of g.values)if(S.push([...h,{axis:g.axis,value:b}]),S.length>=8)break;if(S.length>=8)break}m=S}for(let g of m){if(g.length<2&&!p.trim())continue;let S=[t],h=[];for(let y of g){let x=n.get(`${y.axis}\0${y.value}`);x&&S.push(x),h.push(y.value==="true"?y.axis:y.value)}p.trim()&&S.push(p);let b=S.join(" ").replace(/\s+/g," ").trim();if(!b)continue;let k=Qt({selector:`.${h.join("-")}`,path:o,base:!1},r.classKeywords);a.push({title:k.title,axis:k.axis,base:!1,classes:b,line:st(s,d),group:i,when:g.map(y=>({prop:y.axis,value:y.value}))})}}return a}function Fo(e,t,n){return{title:"Base",axis:null,base:!0,classes:e,line:t,group:n}}function gx(e,t,n){if(!/^(a|Link|NavLink)$/.test(e)||!t)return!1;let r=fa(Te(t),n).find(i=>i.state==="default"&&i.context==="")?.declarations??[],o=r.some(i=>/^background(-color)?$/.test(i.property)&&!/^(transparent|none|inherit)\b/.test(i.value)),s=r.some(i=>i.property==="display"&&/^inline-(flex|block)$/.test(i.value)||i.property==="justify-content"&&i.value==="center"||i.property==="text-align"&&i.value==="center");return o&&s&&r.some(i=>i.property.startsWith("padding"))}function Sp(e,t){return t.elements.includes(e.toLowerCase())?!0:t.identifier.test(e)}function $p(e){let t=e.match(/\bclassName\s*=\s*(?:"([^"]*)"|'([^']*)'|\{\s*"([^"]*)"\s*\}|\{\s*'([^']*)'\s*\})/);return t?.[1]??t?.[2]??t?.[3]??t?.[4]??null}var mx=new Set(["opacity","z-index","font-weight","line-height","flex","flex-grow","flex-shrink","order","zoom"]);function hx(e){return e.replace(/^[A-Z]/,t=>`-${t.toLowerCase()}`).replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function yx(e,t){return t.t==="str"?t.v:t.t==="num"?mx.has(e)?String(t.v):`${t.v}px`:null}function Bo(e,t){if(e.t!=="obj")return[];let n=[],r=[];for(let s of e.entries){if(s.value.t==="obj"){let a=s.key.replace(/^&/,""),c=a===":hover"?"hover":a===":focus"||a===":focus-visible"?"focus":a===":active"?"active":a===":disabled"?"disabled":null;c&&r.push(...Bo(s.value,c));continue}let i=hx(s.key),l=yx(i,s.value);!l||!ae(i,l)||n.push({property:i,value:l,via:"style"})}return[...n.length?[{state:t,context:"",declarations:n}]:[],...r]}function aa(e,t){if(e[t]!=="`")return null;let n="";for(let r=t+1;r<e.length;r++){let o=e[r];if(o==="\\"){let s=e[r+1];if(s===void 0)return null;n+=s==="n"?`
|
|
26
|
-
`:s,r++;continue}if(o==="$"&&e[r+1]==="{"){let s=1;for(r+=2;r<e.length&&s>0;r++)e[r]==="{"?s++:e[r]==="}"&&s--;r--,n+=" ";continue}if(o==="`")return{css:n,end:r+1};n+=o}return null}function bx(e,t){if(e==="default")return t;if(t==="default")return e;let n=[...new Set([...e.split(" + "),...t.split(" + ")])];return n.sort((r,o)=>Me(r)-Me(o)||r.localeCompare(o)),nt(n)}function la(e,t){let n=[];for(let r of
|
|
26
|
+
`:s,r++;continue}if(o==="$"&&e[r+1]==="{"){let s=1;for(r+=2;r<e.length&&s>0;r++)e[r]==="{"?s++:e[r]==="}"&&s--;r--,n+=" ";continue}if(o==="`")return{css:n,end:r+1};n+=o}return null}function bx(e,t){if(e==="default")return t;if(t==="default")return e;let n=[...new Set([...e.split(" + "),...t.split(" + ")])];return n.sort((r,o)=>Me(r)-Me(o)||r.localeCompare(o)),nt(n)}function la(e,t){let n=[];for(let r of ze(`.__gs {
|
|
27
27
|
${e}
|
|
28
|
-
}`)){let o=ue(r.selector),s=o?.[o.length-1];if(!s)continue;let i=mt(s.simples),l=nt(i.states),a=we(r.ownBody).filter(c=>ae(c.property,c.value));a.length&&n.push({state:l,context:r.context,declarations:a});for(let c of Go(r.ownBody,t))n.push({state:bx(l,c.state),context:[r.context,c.context].filter(Boolean).join(" \xB7 "),declarations:c.declarations})}return n}function br(e){let t=e.match(/\bstyle\s*=\s*"([^"]*)"/);if(t){let i=we(t[1]).filter(l=>ae(l.property,l.value));return i.length?[{state:"default",context:"",declarations:i}]:[]}let n=e.search(/\bstyle\s*=\s*\{/);if(n<0)return[];let r=e.indexOf("{",n),o=$e(e,r+1);e[o]==="{"&&(r=o);let s=Ee(e,r);return s?Bo(s.val,"default"):[]}function da(e){let t=$p(e);if(t!==null)return{classes:Te(t),modules:[]};let n=e.search(/\bclassName\s*=\s*\{/);if(n<0)return{classes:[],modules:[]};let r=e.indexOf("{",n),o=0,s=e.length;for(let c=r;c<e.length;c++)if(e[c]==="{")o++;else if(e[c]==="}"&&--o===0){s=c;break}let i=e.slice(r+1,s),l=[];for(let c of i.matchAll(/"([^"]*)"|'([^']*)'|`([^`]*)`/g)){let u=c[1]??c[2]??c[3];l.push(...Te(u.replace(/\$\{[^}]*\}/g," ")))}let a=[...i.matchAll(/\b([A-Za-z_$][\w$]*)(?:\.([\w$]+)|\[\s*["']([\w-]+)["']\s*\])/g)].filter(c=>!/^(cn|clsx|cx|twMerge|classNames|classnames)$/.test(c[1])).map(c=>({ns:c[1],name:c[2]??c[3]}));return{classes:l,modules:a}}function fa(e,t){let n=new Map;for(let r of e){let o=ca(r);if(!o)continue;let s=ua(o,t).filter(a=>ae(a.property,a.value));if(!s.length)continue;let i=`${o.state}\0${o.context}`,l=n.get(i)??{state:o.state,context:o.context,declarations:[]};l.declarations.push(...s),n.set(i,l)}return[...n.values()]}function wx(e,t){let n=$p(e);if(n)return{classes:n,painted:[]};let r=e.search(/\bclassName\s*=\s*\{/);if(r<0)return{classes:"",painted:[]};let o=e.indexOf("{",r),s=$e(e,o+1);if(e.startsWith("css",s)&&!/[\w$]/.test(e[s+3]??"")){let l=$e(e,s+3);if(e[l]==="`"){let a=aa(e,l);return{classes:"",painted:a?la(a.css,t):[]}}if(e[l]==="("){let a=Ee(e,l+1);return{classes:"",painted:a?Bo(a.val,"default"):[]}}}let i=Ee(e,s);return i?{classes:jt(i.val)??"",painted:[]}:{classes:"",painted:[]}}function kx(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(r=>n.includes(r.toLowerCase()))}function xx(e,t,n){let r=[],o=/(?:^|[^\w$])styled(?:\.([A-Za-z][\w]*)|\(\s*(?:["']([A-Za-z][\w]*)["']|([A-Za-z][\w]*))\s*\))/g;for(let i of e.matchAll(o)){let l=i[1]??i[2]??i[3]??"";if(!Sp(l,t))continue;let a=$e(e,(i.index??0)+i[0].length);e.startsWith(".attrs",a)&&(a=$e(e,a+6),e[a]==="("&&(a=zo(e,a,"(",")")),a=$e(e,a));let c=[];if(e[a]==="`"){let u=aa(e,a);u&&(c=la(u.css,n))}else if(e[a]==="("){let u=Ee(e,a+1);u&&(c=Bo(u.val,"default"))}c.length!==0&&r.push({title:"Styled",axis:null,base:!0,classes:"",line:st(e,i.index??0),painted:c})}let s=/(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*css\s*`/g;for(let i of e.matchAll(s)){let l=i[1]??"";if(!kx(l,t))continue;let a=e.indexOf("`",i.index??0),c=a<0?null:aa(e,a);if(!c)continue;let u=la(c.css,n);u.length!==0&&r.push({title:"Css",axis:null,base:!0,classes:"",line:st(e,i.index??0),painted:u})}return r}function vx(e,t){if(t==="default")return`.${e}`;let n=`.${e}`;for(let r of t.split(" + "))r==="hover"?n+=":hover":r==="focus"?n+=":focus":r==="active"?n+=":active":r==="disabled"&&(n+=":disabled");return n}function Sx(e,t,n,r,o,s){let i=Te(e.classes).map(ca).filter(y=>y!==null),l=i.filter(y=>y.stem===null||!r.has(y.stem)),a=(e.painted??[]).filter(y=>y.declarations.length>0);if(l.length===0&&a.length===0)return null;let c=new Map,u=(y,x,v)=>{if(v.length===0)return;let $=`${y}\0${x}`,R=c.get($)??{state:y,context:x,declarations:[]};R.declarations.push(...v),c.set($,R)},p=[o];for(let y of i){let x=ua(y,s).filter(v=>ae(v.property,v.value));u(y.state,y.context,x),y.state==="default"&&y.context===""&&y.stem&&p.push(y.stem)}for(let y of a)u(y.state,y.context,y.declarations);let d=[...c.values()].flatMap(y=>y.declarations);if(!cx(d))return null;let f=c.get("default\0")?.declarations??[];if(_o(f))return null;let m=[...c.values()].map(y=>({state:y.state,context:y.context,line:e.line,declarations:y.declarations})).sort((y,x)=>y.state!==x.state?y.state==="default"?-1:x.state==="default"?1:Me(y.state.split(" + ")[0])-Me(x.state.split(" + ")[0])||y.state.localeCompare(x.state):y.context===""?-1:x.context===""?1:y.context.localeCompare(x.context)),g=[...new Set(i.map(y=>y.stem).filter(y=>y!==null))],S=g.length?g.map(y=>`.${y}`).join(""):n.elements[0]??"button",h=m.flatMap(y=>pa(vx(o,y.state),y.declarations,y.context)),b=n.elements[0]??"button";return{variant:{title:e.title,axis:e.axis,...e.prop&&e.value&&e.value!=="true"?{select:{prop:e.prop,value:e.value}}:{},element:{tag:b,classes:p,attrs:{},ancestors:[]},usage:{status:"unknown",files:[],fileCount:0},selector:S,path:t,line:e.line,base:e.base,states:m},rules:h}}function Cp(e,t,n,r,o,s){let i=rx(t),l=[],a=[],c=/(?:^|[^\w$])(cva|tv)\s*\(/g;for(let k of i.matchAll(c)){let y=(k.index??0)+Math.max(0,k[0].indexOf(k[1])),x=(k.index??0)+k[0].length,v=a.length,$=px(i,x,n,e,v);a.push({name:wp(i,y),defaults:$.defaults}),l.push(...$.slots)}for(let k of i.matchAll(/(?:^|[^\w$])sortCx\s*\(/g)){let y=(k.index??0)+Math.max(0,k[0].indexOf("sortCx")),x=(k.index??0)+k[0].length,v=a.length,$=dx(i,x,n,e,v);$.length!==0&&(a.push({name:wp(i,y),defaults:{}}),l.push(...$))}l.push(...xx(i,n,s));let u=/<([A-Za-z][\w.]*)\b([^>]*?)>/g;for(let k of i.matchAll(u)){let y=k[1],x=k[2]??"",v=wx(x,s),$=[...v.painted,...br(x)],R=v.classes.trim();if(!R&&$.length===0||!Sp(y,n)&&!gx(y,R,s))continue;let I=k.index??0,O=st(i,I);l.push({title:R?"Base":v.painted.length?"Css":"Inline",axis:null,base:!0,classes:R,line:O,painted:$,...R&&$.length===0?{site:{path:e,line:O,offset:I}}:{}})}let p=[],d=[],f=new Map,m=[],g=new Map,S=new Map,h=o;for(let k=0;k<l.length;k++){let y=l[k];if(p.length+d.length>=ex)break;let x=(y.painted??[]).map(O=>`${O.state}|${O.context}|${O.declarations.map(L=>`${L.property}:${L.value}`).join(";")}`).join("||"),v=`${y.classes.replace(/\s+/g," ").trim()}##${x}`,$=g.get(v);if($){y.group!==void 0&&S.set(k,$),y.site&&f.get($)?.sites.push(y.site);continue}h+=1;let R=`__gs-recipe-${h}`,I=Sx(y,e,n,r,R,s);if(I){if(g.set(v,R),y.group!==void 0&&S.set(k,R),y.site){let O={variant:I.variant,sites:[y.site]};f.set(R,O),d.push(O)}else p.push(I.variant);m.push(...I.rules)}}let b=[];for(let k=0;k<a.length;k++){let y=a[k],x={path:e,name:y.name,staticClasses:[],axes:[],compounds:[]},v=new Map;for(let $=0;$<l.length;$++){let R=l[$];if(R.group!==k)continue;let I=S.get($);if(!I)continue;if(!R.prop&&!R.when){x.staticClasses.push(I);continue}if(R.when){x.compounds.push({when:R.when,classes:[I]});continue}let O=v.get(R.prop)??[];O.push({value:R.value,classes:[I]}),v.set(R.prop,O)}for(let[$,R]of v)x.axes.push({prop:$,values:R,...y.defaults[$]?{defaultValue:y.defaults[$]}:{}});(x.staticClasses.length||x.axes.length||x.compounds.length)&&b.push(x)}return{variants:p,inline:d,previewRules:m,nextId:h,recipes:b}}function Rp(e,t){let r=(e.split("/").pop()??"").replace(/(\.module)?\.[^.]+$/i,"").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);return t.some(o=>{let s=o.toLowerCase();return r.includes(s)||r.includes(`${s}s`)})}var $x={primary:"Primary",secondary:"Secondary",destructive:"Destructive",ghost:"Ghost",link:"Link",icon:"Icon"},b1=Object.keys($x),Wo=e=>/size/i.test(e.select?.prop??e.axis??"");function kr(e){let t=new Map;for(let n of e)for(let r of n){let o=`${r.target??""}|${r.state}|${r.context}`,s=t.get(o);if(!s){t.set(o,{...r,declarations:[...r.declarations]});continue}let i=new Map(s.declarations.map(l=>[l.property,l]));for(let l of r.declarations)i.delete(l.property),i.set(l.property,l);t.set(o,{...s,declarations:[...i.values()],...s.marker||r.marker?{marker:s.marker??r.marker}:{}})}return[...t.values()]}function wr(e,t){return e.find(n=>n.state==="default"&&n.context==="")?.declarations.findLast(n=>n.property===t)?.value}function Ke(e){let t=e?/^(-?[\d.]+)(px|rem)?$/.exec(e.trim()):null;return t?Number(t[1])*(t[2]==="rem"?16:1):e?.trim()==="0"?0:null}function Cx(e,t){if(!e.select||Wo(e))return[];let n=t.variants.filter(l=>l.path===e.path&&l.select&&Wo(l));if(!n.length)return[];let r=n[0].select.prop,o=t.recipeDefaults?.find(l=>l.path===e.path&&l.prop===r)?.value,s=[...n].sort((l,a)=>(Ke(wr(l.states,"height"))??0)-(Ke(wr(a.states,"height"))??0)),i=o&&n.find(l=>l.select.value===o)||n.find(l=>/^(medium|default)$/i.test(l.title))||n.find(l=>/^(md|default)$/.test(l.select.value))||s[Math.floor((s.length-1)/2)];return[i,...n.filter(l=>l!==i)]}function Rx(e,t){return e.markup||e.render?[e.states]:[...zi(e,t.variants).filter(r=>r.base&&r!==e).map(r=>r.states),e.states]}function Ax(e,t){let n=Cx(e,t)[0];return kr([...Rx(e,t),...n?[n.states]:[]])}function rn(e){return e.map(t=>({...t,declarations:t.declarations.filter(n=>t.target||!Zt(n))})).filter(t=>t.declarations.length||t.state==="default")}var Mn=/^(height|width|padding(-(inline|block|top|right|bottom|left))?(-(start|end))?|gap|font-size|line-height)$/,ga=/^(transparent|none|initial|inherit|unset)\b/,ya=e=>[...e.matchAll(/var\(\s*(--[\w-]+)/g)].map(t=>t[1]);function wt(e,t){let n=ya(e);if(n.length){let o="",s=0;for(let i of e.matchAll(/var\(\s*(--[\w-]+)/g)){if(i.index<s)continue;let l=i.index+4,a=1;for(;l<e.length&&a;l++)e[l]==="("&&a++,e[l]===")"&&a--;if(a)return e.trim();o+=e.slice(s,i.index)+`var(${i[1]})`,s=l}return o=(o+e.slice(s)).trim().replace(/\s+/g," ").replace(/\s*([(),])\s*/g,"$1"),o===`var(${n[0]})`?n[0]:o}let r=e.trim();return ce(en(e,t))??(/^-?(?:\d+(?:\.\d*)?|\.\d+)$/.test(r)?String(Number(r)):r)}function Ix(e){let t=[0,0,0,0],n=r=>Ke(r)??r;for(let r of e){let o=r.value.trim().split(/\s+/).map(n),[s,i=s,l=s,a=i]=o;r.property==="padding"?t.splice(0,4,s,i,l,a):r.property==="padding-inline"?[t[3],t[1]]=[s,i]:r.property==="padding-block"?[t[0],t[2]]=[s,i]:/^padding-(top|block-start)$/.test(r.property)?t[0]=s:/^padding-(right|inline-end)$/.test(r.property)?t[1]=s:/^padding-(bottom|block-end)$/.test(r.property)?t[2]=s:/^padding-(left|inline-start)$/.test(r.property)&&(t[3]=s)}return t}function Ot(e,t){let n=rn(e).find(k=>!k.target&&k.state==="default"&&k.context==="")?.declarations??[],r=k=>n.findLast(y=>y.property===k)?.value,o=r("background-color")??r("background"),s=o&&!ga.test(o)?{tokens:ya(o),color:ce(en(o,t))}:null,i=Ke(r("border-width")),l=i!==null&&i>0&&r("border-style")!=="none",a=Ix(n.filter(k=>k.property.startsWith("padding"))),c=r("height"),u=r("width"),p=c!==void 0&&c===u&&!/^(auto|100%|fit-content)$/.test(c),d={};for(let k of["height","width","gap","font-size","line-height"]){let y=r(k);y!==void 0&&(d[k]=Ke(y)??y)}a.some(k=>k!==0)&&a.forEach((k,y)=>d[`p${y}`]=k);for(let k of e.filter(y=>y.target&&y.state==="default"&&!y.context))for(let y of k.declarations.filter(x=>Mn.test(x.property)))d[`${k.target}:${y.property}`]=Ke(y.value)??y.value;let f=r("box-shadow"),m=r("color"),g=r("border-radius"),S={bg:o&&!ga.test(o)?wt(o,t):"none",fg:m?wt(m,t):"none",bd:l?wt(r("border-color")??"currentcolor",t):"none",sh:f&&!ga.test(f)?"1":"0",r:g?String(Ke(g)??wt(g,t)):"0"},h=e.filter(k=>k.target&&k.state==="default"&&!k.context).flatMap(k=>k.declarations.filter(y=>!Mn.test(y.property)&&!y.property.startsWith("--")).map(y=>`${k.target}|${y.property}=${wt(y.value,t)}`)).sort().join(";");return{paint:Object.keys(S).map(k=>`${k}=${S[k]}`).join("|")+(h?`|layers=${h}`:""),parts:S,fontWeight:r("font-weight")??null,size:d,square:p,bg:s,bordered:l,padded:a.some(k=>k!==0),color:{tokens:m?ya(m):[]},underline:e.some(k=>k.declarations.some(y=>/^text-decoration(-line)?$/.test(y.property)&&/underline/.test(y.value)))}}var Ex=e=>Object.keys(e).sort().map(t=>{let n=e[t];return`${t}:${typeof n=="number"?Math.round(n):n}`}).join(",");function Tp(e,t=new Map){let n=Ot(e,t);return`${n.paint}|fw=${n.fontWeight??""}#${Ex(n.size)}`}var Tx=/^(border(-(top|bottom)-(left|right))?-radius|transform|translate|scale|rotate|transition(-[\w-]+)?|margin(-[\w-]+)?|top|right|bottom|left|inset(-[\w-]+)?)$/;function Ap(e,t){return rn(e).map(n=>`${n.target??""}|${n.state}|${n.context}|${n.declarations.filter(r=>!Mn.test(r.property)&&!r.property.startsWith("--")&&!Tx.test(r.property)).map(r=>`${r.property}=${wt(r.value,t)}`).sort().join(";")}`).sort().join(`
|
|
29
|
-
`)}var _x=/(?:^|--|[-_])(?:xs|sm|small|md|medium|lg|large|xl|2xl|xxl)$/i,Ip=e=>new Set([...e.matchAll(/\.((?:\\.|[\w-])+)/g)].map(t=>t[1].replace(/\\(.)/g,"$1")));function jx(e,t){let n=Ip(e),r=Ip(t),o=[...n,...r].filter(s=>!(n.has(s)&&r.has(s)));return[...n].some(s=>r.has(s))&&o.length>0&&o.every(s=>_x.test(s))}function Ox(e,t,n){return jx(e.selector,t.selector)&&Ap(e.states,n)===Ap(t.states,n)}function Mx(e){return e.usage.files.flatMap(t=>{let n=t.example?.element?.bodyHtml;return n?[n.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()]:[]})}var Dx=/\b(sign in|log in|sign up|continue) with (google|apple|github|microsoft|facebook|x|slack|linkedin)\b/i;function Px(e,t){let n=e.whole;if(wr(n,"inset")==="0")return{reason:"Overlay, not a button"};let r=Ke(wr(n,"height")),o=Ke(wr(n,"min-width"));return r!==null&&r<=24&&o!==null&&o<=24&&!t.padded?{reason:"Badge, not a button"}:Mx(e.source).some(s=>Dx.test(s))?{reason:"Third-party sign-in, not checked"}:!t.bg&&!t.bordered&&!t.padded&&!t.square?t.underline||t.color.tokens.some(i=>/link|primary|accent/.test(i))?"link":{reason:"Text action"}:null}function Lx(e,t=!1){let n=[];return e.variants.forEach((r,o)=>{if(Wo(r))return;let s=r.base?e.variants.filter(a=>a!==r&&!a.base&&!Wo(a)&&(zi(a,e.variants).includes(r)||a.path===r.path&&r.element?.classes.length&&r.element.classes.filter(c=>!c.startsWith("__gs-")).every(c=>a.element?.classes.includes(c)))):[],i=s.length?r.usage.files.filter(a=>{let c=a.example?.element;return!c||!/^\.[\w-]+$/.test(r.selector)||!c.classes.includes(r.selector.slice(1))?!1:!s.some(u=>u.element?.classes.filter(p=>!p.startsWith("__gs-")).every(p=>c.classes.includes(p)))}):r.usage.files;if(r.base&&!i.length)return;let l=r.base?{...r,usage:{...r.usage,files:i,fileCount:i.length}}:r;n.push({source:l,variant:r,whole:Ax(r,e),order:o});for(let a of r.modifiers??[])!t||!a.alike||n.push({source:a,variant:r,whole:kr([a.states]),order:o})}),n}function Nx(e){let t=e.source;return"places"in t&&t.places?.length?t.places:t.usage.files.map(n=>({path:n.path,line:n.line}))}function _p(e){let t=e.trim().replace(/\s+/g," ");return t.length>=1&&t.length<=40&&!/[<>{};]/.test(t)?t:null}function Xe(e){let t=5381;for(let n=0;n<e.length;n++)t=(t*33^e.charCodeAt(n))>>>0;return t.toString(36)}function jp(e,t=!1){if(t)return`button-live:v1:${Tp(e)}`;let n=kr([rn(e)]).map(r=>[r.target??"",r.state,r.context,r.declarations.filter(o=>!o.property.startsWith("--")).map(o=>[o.property,wt(o.value,new Map)]).sort(([o],[s])=>o.localeCompare(s))]).sort((r,o)=>JSON.stringify(r).localeCompare(JSON.stringify(o)));return`button-look:v1:${Xe(JSON.stringify(n))}`}function ba(e,t){let n=[],r=l=>l===void 0?null:typeof l=="number"?`${l}px`:l,o=(l,a)=>typeof l=="number"&&typeof a=="number"?Math.abs(l-a)<=1:l===a,s=["p0","p1","p2","p3"];for(let l of new Set([...Object.keys(e),...Object.keys(t)]))s.includes(l)||o(e[l],t[l])||n.push({property:l,state:"default",found:r(e[l]),expected:r(t[l])});let i=l=>s.some(a=>l[a]!==void 0)?s.map(a=>r(l[a]??0)).join(" "):null;return s.some(l=>!o(e[l]??0,t[l]??0))&&n.push({property:"padding",state:"default",found:i(e),expected:i(t)}),n}function ma(e,t,n){let r=a=>{let c=new Map;for(let u of rn(a)){let p=`${u.target?`${u.target} \xB7 `:""}${u.context?`${u.state} @ ${u.context}`:u.state}`,d=c.get(p)??new Map;for(let f of u.declarations)(!Mn.test(f.property)||u.state!=="default"||u.context)&&d.set(f.property,f.value);c.set(p,d)}return c},o=r(e),s=r(t),i=(a,c)=>{if(a===void 0||c===void 0)return a===c;let[u,p]=[Ke(a),Ke(c)];return u!==null&&p!==null&&(/(?:px|rem)$/.test(a)||/(?:px|rem)$/.test(c))?Math.abs(u-p)<=1:wt(a,n)===wt(c,n)},l=[];for(let a of o.keys()){let c=o.get(a),u=s.get(a)??new Map;for(let p of new Set([...c.keys(),...u.keys()]))i(c.get(p),u.get(p))||l.push({property:p,state:a,found:c.get(p)??null,expected:u.get(p)??null})}return l}function ha(e,t){let n=o=>`${o.target??""}|${o.state}|${o.context}`,r=new Set(rn(e).map(n));return rn(t).filter(o=>o.state!=="default"&&o.declarations.length&&!r.has(n(o))).map(o=>({state:o.state,label:`${o.state}${o.context?` @ ${o.context}`:""}`,expected:o.declarations.map(s=>`${s.property}: ${s.value}`).join("; ")}))}function Ho(e,t){return t.states?t.states:e.map(n=>!n.target&&n.state==="default"&&n.context===""?{...n,declarations:[...n.declarations.filter(r=>!Mn.test(r.property)),...t.declarations]}:n)}function Vo(e,t,n=[]){let r=Lo(e.previewCss),o=t.specs.map(l=>({spec:l,design:Ot(l.states,r),sizes:(l.sizes.length?l.sizes.map(a=>Ho(l.states,a)):[l.states]).map(a=>({states:a,size:Ot(a,r).size}))})),s=[],i=[];for(let l of Lx(e,!0)){let a=Ot(l.whole,r),c=Px(l,a);if(c&&c!=="link")continue;i.push(ka(l.whole,r));let u=Tp(l.whole,r),p=Nx(l),d={signature:u,places:p.length?p:[{path:l.source.path,line:l.source.line}],states:rn(l.whole),path:l.source.path,line:l.source.line,selector:l.source.selector,...p.length&&{used:!0},...l.variant.render&&{render:l.variant.render,whole:l.whole}},f=t.merged[jp(d.states)],m=o.find(v=>v.spec.id===f);if(m){s.push({...d,result:"exact",spec:m.spec,diff:[]});continue}let g=o.find(v=>v.spec.id===t.merged[u]);if(g){let v=
|
|
28
|
+
}`)){let o=ue(r.selector),s=o?.[o.length-1];if(!s)continue;let i=mt(s.simples),l=nt(i.states),a=we(r.ownBody).filter(c=>ae(c.property,c.value));a.length&&n.push({state:l,context:r.context,declarations:a});for(let c of Go(r.ownBody,t))n.push({state:bx(l,c.state),context:[r.context,c.context].filter(Boolean).join(" \xB7 "),declarations:c.declarations})}return n}function br(e){let t=e.match(/\bstyle\s*=\s*"([^"]*)"/);if(t){let i=we(t[1]).filter(l=>ae(l.property,l.value));return i.length?[{state:"default",context:"",declarations:i}]:[]}let n=e.search(/\bstyle\s*=\s*\{/);if(n<0)return[];let r=e.indexOf("{",n),o=$e(e,r+1);e[o]==="{"&&(r=o);let s=Ee(e,r);return s?Bo(s.val,"default"):[]}function da(e){let t=$p(e);if(t!==null)return{classes:Te(t),modules:[]};let n=e.search(/\bclassName\s*=\s*\{/);if(n<0)return{classes:[],modules:[]};let r=e.indexOf("{",n),o=0,s=e.length;for(let c=r;c<e.length;c++)if(e[c]==="{")o++;else if(e[c]==="}"&&--o===0){s=c;break}let i=e.slice(r+1,s),l=[];for(let c of i.matchAll(/"([^"]*)"|'([^']*)'|`([^`]*)`/g)){let u=c[1]??c[2]??c[3];l.push(...Te(u.replace(/\$\{[^}]*\}/g," ")))}let a=[...i.matchAll(/\b([A-Za-z_$][\w$]*)(?:\.([\w$]+)|\[\s*["']([\w-]+)["']\s*\])/g)].filter(c=>!/^(cn|clsx|cx|twMerge|classNames|classnames)$/.test(c[1])).map(c=>({ns:c[1],name:c[2]??c[3]}));return{classes:l,modules:a}}function fa(e,t){let n=new Map;for(let r of e){let o=ca(r);if(!o)continue;let s=ua(o,t).filter(a=>ae(a.property,a.value));if(!s.length)continue;let i=`${o.state}\0${o.context}`,l=n.get(i)??{state:o.state,context:o.context,declarations:[]};l.declarations.push(...s),n.set(i,l)}return[...n.values()]}function wx(e,t){let n=$p(e);if(n)return{classes:n,painted:[]};let r=e.search(/\bclassName\s*=\s*\{/);if(r<0)return{classes:"",painted:[]};let o=e.indexOf("{",r),s=$e(e,o+1);if(e.startsWith("css",s)&&!/[\w$]/.test(e[s+3]??"")){let l=$e(e,s+3);if(e[l]==="`"){let a=aa(e,l);return{classes:"",painted:a?la(a.css,t):[]}}if(e[l]==="("){let a=Ee(e,l+1);return{classes:"",painted:a?Bo(a.val,"default"):[]}}}let i=Ee(e,s);return i?{classes:jt(i.val)??"",painted:[]}:{classes:"",painted:[]}}function kx(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(r=>n.includes(r.toLowerCase()))}function xx(e,t,n){let r=[],o=/(?:^|[^\w$])styled(?:\.([A-Za-z][\w]*)|\(\s*(?:["']([A-Za-z][\w]*)["']|([A-Za-z][\w]*))\s*\))/g;for(let i of e.matchAll(o)){let l=i[1]??i[2]??i[3]??"";if(!Sp(l,t))continue;let a=$e(e,(i.index??0)+i[0].length);e.startsWith(".attrs",a)&&(a=$e(e,a+6),e[a]==="("&&(a=zo(e,a,"(",")")),a=$e(e,a));let c=[];if(e[a]==="`"){let u=aa(e,a);u&&(c=la(u.css,n))}else if(e[a]==="("){let u=Ee(e,a+1);u&&(c=Bo(u.val,"default"))}c.length!==0&&r.push({title:"Styled",axis:null,base:!0,classes:"",line:st(e,i.index??0),painted:c})}let s=/(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*css\s*`/g;for(let i of e.matchAll(s)){let l=i[1]??"";if(!kx(l,t))continue;let a=e.indexOf("`",i.index??0),c=a<0?null:aa(e,a);if(!c)continue;let u=la(c.css,n);u.length!==0&&r.push({title:"Css",axis:null,base:!0,classes:"",line:st(e,i.index??0),painted:u})}return r}function vx(e,t){if(t==="default")return`.${e}`;let n=`.${e}`;for(let r of t.split(" + "))r==="hover"?n+=":hover":r==="focus"?n+=":focus":r==="active"?n+=":active":r==="disabled"&&(n+=":disabled");return n}function Sx(e,t,n,r,o,s){let i=Te(e.classes).map(ca).filter(y=>y!==null),l=i.filter(y=>y.stem===null||!r.has(y.stem)),a=(e.painted??[]).filter(y=>y.declarations.length>0);if(l.length===0&&a.length===0)return null;let c=new Map,u=(y,x,v)=>{if(v.length===0)return;let $=`${y}\0${x}`,A=c.get($)??{state:y,context:x,declarations:[]};A.declarations.push(...v),c.set($,A)},p=[o];for(let y of i){let x=ua(y,s).filter(v=>ae(v.property,v.value));u(y.state,y.context,x),y.state==="default"&&y.context===""&&y.stem&&p.push(y.stem)}for(let y of a)u(y.state,y.context,y.declarations);let d=[...c.values()].flatMap(y=>y.declarations);if(!cx(d))return null;let f=c.get("default\0")?.declarations??[];if(_o(f))return null;let m=[...c.values()].map(y=>({state:y.state,context:y.context,line:e.line,declarations:y.declarations})).sort((y,x)=>y.state!==x.state?y.state==="default"?-1:x.state==="default"?1:Me(y.state.split(" + ")[0])-Me(x.state.split(" + ")[0])||y.state.localeCompare(x.state):y.context===""?-1:x.context===""?1:y.context.localeCompare(x.context)),g=[...new Set(i.map(y=>y.stem).filter(y=>y!==null))],S=g.length?g.map(y=>`.${y}`).join(""):n.elements[0]??"button",h=m.flatMap(y=>pa(vx(o,y.state),y.declarations,y.context)),b=n.elements[0]??"button";return{variant:{title:e.title,axis:e.axis,...e.prop&&e.value&&e.value!=="true"?{select:{prop:e.prop,value:e.value}}:{},element:{tag:b,classes:p,attrs:{},ancestors:[]},usage:{status:"unknown",files:[],fileCount:0},selector:S,path:t,line:e.line,base:e.base,states:m},rules:h}}function Cp(e,t,n,r,o,s){let i=rx(t),l=[],a=[],c=/(?:^|[^\w$])(cva|tv)\s*\(/g;for(let k of i.matchAll(c)){let y=(k.index??0)+Math.max(0,k[0].indexOf(k[1])),x=(k.index??0)+k[0].length,v=a.length,$=px(i,x,n,e,v);a.push({name:wp(i,y),defaults:$.defaults}),l.push(...$.slots)}for(let k of i.matchAll(/(?:^|[^\w$])sortCx\s*\(/g)){let y=(k.index??0)+Math.max(0,k[0].indexOf("sortCx")),x=(k.index??0)+k[0].length,v=a.length,$=dx(i,x,n,e,v);$.length!==0&&(a.push({name:wp(i,y),defaults:{}}),l.push(...$))}l.push(...xx(i,n,s));let u=/<([A-Za-z][\w.]*)\b([^>]*?)>/g;for(let k of i.matchAll(u)){let y=k[1],x=k[2]??"",v=wx(x,s),$=[...v.painted,...br(x)],A=v.classes.trim();if(!A&&$.length===0||!Sp(y,n)&&!gx(y,A,s))continue;let E=k.index??0,O=st(i,E);l.push({title:A?"Base":v.painted.length?"Css":"Inline",axis:null,base:!0,classes:A,line:O,painted:$,...A&&$.length===0?{site:{path:e,line:O,offset:E}}:{}})}let p=[],d=[],f=new Map,m=[],g=new Map,S=new Map,h=o;for(let k=0;k<l.length;k++){let y=l[k];if(p.length+d.length>=ex)break;let x=(y.painted??[]).map(O=>`${O.state}|${O.context}|${O.declarations.map(L=>`${L.property}:${L.value}`).join(";")}`).join("||"),v=`${y.classes.replace(/\s+/g," ").trim()}##${x}`,$=g.get(v);if($){y.group!==void 0&&S.set(k,$),y.site&&f.get($)?.sites.push(y.site);continue}h+=1;let A=`__gs-recipe-${h}`,E=Sx(y,e,n,r,A,s);if(E){if(g.set(v,A),y.group!==void 0&&S.set(k,A),y.site){let O={variant:E.variant,sites:[y.site]};f.set(A,O),d.push(O)}else p.push(E.variant);m.push(...E.rules)}}let b=[];for(let k=0;k<a.length;k++){let y=a[k],x={path:e,name:y.name,staticClasses:[],axes:[],compounds:[]},v=new Map;for(let $=0;$<l.length;$++){let A=l[$];if(A.group!==k)continue;let E=S.get($);if(!E)continue;if(!A.prop&&!A.when){x.staticClasses.push(E);continue}if(A.when){x.compounds.push({when:A.when,classes:[E]});continue}let O=v.get(A.prop)??[];O.push({value:A.value,classes:[E]}),v.set(A.prop,O)}for(let[$,A]of v)x.axes.push({prop:$,values:A,...y.defaults[$]?{defaultValue:y.defaults[$]}:{}});(x.staticClasses.length||x.axes.length||x.compounds.length)&&b.push(x)}return{variants:p,inline:d,previewRules:m,nextId:h,recipes:b}}function Rp(e,t){let r=(e.split("/").pop()??"").replace(/(\.module)?\.[^.]+$/i,"").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);return t.some(o=>{let s=o.toLowerCase();return r.includes(s)||r.includes(`${s}s`)})}var $x={primary:"Primary",secondary:"Secondary",destructive:"Destructive",ghost:"Ghost",link:"Link",icon:"Icon"},b1=Object.keys($x),Wo=e=>/size/i.test(e.select?.prop??e.axis??"");function kr(e){let t=new Map;for(let n of e)for(let r of n){let o=`${r.target??""}|${r.state}|${r.context}`,s=t.get(o);if(!s){t.set(o,{...r,declarations:[...r.declarations]});continue}let i=new Map(s.declarations.map(l=>[l.property,l]));for(let l of r.declarations)i.delete(l.property),i.set(l.property,l);t.set(o,{...s,declarations:[...i.values()],...s.marker||r.marker?{marker:s.marker??r.marker}:{}})}return[...t.values()]}function wr(e,t){return e.find(n=>n.state==="default"&&n.context==="")?.declarations.findLast(n=>n.property===t)?.value}function Ke(e){let t=e?/^(-?[\d.]+)(px|rem)?$/.exec(e.trim()):null;return t?Number(t[1])*(t[2]==="rem"?16:1):e?.trim()==="0"?0:null}function Cx(e,t){if(!e.select||Wo(e))return[];let n=t.variants.filter(l=>l.path===e.path&&l.select&&Wo(l));if(!n.length)return[];let r=n[0].select.prop,o=t.recipeDefaults?.find(l=>l.path===e.path&&l.prop===r)?.value,s=[...n].sort((l,a)=>(Ke(wr(l.states,"height"))??0)-(Ke(wr(a.states,"height"))??0)),i=o&&n.find(l=>l.select.value===o)||n.find(l=>/^(medium|default)$/i.test(l.title))||n.find(l=>/^(md|default)$/.test(l.select.value))||s[Math.floor((s.length-1)/2)];return[i,...n.filter(l=>l!==i)]}function Rx(e,t){return e.markup||e.render?[e.states]:[...zi(e,t.variants).filter(r=>r.base&&r!==e).map(r=>r.states),e.states]}function Ax(e,t){let n=Cx(e,t)[0];return kr([...Rx(e,t),...n?[n.states]:[]])}function rn(e){return e.map(t=>({...t,declarations:t.declarations.filter(n=>t.target||!Zt(n))})).filter(t=>t.declarations.length||t.state==="default")}var Mn=/^(height|width|padding(-(inline|block|top|right|bottom|left))?(-(start|end))?|gap|font-size|line-height)$/,ga=/^(transparent|none|initial|inherit|unset)\b/,ya=e=>[...e.matchAll(/var\(\s*(--[\w-]+)/g)].map(t=>t[1]);function wt(e,t){let n=ya(e);if(n.length){let o="",s=0;for(let i of e.matchAll(/var\(\s*(--[\w-]+)/g)){if(i.index<s)continue;let l=i.index+4,a=1;for(;l<e.length&&a;l++)e[l]==="("&&a++,e[l]===")"&&a--;if(a)return e.trim();o+=e.slice(s,i.index)+`var(${i[1]})`,s=l}return o=(o+e.slice(s)).trim().replace(/\s+/g," ").replace(/\s*([(),])\s*/g,"$1"),o===`var(${n[0]})`?n[0]:o}let r=e.trim();return ce(en(e,t))??(/^-?(?:\d+(?:\.\d*)?|\.\d+)$/.test(r)?String(Number(r)):r)}function Ix(e){let t=[0,0,0,0],n=r=>Ke(r)??r;for(let r of e){let o=r.value.trim().split(/\s+/).map(n),[s,i=s,l=s,a=i]=o;r.property==="padding"?t.splice(0,4,s,i,l,a):r.property==="padding-inline"?[t[3],t[1]]=[s,i]:r.property==="padding-block"?[t[0],t[2]]=[s,i]:/^padding-(top|block-start)$/.test(r.property)?t[0]=s:/^padding-(right|inline-end)$/.test(r.property)?t[1]=s:/^padding-(bottom|block-end)$/.test(r.property)?t[2]=s:/^padding-(left|inline-start)$/.test(r.property)&&(t[3]=s)}return t}function Ot(e,t){let n=rn(e).find(k=>!k.target&&k.state==="default"&&k.context==="")?.declarations??[],r=k=>n.findLast(y=>y.property===k)?.value,o=r("background-color")??r("background"),s=o&&!ga.test(o)?{tokens:ya(o),color:ce(en(o,t))}:null,i=Ke(r("border-width")),l=i!==null&&i>0&&r("border-style")!=="none",a=Ix(n.filter(k=>k.property.startsWith("padding"))),c=r("height"),u=r("width"),p=c!==void 0&&c===u&&!/^(auto|100%|fit-content)$/.test(c),d={};for(let k of["height","width","gap","font-size","line-height"]){let y=r(k);y!==void 0&&(d[k]=Ke(y)??y)}a.some(k=>k!==0)&&a.forEach((k,y)=>d[`p${y}`]=k);for(let k of e.filter(y=>y.target&&y.state==="default"&&!y.context))for(let y of k.declarations.filter(x=>Mn.test(x.property)))d[`${k.target}:${y.property}`]=Ke(y.value)??y.value;let f=r("box-shadow"),m=r("color"),g=r("border-radius"),S={bg:o&&!ga.test(o)?wt(o,t):"none",fg:m?wt(m,t):"none",bd:l?wt(r("border-color")??"currentcolor",t):"none",sh:f&&!ga.test(f)?"1":"0",r:g?String(Ke(g)??wt(g,t)):"0"},h=e.filter(k=>k.target&&k.state==="default"&&!k.context).flatMap(k=>k.declarations.filter(y=>!Mn.test(y.property)&&!y.property.startsWith("--")).map(y=>`${k.target}|${y.property}=${wt(y.value,t)}`)).sort().join(";");return{paint:Object.keys(S).map(k=>`${k}=${S[k]}`).join("|")+(h?`|layers=${h}`:""),parts:S,fontWeight:r("font-weight")??null,size:d,square:p,bg:s,bordered:l,padded:a.some(k=>k!==0),color:{tokens:m?ya(m):[]},underline:e.some(k=>k.declarations.some(y=>/^text-decoration(-line)?$/.test(y.property)&&/underline/.test(y.value)))}}var Ex=e=>Object.keys(e).sort().map(t=>{let n=e[t];return`${t}:${typeof n=="number"?Math.round(n):n}`}).join(",");function Tp(e,t=new Map){let n=Ot(e,t);return`${n.paint}|fw=${n.fontWeight??""}#${Ex(n.size)}`}var Tx=/^(border(-(top|bottom)-(left|right))?-radius|transform|translate|scale|rotate|transition(-[\w-]+)?|margin(-[\w-]+)?|top|right|bottom|left|inset(-[\w-]+)?)$/;function Ap(e,t){return rn(e).map(n=>`${n.target??""}|${n.state}|${n.context}|${n.declarations.filter(r=>!Mn.test(r.property)&&!r.property.startsWith("--")&&!Tx.test(r.property)).map(r=>`${r.property}=${wt(r.value,t)}`).sort().join(";")}`).sort().join(`
|
|
29
|
+
`)}var _x=/(?:^|--|[-_])(?:xs|sm|small|md|medium|lg|large|xl|2xl|xxl)$/i,Ip=e=>new Set([...e.matchAll(/\.((?:\\.|[\w-])+)/g)].map(t=>t[1].replace(/\\(.)/g,"$1")));function jx(e,t){let n=Ip(e),r=Ip(t),o=[...n,...r].filter(s=>!(n.has(s)&&r.has(s)));return[...n].some(s=>r.has(s))&&o.length>0&&o.every(s=>_x.test(s))}function Ox(e,t,n){return jx(e.selector,t.selector)&&Ap(e.states,n)===Ap(t.states,n)}function Mx(e){return e.usage.files.flatMap(t=>{let n=t.example?.element?.bodyHtml;return n?[n.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()]:[]})}var Dx=/\b(sign in|log in|sign up|continue) with (google|apple|github|microsoft|facebook|x|slack|linkedin)\b/i;function Px(e,t){let n=e.whole;if(wr(n,"inset")==="0")return{reason:"Overlay, not a button"};let r=Ke(wr(n,"height")),o=Ke(wr(n,"min-width"));return r!==null&&r<=24&&o!==null&&o<=24&&!t.padded?{reason:"Badge, not a button"}:Mx(e.source).some(s=>Dx.test(s))?{reason:"Third-party sign-in, not checked"}:!t.bg&&!t.bordered&&!t.padded&&!t.square?t.underline||t.color.tokens.some(i=>/link|primary|accent/.test(i))?"link":{reason:"Text action"}:null}function Lx(e,t=!1){let n=[];return e.variants.forEach((r,o)=>{if(Wo(r))return;let s=r.base?e.variants.filter(a=>a!==r&&!a.base&&!Wo(a)&&(zi(a,e.variants).includes(r)||a.path===r.path&&r.element?.classes.length&&r.element.classes.filter(c=>!c.startsWith("__gs-")).every(c=>a.element?.classes.includes(c)))):[],i=s.length?r.usage.files.filter(a=>{let c=a.example?.element;return!c||!/^\.[\w-]+$/.test(r.selector)||!c.classes.includes(r.selector.slice(1))?!1:!s.some(u=>u.element?.classes.filter(p=>!p.startsWith("__gs-")).every(p=>c.classes.includes(p)))}):r.usage.files;if(r.base&&!i.length)return;let l=r.base?{...r,usage:{...r.usage,files:i,fileCount:i.length}}:r;n.push({source:l,variant:r,whole:Ax(r,e),order:o});for(let a of r.modifiers??[])!t||!a.alike||n.push({source:a,variant:r,whole:kr([a.states]),order:o})}),n}function Nx(e){let t=e.source;return"places"in t&&t.places?.length?t.places:t.usage.files.map(n=>({path:n.path,line:n.line}))}function _p(e){let t=e.trim().replace(/\s+/g," ");return t.length>=1&&t.length<=40&&!/[<>{};]/.test(t)?t:null}function Xe(e){let t=5381;for(let n=0;n<e.length;n++)t=(t*33^e.charCodeAt(n))>>>0;return t.toString(36)}function jp(e,t=!1){if(t)return`button-live:v1:${Tp(e)}`;let n=kr([rn(e)]).map(r=>[r.target??"",r.state,r.context,r.declarations.filter(o=>!o.property.startsWith("--")).map(o=>[o.property,wt(o.value,new Map)]).sort(([o],[s])=>o.localeCompare(s))]).sort((r,o)=>JSON.stringify(r).localeCompare(JSON.stringify(o)));return`button-look:v1:${Xe(JSON.stringify(n))}`}function ba(e,t){let n=[],r=l=>l===void 0?null:typeof l=="number"?`${l}px`:l,o=(l,a)=>typeof l=="number"&&typeof a=="number"?Math.abs(l-a)<=1:l===a,s=["p0","p1","p2","p3"];for(let l of new Set([...Object.keys(e),...Object.keys(t)]))s.includes(l)||o(e[l],t[l])||n.push({property:l,state:"default",found:r(e[l]),expected:r(t[l])});let i=l=>s.some(a=>l[a]!==void 0)?s.map(a=>r(l[a]??0)).join(" "):null;return s.some(l=>!o(e[l]??0,t[l]??0))&&n.push({property:"padding",state:"default",found:i(e),expected:i(t)}),n}function ma(e,t,n){let r=a=>{let c=new Map;for(let u of rn(a)){let p=`${u.target?`${u.target} \xB7 `:""}${u.context?`${u.state} @ ${u.context}`:u.state}`,d=c.get(p)??new Map;for(let f of u.declarations)(!Mn.test(f.property)||u.state!=="default"||u.context)&&d.set(f.property,f.value);c.set(p,d)}return c},o=r(e),s=r(t),i=(a,c)=>{if(a===void 0||c===void 0)return a===c;let[u,p]=[Ke(a),Ke(c)];return u!==null&&p!==null&&(/(?:px|rem)$/.test(a)||/(?:px|rem)$/.test(c))?Math.abs(u-p)<=1:wt(a,n)===wt(c,n)},l=[];for(let a of o.keys()){let c=o.get(a),u=s.get(a)??new Map;for(let p of new Set([...c.keys(),...u.keys()]))i(c.get(p),u.get(p))||l.push({property:p,state:a,found:c.get(p)??null,expected:u.get(p)??null})}return l}function ha(e,t){let n=o=>`${o.target??""}|${o.state}|${o.context}`,r=new Set(rn(e).map(n));return rn(t).filter(o=>o.state!=="default"&&o.declarations.length&&!r.has(n(o))).map(o=>({state:o.state,label:`${o.state}${o.context?` @ ${o.context}`:""}`,expected:o.declarations.map(s=>`${s.property}: ${s.value}`).join("; ")}))}function Ho(e,t){return t.states?t.states:e.map(n=>!n.target&&n.state==="default"&&n.context===""?{...n,declarations:[...n.declarations.filter(r=>!Mn.test(r.property)),...t.declarations]}:n)}function Vo(e,t,n=[]){let r=Lo(e.previewCss),o=t.specs.map(l=>({spec:l,design:Ot(l.states,r),sizes:(l.sizes.length?l.sizes.map(a=>Ho(l.states,a)):[l.states]).map(a=>({states:a,size:Ot(a,r).size}))})),s=[],i=[];for(let l of Lx(e,!0)){let a=Ot(l.whole,r),c=Px(l,a);if(c&&c!=="link")continue;i.push(ka(l.whole,r));let u=Tp(l.whole,r),p=Nx(l),d={signature:u,places:p.length?p:[{path:l.source.path,line:l.source.line}],states:rn(l.whole),path:l.source.path,line:l.source.line,selector:l.source.selector,...p.length&&{used:!0},...l.variant.render&&{render:l.variant.render,whole:l.whole}},f=t.merged[jp(d.states)],m=o.find(v=>v.spec.id===f);if(m){s.push({...d,result:"exact",spec:m.spec,diff:[]});continue}let g=o.find(v=>v.spec.id===t.merged[u]);if(g){let v=A=>A.filter(E=>E.state!=="default"||E.context),$=g.sizes.map(A=>({diff:ma(v(l.whole),v(A.states),r),missing:ha(l.whole,A.states)})).sort((A,E)=>A.diff.length+A.missing.length-E.diff.length-E.missing.length)[0];s.push({...d,spec:g.spec,result:$.diff.length?$.diff.length<=3?"changed":"none":"exact",diff:$.diff,...$.missing.length?{missingStates:$.missing}:{}});continue}let S=v=>`${!!v.bg}|${v.bordered}|${v.square}`,h=(v,$)=>(S(v)===S(a)?0:1e3)+$.length,b=null;for(let v of o){let{size:$,diff:A,states:E}=v.sizes.map(z=>{let w=ba(a.size,z.size),R=ma(l.whole,z.states,r).filter(I=>!(a.square&&a.fontWeight===null&&I.state==="default"&&I.property==="font-weight"&&I.found===null));return{size:w,diff:[...R,...w],states:z.states}}).sort((z,w)=>z.diff.length-w.diff.length||z.size.length-w.size.length)[0]??{size:[],diff:ma(l.whole,v.spec.states,r),states:v.spec.states},O=!A.length&&!$.length,L=ha(l.whole,E);if(O&&!L.length){b={spec:v.spec,diff:[],exact:O,rank:0,states:E};break}let D=h(v.design,A)+L.length;(!b||D<b.rank)&&(b={spec:v.spec,diff:A,exact:O,rank:D,states:E})}let k=b?b.exact?"exact":b.diff.length<=3?"changed":"none":"none",y=k==="exact"?void 0:o.find(v=>!v.spec.from.some($=>$.selector===l.source.selector)&&v.sizes.every($=>ba(a.size,$.size).length)&&v.spec.from.some($=>Ox({selector:$.selector,states:v.spec.states},{selector:l.source.selector,states:l.whole},r)))?.spec,x=b&&(k==="exact"||b.spec.from.some(v=>v.path===l.source.path&&v.selector===l.source.selector))?ha(l.whole,b.states):[];s.push({...d,result:k,spec:b?.spec??null,diff:b?.diff??[],...y&&{newSizeOf:y,newSize:Fx(l,a,y,r)},...x.length&&{missingStates:x}})}return s.push(...Ux(n,t,i,r)),s}function Fx(e,t,n,r){let o=e.source.selector;if(/(?:--|[-_])(?:lg|large)(?:$|[.:\s])/i.test(o))return{label:"Large",named:!0};if(/(?:--|[-_])(?:sm|small)(?:$|[.:\s])/i.test(o))return{label:"Small",named:!0};if(/(?:--|[-_])(?:xs)(?:$|[.:\s])/i.test(o))return{label:"Extra small",named:!0};if(/(?:--|[-_])(?:xl)(?:$|[.:\s])/i.test(o))return{label:"Extra large",named:!0};let s=a=>{let c=Ot(a,r).size.height;return typeof c=="number"?c:null},i=typeof t.size.height=="number"?t.size.height:null,l=(n.sizes.length?n.sizes.map(a=>Ho(n.states,a)):[n.states]).map(s);if(i!==null&&l.length&&l.every(a=>a!==null)){if(l.every(a=>i>a+1))return{label:"Large",named:!0};if(l.every(a=>i<a-1))return{label:"Small",named:!0}}return{label:o,named:!1}}function Op(e){return e.result==="exact"?null:e.result==="changed"&&e.spec?`button:look-changed:${e.spec.id}:${Xe(e.diff.map(t=>`${t.state}|${t.property}=${t.found??""}`).sort().join(";"))}`:`button:look-new:${Dp(e)}`}function Mp(e){if(!e.missingStates?.length||!e.spec)return null;let t=[...new Set(e.missingStates.map(n=>n.label))];return`button:state-missing:${e.spec.id}:${Xe(t.sort().join(";"))}`}function Dp(e){let t=e.states.map(n=>`${n.target??""}|${n.state}|${n.context}|${n.declarations.filter(r=>!Mn.test(r.property)||n.state!=="default"||n.context).map(r=>`${r.property}:${r.value}`).sort().join(";")}`).sort().join(`
|
|
30
30
|
`);return Xe(`${e.signature}
|
|
31
31
|
${t}`)}function ka(e,t){return Ot(e.map(n=>({...n,declarations:n.declarations.map(r=>{let o=en(r.value,t);return{...r,value:ce(o)??o}})})),new Map)}var Ep={bg:"background-color",fg:"color",bd:"border-color",sh:"box-shadow",r:"border-radius"};function wa(e,t){let n=[];for(let s of Object.keys(Ep))s==="fg"&&e.parts.fg==="none"||e.parts[s]!==t.parts[s]&&n.push({property:Ep[s],state:"default",found:t.parts[s],expected:e.parts[s]});e.fontWeight&&t.fontWeight&&e.fontWeight!==t.fontWeight&&n.push({property:"font-weight",state:"default",found:t.fontWeight,expected:e.fontWeight});let r=Object.keys(e.size).filter(s=>s in t.size&&!/^p\d$/.test(s)&&s!=="line-height"&&s!=="gap"&&(s!=="width"||e.square)),o=s=>{let i={};for(let l of r)i[l]=s[l];for(let l of["p0","p1","p2","p3"])l in e.size&&(i[l]=s[l]??0);return i};return[...n,...ba(o(t.size),o(e.size))]}function Pp(e,t,n){let r=(e.sizes.length?e.sizes.map(o=>Ho(e.states,o)):[e.states]).map(o=>ka(o,n));return t.filter(o=>{let s=Ot(o.states,new Map);return r.some(i=>!wa(i,s).length)})}function Ux(e,t,n,r){let o=t.specs.map(i=>({spec:i,designs:(i.sizes.length?i.sizes.map(l=>Ho(i.states,l)):[i.states]).map(l=>ka(l,r))})),s=[];for(let i of e){let l=Ot(i.states,new Map);if(n.some(d=>!wa(d,l).length))continue;let a={live:!0,signature:i.signature,places:i.pages.map(d=>({path:d,line:0})),states:i.states,path:i.pages[0]??"/",line:0,selector:i.label?`the "${i.label}" button`:"a button"},c=o.find(d=>d.spec.id===(t.merged[jp(i.states,!0)]??t.merged[i.signature]));if(c){s.push({...a,result:"exact",spec:c.spec,diff:[]});continue}let u=d=>`${d.parts.bg!=="none"}|${d.bordered}|${d.square}`,p=null;for(let d of o)for(let f of d.designs){let m=wa(f,l),g=(u(f)===u(l)?0:1e3)+m.length;(!p||g<p.rank)&&(p={spec:d.spec,diff:m,rank:g})}s.push({...a,result:p?p.diff.length?p.diff.length<=3?"changed":"none":"exact":"none",spec:p?.spec??null,diff:p?.diff??[]})}return s}var xa=6,zx=/"([^"\\\n]{0,400})"|'([^'\\\n]{0,400})'|`([^`\\]{0,400})`/g,Gx=/\bclass(?:Name)?\s*=\s*(?:"([^"]*)"|'([^']*)')/g,Bx=/\b(?:styles?|classes|css|cls|s)\.([A-Za-z_]\w*)/g,xr=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Wx(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,r)=>r+t(n.slice(r.length)))}function Hx(e,t){let n=Wx(t),r=new Map,o=new Map,s=(l,a,c)=>{let u=l.get(a);u?u.push(c):l.set(a,[c])},i=(l,a)=>{for(let c of l.matchAll(/[\w-]+/g))s(r,c[0],a)};for(let l of n.matchAll(zx))i(l[1]??l[2]??l[3]??"",l.index);for(let l of n.matchAll(Gx))i(l[1]??l[2]??"",l.index);for(let l of n.matchAll(Bx))s(o,l[1],l.index);return{path:e,text:n,original:t,words:r,ids:o}}function Lp(e,t){let n=1;for(let r=e.indexOf(`
|
|
32
32
|
`);r!==-1&&r<t;)n++,r=e.indexOf(`
|
|
33
|
-
`,r+1);return n}var Vx=e=>e.replace(/[-_]+(\w)/g,(t,n)=>n.toUpperCase()),qx=/\[\s*([\w-]+)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*\]/g,Jx=new Set(["data-component","data-slot","role"]);function Np(e,t){return[...e.slice(Yt(e)).matchAll(qx)].map(r=>({name:r[1],value:r[2]??r[3]??r[4]??null})).filter(r=>!Jx.has(r.name)&&!(r.value!==null&&t.has(r.value.toLowerCase())))}function Fp(e){return[...e.slice(Yt(e)).matchAll(/\.((?:\\.|[\w-])+)/g)].map(n=>n[1].replace(/\\(.)/g,"$1"))}function va(e,t,n,r,o=!1,s=[],i=()=>null){let l=null,a=()=>l??=t.map(h=>Hx(h,e.get(h)??"")),c=new Map,u=h=>{let b=c.get(h);if(!b){let k=new RegExp(`["'\`]${xr(h)}["'\`]\\s*\\+`);b=a().filter(y=>y.text.includes(`${h}\${`)||k.test(y.text)),c.set(h,b)}return b},p=(h,b,k)=>Yu(_t(h.original,b,k,h.path),h.original,b,h.path,s,i),d=(h,b)=>({files:h.slice(0,xa).map(({file:k,offset:y,example:x})=>({path:k.path,line:Lp(k.text,y),...o?{example:x??p(k,y,b)}:{}})),fileCount:h.length}),f=(h,b,k)=>{let y=[],x=Vx(h);for(let v of a()){let $=[...r.has(h)?[]:v.words.get(h)??[],...v.ids.get(x)??v.ids.get(h)??[]],
|
|
34
|
-
`),r=0,o=[];for(let s=0;s<n.length;s++){let i=n[s];if(t.lastIndex=0,!!t.test(i)&&(r++,o.length<Hp)){let l=i.trim();o.push({line:s+1,text:l.length>$a?`${l.slice(0,$a)}\u2026`:l})}}return{count:r,lines:o}}function qp(e){let t=e.lastIndexOf("/");return t<0?"":e.slice(0,t)}function Jp(e){let t=[];for(let n of e.split("/"))!n||n==="."||(n===".."?t.pop():t.push(n));return t.join("/")}var Qx=["",".tsx",".ts",".jsx",".js",".mjs",".vue",".svelte",".css",".module.css",".scss","/index.tsx","/index.ts","/index.js"];function De(e,t,n){let r;if(t.startsWith("."))r=Jp(`${qp(e)}/${t}`);else if(t.startsWith("@/"))r=t.slice(2);else if(t.startsWith("~/"))r=t.slice(2);else if(t.startsWith("/"))r=t.slice(1);else return null;for(let o of Qx)if(n(r+o))return r+o;return null}var ev=/import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]|require\(\s*['"]([^'"]+)['"]\s*\)|@import\s+(?:url\()?['"]([^'"]+)['"]/g;function Sa(e){let t=[];for(let n of e.matchAll(ev)){let r=n[1]??n[2]??n[3];r&&t.push(r)}return t}var tv=/export\s+(?:default\s+)?(?:async\s+)?(?:function|const|let|class|var)\s+([A-Za-z_$][\w$]*)|export\s*\{([^}]*)\}/g;function Wp(e){let t=new Set;for(let n of e.matchAll(tv))if(n[1]&&t.add(n[1]),n[2])for(let r of n[2].split(",")){let o=r.trim().split(/\s+as\s+/).pop()?.trim();o&&t.add(o)}return[...t]}var Ca=/var\(\s*(--[\w-]+)/g;function Jo(e){return e.split(" \xB7 ").every(t=>t===""||/^@layer\b/i.test(t))}function Kp(e){let t=[];for(let n of e.matchAll(/(?:^|[;{}])\s*composes\s*:\s*([^;]+)/g)){let r=n[1].trim(),o=/^(.*?)\s+from\s+(['"]?)([^'"]+)\2\s*$/.exec(r);o?t.push({names:o[1].split(/\s+/).filter(Boolean),from:o[3]}):t.push({names:r.split(/\s+/).filter(Boolean),from:null})}return t}function nv(e,t,n){let r=t.startsWith(".")?Jp(`${qp(e)}/${t}`):t.startsWith("@/")?t.slice(2):t.startsWith("~/")||t.startsWith("/")?t.replace(/^~?\//,""):null;return r&&n(r)?r:De(e,t.replace(/\.(?:module\.)?(?:css|scss|sass|less)$/i,""),n)}function rv(e,t){let n=new Map;for(let[r,o]of e)if(Dn.test(r)){for(let s of
|
|
33
|
+
`,r+1);return n}var Vx=e=>e.replace(/[-_]+(\w)/g,(t,n)=>n.toUpperCase()),qx=/\[\s*([\w-]+)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*\]/g,Jx=new Set(["data-component","data-slot","role"]);function Np(e,t){return[...e.slice(Yt(e)).matchAll(qx)].map(r=>({name:r[1],value:r[2]??r[3]??r[4]??null})).filter(r=>!Jx.has(r.name)&&!(r.value!==null&&t.has(r.value.toLowerCase())))}function Fp(e){return[...e.slice(Yt(e)).matchAll(/\.((?:\\.|[\w-])+)/g)].map(n=>n[1].replace(/\\(.)/g,"$1"))}function va(e,t,n,r,o=!1,s=[],i=()=>null){let l=null,a=()=>l??=t.map(h=>Hx(h,e.get(h)??"")),c=new Map,u=h=>{let b=c.get(h);if(!b){let k=new RegExp(`["'\`]${xr(h)}["'\`]\\s*\\+`);b=a().filter(y=>y.text.includes(`${h}\${`)||k.test(y.text)),c.set(h,b)}return b},p=(h,b,k)=>Yu(_t(h.original,b,k,h.path),h.original,b,h.path,s,i),d=(h,b)=>({files:h.slice(0,xa).map(({file:k,offset:y,example:x})=>({path:k.path,line:Lp(k.text,y),...o?{example:x??p(k,y,b)}:{}})),fileCount:h.length}),f=(h,b,k)=>{let y=[],x=Vx(h);for(let v of a()){let $=[...r.has(h)?[]:v.words.get(h)??[],...v.ids.get(x)??v.ids.get(h)??[]],A=$[0];if(A===void 0)continue;let E=A,O;if(o)for(let L of $){let D=p(v,L,b);if(D.kind!=="other"&&(O||(E=L,O=D),!k||k(D))){E=L,O=D;break}}y.push({file:v,offset:E,example:O})}if(y.length)return{status:"used",...d(y,b)};for(let v=h.length-1;v>0;v--){if(h[v]!=="-"&&h[v]!=="_")continue;let $=h.slice(0,v+1),A=h.slice(v+1),E=u($);if(E.length===0||!A)continue;let O=$.slice(0,-1),L=new RegExp(`\\b${xr(O)}\\s*[=:]\\s*\\{?\\s*["'\`]${xr(A)}["'\`]`),D=[];for(let z of a()){let w=L.exec(z.text);w&&D.push({file:z,offset:w.index})}return D.length?{status:"used",via:`via ${O} prop`,...d(D,b)}:{status:"dynamic",via:`built as ${$}\${\u2026}`,...d(E.map(z=>({file:z,offset:0})),b)}}return{status:"unreferenced",files:[],fileCount:0}},m=(h,b)=>{let k=xr(h.name),y=h.value===null?new RegExp(`\\b${k}\\b`):new RegExp(`\\b${k}\\s*[=:]\\s*\\{?\\s*["'\`]${xr(h.value)}["'\`]`),x=[];for(let A of a()){let E=y.exec(A.text);E&&x.push({file:A,offset:E.index})}if(x.length)return{status:"used",via:`via ${h.name} attribute`,...d(x,b)};let v=new RegExp(`\\b${k}\\s*=\\s*\\{(?!\\s*["'\`])`),$=[];for(let A of a()){let E=v.exec(A.text);E&&$.push({file:A,offset:E.index})}return $.length?{status:"dynamic",via:`${h.name} is set from a variable`,...d($,b)}:{status:"unreferenced",files:[],fileCount:0}},g=new Map;if(o&&s.length>0)for(let h of a())for(let b of mr(h.path,h.text,s,i))for(let k of b.selects){let y=g.get(k)??[];y.push({file:h,offset:b.offset}),g.set(k,y)}let S={used:0,unknown:0,dynamic:1,unreferenced:2};for(let h of n){let b=Fp(h.selector),k=Np(h.selector,r),y=h.base&&/^\.[\w-]+$/.test(h.selector)?n.filter(D=>!D.base&&b.every(z=>D.element?.classes.includes(z))):[],x=y.length?D=>{let z=D.element;return!!(z&&b.every(w=>z.classes.includes(w))&&!y.some(w=>Fp(w.selector).every(R=>z.classes.includes(R))&&Np(w.selector,r).every(R=>R.name in z.attrs&&(R.value===null||z.attrs[R.name]===R.value))))}:void 0;if(b.length===0&&k.length===0){h.usage={status:"unknown",files:[],fileCount:0};continue}let v=[...b.map(D=>f(D,b,x)),...k.map(D=>m(D,b))];h.usage=v.reduce((D,z)=>S[z.status]>=S[D.status]?z:D);let $=h.element?.classes.find(D=>D.startsWith("__gs-recipe-")),A=$?g.get($):void 0;if(!A||A.length===0)continue;let E=new Set(h.usage.files.map(D=>D.path)),O=h.usage.fileCount,L=[...h.usage.files];for(let D of A)E.has(D.file.path)||(E.add(D.file.path),O+=1,!(L.length>=xa)&&L.push({path:D.file.path,line:Lp(D.file.text,D.offset),...o?{example:p(D.file,D.offset,[])}:{}}));h.usage={...h.usage,status:h.usage.status==="unknown"?"unknown":"used",files:L,fileCount:O}}}function Up(e,t,n){let r=[],o=new Set;for(let s of t)o.has(s.path)||(o.add(s.path),!(r.length>=xa)&&r.push({path:s.path,line:s.line,...n?{example:_t(e.get(s.path)??"",s.offset,[],s.path)}:{}}));return{status:"used",files:r,fileCount:o.size}}var Ra={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};var Hp=12,$a=200,Mt=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro)$/i,zp=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro|html?|mdx|erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,Dn=/\.(css|scss|sass|less|styl)$/i,Vp=/\.(mdx?|markdown|txt|rst|adoc)$/i,Gp=/(^|\/)(tokens?|design-tokens?|theme)[^/]*\.json$/i,Ge=/(^|\/)(__tests__|tests?|spec|e2e|cypress|playwright)(\/|$)|\.(test|spec)\.[a-z]+$/i,Kx=/(^|\/)(plans?|results?|changelogs?|history|archive)(\/|\.|$)|(^|\/)CHANGELOG/i;function Xx(e){return qo.test(e)&&!/(^|\/)README\.md$/i.test(e)?"instruction":Kx.test(e)?"record":"documentation"}var qo=/(^|\/)(AGENTS|CLAUDE|CONTRIBUTING|README|GUIDELINES?)\.md$|(^|\/)(eslint|stylelint|\.eslintrc|\.stylelintrc)[^/]*$|(^|\/)\.cursor\/|(^|\/)\.claude\//i;function Aa(e){return e.filter(t=>(Vp.test(t)||qo.test(t))&&!Ge.test(t)).map(t=>({path:t,kind:Xx(t)}))}function Dt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Zx(e){return(e.split("/").pop()??"").replace(/(\.module)?\.[^.]+$/i,"")}function Bp(e,t){let n=Zx(e).toLowerCase();return t.some(r=>{let o=r.toLowerCase();return n===o||n===`${o}s`})}function Yx(e,t){let n=1;for(let r=0;r<t;r++)e.charCodeAt(r)===10&&n++;return n}function Pt(e,t){let n=e.split(`
|
|
34
|
+
`),r=0,o=[];for(let s=0;s<n.length;s++){let i=n[s];if(t.lastIndex=0,!!t.test(i)&&(r++,o.length<Hp)){let l=i.trim();o.push({line:s+1,text:l.length>$a?`${l.slice(0,$a)}\u2026`:l})}}return{count:r,lines:o}}function qp(e){let t=e.lastIndexOf("/");return t<0?"":e.slice(0,t)}function Jp(e){let t=[];for(let n of e.split("/"))!n||n==="."||(n===".."?t.pop():t.push(n));return t.join("/")}var Qx=["",".tsx",".ts",".jsx",".js",".mjs",".vue",".svelte",".css",".module.css",".scss","/index.tsx","/index.ts","/index.js"];function De(e,t,n){let r;if(t.startsWith("."))r=Jp(`${qp(e)}/${t}`);else if(t.startsWith("@/"))r=t.slice(2);else if(t.startsWith("~/"))r=t.slice(2);else if(t.startsWith("/"))r=t.slice(1);else return null;for(let o of Qx)if(n(r+o))return r+o;return null}var ev=/import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]|require\(\s*['"]([^'"]+)['"]\s*\)|@import\s+(?:url\()?['"]([^'"]+)['"]/g;function Sa(e){let t=[];for(let n of e.matchAll(ev)){let r=n[1]??n[2]??n[3];r&&t.push(r)}return t}var tv=/export\s+(?:default\s+)?(?:async\s+)?(?:function|const|let|class|var)\s+([A-Za-z_$][\w$]*)|export\s*\{([^}]*)\}/g;function Wp(e){let t=new Set;for(let n of e.matchAll(tv))if(n[1]&&t.add(n[1]),n[2])for(let r of n[2].split(",")){let o=r.trim().split(/\s+as\s+/).pop()?.trim();o&&t.add(o)}return[...t]}var Ca=/var\(\s*(--[\w-]+)/g;function Jo(e){return e.split(" \xB7 ").every(t=>t===""||/^@layer\b/i.test(t))}function Kp(e){let t=[];for(let n of e.matchAll(/(?:^|[;{}])\s*composes\s*:\s*([^;]+)/g)){let r=n[1].trim(),o=/^(.*?)\s+from\s+(['"]?)([^'"]+)\2\s*$/.exec(r);o?t.push({names:o[1].split(/\s+/).filter(Boolean),from:o[3]}):t.push({names:r.split(/\s+/).filter(Boolean),from:null})}return t}function nv(e,t,n){let r=t.startsWith(".")?Jp(`${qp(e)}/${t}`):t.startsWith("@/")?t.slice(2):t.startsWith("~/")||t.startsWith("/")?t.replace(/^~?\//,""):null;return r&&n(r)?r:De(e,t.replace(/\.(?:module\.)?(?:css|scss|sass|less)$/i,""),n)}function rv(e,t){let n=new Map;for(let[r,o]of e)if(Dn.test(r)){for(let s of ze(o))if(Jo(s.context))for(let i of re(s.selector)){let l=/^\.([\w-]+)$/.exec(i.trim())?.[1];if(!l)continue;let a=`${r}\0${l}`,c=n.get(a)??{decls:[],composes:[]};c.decls.push(...we(s.ownBody));for(let u of Go(s.ownBody,t))u.state==="default"&&u.context===""&&c.decls.push(...u.declarations);c.composes.push(...Kp(s.ownBody)),n.set(a,c)}}return n}function ov(e,t,n,r){let o=[],s=new Set,i=(a,c,u)=>{if(u>4)return;let p=`${a}\0${c}`;if(s.has(p))return;s.add(p);let d=n.get(p);if(d){for(let f of d.composes)l(a,f,u+1);o.push(...d.decls)}},l=(a,c,u)=>{for(let p of c.names)if(c.from==="global")for(let d of n.keys()){let f=d.indexOf("\0"),m=d.slice(0,f);d.slice(f+1)!==p||/\.module\./i.test(m)||i(m,p,u)}else if(c.from){let d=nv(a,c.from,r);d&&i(d,p,u)}else i(a,p,u)};for(let a of Kp(t))l(e,a,0);return o}function sv(e,t){let n=xp(t);return n?re(e).map(r=>{let o=Math.max(r.lastIndexOf(" "),r.lastIndexOf(">"),r.lastIndexOf("+"),r.lastIndexOf("~"));return o<0?`${r}${n}`:`${r.slice(0,o+1)}${r.slice(o+1)}${n}`}).join(", "):e}var iv=/^(?::root|html|body|\*)$/i,av=25e4,lv=/<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g,cv=/\b(?:styles?|classes|css|cls)\s*(?:\.([A-Za-z_]\w*)|\[\s*["']([\w-]+)["']\s*\])/g,uv=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]);function pv(e){let t=new Set,n=new Set;for(let r of e.matchAll(lv)){let o=r[1],s=uv.has(o.toLowerCase())&&o===o.toLowerCase()?t:n;for(let i of r[2].matchAll(cv))s.add(i[1]??i[2])}return{parts:new Set([...t].filter(r=>!n.has(r))),controls:n}}function dv(e,t){let n=new Map;for(let r of t)if(Dn.test(r)){for(let o of ze(e.get(r)))if(Jo(o.context)&&re(o.selector).some(s=>iv.test(s)))for(let s of we(o.ownBody))s.property.startsWith("--")&&!n.has(s.property)&&n.set(s.property,s.value)}return n}function fv(e,t){let n=new Set,r=[],o=l=>{for(let a of l.matchAll(Ca))n.has(a[1])||(n.add(a[1]),r.push(a[1]))};for(let l of t)o(l);let s=[];for(let l=r.shift();l;l=r.shift()){let a=e.get(l);a===void 0||!ae(l,a)||(s.push(`${l}:${a}`),o(a))}return`${s.length?`:root{${s.join(";")}}
|
|
35
35
|
`:""}${t.join(`
|
|
36
|
-
`)}`.slice(0,av)}function Xp(e,t){let n=[...e.keys()].sort(),r=dv(e,n),o=new Set(r.keys()),s=C=>e.has(C),i=new Map,l=(C,j,M,U)=>{let K=`${j}:${C}`,se=i.get(K);if(se){se.note.includes(M)||(se.note+=`; ${M}`);return}i.set(K,{path:C,role:j,note:M,matches:U.count,lines:U.lines})},a=new Set,c=new Set;for(let C of n){if(!Mt.test(C)||
|
|
36
|
+
`)}`.slice(0,av)}function Xp(e,t){let n=[...e.keys()].sort(),r=dv(e,n),o=new Set(r.keys()),s=C=>e.has(C),i=new Map,l=(C,j,M,U)=>{let K=`${j}:${C}`,se=i.get(K);if(se){se.note.includes(M)||(se.note+=`; ${M}`);return}i.set(K,{path:C,role:j,note:M,matches:U.count,lines:U.lines})},a=new Set,c=new Set;for(let C of n){if(!Mt.test(C)||Ge.test(C))continue;let j=e.get(C),M=Wp(j).filter(X=>t.identifier.test(X)),U=C.split("/").pop()??"",K=new RegExp(t.classKeywords.join("|"),"i").test(U);if(M.length===0&&!K)continue;for(let X of M)a.add(X);c.add(C);let se=M.length?new RegExp(`\\b(?:${M.map(Dt).join("|")})\\b`,"g"):t.prose;l(C,"implements",M.length?`exports ${M.join(", ")}`:"named for the concept",Pt(j,se))}let u=new Set,p=[],d=[],f=[],m=new Map,g=C=>Bp(C,t.classKeywords)||/\.module\.[a-z]+$/i.test(C)&&m.has(C),S=null,h=()=>S??=rv(e,o),b=C=>{let j=g(C),M=[],U=0;for(let X of ze(e.get(C))){let fe=re(X.selector).filter(oe=>jn(oe,t,j));if(fe.length===0)continue;U+=1;for(let oe of X.ownBody.matchAll(Ca))u.add(oe[1]);let ie=Go(X.ownBody,o),Ie=[...ov(C,X.ownBody,h(),s),...we(X.ownBody),...ie.filter(oe=>oe.state==="default"&&oe.context==="").flatMap(oe=>oe.declarations)];for(let oe of Ie)for(let Oe of oe.value.matchAll(Ca))u.add(Oe[1]);M.push({block:X,parts:fe,declarations:Ie,previewContext:Jo(X.context)?"":null,listed:!0});for(let oe of ie){if(oe.state==="default"&&oe.context==="")continue;let Oe=sv(fe.join(", "),oe.state),Rt=re(Oe).filter(fo=>jn(fo,t,j));if(Rt.length===0)continue;let be=[X.context,oe.context].filter(Boolean).join(" \xB7 ");M.push({block:{...X,selector:Oe,context:be},parts:Rt,declarations:oe.declarations,previewContext:Jo(X.context)?oe.context:null,listed:!1})}}let K={parts:new Set,controls:new Set};for(let X of m.get(C)??[]){let fe=pv(e.get(X)??"");for(let ie of fe.parts)K.parts.add(ie);for(let ie of fe.controls)K.controls.add(ie)}p.push(...sp(C,M.map(({block:X,parts:fe,declarations:ie})=>({selector:fe.join(", "),declarations:ie,line:X.line,context:X.context})),t,j,K)),f.push(...M.map(({block:X,parts:fe,declarations:ie})=>({path:C,selector:fe.join(", "),declarations:ie.filter(Ie=>ae(Ie.property,Ie.value)),line:X.line,context:X.context})));let se=/\.module\.[a-z]+$/i.test(C)?`${Lu(C)} `:"";for(let{parts:X,declarations:fe,previewContext:ie}of M){if(ie===null)continue;let Ie=X.flatMap(Oe=>{let Rt=jn(Oe,t,j);return Rt?[`${se}${cr(Rt.compounds)}`]:[]}),oe=fe.filter(Oe=>ae(Oe.property,Oe.value));if(!(Ie.length===0||oe.length===0))for(let Oe of Ie)d.push(...pa(Oe,oe,ie))}return{count:U,lines:M.filter(X=>X.listed).slice(0,Hp).map(({block:X})=>({line:X.line,text:X.selector.replace(/\s+/g," ").slice(0,$a)}))}},k=new Map;for(let C of c)for(let j of Sa(e.get(C))){let M=De(C,j,s);if(M&&Dn.test(M)){let U=k.get(M)??[];U.push(C.split("/").pop()??C),k.set(M,U),Bp(C,t.classKeywords)&&m.set(M,[...m.get(M)??[],C])}}for(let C of n){if(!Dn.test(C))continue;let j=b(C),M=k.get(C);if(j.count===0)continue;let U=[];M&&U.push(`imported by ${M.join(", ")}`),j.count>0&&U.push(`${j.count} matching rule${j.count===1?"":"s"}`),l(C,"styles",U.join("; "),j)}let y=new Set;for(let C of p)for(let j of C.selector.matchAll(/\.((?:\\.|[\w-])+)/g))y.add(j[1].replace(/\\(.)/g,"$1"));let x=new Set(c),v=new RegExp([...t.elements.map(C=>`<${Dt(C)}\\b`),...t.roles.map(C=>`role=["']${Dt(C)}["']`)].join("|")),$=/<(?:a|Link|NavLink)\b[^>]*\bclassName=[^>]*\bbg-/;for(let C of n){if(!Mt.test(C)||Ge.test(C))continue;let j=e.get(C)??"";(v.test(j)||$.test(j))&&x.add(C)}for(let C of c)for(let j of Sa(e.get(C))){let M=De(C,j,s);!M||!Mt.test(M)||Ge.test(M)||Rp(M,t.classKeywords)&&x.add(M)}let A=0,E=[],O=[];for(let C of x){let j=Cp(C,e.get(C)??"",t,y,A,o);A=j.nextId,E.push(...j.recipes),p.push(...j.variants),O.push(...j.inline),d.push(...j.previewRules)}let L=Iu(O);p.push(...L.variants);let D=Qu([...c].map(C=>({path:C,source:e.get(C)??"",names:Wp(e.get(C)??"").filter(j=>t.identifier.test(j))})),E,(C,j)=>De(C,j,s)),z=[];if(u.size>0){let C=new RegExp(`(?:^|[\\s{;])(${[...u].map(Dt).join("|")})\\s*:`),j=new Map;for(let M of n){if(!Dn.test(M)&&!Gp.test(M))continue;let U=e.get(M),K=Pt(U,C);if(K.count!==0){for(let se of U.matchAll(new RegExp(C.source,"gm"))){let X=j.get(se[1])??[];X.includes(M)||X.push(M),j.set(se[1],X)}l(M,"tokens",`defines ${K.count} token${K.count===1?"":"s"} read by ${t.label.toLowerCase()} styles`,K)}}for(let M of[...u].sort())z.push({name:M,definedIn:j.get(M)??[]})}for(let C of n){if(!Gp.test(C))continue;let j=Pt(e.get(C),t.prose);j.count>0&&l(C,"tokens","token file mentions the concept",j)}let w=[...a],R=new RegExp([...w.length?[`<(?:${w.map(Dt).join("|")})\\b`]:[],...t.elements.map(C=>`<${Dt(C)}\\b`),...t.roles.map(C=>`role=["']${Dt(C)}["']`)].join("|"));for(let C of n){if(!Mt.test(C)||c.has(C))continue;let j=e.get(C),M=Ge.test(C),U=Pt(j,R),K=Sa(j).some(X=>{let fe=De(C,X,s);return fe!=null&&c.has(fe)});if(U.count===0&&!K)continue;let se=U.count>0?`${U.count} render${U.count===1?"":"s"}`:"imports a button component";l(C,M?"tests":"uses",se,U.count?U:Pt(j,t.prose))}for(let C of n){if(!(Vp.test(C)||qo.test(C)))continue;let M=e.get(C),U=Pt(M,t.prose);U.count!==0&&l(C,Ge.test(C)?"tests":"describes",qo.test(C)?"repo rules / instructions":"documentation",U)}for(let C of n){if(!Ge.test(C)||i.has(`tests:${C}`)||!Mt.test(C))continue;let j=Pt(e.get(C),t.prose);j.count>0&&l(C,"tests","mentions the concept",j)}let I=[...i.values()].sort((C,j)=>j.matches-C.matches||C.path.localeCompare(j.path)),N={implements:0,styles:0,tokens:0,uses:0,describes:0,tests:0};for(let C of I)N[C.role]++;let F=ip(p);va(e,n.filter(C=>zp.test(C)&&!Ge.test(C)),F,new Set(t.elements),!0,D,(C,j)=>De(C,j,s)),va(e,n.filter(C=>zp.test(C)&&!Ge.test(C)),F.flatMap(C=>C.modifiers??[]),new Set(t.elements));for(let C of F){if(!C.path.endsWith(tn))continue;let j=C.path.slice(0,-tn.length),M=C.usage.files.filter(U=>U.path===j);C.usage={...C.usage,files:M,fileCount:M.length,...M.length?{}:{status:"unreferenced"}}}for(let[C,j]of L.sites)C.usage=Up(e,j,!("alike"in C));let _=new Map(n.map((C,j)=>[C,j])),P=n.flatMap(C=>{if(!Dn.test(C))return[];let j=g(C);return ze(e.get(C)).flatMap(M=>{let U=re(M.selector).filter(se=>!jn(se,t,j));if(!U.length)return[];let K=we(M.ownBody).filter(se=>ae(se.property,se.value));return K.length?[{path:C,selector:U.join(", "),declarations:K,line:M.line,context:M.context,borrowed:!0}]:[]})});F.push(...hv(e,n.filter(C=>Mt.test(C)&&!Ge.test(C)),D,p,[...f,...P],o,(C,j)=>De(C,j,s))),F=tp(e,F,[...f,...P].sort((C,j)=>_.get(C.path)-_.get(j.path)||C.line-j.line));let T=[];if(a.size>0){let C=new RegExp(t.elements.map(j=>`<${Dt(j)}\\b`).join("|"),"g");for(let j of n){if(!Mt.test(j)||Ge.test(j)||c.has(j))continue;let M=e.get(j),U=(M.match(C)??[]).length;if(U===0)continue;let K=Pt(M,new RegExp(C.source));T.push({path:j,line:K.lines[0]?.line??1,count:U})}}let B=[],Y=new Set;for(let C of n){if(!Mt.test(C)||Ge.test(C))continue;let j=e.get(C),M=mr(C,j,D,(U,K)=>De(U,K,s));for(let U of M)for(let K of U.unknown){let se=[...K.known].sort();if(K.cls!==void 0){if(y.has(K.cls))continue;let ie=K.cls.slice(0,K.cls.length-K.value.length),Ie=[...y].filter(oe=>oe.startsWith(ie)&&oe.length>ie.length).map(oe=>oe.slice(ie.length));if(Ie.length===0)continue;se=[...new Set([...K.known,...Ie])].sort()}if(se.length===0)continue;let X=Yx(j,U.offset),fe=`${C}\0${U.component}\0${K.prop}\0${K.value}`;Y.has(fe)||(Y.add(fe),B.push({path:C,line:X,component:U.component,prop:K.prop,value:K.value,known:se}))}}let me=Aa(n);F.sort((C,j)=>Number(j.base)-Number(C.base)||C.path.localeCompare(j.path)||C.line-j.line);let J=No(e,me,t,F),te=hp([...m.entries()].map(([C,j])=>({sheet:C,sources:j.map(M=>e.get(M)??""),rules:ze(e.get(C)??"").map(M=>({selector:M.selector,declarations:we(M.ownBody)}))})));return{components:w.sort(),tokens:z,findings:I,variants:F,audit:fp({variants:F,tokens:z,tokenValues:r,hasComponent:a.size>0,nativeUses:T,unknownProps:B,guidance:J,noun:t.label.toLowerCase(),element:t.elements[0]??t.id}),guidance:J,content:te,previewCss:fv(r,d),recipeDefaults:E.flatMap(C=>C.axes.flatMap(j=>j.defaultValue?[{path:C.path,prop:j.prop,value:j.defaultValue}]:[])),counts:N}}var gv=/^(background(-color|-image)?|color|border(-.+)?|outline(-.+)?|box-shadow|opacity|font(-weight|-size|-family)?|letter-spacing|text-transform|padding(-.+)?|height|min-height|line-height|--.+)$/,mv=60;function hv(e,t,n,r,o,s,i){if(!n.length)return[];let l=new Map;for(let u of r){let p=u.element?.classes[0];p?.startsWith("__gs-recipe-")&&l.set(p,u.states)}let a=new Map;for(let u of o)for(let p of re(u.selector)){let d=ue(p);if(d?.length!==1)continue;let f=mt(d[0].simples),[m]=f.identity;if(!(f.identity.length!==1||m?.kind!=="class"))for(let g of[`${u.path}\0${m.name}`,`\0${m.name}`])g.startsWith("\0")&&/\.module\./.test(u.path)||a.set(g,[...a.get(g)??[],{state:nt(f.states),context:u.context,declarations:u.declarations}])}let c=new Map;for(let u of t){let p=e.get(u)??"";if(!p.includes("<"))continue;let d=new Map;for(let f of p.matchAll(/import\s+([A-Za-z_$][\w$]*)\s+from\s+["']([^"']+\.module\.[a-z]+)["']/g)){let m=i(u,f[2]);m&&d.set(f[1],m)}for(let f of mr(u,p,n,i)){if(c.size>=mv)break;if(!f.recipe)continue;let m=/\basChild\b/.test(f.attrs)?/<[A-Za-z][\w.]*\b((?:[^>"'{]|"[^"]*"|'[^']*'|\{[^}]*\})*?)\/?>/.exec(f.body)?.[1]:void 0,g=[];for(let $ of[f.attrs,m??""]){let A=da($);g.push(...fa(A.classes,s));for(let E of A.classes)g.push(...a.get(`\0${E}`)??[]);for(let E of A.modules){let O=d.get(E.ns);O&&g.push(...a.get(`${O}\0${E.name}`)??[])}g.push(...br($))}let S=g.map($=>({...$,declarations:$.declarations.filter(A=>gv.test(A.property))})).filter($=>$.declarations.length);if(!S.length)continue;let h=p.slice(0,f.offset).split(`
|
|
37
37
|
`).length,b=kr([...f.recipe.map($=>l.get($)??[]),S.map($=>({...$,line:h}))]),k=`${f.component}|${JSON.stringify(b)}`,y=c.get(k),x={path:u,line:h};if(y){y.places.push(x),y.usage.files.some($=>$.path===u)||y.usage.files.push(x),y.usage.fileCount=new Set(y.places.map($=>$.path)).size;continue}let v=f.body.replace(/<[^>]*>|\{[^}]*\}/g," ").replace(/\s+/g," ").trim();c.set(k,{title:v||f.component,axis:null,element:{tag:f.rootTag,classes:da(f.attrs).classes,attrs:{},ancestors:[]},usage:{status:"used",files:[x],fileCount:1},selector:`${f.component}[className]`,path:u,line:h,base:!1,markup:!0,callSite:!0,places:[x],states:b})}}return[...c.values()]}function Ea(e){let t=new Map;for(let[n,r]of e)dr.test(n)||(t.set(n,r),/\.(html?|vue|svelte|astro)$/i.test(n)&&/<style\b/i.test(r)&&t.set(`${n}${tn}`,r.replace(/([\s\S]*?)(<style\b[^>]*>)([\s\S]*?)(<\/style>|$)|[\s\S]+$/gi,(o,s,i,l,a)=>s===void 0?o.replace(/[^\n]/g,""):`${s.replace(/[^\n]/g,"")}${" ".repeat(i.length)}${l}${" ".repeat(a.length)}`)));return t}function Ta(e,t={}){let n=Ea(e),r=Xp(n,Ra);return{concept:"button",label:Ra.label,...r,repo:{fullName:"",ref:"",rootPath:"",htmlUrl:"",...t},index:{files:n.size,truncated:!1,skipped:0}}}var yv={"style.new":"look-new","state.changed":"look-changed","state.missing":"state-missing","native.element":"native-button","prop.unknown":"prop-unknown"},Yp=["background-color","background","color","border-color"];function bv(e){let t=e.observed?.declarations??e.baseline?.declarations??[];for(let n of Yp){let r=t.find(o=>o.property===n);if(r)return r}return t[0]??null}var Ko=e=>e.replaceAll("Design Contract","contract").replaceAll("ask for an exception","ask for review"),wv=new Set(["native-button","prop-unknown","state-missing"]);function kv(e){let t=e.filter(n=>n.state==="default"&&!n.context).flatMap(n=>n.declarations);for(let n of Yp){let r=t.findLast(o=>o.property===n);if(r)return r}return t[0]??null}function Zp(e,t,n,r,o){let s=a=>a.pages.map(c=>({fingerprint:null,page:c,viewport:{width:1440,height:900},state:"default",capturedAt:"",element:{selector:"",label:a.label},property:"appearance",value:a.signature,declared:null,via:[],...a.example?{picture:a.example}:{pictureMissing:"No picture was taken of this control."}}));if(e.live){let a=n.find(c=>c.signature===e.signature);return{definitions:[],definitionCount:0,observed:a?s(a).slice(0,10):[],gaps:["Found only on the live site; Grum found no code that draws it."]}}let i=o?Pp({states:e.states,sizes:[]},n,r):[];return{definitions:[{fingerprint:It({file:e.path,selector:e.selector,context:"",property:"button",value:e.signature}),place:t.find(a=>a.file===e.path&&a.line===e.line)??{file:e.path,line:e.line,snippet:e.selector},origin:"component",selector:e.selector,context:"",property:"button",value:e.signature,uses:e.used?t.map(a=>({...a,page:null})):[],useCount:e.used?t.length:0,...!e.used&&{unknown:"Grum found where the look is written, not an element that uses it"}}],definitionCount:1,observed:i.flatMap(s).slice(0,10),gaps:o?[]:["The difference is in an interaction state, which the resting capture doesn't show."]}}function xv(e,t,n,r,o=new Set){let s=new Map,i=Lo(e.previewCss),l=(u,p,d)=>ht(n.get(p)?.split(`
|
|
38
|
-
`)[d-1]??u.selector),a=(u,p,d)=>{for(let m of p)u.places.some(g=>g.file===m.file&&g.line===m.line)||u.places.push(m);u.uses=u.places.length;let f=u.evidence;for(let m of d.definitions)f.definitions.some(g=>g.fingerprint===m.fingerprint)||(f.definitions.push(m),f.definitionCount++);for(let m of d.observed)f.observed.length<10&&!f.observed.some(g=>g.page===m.page&&g.value===m.value)&&f.observed.push(m)},c=u=>({id:u.id,name:u.name,sizes:u.sizes.map(p=>p.label)});for(let u of Vo(e,t,r)){for(let
|
|
38
|
+
`)[d-1]??u.selector),a=(u,p,d)=>{for(let m of p)u.places.some(g=>g.file===m.file&&g.line===m.line)||u.places.push(m);u.uses=u.places.length;let f=u.evidence;for(let m of d.definitions)f.definitions.some(g=>g.fingerprint===m.fingerprint)||(f.definitions.push(m),f.definitionCount++);for(let m of d.observed)f.observed.length<10&&!f.observed.some(g=>g.page===m.page&&g.value===m.value)&&f.observed.push(m)},c=u=>({id:u.id,name:u.name,sizes:u.sizes.map(p=>p.label)});for(let u of Vo(e,t,r)){for(let A of u.missingStates??[])o.add(`${u.selector}|${A.state}`);let p=u.places.map(A=>({file:A.path,line:A.line,snippet:u.live?`On the live site: ${u.selector}`:l(u,A.path,A.line)}));if(u.missingStates?.length&&u.spec){let A=[...new Set(u.missingStates.map(D=>D.label))].sort(),E=Mp(u),O=Zp(u,p,r,i,!1),L=s.get(E);if(L)a(L,p,O);else{let D=u.missingStates[0];s.set(E,{key:E,area:"button",kind:"state-missing",title:`${u.spec.name}: approved ${A.join(", ")} state${A.length===1?" is":"s are"} missing`,found:A.join(", "),foundColor:null,property:D.state,uses:p.length,severity:"high",suggestion:null,action:"Use a contract button",places:p,fix:`The approved ${u.spec.name} has ${A.length===1?`a ${A[0]} state`:`${A.join(", ")} states`} (${D.expected}); this one (${u.selector}) doesn't. Restore it, or ask for review.`,evidence:O,button:{reason:"missing-state",spec:c(u.spec),selector:u.selector,states:A}})}}if(u.result==="exact")continue;let d=u.result==="changed"&&u.spec,f=u.newSizeOf,m=[...new Set(u.diff.map(A=>A.property))],g=u.diff[0],S=d?g&&{property:g.property,value:g.found??""}:kv(u.states),h=Op(u),b=d?u.diff.every(A=>A.state==="default"):!0,k=Zp(u,p,r,i,b),y=s.get(h);if(y){a(y,p,k);continue}let x=f?u.newSize??{label:u.selector,named:!1}:null,v=f?.sizes.map(A=>A.label)??[],$=(x?x.label:S?.value||(d?m.join(", "):"New button")).slice(0,300);s.set(h,{key:h,area:"button",kind:d?"look-changed":"look-new",title:f&&x?x.named?`${f.name} in ${x.label}, a size the contract doesn't have`:`${f.name} in a size the contract doesn't have (${x.label})`:d?`Overrides ${u.spec.name}: ${m.join(", ")}`:"New button",found:$,foundColor:x?null:S?ce(S.value):null,property:x?"size":S?.property??"",uses:p.length,severity:f?"medium":"high",suggestion:null,action:"Use a contract button",places:p,fix:f&&x?`${f.name} has ${vv(v)||"no sizes"} in the contract. This uses ${x.named?x.label:`another size (${x.label})`} with the same appearance and states. Request approval for ${x.named?x.label:"this size"}, or use an approved size.`:d?`Use ${u.spec.name} as it is, or ask for review.`:u.spec?`Use ${u.spec.name} or ask for review.`:"Use a contract button or ask for review.",evidence:k,button:{reason:f?"missing-size":d?"changed":"new",spec:f?c(f):u.spec?c(u.spec):null,...x&&{size:x},selector:u.selector}})}return[...s.values()]}var vv=e=>e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function Sv(e,t,n=new Map,r,o=[]){let s=[],i=new Set,l=r?xv(e,r,n,o,i):[],a=new Map(e.variants.map(c=>[Eo(c),c.selector]));for(let c of Ou(e,t)){let u=yv[c.kind];if(!u||r&&!wv.has(u)||u==="state-missing"&&c.styleId&&i.has(`${a.get(c.styleId)}|${c.state}`))continue;let p=c.styleId&&a.get(c.styleId)||Ko(c.title),d=c.refs.map(g=>({file:g.path,line:g.line,snippet:ht(n.get(g.path)?.split(`
|
|
39
39
|
`)[g.line-1]??p)}));if(!d.length)continue;let f=bv(c),m=(f?.value??(u==="native-button"?"<button>":Ko(c.title))).slice(0,300);s.push({key:`button:${u}:${c.id.slice(c.id.indexOf(":")+1)}`,area:"button",kind:u,title:Ko(c.title),found:m,foundColor:f?ce(f.value):null,property:f?.property??"",uses:d.length,severity:"high",suggestion:null,action:"Use a contract button",places:d,fix:Ko(c.fix),evidence:{definitions:[{fingerprint:It({file:d[0].file,selector:p,context:"",property:u,value:c.id}),place:d[0],origin:"component",selector:c.styleId&&a.get(c.styleId)||null,context:"",property:u,value:m,uses:d.map(g=>({...g,page:null})),useCount:d.length}],definitionCount:1,observed:[],gaps:["Grum doesn't match this kind of button finding to the live site yet."]}})}return[...l,...s]}function Qp(e,t,n){return Sv(Ta(e),t,e,n)}function Zo(e){let t=[],n="",r=0;for(let o of e.trim())o==="("?r++:o===")"&&(r=Math.max(0,r-1)),/\s/.test(o)&&r===0?(n&&t.push(n),n=""):n+=o;return n&&t.push(n),t}function $v(e){let t=e;return/^#[0-9a-f]{3,4}$/i.test(t)&&(t=`#${[...t.slice(1)].map(n=>n+n).join("")}`),t=t.replace(/(^|[\s(,/-])\.(\d)/g,"$10.$2"),t=t.replace(/(\d+\.\d*?)0+(?=[a-z%]|$|[\s),])/gi,"$1"),t=t.replace(/(\d)\.(?=[a-z%]|$|[\s),])/gi,"$1"),/^[+-]?0(?:\.0+)?(?:px|rem|em|%|vh|vw|ch|ex)?$/i.test(t)&&(t="0"),t}function Cv(e){let t=e.replace(/\s*!important\s*$/i,"").replace(/\s+/g," ").replace(/\(\s+/g,"(").replace(/\s+\)/g,")").replace(/\s*,\s*/g,",").trim().toLowerCase();return Zo(t).map($v).join(" ")}var _a=["top","right","bottom","left"],Rv=["top-left","top-right","bottom-right","bottom-left"];function Xo(e){let t=Zo(e),[n,r=n,o=n,s=r]=t;return[n??"",r??"",o??"",s??""]}var Av=/^(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/,Iv=/^(?:-?[\d.]+[a-z%]*|thin|medium|thick|0)$/;function ja(e){let t="medium",n="none",r=[];for(let o of Zo(e))Av.test(o)?n=o:Iv.test(o)?t=o:r.push(o);return{width:t,style:n,color:r.join(" ")||"currentcolor"}}function Yo(e,t){let n=e.toLowerCase(),r=Cv(t),o=(i,l,a)=>_a.map((c,u)=>[`${i}-${c}${l}`,a[u]]);if(n==="padding"||n==="margin")return o(n,"",Xo(r));let s=/^(padding|margin)-(inline|block)(?:-(start|end))?$/.exec(n);if(s){let[,i,l,a]=s,[c,u=c]=Zo(r),p=l==="inline"?["left","right"]:["top","bottom"];return a?[[`${i}-${p[a==="start"?0:1]}`,c??""]]:[[`${i}-${p[0]}`,c??""],[`${i}-${p[1]}`,u??""]]}if(n==="border-width"||n==="border-style"||n==="border-color"){let i=n.slice(7);return o("border",`-${i}`,Xo(r))}if(n==="border"||/^border-(top|right|bottom|left)$/.test(n)){let{width:i,style:l,color:a}=ja(r);return(n==="border"?_a:[n.slice(7)]).flatMap(u=>[[`border-${u}-width`,i],[`border-${u}-style`,l],[`border-${u}-color`,a]])}if(/^border-(inline|block)$/.test(n)){let{width:i,style:l,color:a}=ja(r);return(n==="border-inline"?["left","right"]:["top","bottom"]).flatMap(u=>[[`border-${u}-width`,i],[`border-${u}-style`,l],[`border-${u}-color`,a]])}if(n==="border-radius"&&!r.includes("/")){let i=Xo(r);return Rv.map((l,a)=>[`border-${l}-radius`,i[a]])}if(n==="outline"){if(r==="none"||r==="0")return[["outline-style","none"],["outline-width","medium"],["outline-color","currentcolor"]];let{width:i,style:l,color:a}=ja(r);return[["outline-width",i],["outline-style",l],["outline-color",a]]}return n==="inset"?_a.map((i,l)=>[i,Xo(r)[l]]):[[n,r]]}function vr(e){let t=new Map;for(let n of e)for(let[r,o]of Yo(n.property,n.value))t.delete(r),t.set(r,o);return t}function Ev(e){return e.state==="default"||!e.markers?"":Object.keys(e.markers).sort().join(",")}var Lt=e=>`${e.target}|${e.state}|${Ev(e)}|${e.context}`;function Tv(e){let t=[];for(let n of e)for(let[r,o]of vr(n.declarations))t.push(`${Lt(n)}|${r}=${o}`);return t.sort()}function ed(e){let t=Object.entries(e.attrs).filter(([n])=>n==="data-slot"||n==="role").map(([n,r])=>`${n}=${r}`).sort().join(",");return`${e.part}:${e.tag}${e.conditional?"?":""}[${t}](${e.children.map(ed).join(",")})`}var Pn=e=>ed(e.root);function td(e,t){return Xe(`${Pn(t)}
|
|
40
40
|
${Tv(e).join(`
|
|
41
41
|
`)}`)}var Pa=60,_v=60,jv=40,Ov=300;function sn(e){return e.sizes.length?e.sizes:[{label:"Default",states:e.states,fingerprint:e.fingerprint}]}var Sr=["top","right","bottom","left"],Mv=["top-left","top-right","bottom-right","bottom-left"];function Dv(e){let t=[],n=new Set,r=[["padding",o=>`padding-${o}`,Sr],["margin",o=>`margin-${o}`,Sr],["border-width",o=>`border-${o}-width`,Sr],["border-style",o=>`border-${o}-style`,Sr],["border-color",o=>`border-${o}-color`,Sr],["border-radius",o=>`border-${o}-radius`,Mv]];for(let o of e){if(n.has(o))continue;let s=r.find(([,i,l])=>l.some(a=>i(a)===o.property));if(s){let[i,l,a]=s,c=a.map(u=>e.find(p=>p.property===l(u)&&p.target===o.target&&p.state===o.state&&p.context===o.context));if(c.every(u=>u&&u.expected===o.expected&&u.found===o.found)){for(let u of c)n.add(u);t.push({...o,property:i});continue}}n.add(o),t.push(o)}return t}function Pv(e,t,n=!1){let r=new Map(e.map(l=>[Lt(l),l])),o=new Map(t.map(l=>[Lt(l),l])),s=[],i=[];for(let[l,a]of r){let c=o.get(l);if(!c){if(n)continue;if(a.state!=="default"){i.push({target:a.target,state:a.state,context:a.context,key:l});continue}}let u=vr(a.declarations),p=c?vr(c.declarations):new Map;for(let[d,f]of u){let m=p.get(d);m!==f&&(n&&m===void 0||s.push({target:a.target,state:a.state,context:a.context,property:d,expected:f,found:m??null}))}if(!n)for(let[d,f]of p)u.has(d)||s.push({target:a.target,state:a.state,context:a.context,property:d,expected:null,found:f})}if(!n){for(let[l,a]of o)if(!r.has(l))for(let[c,u]of vr(a.declarations))s.push({target:a.target,state:a.state,context:a.context,property:c,expected:null,found:u})}return{diff:Dv(s),missing:i}}var Lv=(e,t)=>({target:"structure",state:"default",context:"",property:"parts",expected:e,found:t});function nd(e,t){let n=null;for(let r of sn(t)){let{diff:o,missing:s}=Pv(r.states,e.states);Pn(t.render)!==Pn(e.render)&&o.unshift(Lv(Pn(t.render),Pn(e.render))),(!n||o.length+s.length<n.diff.length+n.missing.length)&&(n={size:r,diff:o,missing:s})}return n}function Nv(e,t){let n=[];for(let r of e.usages){let o=t.merged[r.fingerprint],s=o?t.specs.find(c=>c.id===o):void 0;if(s){n.push({result:"exact",spec:s,size:null,diff:[],missing:[],associated:!0,usage:r});continue}let i=t.specs.find(c=>sn(c).some(u=>u.fingerprint===r.fingerprint)),l=r.association?t.specs.find(c=>c.sources.includes(r.association)):void 0;if(i&&(!l||l===i)){let c=sn(i).find(u=>u.fingerprint===r.fingerprint);n.push({result:"exact",spec:i,size:c.label,diff:[],missing:[],associated:l===i,usage:r});continue}if(l){let c=nd(r,l);n.push({result:c.diff.length||c.missing.length?"changed":"exact",spec:l,size:c.size.label,diff:c.diff,missing:c.missing,associated:!0,usage:r});continue}let a=null;for(let c of t.specs){let u=nd(r,c),p=u.diff.length+u.missing.length;(!a||p<a.n)&&(a={spec:c,size:u.size.label,n:p})}n.push({result:"none",spec:a?.spec??null,size:a?.size??null,diff:[],missing:[],associated:!1,usage:r})}return n}function sd(e,t){return{structure:e.structure,type:e.type,states:e.states.slice(0,_v).map(n=>({...n,declarations:n.declarations.slice(0,jv).map(r=>({property:r.property,value:r.value.slice(0,Ov),...r.via?{via:r.via.slice(0,120)}:{}}))})),render:e.render,tailwind:e.tailwind,...t&&Object.keys(t).length?{tokenValues:{...t}}:{}}}var Oa=(e,t)=>{let n=sn(e).find(r=>r.label===t)??sn(e)[0];return sd({...e,states:n.states},e.tokenValues)};function Fv(e){return`${e.target}|${e.state}|${e.context}|${e.property}|${e.expected??"\u2205"}|${e.found??"\u2205"}`}function Uv(e,t,n){return`input:look-changed:${e}:${Xe(`${t??""}
|
|
42
42
|
${n.map(Fv).sort().join(`
|
|
43
43
|
`)}`)}`}function zv(e,t){return`input:state-missing:${e}:${Xe(t.map(n=>n.key).sort().join(`
|
|
44
44
|
`))}`}var Gv=e=>`input:look-new:${e}`,Ma=e=>e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`,Da=e=>e.replaceAll(" + "," and ");function Bv(e){for(let t of e)if(t.found&&/color|background/.test(t.property)){let n=ce(t.found);if(n)return n}return null}function on(e){return{file:e.path,line:e.line,snippet:e.example.source.split(`
|
|
45
|
-
`)[0].trim().slice(0,140)}}function rd(e,t){return{definitions:e.slice(0,20).map(r=>({fingerprint:It({file:r.usage.path,selector:r.usage.association??"",context:String(r.usage.line),property:"input",value:r.usage.fingerprint}),place:on(r.usage),origin:"component",selector:r.usage.association,context:"",property:"input",value:r.usage.fingerprint,uses:r.usage.via==="definition"?[]:[{...on(r.usage),page:null}],useCount:r.usage.via==="definition"?0:1,...r.usage.via==="definition"&&{unknown:"This is the component's definition; its uses are listed with the finding."}})),definitionCount:e.length,observed:[],gaps:t?["No live capture has matched this input yet."]:["The difference is in an interaction state, which a resting capture doesn't show."]}}var Wv=12,Hv=8;function Vv(e,t){let n=[],r=new Map;for(let o of t){if(o.found===null)continue;let s=`${o.target}|${o.state}|${o.context}`,i=r.get(s)??new Set;for(let[l]of Yo(o.property,"0"))i.add(l);r.set(s,i)}for(let o of e)for(let s of o.usage.states){let i=r.get(`${s.target}|${s.state}|${s.context}`);if(i)for(let l of s.declarations)!l.at||n.length>=Hv||Yo(l.property,l.value).some(([a])=>i.has(a))&&(n.some(a=>a.file===l.at.file&&a.line===l.at.line)||n.push({file:l.at.file,line:l.at.line,snippet:l.at.selector}))}return n}function od(e){return e.filter(t=>t.usage.via!=="definition").slice(0,Wv).map(t=>({file:t.usage.path,line:t.usage.line,identity:t.usage.identity,structure:t.usage.structure}))}function La(e,t){let n=new Map,r=e.tokenValues,o=(c,u,p)=>{let d=n.get(c);if(d){let f=on(u.usage);d.issue.places.some(m=>m.file===f.file&&m.line===f.line)||(d.issue.places.push(f),d.matches.push(u)),d.issue.uses=d.issue.places.length;return}n.set(c,{issue:p(),matches:[u]})},s=new Set,i=Nv(e,t);for(let c of i){let u=c.usage,p=sd(u,r);if(c.result==="exact")continue;if(s.add(`${u.path}:${u.line}`),c.result==="changed"&&c.spec){let f=c.spec;if(c.missing.length){let m=[...new Set(c.missing.map(S=>S.state))],g=zv(f.id,c.missing);o(g,c,()=>({key:g,area:"input",kind:"state-missing",title:`${f.name}: approved ${Ma(m.map(Da))} state${m.length===1?" is":"s are"} missing`,found:m.join(", ").slice(0,300),foundColor:null,property:m[0],uses:1,severity:"high",suggestion:null,action:"Use a contract input",places:[on(u)],fix:`The approved ${f.name} has ${m.length===1?`a ${Da(m[0])} state`:`${Ma(m.map(Da))} states`}; this one doesn't. Restore ${m.length===1?"it":"them"}, or ask for review.`,input:{reason:"missing-state",spec:{id:f.id,name:f.name},association:u.association,...c.size&&sn(f).length>1?{size:c.size}:{},diff:[],missing:m,fingerprint:u.fingerprint,approved:Oa(f,c.size),proposed:p}}))}if(c.diff.length){let m=Uv(f.id,c.size,c.diff),g=[...new Set(c.diff.map(h=>h.property))],S=c.diff.find(h=>h.found!==null)??c.diff[0];o(m,c,()=>({key:m,area:"input",kind:"look-changed",title:`Overrides ${f.name}: ${g.slice(0,4).join(", ")}${g.length>4?"\u2026":""}`,found:(S.found??`no ${S.property}`).slice(0,300),foundColor:Bv(c.diff),property:S.property,uses:1,severity:"high",suggestion:null,action:"Use a contract input",places:[on(u)],fix:`Use ${f.name} as it is, or ask for review.`,input:{reason:"changed",spec:{id:f.id,name:f.name},association:u.association,...c.size&&sn(f).length>1?{size:c.size}:{},diff:c.diff.slice(0,Pa),fingerprint:u.fingerprint,approved:Oa(f,c.size),proposed:p}}))}continue}let d=Gv(u.fingerprint);o(d,c,()=>({key:d,area:"input",kind:"look-new",title:u.structure==="field"?"New text field":"New input",found:(u.component?`<${u.component}>`:"<input>").slice(0,300),foundColor:null,property:"",uses:1,severity:"high",suggestion:null,action:"Use a contract input",places:[on(u)],fix:c.spec?`Use ${c.spec.name} or ask for review.`:"Use a contract input or ask for review.",input:{reason:"new",spec:c.spec?{id:c.spec.id,name:c.spec.name}:null,association:u.association,diff:[],fingerprint:u.fingerprint,...c.spec?{approved:Oa(c.spec,c.size)}:{},proposed:p}}))}for(let{issue:c,matches:u}of n.values()){if(c.uses=c.places.length,c.input&&(c.input.locators=od(u)),c.kind==="look-changed"&&c.input)for(let d of Vv(u,c.input.diff))c.places.some(f=>f.file===d.file&&f.line===d.line)||c.places.push(d);let p=!c.input?.diff.some(d=>d.state!=="default")&&!c.input?.missing?.length;c.evidence=rd(u,p)}let l=[...n.values()].map(c=>c.issue);if(e.definitions.length){let c=new Map;for(let u of i)u.usage.via!=="native"||u.result!=="exact"||!u.spec||u.spec.sources.some(p=>p.startsWith("component:"))&&c.set(u.spec.id,[...c.get(u.spec.id)??[],u]);for(let[u,p]of c){let d=p[0].spec,f=p.map(g=>on(g.usage)),m=d.sources.find(g=>g.startsWith("component:"))?.slice(10).split("?")[0];l.push({key:`input:native-input:${u}`,area:"input",kind:"native-input",title:`Raw <input> instead of ${m??d.name}`,found:"<input>",foundColor:null,property:"",uses:f.length,severity:"medium",suggestion:null,action:"Use a contract input",places:f,fix:`Render ${m??d.name} instead of a raw <input> with its look.`,evidence:rd(p,!0),input:{locators:od(p),reason:"native",spec:{id:d.id,name:d.name},association:p[0].usage.association,diff:[],fingerprint:p[0].usage.fingerprint}})}}let a=new Map;for(let c of e.unknownProps){let u=`input:prop-unknown:${c.component}:${c.prop}:${c.value}`;a.set(u,[...a.get(u)??[],c])}for(let[c,u]of a){let p=u[0],d=u.map(f=>({file:f.path,line:f.line,snippet:`<${f.component} ${f.prop}="${f.value}">`}));l.push({key:c,area:"input",kind:"prop-unknown",title:`<${p.component}> has no ${p.prop} "${p.value}"`,found:`${p.prop}="${p.value}"`.slice(0,300),foundColor:null,property:p.prop,uses:d.length,severity:"high",suggestion:null,action:"Use a contract input",places:d,fix:`Use one of ${Ma(p.known.map(f=>`${p.prop}="${f}"`))}.`,evidence:{definitions:[],definitionCount:0,observed:[],gaps:["The value selects no style, so the input renders without one."]},input:{reason:"prop-unknown",spec:null,association:`component:${p.component}`,diff:[],fingerprint:Xe(c)}})}return l}var id=["hover","focus","focus-visible","focus-within","active","placeholder-shown","autofill","read-only","disabled","required","invalid","user-invalid","aria-invalid","data-invalid"];function $r(e){let t=id.indexOf(e);return t===-1?id.length:t}function ld(e){let t=[...new Set(e)].sort((n,r)=>$r(n)-$r(r)||n.localeCompare(r));return t.length?t.join(" + "):"default"}var qv=e=>`__gs-s-${e.replace(/[^a-z0-9-]/gi,"")}`,it=e=>({state:e,marker:{classes:[qv(e)],attrs:{}}}),_e=(e,t,n="")=>({state:e,marker:{classes:[],attrs:{[t]:n}}}),Fa={hover:()=>it("hover"),focus:()=>it("focus"),"focus-visible":()=>it("focus-visible"),"focus-within":()=>it("focus-within"),active:()=>it("active"),"placeholder-shown":()=>it("placeholder-shown"),autofill:()=>it("autofill"),"-webkit-autofill":()=>it("autofill"),invalid:()=>it("invalid"),"user-invalid":()=>it("user-invalid"),disabled:()=>_e("disabled","disabled"),"read-only":()=>_e("read-only","readonly"),"-moz-read-only":()=>_e("read-only","readonly"),required:()=>_e("required","required")},Jv=new Set(["enabled","read-write","-moz-read-write","optional","valid","user-valid"]),Kv=new Set(["error","invalid","disabled","focus","focused","active","readonly","filled","dirty","touched","valid","success","warning"]),cd=/^(?:aria-(?:invalid|disabled|readonly|required|busy)|data-(?:disabled|invalid|readonly|focus|focused|focus-visible|hover|hovered|pressed|touched|dirty|filled|error|valid|required))$/,ud=/^(?:false|off|0)$/i;function pd(e){if(e.kind==="pseudo")return Jv.has(e.name)?"resting":e.name==="not"&&e.args?re(e.args).every(n=>{let r=tt(n);return r!==null&&r.every(o=>pd(o)!==null)})?"resting":null:Fa[e.name]?.()??null;if(e.kind==="attr"){if(e.name==="data-state"&&e.value)return _e(e.value.toLowerCase(),"data-state",e.value);if(e.name==="disabled")return _e("disabled","disabled");if(e.name==="readonly")return _e("read-only","readonly");if(e.name==="required")return _e("required","required");if(!cd.test(e.name))return null;if(e.value!==null&&ud.test(e.value))return"resting";let t=e.value??(e.name.startsWith("aria-")?"true":"");return _e(e.name,e.name,t)}if(e.kind==="class"){let t=e.name.toLowerCase();if(/^(?:is|has)-[\w-]+$/.test(t)||Kv.has(t))return{state:e.name,marker:{classes:[e.name],attrs:{}}}}return null}function Qo(e){let t=[],n=[],r={classes:[],attrs:{}},o=null;for(let s of e){if(s.kind==="pseudoElement"){o=s.name;continue}let i=pd(s);if(i!=="resting"){if(!i){t.push(s);continue}n.includes(i.state)||n.push(i.state);for(let l of i.marker.classes)r.classes.includes(l)||r.classes.push(l);Object.assign(r.attrs,i.marker.attrs)}}return{identity:t,states:n,marker:r,pseudo:o}}var Na={sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"},Xv="(prefers-color-scheme: dark)",Zv=new Set(["file"]);function ad(e){if(Fa[e])return Fa[e]();if(/^aria-(invalid|disabled|readonly|required|busy)$/.exec(e))return _e(e,e,"true");let n=/^aria-\[([\w-]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\]]*)))?\]$/.exec(e);if(n){let s=`aria-${n[1]}`,i=n[2]??n[3]??n[4]??"true";return!cd.test(s)||ud.test(i)?null:_e(s,s,i)}let r=/^data-([a-z][\w-]*)$/.exec(e);if(r)return _e(`data-${r[1]}`,`data-${r[1]}`);let o=/^data-\[([\w-]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\]]*)))?\]$/.exec(e);if(o){let s=o[1],i=o[2]??o[3]??o[4];return s==="state"&&i?_e(i.toLowerCase(),"data-state",i):_e(`data-${s}`,`data-${s}`,i??"")}return null}function Yv(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 r=[],o="",s=0;for(let l of t)l==="["||l==="("?s++:(l==="]"||l===")")&&(s=Math.max(0,s-1)),l===":"&&s===0?(r.push(o),o=""):o+=l;let i=o;return i?{parts:r,utility:i,important:n}:null}function Qv(e,t){if(t.size===0)return!0;for(let n of e)for(let r of n.value.matchAll(/var\((--[\w-]+),\s*var\((--color-[\w-]+)\)\)/g))if(!t.has(r[1])&&!t.has(r[2]))return!1;return!0}function e0(e,t){let n=yr(e,t);if(n)return Qv(n,t)?n:null;let r=/^ring-(\d+)$/.exec(e);return r?(yr("ring-2",t)??[]).map(o=>o.property==="--gs-ring-w"?{...o,value:`${r[1]}px`}:o):e==="shadow-xs"?[{property:"box-shadow",value:"0 1px 2px 0 rgb(0 0 0 / 0.05)"}]:null}function Ua(e,t){let n=Yv(e);if(!n)return null;let r=[],o=[],s=[],i=[],l=!1,a="self";for(let p of n.parts){if(Zv.has(p))return null;if(p==="placeholder"){a="placeholder";continue}if(p==="dark"){l=!0;continue}if(Na[p]){o.push(Na[p]);continue}let d=/^max-(sm|md|lg|xl|2xl)$/.exec(p);if(d){i.push(Na[d[1]]);continue}let f=/^min-\[([\d.]+(?:px|rem|em))\]$/.exec(p);if(f){o.push(f[1]);continue}let m=/^max-\[([\d.]+(?:px|rem|em))\]$/.exec(p);if(m){s.push(m[1]);continue}if(p==="enabled")continue;let g=/^group-(.+?)(?:\/[\w-]+)?$/.exec(p);if(g){let h=ad(g[1]);if(!h)return"uncertain";r.push({...h,carrier:"group"});continue}let S=ad(p);if(S){r.push({...S,carrier:"self"});continue}return"uncertain"}let c=e0(n.utility,t);if(!c)return null;let u=[];for(let p of o)u.push(`(min-width: ${p})`);for(let p of s)u.push(`(max-width: ${p})`);for(let p of i)u.push(`not all and (min-width: ${p})`);return l&&u.push(Xv),{token:e,target:a,states:r,context:u.length?`@media ${u.join(" and ")}`:"",declarations:c.map(p=>({property:p.property,value:n.important?`${p.value} !important`:p.value,via:e}))}}var md=/\.(css|scss|sass|less|pcss)$/i,hd=e=>/\.module\.[a-z]+$/i.test(e);function t0(e){let t=0;for(let n of e)for(let r of n.simples)r.kind==="id"?t+=100:r.kind==="tag"||r.kind==="pseudoElement"?t+=1:r.kind==="universal"||r.kind==="pseudo"&&r.name==="where"?t+=0:t+=10;return t}function yd(e){let t=new Map;for(let[n,r]of[...e].sort(([o],[s])=>o.localeCompare(s)))if(!(!md.test(n)&&!n.endsWith("#style.css"))){for(let o of Ge(r))if(!(!o.context.split(" \xB7 ").every(i=>i===""||/^@layer\b/i.test(i))||!re(o.selector).some(i=>/^(?::root|html|body|:host)$/i.test(i.trim()))))for(let i of we(o.ownBody))i.property.startsWith("--")&&!t.has(i.property)&&t.set(i.property,i.value)}return t}function bd(e,t){let n=[],r=0;for(let[o,s]of[...e].sort(([i],[l])=>i.localeCompare(l)))if(!(!md.test(o)&&!o.endsWith("#style.css")))for(let i of Ge(s)){let l=we(i.ownBody).filter(u=>!u.property.startsWith("@")&&ae(u.property,u.value)),a=[],c=[];for(let u of i.ownBody.matchAll(/@apply\s+([^;{}]+)/g))for(let p of Te(u[1])){let d=Ua(p,t);if(!d||d==="uncertain"||d.states.some(m=>m.carrier!=="self"))continue;let f={classes:[],attrs:{}};for(let m of d.states)f.classes.push(...m.marker.classes),Object.assign(f.attrs,m.marker.attrs);a.push({states:d.states.map(m=>m.state),marker:f,pseudo:d.target==="placeholder"?"placeholder":null}),c.push(d.declarations.filter(m=>ae(m.property,m.value)))}for(let u of re(i.selector)){let p=ue(u);if(!p)continue;let d={path:o,compounds:p,context:i.context.split(" \xB7 ").filter(f=>f&&!/^@layer\b/i.test(f)).join(" \xB7 "),line:i.line,specificity:t0(p),selector:u};l.length&&n.push({...d,declarations:l,order:r++}),a.forEach((f,m)=>{c[m].length&&n.push({...d,declarations:c[m],applied:f,order:r++})})}}return n}var dd=new WeakMap;function n0(e){let t=dd.get(e);if(t)return t;t=new Set;for(let n of e)for(let r of n.compounds)for(let o of r.simples)o.kind==="class"&&t.add(o.name);return dd.set(e,t),t}function r0(e,t){let n=e.attrs[t.name];if(n===void 0)return!1;let r=t.value??"";return t.op?t.op==="="?n===r:t.op==="~="?n.split(/\s+/).includes(r):t.op==="^="?r!==""&&n.startsWith(r):t.op==="$="?r!==""&&n.endsWith(r):t.op==="*="?r!==""&&n.includes(r):t.op==="|="?n===r||n.startsWith(`${r}-`):!1:!0}function wd(e,t,n){for(let r of t)if(r.kind==="tag"){if(e.tag!==r.name)return!1}else if(r.kind==="class"){if(!(hd(n.path)?e.modules.get(n.path)?.has(r.name):e.classes.includes(r.name)))return!1}else if(r.kind==="id"){if(e.attrs.id!==r.name)return!1}else if(r.kind==="attr"){if(!r0(e,r))return!1}else if(r.kind==="pseudo"){if(r.name==="root"){if(e.tag!=="html")return!1;continue}let o=r.args?re(r.args).map(tt):[];if(!/^(is|where|matches|any|not)$/.test(r.name)||o.some(l=>l===null))return"uncertain";let s=o.map(l=>{let a=Qo(l);return a.states.length||a.pseudo?"uncertain":wd(e,a.identity,n)});if(s.includes("uncertain"))return"uncertain";let i=s.some(l=>l===!0);if(r.name==="not"?i:!i)return!1}return!0}function za(e,t,n,r){let o=n.compounds[r],s=Qo(o.simples),i=wd(e[t],s.identity,n);if(i==="uncertain")return"uncertain";if(!i)return null;let l=[...s.states],a={classes:[...s.marker.classes],attrs:{...s.marker.attrs}},c=r===n.compounds.length-1?s.pseudo:null;if(r!==n.compounds.length-1&&s.pseudo)return null;r===n.compounds.length-1&&n.applied&&(l.push(...n.applied.states),a.classes.push(...n.applied.marker.classes),Object.assign(a.attrs,n.applied.marker.attrs),c=n.applied.pseudo??c);let u=l.length?[{node:t,states:l,marker:a}]:[];if(r===0)return{carriers:u,pseudo:c};let p=o.combinator;if(p==="+"||p==="~")return"uncertain";let d=e[t].parent,f=!1;for(;d>=0;){let m=za(e,d,n,r-1);if(m==="uncertain")f=!0;else if(m)return{carriers:[...m.carriers,...u],pseudo:c};if(p===">")break;d=e[d].parent}return f?"uncertain":null}var o0=/^(margin(-.+)?|width|min-width|max-width|flex|flex-(grow|shrink|basis)|align-self|justify-self|place-self|order|top|right|bottom|left|inset(-.+)?|z-index|float|clear|grid-(column|row|area)(-.+)?)$/,s0=/^(width|min-width|max-width|flex(-grow|-shrink|-basis)?|align-self|justify-self)$/;function i0(e,t,n){let r=n.property.toLowerCase();if(t){if(r==="position")return!/^\s*(relative|static)\b/.test(n.value);if(o0.test(r))return!0}return e.part==="control"&&s0.test(r)}function Ga(e,t,n=0){if(n>6||!e.includes("var("))return e;let r="",o=0;for(;;){let s=e.indexOf("var(",o);if(s<0)return r+e.slice(o);let i=1,l=-1,a=s+4;for(;a<e.length&&i>0;a++){let d=e[a];d==="("?i++:d===")"?i--:d===","&&i===1&&l<0&&(l=a)}if(i>0)return r+e.slice(o);let c=e.slice(s+4,l<0?a-1:l).trim(),u=l<0?void 0:e.slice(l+1,a-1).trim(),p;t.has(c)?p=Ga(t.get(c),t,n+1):c.startsWith("--gs-")?p=Ga(u??"",t,n+1):p=e.slice(s,a),r+=e.slice(o,s)+p,o=a}}var fd=["field","label","prefix","control","placeholder","suffix","help","error"],gd=e=>{let t=e.split("::")[0],n=fd.indexOf(t);return n===-1?fd.length+Number(/\d+/.exec(t)?.[0]??0):n};function a0(e){return e.sort((t,n)=>gd(t.target)-gd(n.target)||t.target.localeCompare(n.target)||+(t.context!=="")-+(n.context!=="")||t.context.localeCompare(n.context)||+(t.state!=="default")-+(n.state!=="default")||$r(t.state.split(" + ")[0])-$r(n.state.split(" + ")[0])||t.state.localeCompare(n.state)||Lt(t).localeCompare(Lt(n)))}function kd(e,t,n,r){let o=new Set,s=new Map,i=b=>b>=0&&e[b].part!=="",l=e.findIndex(b=>b.part==="control"),a=new Set,c=!1,u=!1,p=(b,k,y,x,v)=>{let $={},R=[];for(let z of y){let w=e[z.node].part,A=$[w]??={classes:[],attrs:{}};for(let E of z.marker.classes)A.classes.includes(E)||A.classes.push(E);Object.assign(A.attrs,z.marker.attrs),R.push(...z.states)}let I=ld(R),O={target:k,state:I,...I!=="default"?{markers:$}:{},context:x,node:b},L=Lt(O),D=s.get(L)??{...O,contributions:[]};D.contributions.push(v),s.set(L,D)};for(let b of t){let k=b.compounds.length-1,y=b.compounds[k];y.simples.every(x=>x.kind==="universal"||x.kind==="pseudo"&&x.name==="root")||e.forEach((x,v)=>{if(!i(v))return;let $=za(e,v,b,k);if($==="uncertain"){o.add(b.selector);return}if(!$)return;if($.carriers.some(O=>!i(O.node))){o.add(b.selector);return}let R=x.part;if($.pseudo==="placeholder"){if(x.part!=="control")return;R="placeholder"}else if($.pseudo==="before"||$.pseudo==="after")R=`${x.part}::${$.pseudo}`;else if($.pseudo)return;if(v===l){let L=Qo(y.simples).identity.filter(D=>D.kind==="class");for(let D of L)D.kind==="class"&&a.add(hd(b.path)?`${b.path}#${D.name}`:D.name);L.length||(c=!0)}let I={file:b.path.replace(/#style\.css$/,""),line:b.line,selector:b.selector.slice(0,140)};p(v,R,$.carriers,b.context,{layer:0,specificity:b.specificity,order:b.order,declarations:b.declarations.map(O=>({...O,at:I}))})})}let d=n0(t);e.forEach((b,k)=>{i(k)&&(b.classes.forEach((y,x)=>{if(d.has(y))return;let v=Ua(y,n);if(!v)return;if(v==="uncertain"){o.add(y);return}u=!0;let $=b.part;if(v.target==="placeholder"){if(b.part!=="control"){o.add(y);return}$="placeholder"}let R=[];for(let I of v.states){let O=k;if(I.carrier==="group"){O=-1;for(let L=b.parent;i(L);L=e[L].parent)if(e[L].classes.some(D=>/^group(?:\/[\w-]+)?$/.test(D))){O=L;break}if(O<0){o.add(y);return}}R.push({node:O,states:[I.state],marker:I.marker})}p(k,$,R,v.context,{layer:1,specificity:10,order:x,declarations:v.declarations.filter(I=>ae(I.property,I.value))})}),b.style.length&&p(k,b.part,[],"",{layer:2,specificity:1e3,order:0,declarations:b.style.filter(y=>ae(y.property,y.value))}))});let f=new Map;for(let[b,k]of s){let y=[...k.contributions].sort((v,$)=>v.layer-$.layer||v.specificity-$.specificity||v.order-$.order),x=new Map;for(let v of y)for(let $ of v.declarations){let R=$.property.toLowerCase(),I=x.get(R),O=/!important\s*$/i.test($.value);I&&/!important\s*$/i.test(I.value)&&!O||(x.delete(R),x.set(R,{...$,property:R}))}f.set(b,{slot:k,decls:[...x.values()]})}let m=new Map;e.forEach((b,k)=>{if(!(i(k)||b.tag==="html"))for(let y of t){if(y.context||y.applied)continue;let x=za(e,k,y,y.compounds.length-1);if(!(!x||x==="uncertain"||x.carriers.length||x.pseudo))for(let v of y.declarations)v.property.startsWith("--")&&r.get(v.property)!==v.value&&m.set(v.property,v.value)}});let g=b=>{let k=[];for(let y=b;i(y);y=e[y].parent)k.unshift(y);return k},S=[];for(let{slot:b,decls:k}of f.values()){let y=new Map(m);for(let R of g(b.node))for(let{slot:I,decls:O}of f.values())if(!(I.node!==R||I.target.includes("::")||I.target==="placeholder")&&!(I.state!=="default"&&I.state!==b.state)&&!(I.context!==""&&I.context!==b.context))for(let L of O)L.property.startsWith("--")&&y.set(L.property,L.value);let x=e[b.node],v=!i(x.parent),$=k.filter(R=>!R.property.startsWith("--")).filter(R=>b.target==="placeholder"||!i0(x,v,R)).map(R=>({...R,value:Ga(R.value,y).replace(/\s*!important\s*$/i,"").replace(/\s+/g," ").trim()})).filter(R=>R.value!=="");$.length&&S.push({target:b.target,state:b.state,...b.markers?{markers:b.markers}:{},context:b.context,declarations:$})}a0(S);let h=c0(e);return{states:S,render:h,fingerprint:td(S,h),tailwind:u,uncertain:[...o].sort().slice(0,20),controlRuleClasses:[...a].sort(),elementRules:c}}var l0=/^(type|role|data-slot|data-size|data-variant|aria-hidden)$/;function c0(e){let t=r=>{let o=e[r],s={};for(let[i,l]of Object.entries(o.attrs))l0.test(i)&&/^[\w -]{0,40}$/.test(l)&&(s[i]=l);return{part:o.part,tag:o.tag,attrs:s,...o.text?{text:o.text}:{},...o.conditional?{conditional:!0}:{},children:e.flatMap((i,l)=>i.part&&i.parent===r?[t(l)]:[])}},n=e.findIndex(r=>r.part!==""&&(r.parent<0||e[r.parent].part===""));return{root:t(n<0?0:n)}}var u0=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),p0=14,d0=240,es=e=>"tag"in e;function ts(e,t){let n=e[t];for(let r=t+1;r<e.length;r++){let o=e[r];if(o==="\\"){r++;continue}if(n==="`"&&o==="$"&&e[r+1]==="{"){r=Cr(e,r+1)-1;continue}if(o===n)return r+1;if(n!=="`"&&o===`
|
|
45
|
+
`)[0].trim().slice(0,140)}}function rd(e,t){return{definitions:e.slice(0,20).map(r=>({fingerprint:It({file:r.usage.path,selector:r.usage.association??"",context:String(r.usage.line),property:"input",value:r.usage.fingerprint}),place:on(r.usage),origin:"component",selector:r.usage.association,context:"",property:"input",value:r.usage.fingerprint,uses:r.usage.via==="definition"?[]:[{...on(r.usage),page:null}],useCount:r.usage.via==="definition"?0:1,...r.usage.via==="definition"&&{unknown:"This is the component's definition; its uses are listed with the finding."}})),definitionCount:e.length,observed:[],gaps:t?["No live capture has matched this input yet."]:["The difference is in an interaction state, which a resting capture doesn't show."]}}var Wv=12,Hv=8;function Vv(e,t){let n=[],r=new Map;for(let o of t){if(o.found===null)continue;let s=`${o.target}|${o.state}|${o.context}`,i=r.get(s)??new Set;for(let[l]of Yo(o.property,"0"))i.add(l);r.set(s,i)}for(let o of e)for(let s of o.usage.states){let i=r.get(`${s.target}|${s.state}|${s.context}`);if(i)for(let l of s.declarations)!l.at||n.length>=Hv||Yo(l.property,l.value).some(([a])=>i.has(a))&&(n.some(a=>a.file===l.at.file&&a.line===l.at.line)||n.push({file:l.at.file,line:l.at.line,snippet:l.at.selector}))}return n}function od(e){return e.filter(t=>t.usage.via!=="definition").slice(0,Wv).map(t=>({file:t.usage.path,line:t.usage.line,identity:t.usage.identity,structure:t.usage.structure}))}function La(e,t){let n=new Map,r=e.tokenValues,o=(c,u,p)=>{let d=n.get(c);if(d){let f=on(u.usage);d.issue.places.some(m=>m.file===f.file&&m.line===f.line)||(d.issue.places.push(f),d.matches.push(u)),d.issue.uses=d.issue.places.length;return}n.set(c,{issue:p(),matches:[u]})},s=new Set,i=Nv(e,t);for(let c of i){let u=c.usage,p=sd(u,r);if(c.result==="exact")continue;if(s.add(`${u.path}:${u.line}`),c.result==="changed"&&c.spec){let f=c.spec;if(c.missing.length){let m=[...new Set(c.missing.map(S=>S.state))],g=zv(f.id,c.missing);o(g,c,()=>({key:g,area:"input",kind:"state-missing",title:`${f.name}: approved ${Ma(m.map(Da))} state${m.length===1?" is":"s are"} missing`,found:m.join(", ").slice(0,300),foundColor:null,property:m[0],uses:1,severity:"high",suggestion:null,action:"Use a contract input",places:[on(u)],fix:`The approved ${f.name} has ${m.length===1?`a ${Da(m[0])} state`:`${Ma(m.map(Da))} states`}; this one doesn't. Restore ${m.length===1?"it":"them"}, or ask for review.`,input:{reason:"missing-state",spec:{id:f.id,name:f.name},association:u.association,...c.size&&sn(f).length>1?{size:c.size}:{},diff:[],missing:m,fingerprint:u.fingerprint,approved:Oa(f,c.size),proposed:p}}))}if(c.diff.length){let m=Uv(f.id,c.size,c.diff),g=[...new Set(c.diff.map(h=>h.property))],S=c.diff.find(h=>h.found!==null)??c.diff[0];o(m,c,()=>({key:m,area:"input",kind:"look-changed",title:`Overrides ${f.name}: ${g.slice(0,4).join(", ")}${g.length>4?"\u2026":""}`,found:(S.found??`no ${S.property}`).slice(0,300),foundColor:Bv(c.diff),property:S.property,uses:1,severity:"high",suggestion:null,action:"Use a contract input",places:[on(u)],fix:`Use ${f.name} as it is, or ask for review.`,input:{reason:"changed",spec:{id:f.id,name:f.name},association:u.association,...c.size&&sn(f).length>1?{size:c.size}:{},diff:c.diff.slice(0,Pa),fingerprint:u.fingerprint,approved:Oa(f,c.size),proposed:p}}))}continue}let d=Gv(u.fingerprint);o(d,c,()=>({key:d,area:"input",kind:"look-new",title:u.structure==="field"?"New text field":"New input",found:(u.component?`<${u.component}>`:"<input>").slice(0,300),foundColor:null,property:"",uses:1,severity:"high",suggestion:null,action:"Use a contract input",places:[on(u)],fix:c.spec?`Use ${c.spec.name} or ask for review.`:"Use a contract input or ask for review.",input:{reason:"new",spec:c.spec?{id:c.spec.id,name:c.spec.name}:null,association:u.association,diff:[],fingerprint:u.fingerprint,...c.spec?{approved:Oa(c.spec,c.size)}:{},proposed:p}}))}for(let{issue:c,matches:u}of n.values()){if(c.uses=c.places.length,c.input&&(c.input.locators=od(u)),c.kind==="look-changed"&&c.input)for(let d of Vv(u,c.input.diff))c.places.some(f=>f.file===d.file&&f.line===d.line)||c.places.push(d);let p=!c.input?.diff.some(d=>d.state!=="default")&&!c.input?.missing?.length;c.evidence=rd(u,p)}let l=[...n.values()].map(c=>c.issue);if(e.definitions.length){let c=new Map;for(let u of i)u.usage.via!=="native"||u.result!=="exact"||!u.spec||u.spec.sources.some(p=>p.startsWith("component:"))&&c.set(u.spec.id,[...c.get(u.spec.id)??[],u]);for(let[u,p]of c){let d=p[0].spec,f=p.map(g=>on(g.usage)),m=d.sources.find(g=>g.startsWith("component:"))?.slice(10).split("?")[0];l.push({key:`input:native-input:${u}`,area:"input",kind:"native-input",title:`Raw <input> instead of ${m??d.name}`,found:"<input>",foundColor:null,property:"",uses:f.length,severity:"medium",suggestion:null,action:"Use a contract input",places:f,fix:`Render ${m??d.name} instead of a raw <input> with its look.`,evidence:rd(p,!0),input:{locators:od(p),reason:"native",spec:{id:d.id,name:d.name},association:p[0].usage.association,diff:[],fingerprint:p[0].usage.fingerprint}})}}let a=new Map;for(let c of e.unknownProps){let u=`input:prop-unknown:${c.component}:${c.prop}:${c.value}`;a.set(u,[...a.get(u)??[],c])}for(let[c,u]of a){let p=u[0],d=u.map(f=>({file:f.path,line:f.line,snippet:`<${f.component} ${f.prop}="${f.value}">`}));l.push({key:c,area:"input",kind:"prop-unknown",title:`<${p.component}> has no ${p.prop} "${p.value}"`,found:`${p.prop}="${p.value}"`.slice(0,300),foundColor:null,property:p.prop,uses:d.length,severity:"high",suggestion:null,action:"Use a contract input",places:d,fix:`Use one of ${Ma(p.known.map(f=>`${p.prop}="${f}"`))}.`,evidence:{definitions:[],definitionCount:0,observed:[],gaps:["The value selects no style, so the input renders without one."]},input:{reason:"prop-unknown",spec:null,association:`component:${p.component}`,diff:[],fingerprint:Xe(c)}})}return l}var id=["hover","focus","focus-visible","focus-within","active","placeholder-shown","autofill","read-only","disabled","required","invalid","user-invalid","aria-invalid","data-invalid"];function $r(e){let t=id.indexOf(e);return t===-1?id.length:t}function ld(e){let t=[...new Set(e)].sort((n,r)=>$r(n)-$r(r)||n.localeCompare(r));return t.length?t.join(" + "):"default"}var qv=e=>`__gs-s-${e.replace(/[^a-z0-9-]/gi,"")}`,it=e=>({state:e,marker:{classes:[qv(e)],attrs:{}}}),_e=(e,t,n="")=>({state:e,marker:{classes:[],attrs:{[t]:n}}}),Fa={hover:()=>it("hover"),focus:()=>it("focus"),"focus-visible":()=>it("focus-visible"),"focus-within":()=>it("focus-within"),active:()=>it("active"),"placeholder-shown":()=>it("placeholder-shown"),autofill:()=>it("autofill"),"-webkit-autofill":()=>it("autofill"),invalid:()=>it("invalid"),"user-invalid":()=>it("user-invalid"),disabled:()=>_e("disabled","disabled"),"read-only":()=>_e("read-only","readonly"),"-moz-read-only":()=>_e("read-only","readonly"),required:()=>_e("required","required")},Jv=new Set(["enabled","read-write","-moz-read-write","optional","valid","user-valid"]),Kv=new Set(["error","invalid","disabled","focus","focused","active","readonly","filled","dirty","touched","valid","success","warning"]),cd=/^(?:aria-(?:invalid|disabled|readonly|required|busy)|data-(?:disabled|invalid|readonly|focus|focused|focus-visible|hover|hovered|pressed|touched|dirty|filled|error|valid|required))$/,ud=/^(?:false|off|0)$/i;function pd(e){if(e.kind==="pseudo")return Jv.has(e.name)?"resting":e.name==="not"&&e.args?re(e.args).every(n=>{let r=tt(n);return r!==null&&r.every(o=>pd(o)!==null)})?"resting":null:Fa[e.name]?.()??null;if(e.kind==="attr"){if(e.name==="data-state"&&e.value)return _e(e.value.toLowerCase(),"data-state",e.value);if(e.name==="disabled")return _e("disabled","disabled");if(e.name==="readonly")return _e("read-only","readonly");if(e.name==="required")return _e("required","required");if(!cd.test(e.name))return null;if(e.value!==null&&ud.test(e.value))return"resting";let t=e.value??(e.name.startsWith("aria-")?"true":"");return _e(e.name,e.name,t)}if(e.kind==="class"){let t=e.name.toLowerCase();if(/^(?:is|has)-[\w-]+$/.test(t)||Kv.has(t))return{state:e.name,marker:{classes:[e.name],attrs:{}}}}return null}function Qo(e){let t=[],n=[],r={classes:[],attrs:{}},o=null;for(let s of e){if(s.kind==="pseudoElement"){o=s.name;continue}let i=pd(s);if(i!=="resting"){if(!i){t.push(s);continue}n.includes(i.state)||n.push(i.state);for(let l of i.marker.classes)r.classes.includes(l)||r.classes.push(l);Object.assign(r.attrs,i.marker.attrs)}}return{identity:t,states:n,marker:r,pseudo:o}}var Na={sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"},Xv="(prefers-color-scheme: dark)",Zv=new Set(["file"]);function ad(e){if(Fa[e])return Fa[e]();if(/^aria-(invalid|disabled|readonly|required|busy)$/.exec(e))return _e(e,e,"true");let n=/^aria-\[([\w-]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\]]*)))?\]$/.exec(e);if(n){let s=`aria-${n[1]}`,i=n[2]??n[3]??n[4]??"true";return!cd.test(s)||ud.test(i)?null:_e(s,s,i)}let r=/^data-([a-z][\w-]*)$/.exec(e);if(r)return _e(`data-${r[1]}`,`data-${r[1]}`);let o=/^data-\[([\w-]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\]]*)))?\]$/.exec(e);if(o){let s=o[1],i=o[2]??o[3]??o[4];return s==="state"&&i?_e(i.toLowerCase(),"data-state",i):_e(`data-${s}`,`data-${s}`,i??"")}return null}function Yv(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 r=[],o="",s=0;for(let l of t)l==="["||l==="("?s++:(l==="]"||l===")")&&(s=Math.max(0,s-1)),l===":"&&s===0?(r.push(o),o=""):o+=l;let i=o;return i?{parts:r,utility:i,important:n}:null}function Qv(e,t){if(t.size===0)return!0;for(let n of e)for(let r of n.value.matchAll(/var\((--[\w-]+),\s*var\((--color-[\w-]+)\)\)/g))if(!t.has(r[1])&&!t.has(r[2]))return!1;return!0}function e0(e,t){let n=yr(e,t);if(n)return Qv(n,t)?n:null;let r=/^ring-(\d+)$/.exec(e);return r?(yr("ring-2",t)??[]).map(o=>o.property==="--gs-ring-w"?{...o,value:`${r[1]}px`}:o):e==="shadow-xs"?[{property:"box-shadow",value:"0 1px 2px 0 rgb(0 0 0 / 0.05)"}]:null}function Ua(e,t){let n=Yv(e);if(!n)return null;let r=[],o=[],s=[],i=[],l=!1,a="self";for(let p of n.parts){if(Zv.has(p))return null;if(p==="placeholder"){a="placeholder";continue}if(p==="dark"){l=!0;continue}if(Na[p]){o.push(Na[p]);continue}let d=/^max-(sm|md|lg|xl|2xl)$/.exec(p);if(d){i.push(Na[d[1]]);continue}let f=/^min-\[([\d.]+(?:px|rem|em))\]$/.exec(p);if(f){o.push(f[1]);continue}let m=/^max-\[([\d.]+(?:px|rem|em))\]$/.exec(p);if(m){s.push(m[1]);continue}if(p==="enabled")continue;let g=/^group-(.+?)(?:\/[\w-]+)?$/.exec(p);if(g){let h=ad(g[1]);if(!h)return"uncertain";r.push({...h,carrier:"group"});continue}let S=ad(p);if(S){r.push({...S,carrier:"self"});continue}return"uncertain"}let c=e0(n.utility,t);if(!c)return null;let u=[];for(let p of o)u.push(`(min-width: ${p})`);for(let p of s)u.push(`(max-width: ${p})`);for(let p of i)u.push(`not all and (min-width: ${p})`);return l&&u.push(Xv),{token:e,target:a,states:r,context:u.length?`@media ${u.join(" and ")}`:"",declarations:c.map(p=>({property:p.property,value:n.important?`${p.value} !important`:p.value,via:e}))}}var md=/\.(css|scss|sass|less|pcss)$/i,hd=e=>/\.module\.[a-z]+$/i.test(e);function t0(e){let t=0;for(let n of e)for(let r of n.simples)r.kind==="id"?t+=100:r.kind==="tag"||r.kind==="pseudoElement"?t+=1:r.kind==="universal"||r.kind==="pseudo"&&r.name==="where"?t+=0:t+=10;return t}function yd(e){let t=new Map;for(let[n,r]of[...e].sort(([o],[s])=>o.localeCompare(s)))if(!(!md.test(n)&&!n.endsWith("#style.css"))){for(let o of ze(r))if(!(!o.context.split(" \xB7 ").every(i=>i===""||/^@layer\b/i.test(i))||!re(o.selector).some(i=>/^(?::root|html|body|:host)$/i.test(i.trim()))))for(let i of we(o.ownBody))i.property.startsWith("--")&&!t.has(i.property)&&t.set(i.property,i.value)}return t}function bd(e,t){let n=[],r=0;for(let[o,s]of[...e].sort(([i],[l])=>i.localeCompare(l)))if(!(!md.test(o)&&!o.endsWith("#style.css")))for(let i of ze(s)){let l=we(i.ownBody).filter(u=>!u.property.startsWith("@")&&ae(u.property,u.value)),a=[],c=[];for(let u of i.ownBody.matchAll(/@apply\s+([^;{}]+)/g))for(let p of Te(u[1])){let d=Ua(p,t);if(!d||d==="uncertain"||d.states.some(m=>m.carrier!=="self"))continue;let f={classes:[],attrs:{}};for(let m of d.states)f.classes.push(...m.marker.classes),Object.assign(f.attrs,m.marker.attrs);a.push({states:d.states.map(m=>m.state),marker:f,pseudo:d.target==="placeholder"?"placeholder":null}),c.push(d.declarations.filter(m=>ae(m.property,m.value)))}for(let u of re(i.selector)){let p=ue(u);if(!p)continue;let d={path:o,compounds:p,context:i.context.split(" \xB7 ").filter(f=>f&&!/^@layer\b/i.test(f)).join(" \xB7 "),line:i.line,specificity:t0(p),selector:u};l.length&&n.push({...d,declarations:l,order:r++}),a.forEach((f,m)=>{c[m].length&&n.push({...d,declarations:c[m],applied:f,order:r++})})}}return n}var dd=new WeakMap;function n0(e){let t=dd.get(e);if(t)return t;t=new Set;for(let n of e)for(let r of n.compounds)for(let o of r.simples)o.kind==="class"&&t.add(o.name);return dd.set(e,t),t}function r0(e,t){let n=e.attrs[t.name];if(n===void 0)return!1;let r=t.value??"";return t.op?t.op==="="?n===r:t.op==="~="?n.split(/\s+/).includes(r):t.op==="^="?r!==""&&n.startsWith(r):t.op==="$="?r!==""&&n.endsWith(r):t.op==="*="?r!==""&&n.includes(r):t.op==="|="?n===r||n.startsWith(`${r}-`):!1:!0}function wd(e,t,n){for(let r of t)if(r.kind==="tag"){if(e.tag!==r.name)return!1}else if(r.kind==="class"){if(!(hd(n.path)?e.modules.get(n.path)?.has(r.name):e.classes.includes(r.name)))return!1}else if(r.kind==="id"){if(e.attrs.id!==r.name)return!1}else if(r.kind==="attr"){if(!r0(e,r))return!1}else if(r.kind==="pseudo"){if(r.name==="root"){if(e.tag!=="html")return!1;continue}let o=r.args?re(r.args).map(tt):[];if(!/^(is|where|matches|any|not)$/.test(r.name)||o.some(l=>l===null))return"uncertain";let s=o.map(l=>{let a=Qo(l);return a.states.length||a.pseudo?"uncertain":wd(e,a.identity,n)});if(s.includes("uncertain"))return"uncertain";let i=s.some(l=>l===!0);if(r.name==="not"?i:!i)return!1}return!0}function za(e,t,n,r){let o=n.compounds[r],s=Qo(o.simples),i=wd(e[t],s.identity,n);if(i==="uncertain")return"uncertain";if(!i)return null;let l=[...s.states],a={classes:[...s.marker.classes],attrs:{...s.marker.attrs}},c=r===n.compounds.length-1?s.pseudo:null;if(r!==n.compounds.length-1&&s.pseudo)return null;r===n.compounds.length-1&&n.applied&&(l.push(...n.applied.states),a.classes.push(...n.applied.marker.classes),Object.assign(a.attrs,n.applied.marker.attrs),c=n.applied.pseudo??c);let u=l.length?[{node:t,states:l,marker:a}]:[];if(r===0)return{carriers:u,pseudo:c};let p=o.combinator;if(p==="+"||p==="~")return"uncertain";let d=e[t].parent,f=!1;for(;d>=0;){let m=za(e,d,n,r-1);if(m==="uncertain")f=!0;else if(m)return{carriers:[...m.carriers,...u],pseudo:c};if(p===">")break;d=e[d].parent}return f?"uncertain":null}var o0=/^(margin(-.+)?|width|min-width|max-width|flex|flex-(grow|shrink|basis)|align-self|justify-self|place-self|order|top|right|bottom|left|inset(-.+)?|z-index|float|clear|grid-(column|row|area)(-.+)?)$/,s0=/^(width|min-width|max-width|flex(-grow|-shrink|-basis)?|align-self|justify-self)$/;function i0(e,t,n){let r=n.property.toLowerCase();if(t){if(r==="position")return!/^\s*(relative|static)\b/.test(n.value);if(o0.test(r))return!0}return e.part==="control"&&s0.test(r)}function Ga(e,t,n=0){if(n>6||!e.includes("var("))return e;let r="",o=0;for(;;){let s=e.indexOf("var(",o);if(s<0)return r+e.slice(o);let i=1,l=-1,a=s+4;for(;a<e.length&&i>0;a++){let d=e[a];d==="("?i++:d===")"?i--:d===","&&i===1&&l<0&&(l=a)}if(i>0)return r+e.slice(o);let c=e.slice(s+4,l<0?a-1:l).trim(),u=l<0?void 0:e.slice(l+1,a-1).trim(),p;t.has(c)?p=Ga(t.get(c),t,n+1):c.startsWith("--gs-")?p=Ga(u??"",t,n+1):p=e.slice(s,a),r+=e.slice(o,s)+p,o=a}}var fd=["field","label","prefix","control","placeholder","suffix","help","error"],gd=e=>{let t=e.split("::")[0],n=fd.indexOf(t);return n===-1?fd.length+Number(/\d+/.exec(t)?.[0]??0):n};function a0(e){return e.sort((t,n)=>gd(t.target)-gd(n.target)||t.target.localeCompare(n.target)||+(t.context!=="")-+(n.context!=="")||t.context.localeCompare(n.context)||+(t.state!=="default")-+(n.state!=="default")||$r(t.state.split(" + ")[0])-$r(n.state.split(" + ")[0])||t.state.localeCompare(n.state)||Lt(t).localeCompare(Lt(n)))}function kd(e,t,n,r){let o=new Set,s=new Map,i=b=>b>=0&&e[b].part!=="",l=e.findIndex(b=>b.part==="control"),a=new Set,c=!1,u=!1,p=(b,k,y,x,v)=>{let $={},A=[];for(let z of y){let w=e[z.node].part,R=$[w]??={classes:[],attrs:{}};for(let I of z.marker.classes)R.classes.includes(I)||R.classes.push(I);Object.assign(R.attrs,z.marker.attrs),A.push(...z.states)}let E=ld(A),O={target:k,state:E,...E!=="default"?{markers:$}:{},context:x,node:b},L=Lt(O),D=s.get(L)??{...O,contributions:[]};D.contributions.push(v),s.set(L,D)};for(let b of t){let k=b.compounds.length-1,y=b.compounds[k];y.simples.every(x=>x.kind==="universal"||x.kind==="pseudo"&&x.name==="root")||e.forEach((x,v)=>{if(!i(v))return;let $=za(e,v,b,k);if($==="uncertain"){o.add(b.selector);return}if(!$)return;if($.carriers.some(O=>!i(O.node))){o.add(b.selector);return}let A=x.part;if($.pseudo==="placeholder"){if(x.part!=="control")return;A="placeholder"}else if($.pseudo==="before"||$.pseudo==="after")A=`${x.part}::${$.pseudo}`;else if($.pseudo)return;if(v===l){let L=Qo(y.simples).identity.filter(D=>D.kind==="class");for(let D of L)D.kind==="class"&&a.add(hd(b.path)?`${b.path}#${D.name}`:D.name);L.length||(c=!0)}let E={file:b.path.replace(/#style\.css$/,""),line:b.line,selector:b.selector.slice(0,140)};p(v,A,$.carriers,b.context,{layer:0,specificity:b.specificity,order:b.order,declarations:b.declarations.map(O=>({...O,at:E}))})})}let d=n0(t);e.forEach((b,k)=>{i(k)&&(b.classes.forEach((y,x)=>{if(d.has(y))return;let v=Ua(y,n);if(!v)return;if(v==="uncertain"){o.add(y);return}u=!0;let $=b.part;if(v.target==="placeholder"){if(b.part!=="control"){o.add(y);return}$="placeholder"}let A=[];for(let E of v.states){let O=k;if(E.carrier==="group"){O=-1;for(let L=b.parent;i(L);L=e[L].parent)if(e[L].classes.some(D=>/^group(?:\/[\w-]+)?$/.test(D))){O=L;break}if(O<0){o.add(y);return}}A.push({node:O,states:[E.state],marker:E.marker})}p(k,$,A,v.context,{layer:1,specificity:10,order:x,declarations:v.declarations.filter(E=>ae(E.property,E.value))})}),b.style.length&&p(k,b.part,[],"",{layer:2,specificity:1e3,order:0,declarations:b.style.filter(y=>ae(y.property,y.value))}))});let f=new Map;for(let[b,k]of s){let y=[...k.contributions].sort((v,$)=>v.layer-$.layer||v.specificity-$.specificity||v.order-$.order),x=new Map;for(let v of y)for(let $ of v.declarations){let A=$.property.toLowerCase(),E=x.get(A),O=/!important\s*$/i.test($.value);E&&/!important\s*$/i.test(E.value)&&!O||(x.delete(A),x.set(A,{...$,property:A}))}f.set(b,{slot:k,decls:[...x.values()]})}let m=new Map;e.forEach((b,k)=>{if(!(i(k)||b.tag==="html"))for(let y of t){if(y.context||y.applied)continue;let x=za(e,k,y,y.compounds.length-1);if(!(!x||x==="uncertain"||x.carriers.length||x.pseudo))for(let v of y.declarations)v.property.startsWith("--")&&r.get(v.property)!==v.value&&m.set(v.property,v.value)}});let g=b=>{let k=[];for(let y=b;i(y);y=e[y].parent)k.unshift(y);return k},S=[];for(let{slot:b,decls:k}of f.values()){let y=new Map(m);for(let A of g(b.node))for(let{slot:E,decls:O}of f.values())if(!(E.node!==A||E.target.includes("::")||E.target==="placeholder")&&!(E.state!=="default"&&E.state!==b.state)&&!(E.context!==""&&E.context!==b.context))for(let L of O)L.property.startsWith("--")&&y.set(L.property,L.value);let x=e[b.node],v=!i(x.parent),$=k.filter(A=>!A.property.startsWith("--")).filter(A=>b.target==="placeholder"||!i0(x,v,A)).map(A=>({...A,value:Ga(A.value,y).replace(/\s*!important\s*$/i,"").replace(/\s+/g," ").trim()})).filter(A=>A.value!=="");$.length&&S.push({target:b.target,state:b.state,...b.markers?{markers:b.markers}:{},context:b.context,declarations:$})}a0(S);let h=c0(e);return{states:S,render:h,fingerprint:td(S,h),tailwind:u,uncertain:[...o].sort().slice(0,20),controlRuleClasses:[...a].sort(),elementRules:c}}var l0=/^(type|role|data-slot|data-size|data-variant|aria-hidden)$/;function c0(e){let t=r=>{let o=e[r],s={};for(let[i,l]of Object.entries(o.attrs))l0.test(i)&&/^[\w -]{0,40}$/.test(l)&&(s[i]=l);return{part:o.part,tag:o.tag,attrs:s,...o.text?{text:o.text}:{},...o.conditional?{conditional:!0}:{},children:e.flatMap((i,l)=>i.part&&i.parent===r?[t(l)]:[])}},n=e.findIndex(r=>r.part!==""&&(r.parent<0||e[r.parent].part===""));return{root:t(n<0?0:n)}}var u0=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),p0=14,d0=240,es=e=>"tag"in e;function ts(e,t){let n=e[t];for(let r=t+1;r<e.length;r++){let o=e[r];if(o==="\\"){r++;continue}if(n==="`"&&o==="$"&&e[r+1]==="{"){r=Cr(e,r+1)-1;continue}if(o===n)return r+1;if(n!=="`"&&o===`
|
|
46
46
|
`)return r}return e.length}function Cr(e,t){let n=0;for(let r=t;r<e.length;r++){let o=e[r];if(o==='"'||o==="'"||o==="`"){r=ts(e,r)-1;continue}if(o==="/"&&e[r+1]==="/"){let s=e.indexOf(`
|
|
47
|
-
`,r);r=s<0?e.length:s;continue}if(o==="/"&&e[r+1]==="*"){let s=e.indexOf("*/",r+2);r=s<0?e.length:s+1;continue}if(o==="{")n++;else if(o==="}"&&--n===0)return r+1}return e.length}function Ba(e,t){if(e[t]!=="<")return null;let n=/^<([A-Za-z][\w.:-]*)?/.exec(e.slice(t,t+80));if(!n)return null;let r=n[1]??"",o=t+n[0].length,s=o;for(;o<e.length;){let i=e[o];if(i==='"'||i==="'"){o=ts(e,o);continue}if(i==="{"){o=Cr(e,o);continue}if(i===">"){let l=e.slice(s,o),a=/\/\s*$/.test(l);return{tag:r,attrs:a?l.replace(/\/\s*$/,""):l,end:o+1,selfClosing:a}}if(i==="<")return null;o++}return null}function Wa(e){let t=[],n=[],r=0;for(;r<e.length;){let o=e[r];if(/\s/.test(o)){r++;continue}if(o==="{"){let a=Cr(e,r),c=e.slice(r+1,a-1).trim();c.startsWith("...")&&n.push(c.slice(3).trim()),r=a;continue}let s=/^[^\s=>/"'{}]+/.exec(e.slice(r));if(!s){r++;continue}r+=s[0].length;let i=r;for(;i<e.length&&/\s/.test(e[i]);)i++;if(e[i]!=="="){t.push({name:s[0],kind:"bool",value:""});continue}for(i++;i<e.length&&/\s/.test(e[i]);)i++;let l=e[i];if(l==='"'||l==="'"){let a=ts(e,i);t.push({name:s[0],kind:"string",value:e.slice(i+1,a-1)}),r=a}else if(l==="{"){let a=Cr(e,i);t.push({name:s[0],kind:"expr",value:e.slice(i+1,a-1).trim()}),r=a}else{let a=/^[^\s>]+/.exec(e.slice(i))?.[0]??"";t.push({name:s[0],kind:"string",value:a}),r=i+a.length}}return{attrs:t,spreads:n}}var f0=/[([?:&|,={};!]$|(?:^|\W)(?:return|=>)\s*$/;function g0(e,t,n,r,o){let s=[];for(let i=t;i<n;i++){let l=e[i];if(l==='"'||l==="'"||l==="`"){i=ts(e,i)-1;continue}if(l!=="<"||!/[A-Za-z>]/.test(e[i+1]??"")||!f0.test(e.slice(Math.max(t,i-12),i).trimEnd()))continue;let a=Ln(e,i,r+1,!0,o);a&&(s.push(a),i=a.end-1)}return s}function Ln(e,t,n=0,r=!1,o={nodes:0}){if(n>p0||o.nodes>=d0)return null;let s=Ba(e,t);if(!s)return null;o.nodes++;let{attrs:i,spreads:l}=Wa(s.attrs),a={tag:s.tag,attrs:i,spreads:l,start:t,end:s.end,children:[],conditional:r};if(s.selfClosing||u0.has(s.tag.toLowerCase()))return a;let c=s.end,u="",p=()=>{u.trim()&&a.children.push({text:u.replace(/\s+/g," ").trim()}),u=""};for(;c<e.length;){let d=e[c];if(d==="<"&&e.startsWith("<!--",c)){let f=e.indexOf("-->",c);c=f<0?e.length:f+3;continue}if(d==="<"&&e[c+1]==="/"){let f=/^<\/([A-Za-z][\w.:-]*)?\s*>/.exec(e.slice(c,c+100));return p(),f&&(f[1]??"")===s.tag?(a.end=c+f[0].length,a):null}if(d==="<"&&/[A-Za-z>]/.test(e[c+1]??"")){p();let f=Ln(e,c,n+1,r,o);if(!f)return null;a.children.push(f),c=f.end;continue}if(d==="{"){p();let f=Cr(e,c),m=e.slice(c+1,f-1),g=g0(e,c+1,f-1,n,o);g.length?a.children.push(...g):m.trim()&&!/^\s*\/\*[\s\S]*\*\/\s*$/.test(m)&&a.children.push({expr:m.trim()}),c=f;continue}u+=d,c++}return null}function xd(e,t,n){let r=/(?:\breturn\b|=>)\s*\(?\s*</g;r.lastIndex=t;for(let o=r.exec(e);o&&o.index<n;o=r.exec(e)){let s=o.index+o[0].length-1,i=Ln(e,s);if(i)return i}return null}function We(e,...t){return e.attrs.find(n=>t.includes(n.name))}var Nn=["text","email","password","search","tel","url"];var m0=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro|html?)$/i,h0=/\.(tsx|jsx|js|mjs|cjs)$/i,y0=400,b0=50,vd=/^(?:[A-Z][A-Za-z0-9]*)?(?:Input|TextField|TextBox|SearchField)$/,Sd=/Check|Radio|Switch|Select|Combo|Textarea|TextArea|Date|Time|File|Color|Range|Number|Slider|Otp|OTP|Pin|Group|Label|Hidden|Toggle|Tag|Chip|Mask|Phone|Currency|Upload|Addon/,w0={"@base-ui/react/input":["Input"],"@base-ui-components/react/input":["Input"],"@base-ui/react":["Input"],"@headlessui/react":["Input"],"react-aria-components":["Input"]},k0=/^(lucide-react|@heroicons\/react|react-icons|@radix-ui\/react-icons|@tabler\/icons-react|@phosphor-icons\/react)(\/|$)/,x0=/(input|field|form-control|textbox|text-box|searchbox|search-box)/i,v0=/(checkbox|radio|switch|select|textarea|range|file|group|wrap|label|help|hint|error|addon|icon)/i,$d=/^(size|sizes|inputSize|scale)$/i,Cd=/^(xs|sm|small|md|medium|base|default|lg|large|xl|2xl)$/i,Ha=e=>Nn.includes(e);function S0(e){let t=new Map;for(let n of e.matchAll(/import\s+(?!type\s)([^"';]*?)\s+from\s+["']([^"']+)["']/g)){let r=n[1].trim(),o=n[2],s=/\{([\s\S]*)\}/.exec(r);if(s)for(let a of s[1].split(",")){let[c,u]=a.replace(/^\s*type\s+/,"").trim().split(/\s+as\s+/);c&&t.set((u??c).trim(),{from:o,name:c.trim()})}let i=/\*\s+as\s+([\w$]+)/.exec(r);i&&t.set(i[1],{from:o,name:"*"});let l=/^([\w$]+)\s*(?:,|$)/.exec(r);l&&t.set(l[1],{from:o,name:"default"})}return t}function ns(e){if(!e)return[];let t=jt(e);return t?Te(t):[]}function $0(e,t){let n=e[0],r=t?n:e[1],o=t?n?.t==="obj"?ns(n.entries.find(c=>c.key==="base")?.value):[]:ns(n),s={base:o,axes:[],compounds:[]};if(r?.t!=="obj")return o.length?s:null;let i=r.entries.find(c=>c.key==="variants")?.value,l=r.entries.find(c=>c.key==="defaultVariants")?.value;if(i?.t==="obj")for(let c of i.entries){if(c.value.t!=="obj")continue;let u=new Map;for(let d of c.value.entries)u.set(d.key,ns(d.value));let p=l?.t==="obj"?l.entries.find(d=>d.key===c.key)?.value:void 0;s.axes.push({prop:c.key,values:u,...p?.t==="str"&&p.v?{defaultValue:p.v}:{},...p?.t==="bool"?{defaultValue:String(p.v)}:{}})}let a=r.entries.find(c=>c.key==="compoundVariants")?.value;if(a?.t==="arr")for(let c of a.items){if(c.t!=="obj")continue;let u={},p=[],d=!0;for(let f of c.entries)f.key==="class"||f.key==="className"?p=ns(f.value):f.value.t==="str"&&f.value.v?u[f.key]=f.value.v:f.value.t==="bool"?u[f.key]=String(f.value.v):d=!1;d&&p.length&&s.compounds.push({when:u,classes:p})}return s}function C0(e,t){let n=[],r=t+1;for(;r<e.length;){for(;/[\s,]/.test(e[r]??"");)r++;if(e[r]===")"||r>=e.length)break;let o=Ee(e,r);if(!o)break;n.push(o.val),r=o.end}return n}var an=()=>({classes:[],modules:[],conditional:[],forwards:!1,recipe:null,dynamic:!1}),R0=/^(cn|clsx|cx|classNames|classnames|twMerge|twJoin|cva)$/;function Rr(e,t=","){let n=[],r=0,o="";for(let s=0;s<e.length;s++){let i=e[s];if(i==='"'||i==="'"||i==="`"){let l=i,a=s+1;for(;a<e.length&&e[a]!==l;a++)e[a]==="\\"&&a++;o+=e.slice(s,a+1),s=a;continue}"([{".includes(i)?r++:")]}".includes(i)&&r--,i===t&&r===0?(n.push(o.trim()),o=""):o+=i}return o.trim()&&n.push(o.trim()),n}function Rd(e){return[...e.matchAll(/"([^"]*)"|'([^']*)'|`([^`$]*)`/g)].flatMap(t=>Te(t[1]??t[2]??t[3]??""))}function Od(e,t,n,r=0){if(r>2)return null;let s=new RegExp(`(?:const|let|var)\\s+${e}\\s*(?::[^=]+)?=\\s*`,"g").exec(t.source);if(s){let a=Ee(t.source,s.index+s[0].length);if(a){let c=jt(a.val);if(c!==null)return Te(c)}return null}let i=t.imports.get(e);if(!i)return null;let l=De(t.path,i.from,a=>n.has(a));return l?Od(i.name,os(l,n),n,r+1):null}function rs(e,t,n,r){let o=e.trim();if(!o)return;if(/^(["'])[\s\S]*\1$/.test(o)){r.classes.push(...Te(o.slice(1,-1)));return}if(o.startsWith("`")){let a=o.slice(1,-1);a.includes("${")&&(r.dynamic=!0),r.classes.push(...Te(a.replace(/\$\{[^}]*\}/g," ")));return}if(/^(?:[\w$]+\.)?className$/.test(o)){r.forwards=!0;return}let s=Rr(o,"+");if(s.length>1){for(let a of s)rs(a,t,n,r);return}let i=/^([\w$]+)(?:\.([\w$]+)|\[\s*["']([\w-]+)["']\s*\])$/.exec(o);if(i&&t.sheets.has(i[1])){r.modules.push({sheet:t.sheets.get(i[1]),name:i[2]??i[3]});return}if(/&&|\?|\|\|/.test(o)&&!/^[\w$]+\s*\(/.test(o)){r.conditional.push(...Rd(o)),/\bclassName\b/.test(o)&&(r.forwards=!0);return}if(o.startsWith("[")){let a=o.replace(/\]\s*\.join\([^)]*\)\s*$/,"]").slice(1,-1);for(let c of Rr(a))rs(c,t,n,r);return}if(o.startsWith("{")){r.conditional.push(...Rd(o));return}let l=/^([\w$]+)\s*\(([\s\S]*)\)$/.exec(o);if(l){let a=l[1];if(R0.test(a)){for(let u of Rr(l[2]))rs(u,t,n,r);return}let c=A0(a,t,n);if(c){r.recipe={recipe:c,args:l[2].trim()},/\bclassName\b/.test(l[2])&&(r.forwards=!0);return}r.dynamic=!0;return}if(/^[\w$]+$/.test(o)){let a=Od(o,t,n);a?r.classes.push(...a):r.dynamic=!0;return}r.dynamic=!0}function Fn(e,t,n){let r=an();return!e||e.kind==="bool"?r:e.kind==="string"?(r.classes.push(...Te(e.value)),r):(rs(e.value,t,n,r),r)}function A0(e,t,n){let r=t.recipes.get(e);if(r)return r;let o=t.imports.get(e);if(!o)return null;let s=De(t.path,o.from,i=>n.has(i));return s?os(s,n).recipes.get(o.name)??null:null}var Ad=new WeakMap;function os(e,t){let n=Ad.get(t);n||Ad.set(t,n=new Map);let r=n.get(e);if(r)return r;let o=t.get(e)??"",s=S0(o),i=new Map;for(let[c,u]of s)if(/\.module\.[a-z]+$/i.test(u.from)){let p=De(e,u.from,d=>t.has(d));p&&i.set(c,p)}let l=new Map;for(let c of o.matchAll(/(?:const|let|var)\s+([\w$]+)\s*=\s*(cva|tv)\s*\(/g)){let u=c.index+c[0].length-1,p=$0(C0(o,u),c[2]==="tv");p&&l.set(c[1],p)}let a={path:e,source:o,imports:s,sheets:i,recipes:l};return n.set(e,a),a}var I0=/^[ \t]*(?:export\s+)?(?:default\s+)?(?:async\s+)?(?:function\s+([A-Z][\w$]*)|(?:const|let)\s+([A-Z][\w$]*)\s*(?::[^=\n]+)?=)/gm;function Ka(e,t){let n=1;for(let r=0;r<t&&r<e.length;r++)e.charCodeAt(r)===10&&n++;return n}function E0(e,t){let n=[...t.matchAll(I0)].map(o=>({name:o[1]??o[2],at:o.index,head:o[0]})),r=[];return n.forEach((o,s)=>{let i=n[s+1]?.at??t.length,l=t.slice(o.at,i),a=new Map,c=/\(\s*\{([^{}]*)\}\s*(?::[^,)]*)?[,)]/.exec(l.slice(0,600)),u=!1;if(c)for(let d of Rr(c[1])){if(d.startsWith("...")){u=!0;continue}let f=/^([\w$]+)(?:\s*:\s*[\w$]+)?(?:\s*=\s*([\s\S]+))?$/.exec(d.trim());if(!f)continue;let m=f[2]?/^["']([^"']*)["']$/.exec(f[2].trim())?.[1]??null:null;a.set(f[1],m)}else u=!0;let p=/\bexport\b/.test(o.head)||new RegExp(`export\\s*\\{[^}]*\\b${o.name}\\b`).test(t)||new RegExp(`export\\s+default\\s+${o.name}\\b`).test(t);r.push({name:o.name,path:e,line:Ka(t,o.at),start:o.at,end:i,root:xd(t,o.at,i),params:a,rest:u,exported:p})}),r}var at=(e,t)=>e.attrs.find(n=>n.name===t);function je(e){if(!e)return null;if(e.kind==="string")return e.value;if(e.kind==="bool")return"";let t=/^(["'`])([^"'`$]*)\1$/.exec(e.value.trim());return t?t[2]:null}function Id(e){let t=[],n=r=>{(r.tag==="input"||/^[A-Z]/.test(r.tag))&&t.push(r);for(let o of r.children)es(o)&&n(o)};return n(e),t}function Ar(e){return e?e.kind==="string"?we(e.value):e.kind==="expr"?br(`style={${e.value}}`).flatMap(t=>t.state==="default"&&!t.context?t.declarations:[]):[]:[]}function Xa(e){let t={};for(let n of e.attrs){let r=n.name==="htmlFor"?"for":n.name;if(/^(class|className|style|ref|key|on[A-Z].*|value|defaultValue|dangerouslySetInnerHTML)$/.test(r))continue;let o=je(n);o!==null&&o.length<=80&&(t[r.toLowerCase()==="readonly"?"readonly":r]=o)}return t}var T0=(e,t)=>t?"svg":/Label$/.test(e)?"label":/(Description|Hint|Help|Error|Message)$/.test(e)?"p":"div";function _0(e,t){let n=[...e.base];for(let r of e.axes){let o=t[r.prop]??r.defaultValue;o!==void 0&&n.push(...r.values.get(o)??[])}for(let r of e.compounds)Object.entries(r.when).every(([o,s])=>(t[o]??e.axes.find(i=>i.prop===o)?.defaultValue)===s)&&n.push(...r.classes);return n}function Md(e,t,n,r,o,s=0){let i=[],l=[],a=e.type,c=(u,p)=>{if(s>4)return;let d=u===e.control;if(d&&e.inner){let v=Fn(We(u,"className"),e.ctx,r),$=v.forwards?t.classes:an(),R=u.spreads.length?{...n}:{};for(let D of u.attrs){let z=je(D);z!==null?R[D.name]=z:D.kind==="expr"&&/^[\w$]+$/.test(D.value)&&n[D.value]!==void 0&&(R[D.name]=n[D.value])}let I=je(at(u,"type")),O=Md(e.inner,{classes:Ed(v,$),style:[...Ar(We(u,"style")),...t.style],attrs:[...u.attrs,...t.attrs],spreads:[...u.spreads,...t.spreads]},R,r,o,s+1),L=i.length;for(let D of O.nodes)i.push({...D,parent:D.parent<0?p:D.parent+L});(O.type!==null||I)&&(a=I??O.type),l.push(...O.uncertain);return}let f=Fn(We(u,"className","class"),e.ctx,r),m=f;if(d){let v=f.recipe?_0(f.recipe.recipe,{...j0(f.recipe.args,n,e.params)}):[];m=Ed({...f,classes:[...v,...f.classes]},f.forwards?t.classes:an())}l.push(...m.conditional.map(v=>`${v} (conditional)`)),m.dynamic&&l.push(`${u.tag} className is built at runtime`);let g=/^[A-Z]/.test(u.tag)?e.ctx.imports.get(u.tag.split(".")[0]):void 0,S=!!(g&&k0.test(g.from))||/Icon$/.test(u.tag),h=d?"input":/^[A-Z]/.test(u.tag)?T0(u.tag,S):u.tag.toLowerCase(),b=Xa(u);if(d){let v=je(t.attrs.find($=>$.name==="type"));a===null&&v!==null&&(a=v),b.type=a??"text";for(let $ of t.attrs){let R=je($);R!==null&&/^(id|name|aria-label|data-slot)$/.test($.name)&&(b[$.name]=R)}}let k=new Map;for(let v of m.modules){let $=k.get(v.sheet)??new Set;$.add(v.name),k.set(v.sheet,$)}let y=u.children.flatMap(v=>"text"in v?[v.text]:[]).join(" ").trim(),x=i.length;if(i.push({part:d?"control":"",tag:h,classes:m.classes,modules:k,attrs:b,style:d?[...Ar(We(u,"style")),...t.style]:Ar(We(u,"style")),...y&&y.length<=24?{text:y}:{},...u.conditional?{conditional:!0}:{},parent:p}),!(h==="input"||h==="svg")){for(let v of u.children)if(es(v))if(v.tag==="")for(let $ of v.children)es($)&&c($,x);else c(v,x)}};return e.root&&c(e.root,-1),{nodes:i,type:a,uncertain:l}}function Ed(e,t){return{classes:[...e.classes,...t.classes],modules:[...e.modules,...t.modules],conditional:[...e.conditional,...t.conditional],forwards:e.forwards||t.forwards,recipe:e.recipe??t.recipe,dynamic:e.dynamic||t.dynamic}}function j0(e,t,n){let r={},o=/^\{([\s\S]*)\}$/.exec(e.trim())?.[1];if(o===void 0)return r;for(let s of Rr(o)){if(s.startsWith("..."))continue;let i=/^([\w$]+)\s*(?::\s*([\s\S]+))?$/.exec(s.trim());if(!i)continue;let l=i[1],a=i[2]?.trim(),c=a?/^["'`]([^"'`$]*)["'`]$/.exec(a)?.[1]:void 0;if(c!==void 0){r[l]=c;continue}let u=a&&/^[\w$]+$/.test(a)?a:l,p=t[u]??n.get(u);p!=null&&(r[l]=p)}return r}function O0(e){let t=e.findIndex(i=>i.part==="control"),n=new Set(["control"]),r=(i,l)=>{n.has(l)&&(l=`node-${i}`),n.add(l),e[i].part=l};t>0&&r(0,"field");let o=i=>[i.tag,...i.classes,...[...i.modules.values()].flatMap(l=>[...l]),i.attrs["data-slot"]??"",i.attrs.role??""].join(" "),s=t>=0?e[t].parent:-1;e.forEach((i,l)=>{if(i.part)return;let a=o(i);i.tag==="label"||/(^|[\s_-])label\b/i.test(a)?r(l,"label"):/\b(alert)\b|(^|[\s_-])(error|errors|invalid)\b|field-?error/i.test(a)?r(l,"error"):/(^|[\s_-])(help|hint|description)\b/i.test(a)?r(l,"help"):i.parent===s&&s>=0&&/^(svg|span|i|img|button|kbd|div)$/.test(i.tag)&&!i.text?.match(/\w{4,}/)?r(l,l<t?"prefix":"suffix"):r(l,`node-${l}`),["label","help","error"].includes(i.part)&&(i.text={label:"Label",help:"Help text",error:"Error message"}[i.part])})}function M0(e,t,n){let r=/<!--[\s\S]*?-->|<(\/)?([a-zA-Z][\w.:-]*)/g,o=[],s=0;return i=>{r.lastIndex=s;for(let l=r.exec(e);l&&l.index<i;l=r.exec(e)){if(!l[2]){s=r.lastIndex;continue}let a=l[2];if(l[1]){let g=o.findLastIndex(h=>h.name===a);g>=0&&(o.length=g);let S=e.indexOf(">",l.index);s=r.lastIndex=S<0?e.length:S+1;continue}let c=Ba(e,l.index);if(!c){s=r.lastIndex;continue}if(c.end>i)break;s=r.lastIndex=c.end;let u=a.toLowerCase();if(c.selfClosing||/^(input|img|br|hr|meta|link|source|wbr|area|col|embed|track)$/.test(u))continue;if(u==="script"||u==="style"){let g=e.indexOf(`</${u}`,s);s=r.lastIndex=g<0?e.length:g;continue}if(/^[A-Z]/.test(a)){o.push({name:a,node:{part:"",tag:"",classes:[],modules:new Map,attrs:{},style:[],parent:-1}});continue}let{attrs:p}=Wa(c.attrs),d=Fn(p.find(g=>g.name==="className"||g.name==="class"),t,n),f=new Map;for(let g of d.modules)f.set(g.sheet,new Set([...f.get(g.sheet)??[],g.name]));let m={tag:a,attrs:p,spreads:[],start:l.index,end:c.end,children:[],conditional:!1};o.push({name:a,node:{part:"",tag:u,classes:d.classes,modules:f,attrs:Xa(m),style:[],parent:-1}})}return o.filter(l=>l.node.tag).map(l=>l.node)}}function D0(e,t){let n=e.length,r=e.map(s=>({...s}));t.forEach((s,i)=>r.push({...s,part:"",parent:i===0?-1:n+i-1}));let o=r.findIndex(s=>s.parent<0);return t.length&&o>=0&&o<n&&(r[o].parent=r.length-1),r}function Td(e,t,n,r,o){if(n.has(e))return n.get(e);let s=t.imports.get(e);if(!s)return null;let i=De(t.path,s.from,l=>o.has(l));if(!i)return null;if(s.name==="default"){let l=o.get(i)??"",a=/export\s+default\s+(?:function\s+)?([A-Z][\w$]*)/.exec(l);return a?r.get(`${i}#${a[1]}`)??null:null}return r.get(`${i}#${s.name}`)??null}function Va(e,t,n,r){let o=je(at(e,"id")),s=je(at(e,"name")),i=je(at(e,"aria-label")),l=je(at(e,"data-slot")),a=(i??n)?.replace(/\s+/g," ").trim().slice(0,80);return{type:t,...o?{id:o}:{},...s?{name:s}:{},...a?{label:a}:{},...l?{dataSlot:l}:{},...r.length?{classes:r.slice(0,8)}:{}}}function _d(e,t){let n=je(at(t,"id"));if(n){let s=new RegExp(`<label\\b[^>]*\\b(?:for|htmlFor)=["'{]+${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}["'}]+[^>]*>([^<{]{1,80})<`).exec(e);if(s)return s[1].trim()||null}let r=e.lastIndexOf("<label",t.start);if(r>=0){let o=Ln(e,r);if(o&&o.end>t.end)return o.children.flatMap(i=>"text"in i?[i.text]:[]).join(" ").trim()||null}return null}function qa(e,t,n){let r=Ka(e,t),o=e.slice(t,n).split(`
|
|
47
|
+
`,r);r=s<0?e.length:s;continue}if(o==="/"&&e[r+1]==="*"){let s=e.indexOf("*/",r+2);r=s<0?e.length:s+1;continue}if(o==="{")n++;else if(o==="}"&&--n===0)return r+1}return e.length}function Ba(e,t){if(e[t]!=="<")return null;let n=/^<([A-Za-z][\w.:-]*)?/.exec(e.slice(t,t+80));if(!n)return null;let r=n[1]??"",o=t+n[0].length,s=o;for(;o<e.length;){let i=e[o];if(i==='"'||i==="'"){o=ts(e,o);continue}if(i==="{"){o=Cr(e,o);continue}if(i===">"){let l=e.slice(s,o),a=/\/\s*$/.test(l);return{tag:r,attrs:a?l.replace(/\/\s*$/,""):l,end:o+1,selfClosing:a}}if(i==="<")return null;o++}return null}function Wa(e){let t=[],n=[],r=0;for(;r<e.length;){let o=e[r];if(/\s/.test(o)){r++;continue}if(o==="{"){let a=Cr(e,r),c=e.slice(r+1,a-1).trim();c.startsWith("...")&&n.push(c.slice(3).trim()),r=a;continue}let s=/^[^\s=>/"'{}]+/.exec(e.slice(r));if(!s){r++;continue}r+=s[0].length;let i=r;for(;i<e.length&&/\s/.test(e[i]);)i++;if(e[i]!=="="){t.push({name:s[0],kind:"bool",value:""});continue}for(i++;i<e.length&&/\s/.test(e[i]);)i++;let l=e[i];if(l==='"'||l==="'"){let a=ts(e,i);t.push({name:s[0],kind:"string",value:e.slice(i+1,a-1)}),r=a}else if(l==="{"){let a=Cr(e,i);t.push({name:s[0],kind:"expr",value:e.slice(i+1,a-1).trim()}),r=a}else{let a=/^[^\s>]+/.exec(e.slice(i))?.[0]??"";t.push({name:s[0],kind:"string",value:a}),r=i+a.length}}return{attrs:t,spreads:n}}var f0=/[([?:&|,={};!]$|(?:^|\W)(?:return|=>)\s*$/;function g0(e,t,n,r,o){let s=[];for(let i=t;i<n;i++){let l=e[i];if(l==='"'||l==="'"||l==="`"){i=ts(e,i)-1;continue}if(l!=="<"||!/[A-Za-z>]/.test(e[i+1]??"")||!f0.test(e.slice(Math.max(t,i-12),i).trimEnd()))continue;let a=Ln(e,i,r+1,!0,o);a&&(s.push(a),i=a.end-1)}return s}function Ln(e,t,n=0,r=!1,o={nodes:0}){if(n>p0||o.nodes>=d0)return null;let s=Ba(e,t);if(!s)return null;o.nodes++;let{attrs:i,spreads:l}=Wa(s.attrs),a={tag:s.tag,attrs:i,spreads:l,start:t,end:s.end,children:[],conditional:r};if(s.selfClosing||u0.has(s.tag.toLowerCase()))return a;let c=s.end,u="",p=()=>{u.trim()&&a.children.push({text:u.replace(/\s+/g," ").trim()}),u=""};for(;c<e.length;){let d=e[c];if(d==="<"&&e.startsWith("<!--",c)){let f=e.indexOf("-->",c);c=f<0?e.length:f+3;continue}if(d==="<"&&e[c+1]==="/"){let f=/^<\/([A-Za-z][\w.:-]*)?\s*>/.exec(e.slice(c,c+100));return p(),f&&(f[1]??"")===s.tag?(a.end=c+f[0].length,a):null}if(d==="<"&&/[A-Za-z>]/.test(e[c+1]??"")){p();let f=Ln(e,c,n+1,r,o);if(!f)return null;a.children.push(f),c=f.end;continue}if(d==="{"){p();let f=Cr(e,c),m=e.slice(c+1,f-1),g=g0(e,c+1,f-1,n,o);g.length?a.children.push(...g):m.trim()&&!/^\s*\/\*[\s\S]*\*\/\s*$/.test(m)&&a.children.push({expr:m.trim()}),c=f;continue}u+=d,c++}return null}function xd(e,t,n){let r=/(?:\breturn\b|=>)\s*\(?\s*</g;r.lastIndex=t;for(let o=r.exec(e);o&&o.index<n;o=r.exec(e)){let s=o.index+o[0].length-1,i=Ln(e,s);if(i)return i}return null}function Be(e,...t){return e.attrs.find(n=>t.includes(n.name))}var Nn=["text","email","password","search","tel","url"];var m0=/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro|html?)$/i,h0=/\.(tsx|jsx|js|mjs|cjs)$/i,y0=400,b0=50,vd=/^(?:[A-Z][A-Za-z0-9]*)?(?:Input|TextField|TextBox|SearchField)$/,Sd=/Check|Radio|Switch|Select|Combo|Textarea|TextArea|Date|Time|File|Color|Range|Number|Slider|Otp|OTP|Pin|Group|Label|Hidden|Toggle|Tag|Chip|Mask|Phone|Currency|Upload|Addon/,w0={"@base-ui/react/input":["Input"],"@base-ui-components/react/input":["Input"],"@base-ui/react":["Input"],"@headlessui/react":["Input"],"react-aria-components":["Input"]},k0=/^(lucide-react|@heroicons\/react|react-icons|@radix-ui\/react-icons|@tabler\/icons-react|@phosphor-icons\/react)(\/|$)/,x0=/(input|field|form-control|textbox|text-box|searchbox|search-box)/i,v0=/(checkbox|radio|switch|select|textarea|range|file|group|wrap|label|help|hint|error|addon|icon)/i,$d=/^(size|sizes|inputSize|scale)$/i,Cd=/^(xs|sm|small|md|medium|base|default|lg|large|xl|2xl)$/i,Ha=e=>Nn.includes(e);function S0(e){let t=new Map;for(let n of e.matchAll(/import\s+(?!type\s)([^"';]*?)\s+from\s+["']([^"']+)["']/g)){let r=n[1].trim(),o=n[2],s=/\{([\s\S]*)\}/.exec(r);if(s)for(let a of s[1].split(",")){let[c,u]=a.replace(/^\s*type\s+/,"").trim().split(/\s+as\s+/);c&&t.set((u??c).trim(),{from:o,name:c.trim()})}let i=/\*\s+as\s+([\w$]+)/.exec(r);i&&t.set(i[1],{from:o,name:"*"});let l=/^([\w$]+)\s*(?:,|$)/.exec(r);l&&t.set(l[1],{from:o,name:"default"})}return t}function ns(e){if(!e)return[];let t=jt(e);return t?Te(t):[]}function $0(e,t){let n=e[0],r=t?n:e[1],o=t?n?.t==="obj"?ns(n.entries.find(c=>c.key==="base")?.value):[]:ns(n),s={base:o,axes:[],compounds:[]};if(r?.t!=="obj")return o.length?s:null;let i=r.entries.find(c=>c.key==="variants")?.value,l=r.entries.find(c=>c.key==="defaultVariants")?.value;if(i?.t==="obj")for(let c of i.entries){if(c.value.t!=="obj")continue;let u=new Map;for(let d of c.value.entries)u.set(d.key,ns(d.value));let p=l?.t==="obj"?l.entries.find(d=>d.key===c.key)?.value:void 0;s.axes.push({prop:c.key,values:u,...p?.t==="str"&&p.v?{defaultValue:p.v}:{},...p?.t==="bool"?{defaultValue:String(p.v)}:{}})}let a=r.entries.find(c=>c.key==="compoundVariants")?.value;if(a?.t==="arr")for(let c of a.items){if(c.t!=="obj")continue;let u={},p=[],d=!0;for(let f of c.entries)f.key==="class"||f.key==="className"?p=ns(f.value):f.value.t==="str"&&f.value.v?u[f.key]=f.value.v:f.value.t==="bool"?u[f.key]=String(f.value.v):d=!1;d&&p.length&&s.compounds.push({when:u,classes:p})}return s}function C0(e,t){let n=[],r=t+1;for(;r<e.length;){for(;/[\s,]/.test(e[r]??"");)r++;if(e[r]===")"||r>=e.length)break;let o=Ee(e,r);if(!o)break;n.push(o.val),r=o.end}return n}var an=()=>({classes:[],modules:[],conditional:[],forwards:!1,recipe:null,dynamic:!1}),R0=/^(cn|clsx|cx|classNames|classnames|twMerge|twJoin|cva)$/;function Rr(e,t=","){let n=[],r=0,o="";for(let s=0;s<e.length;s++){let i=e[s];if(i==='"'||i==="'"||i==="`"){let l=i,a=s+1;for(;a<e.length&&e[a]!==l;a++)e[a]==="\\"&&a++;o+=e.slice(s,a+1),s=a;continue}"([{".includes(i)?r++:")]}".includes(i)&&r--,i===t&&r===0?(n.push(o.trim()),o=""):o+=i}return o.trim()&&n.push(o.trim()),n}function Rd(e){return[...e.matchAll(/"([^"]*)"|'([^']*)'|`([^`$]*)`/g)].flatMap(t=>Te(t[1]??t[2]??t[3]??""))}function Od(e,t,n,r=0){if(r>2)return null;let s=new RegExp(`(?:const|let|var)\\s+${e}\\s*(?::[^=]+)?=\\s*`,"g").exec(t.source);if(s){let a=Ee(t.source,s.index+s[0].length);if(a){let c=jt(a.val);if(c!==null)return Te(c)}return null}let i=t.imports.get(e);if(!i)return null;let l=De(t.path,i.from,a=>n.has(a));return l?Od(i.name,os(l,n),n,r+1):null}function rs(e,t,n,r){let o=e.trim();if(!o)return;if(/^(["'])[\s\S]*\1$/.test(o)){r.classes.push(...Te(o.slice(1,-1)));return}if(o.startsWith("`")){let a=o.slice(1,-1);a.includes("${")&&(r.dynamic=!0),r.classes.push(...Te(a.replace(/\$\{[^}]*\}/g," ")));return}if(/^(?:[\w$]+\.)?className$/.test(o)){r.forwards=!0;return}let s=Rr(o,"+");if(s.length>1){for(let a of s)rs(a,t,n,r);return}let i=/^([\w$]+)(?:\.([\w$]+)|\[\s*["']([\w-]+)["']\s*\])$/.exec(o);if(i&&t.sheets.has(i[1])){r.modules.push({sheet:t.sheets.get(i[1]),name:i[2]??i[3]});return}if(/&&|\?|\|\|/.test(o)&&!/^[\w$]+\s*\(/.test(o)){r.conditional.push(...Rd(o)),/\bclassName\b/.test(o)&&(r.forwards=!0);return}if(o.startsWith("[")){let a=o.replace(/\]\s*\.join\([^)]*\)\s*$/,"]").slice(1,-1);for(let c of Rr(a))rs(c,t,n,r);return}if(o.startsWith("{")){r.conditional.push(...Rd(o));return}let l=/^([\w$]+)\s*\(([\s\S]*)\)$/.exec(o);if(l){let a=l[1];if(R0.test(a)){for(let u of Rr(l[2]))rs(u,t,n,r);return}let c=A0(a,t,n);if(c){r.recipe={recipe:c,args:l[2].trim()},/\bclassName\b/.test(l[2])&&(r.forwards=!0);return}r.dynamic=!0;return}if(/^[\w$]+$/.test(o)){let a=Od(o,t,n);a?r.classes.push(...a):r.dynamic=!0;return}r.dynamic=!0}function Fn(e,t,n){let r=an();return!e||e.kind==="bool"?r:e.kind==="string"?(r.classes.push(...Te(e.value)),r):(rs(e.value,t,n,r),r)}function A0(e,t,n){let r=t.recipes.get(e);if(r)return r;let o=t.imports.get(e);if(!o)return null;let s=De(t.path,o.from,i=>n.has(i));return s?os(s,n).recipes.get(o.name)??null:null}var Ad=new WeakMap;function os(e,t){let n=Ad.get(t);n||Ad.set(t,n=new Map);let r=n.get(e);if(r)return r;let o=t.get(e)??"",s=S0(o),i=new Map;for(let[c,u]of s)if(/\.module\.[a-z]+$/i.test(u.from)){let p=De(e,u.from,d=>t.has(d));p&&i.set(c,p)}let l=new Map;for(let c of o.matchAll(/(?:const|let|var)\s+([\w$]+)\s*=\s*(cva|tv)\s*\(/g)){let u=c.index+c[0].length-1,p=$0(C0(o,u),c[2]==="tv");p&&l.set(c[1],p)}let a={path:e,source:o,imports:s,sheets:i,recipes:l};return n.set(e,a),a}var I0=/^[ \t]*(?:export\s+)?(?:default\s+)?(?:async\s+)?(?:function\s+([A-Z][\w$]*)|(?:const|let)\s+([A-Z][\w$]*)\s*(?::[^=\n]+)?=)/gm;function Ka(e,t){let n=1;for(let r=0;r<t&&r<e.length;r++)e.charCodeAt(r)===10&&n++;return n}function E0(e,t){let n=[...t.matchAll(I0)].map(o=>({name:o[1]??o[2],at:o.index,head:o[0]})),r=[];return n.forEach((o,s)=>{let i=n[s+1]?.at??t.length,l=t.slice(o.at,i),a=new Map,c=/\(\s*\{([^{}]*)\}\s*(?::[^,)]*)?[,)]/.exec(l.slice(0,600)),u=!1;if(c)for(let d of Rr(c[1])){if(d.startsWith("...")){u=!0;continue}let f=/^([\w$]+)(?:\s*:\s*[\w$]+)?(?:\s*=\s*([\s\S]+))?$/.exec(d.trim());if(!f)continue;let m=f[2]?/^["']([^"']*)["']$/.exec(f[2].trim())?.[1]??null:null;a.set(f[1],m)}else u=!0;let p=/\bexport\b/.test(o.head)||new RegExp(`export\\s*\\{[^}]*\\b${o.name}\\b`).test(t)||new RegExp(`export\\s+default\\s+${o.name}\\b`).test(t);r.push({name:o.name,path:e,line:Ka(t,o.at),start:o.at,end:i,root:xd(t,o.at,i),params:a,rest:u,exported:p})}),r}var at=(e,t)=>e.attrs.find(n=>n.name===t);function je(e){if(!e)return null;if(e.kind==="string")return e.value;if(e.kind==="bool")return"";let t=/^(["'`])([^"'`$]*)\1$/.exec(e.value.trim());return t?t[2]:null}function Id(e){let t=[],n=r=>{(r.tag==="input"||/^[A-Z]/.test(r.tag))&&t.push(r);for(let o of r.children)es(o)&&n(o)};return n(e),t}function Ar(e){return e?e.kind==="string"?we(e.value):e.kind==="expr"?br(`style={${e.value}}`).flatMap(t=>t.state==="default"&&!t.context?t.declarations:[]):[]:[]}function Xa(e){let t={};for(let n of e.attrs){let r=n.name==="htmlFor"?"for":n.name;if(/^(class|className|style|ref|key|on[A-Z].*|value|defaultValue|dangerouslySetInnerHTML)$/.test(r))continue;let o=je(n);o!==null&&o.length<=80&&(t[r.toLowerCase()==="readonly"?"readonly":r]=o)}return t}var T0=(e,t)=>t?"svg":/Label$/.test(e)?"label":/(Description|Hint|Help|Error|Message)$/.test(e)?"p":"div";function _0(e,t){let n=[...e.base];for(let r of e.axes){let o=t[r.prop]??r.defaultValue;o!==void 0&&n.push(...r.values.get(o)??[])}for(let r of e.compounds)Object.entries(r.when).every(([o,s])=>(t[o]??e.axes.find(i=>i.prop===o)?.defaultValue)===s)&&n.push(...r.classes);return n}function Md(e,t,n,r,o,s=0){let i=[],l=[],a=e.type,c=(u,p)=>{if(s>4)return;let d=u===e.control;if(d&&e.inner){let v=Fn(Be(u,"className"),e.ctx,r),$=v.forwards?t.classes:an(),A=u.spreads.length?{...n}:{};for(let D of u.attrs){let z=je(D);z!==null?A[D.name]=z:D.kind==="expr"&&/^[\w$]+$/.test(D.value)&&n[D.value]!==void 0&&(A[D.name]=n[D.value])}let E=je(at(u,"type")),O=Md(e.inner,{classes:Ed(v,$),style:[...Ar(Be(u,"style")),...t.style],attrs:[...u.attrs,...t.attrs],spreads:[...u.spreads,...t.spreads]},A,r,o,s+1),L=i.length;for(let D of O.nodes)i.push({...D,parent:D.parent<0?p:D.parent+L});(O.type!==null||E)&&(a=E??O.type),l.push(...O.uncertain);return}let f=Fn(Be(u,"className","class"),e.ctx,r),m=f;if(d){let v=f.recipe?_0(f.recipe.recipe,{...j0(f.recipe.args,n,e.params)}):[];m=Ed({...f,classes:[...v,...f.classes]},f.forwards?t.classes:an())}l.push(...m.conditional.map(v=>`${v} (conditional)`)),m.dynamic&&l.push(`${u.tag} className is built at runtime`);let g=/^[A-Z]/.test(u.tag)?e.ctx.imports.get(u.tag.split(".")[0]):void 0,S=!!(g&&k0.test(g.from))||/Icon$/.test(u.tag),h=d?"input":/^[A-Z]/.test(u.tag)?T0(u.tag,S):u.tag.toLowerCase(),b=Xa(u);if(d){let v=je(t.attrs.find($=>$.name==="type"));a===null&&v!==null&&(a=v),b.type=a??"text";for(let $ of t.attrs){let A=je($);A!==null&&/^(id|name|aria-label|data-slot)$/.test($.name)&&(b[$.name]=A)}}let k=new Map;for(let v of m.modules){let $=k.get(v.sheet)??new Set;$.add(v.name),k.set(v.sheet,$)}let y=u.children.flatMap(v=>"text"in v?[v.text]:[]).join(" ").trim(),x=i.length;if(i.push({part:d?"control":"",tag:h,classes:m.classes,modules:k,attrs:b,style:d?[...Ar(Be(u,"style")),...t.style]:Ar(Be(u,"style")),...y&&y.length<=24?{text:y}:{},...u.conditional?{conditional:!0}:{},parent:p}),!(h==="input"||h==="svg")){for(let v of u.children)if(es(v))if(v.tag==="")for(let $ of v.children)es($)&&c($,x);else c(v,x)}};return e.root&&c(e.root,-1),{nodes:i,type:a,uncertain:l}}function Ed(e,t){return{classes:[...e.classes,...t.classes],modules:[...e.modules,...t.modules],conditional:[...e.conditional,...t.conditional],forwards:e.forwards||t.forwards,recipe:e.recipe??t.recipe,dynamic:e.dynamic||t.dynamic}}function j0(e,t,n){let r={},o=/^\{([\s\S]*)\}$/.exec(e.trim())?.[1];if(o===void 0)return r;for(let s of Rr(o)){if(s.startsWith("..."))continue;let i=/^([\w$]+)\s*(?::\s*([\s\S]+))?$/.exec(s.trim());if(!i)continue;let l=i[1],a=i[2]?.trim(),c=a?/^["'`]([^"'`$]*)["'`]$/.exec(a)?.[1]:void 0;if(c!==void 0){r[l]=c;continue}let u=a&&/^[\w$]+$/.test(a)?a:l,p=t[u]??n.get(u);p!=null&&(r[l]=p)}return r}function O0(e){let t=e.findIndex(i=>i.part==="control"),n=new Set(["control"]),r=(i,l)=>{n.has(l)&&(l=`node-${i}`),n.add(l),e[i].part=l};t>0&&r(0,"field");let o=i=>[i.tag,...i.classes,...[...i.modules.values()].flatMap(l=>[...l]),i.attrs["data-slot"]??"",i.attrs.role??""].join(" "),s=t>=0?e[t].parent:-1;e.forEach((i,l)=>{if(i.part)return;let a=o(i);i.tag==="label"||/(^|[\s_-])label\b/i.test(a)?r(l,"label"):/\b(alert)\b|(^|[\s_-])(error|errors|invalid)\b|field-?error/i.test(a)?r(l,"error"):/(^|[\s_-])(help|hint|description)\b/i.test(a)?r(l,"help"):i.parent===s&&s>=0&&/^(svg|span|i|img|button|kbd|div)$/.test(i.tag)&&!i.text?.match(/\w{4,}/)?r(l,l<t?"prefix":"suffix"):r(l,`node-${l}`),["label","help","error"].includes(i.part)&&(i.text={label:"Label",help:"Help text",error:"Error message"}[i.part])})}function M0(e,t,n){let r=/<!--[\s\S]*?-->|<(\/)?([a-zA-Z][\w.:-]*)/g,o=[],s=0;return i=>{r.lastIndex=s;for(let l=r.exec(e);l&&l.index<i;l=r.exec(e)){if(!l[2]){s=r.lastIndex;continue}let a=l[2];if(l[1]){let g=o.findLastIndex(h=>h.name===a);g>=0&&(o.length=g);let S=e.indexOf(">",l.index);s=r.lastIndex=S<0?e.length:S+1;continue}let c=Ba(e,l.index);if(!c){s=r.lastIndex;continue}if(c.end>i)break;s=r.lastIndex=c.end;let u=a.toLowerCase();if(c.selfClosing||/^(input|img|br|hr|meta|link|source|wbr|area|col|embed|track)$/.test(u))continue;if(u==="script"||u==="style"){let g=e.indexOf(`</${u}`,s);s=r.lastIndex=g<0?e.length:g;continue}if(/^[A-Z]/.test(a)){o.push({name:a,node:{part:"",tag:"",classes:[],modules:new Map,attrs:{},style:[],parent:-1}});continue}let{attrs:p}=Wa(c.attrs),d=Fn(p.find(g=>g.name==="className"||g.name==="class"),t,n),f=new Map;for(let g of d.modules)f.set(g.sheet,new Set([...f.get(g.sheet)??[],g.name]));let m={tag:a,attrs:p,spreads:[],start:l.index,end:c.end,children:[],conditional:!1};o.push({name:a,node:{part:"",tag:u,classes:d.classes,modules:f,attrs:Xa(m),style:[],parent:-1}})}return o.filter(l=>l.node.tag).map(l=>l.node)}}function D0(e,t){let n=e.length,r=e.map(s=>({...s}));t.forEach((s,i)=>r.push({...s,part:"",parent:i===0?-1:n+i-1}));let o=r.findIndex(s=>s.parent<0);return t.length&&o>=0&&o<n&&(r[o].parent=r.length-1),r}function Td(e,t,n,r,o){if(n.has(e))return n.get(e);let s=t.imports.get(e);if(!s)return null;let i=De(t.path,s.from,l=>o.has(l));if(!i)return null;if(s.name==="default"){let l=o.get(i)??"",a=/export\s+default\s+(?:function\s+)?([A-Z][\w$]*)/.exec(l);return a?r.get(`${i}#${a[1]}`)??null:null}return r.get(`${i}#${s.name}`)??null}function Va(e,t,n,r){let o=je(at(e,"id")),s=je(at(e,"name")),i=je(at(e,"aria-label")),l=je(at(e,"data-slot")),a=(i??n)?.replace(/\s+/g," ").trim().slice(0,80);return{type:t,...o?{id:o}:{},...s?{name:s}:{},...a?{label:a}:{},...l?{dataSlot:l}:{},...r.length?{classes:r.slice(0,8)}:{}}}function _d(e,t){let n=je(at(t,"id"));if(n){let s=new RegExp(`<label\\b[^>]*\\b(?:for|htmlFor)=["'{]+${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}["'}]+[^>]*>([^<{]{1,80})<`).exec(e);if(s)return s[1].trim()||null}let r=e.lastIndexOf("<label",t.start);if(r>=0){let o=Ln(e,r);if(o&&o.end>t.end)return o.children.flatMap(i=>"text"in i?[i.text]:[]).join(" ").trim()||null}return null}function qa(e,t,n){let r=Ka(e,t),o=e.slice(t,n).split(`
|
|
48
48
|
`).slice(0,12),s=Math.min(...o.slice(1).filter(i=>i.trim()).map(i=>/^ */.exec(i)[0].length),1/0);return{source:o.map((i,l)=>l===0||!Number.isFinite(s)?i:i.slice(s)).map(i=>i.length>200?`${i.slice(0,200)}\u2026`:i).join(`
|
|
49
|
-
`),startLine:r}}var Ja=e=>{let n=e.replace(/^\.|^class:/,"").replace(/([a-z\d])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).join(" ").toLowerCase();return n?n[0].toUpperCase()+n.slice(1):"Input"};function Za(e){let t=Ea(e),n=[...t.keys()].sort(),r=yd(t),o=new Set(r.keys()),s=bd(t,o),i=[],l=(w,
|
|
50
|
-
`)[B-1]??"<input>")});continue}let Y=Td(T.tag,E,N,c,t);if(!Y||F(P.index)?.control.start===P.index)continue;let me=at(T,"type");if(Y.type===null&&me){let j=je(me);if(j===null){m.set("dynamic",(m.get("dynamic")??0)+1),l(w,B,`<${T.tag}> type is set at runtime`);continue}if(!Ha(j.toLowerCase())){m.set(j.toLowerCase(),(m.get(j.toLowerCase())??0)+1);continue}}let J={};for(let j of Y.info.axes){let M=at(T,j.prop);if(!M)continue;let U=je(M);if(U===null){l(w,B,`<${T.tag} ${j.prop}> is chosen at runtime`);continue}if(!j.values.includes(U)){S.push({path:w,line:B,component:T.tag,prop:j.prop,value:U,known:[...j.values].sort()});continue}J[j.prop]=U}let te={classes:Fn(We(T,"className"),E,t),style:Ar(We(T,"style")),attrs:T.attrs,spreads:T.spreads};Y.info.forwardsClassName||(te.classes=an());let C=y(Y,te,J,_(P.index),`component:${Y.name}`);f.push({...C,path:w,line:B,via:"component",component:T.tag,example:qa(A,T.start,T.end),identity:Va(T,C.type,_d(A,T),te.classes.classes)})}}let x=new Map,v=new Map,$=(w,A,E,N,F,_)=>{let P=v.get(w.fingerprint);if(P)return A&&!P.sources.includes(A)&&P.sources.push(A),P.from.some(B=>B.path===N.path&&B.line===N.line)||P.from.push(N),F&&!P.suggested&&Object.assign(P,{suggested:F,reason:_,title:E}),P;let T={...w,sources:A?[A]:[],title:E,sizes:[],from:[N],evidence:{files:0,sites:[]},suggested:F,reason:_};return x.set(A??`look:${w.fingerprint}`,T),v.set(w.fingerprint,T),T};for(let w of p){let A=w.info.axes.find(F=>$d.test(F.prop)||F.values.every(_=>Cd.test(_))),E=w.info.axes.filter(F=>F!==A),N=[{}];for(let F of E){let _=[];for(let P of N)for(let T of F.values)_.length<8&&_.push({...P,[F.prop]:T});N=_}for(let F of N){let _=y(w,{classes:an(),style:[],attrs:[],spreads:[]},F,[],`component:${w.name}`),P=Object.values(F).filter(Y=>Y!=="default"),T=P.length?`${w.name} ${P.join(" ")}`:w.name,B=$(_,_.association,T,{path:w.path,line:w.line,label:w.name},!0,w.info.structure==="field"?`Field component ${w.name}`:`Component ${w.name}`);if(A)for(let Y of A.values){if(Y===(F[A.prop]??A.defaultValue)||B.sizes.some(J=>J.select?.value===Y))continue;let me=y(w,{classes:an(),style:[],attrs:[],spreads:[]},{...F,[A.prop]:Y},[],`component:${w.name}`);B.sizes.push({label:Ja(Y),select:{prop:A.prop,value:Y},states:me.states,fingerprint:me.fingerprint})}}}let R=new Map;for(let w of f)w.via==="native"&&w.association&&R.set(w.association,[...R.get(w.association)??[],w]);for(let[w,A]of[...R].sort(([E],[N])=>E.localeCompare(N))){let E=new Map;for(let C of A)E.set(C.type,(E.get(C.type)??0)+1);let N=[...E].sort((C,j)=>j[1]-C[1]||C[0].localeCompare(j[0]))[0][0],F=w.startsWith("class:")?w.slice(6).split(".").filter(Boolean):[],_=new Map,P=[];for(let C of F){let j=C.indexOf("#");j<0?P.push(C):_.set(C.slice(0,j),new Set([..._.get(C.slice(0,j))??[],C.slice(j+1)]))}let T=A[0],Y=A.find(C=>C.type===N&&C.render.root.attrs.type!==void 0)||N!=="text"?{type:N}:{},me=b([{part:"control",tag:"input",classes:P,modules:_,attrs:Y,style:[],parent:-1}],[]),J=k(me,"control",N,w),te=w==="element:input"?"Input element":Ja(F.map(C=>C.split("#").pop()).join(" "));$(J,w,te,{path:T.path,line:T.line,label:w.replace(/^class:/,"")},!0,w==="element:input"?"Styled by the input element's own rules":`Stylesheet class ${w.replace(/^class:/,"")}`)}for(let w of f)w.via!=="native"||w.association||$(w,null,`Input in ${w.path.split("/").pop()}`,{path:w.path,line:w.line,label:w.path},!1,"One-off classes on a raw <input>; not a shared pattern");let I=[...x.values()],O=I.some(w=>w.suggested&&w.sources.some(A=>!A.startsWith("element:")));for(let w of I)O&&w.sources.length&&w.sources.every(A=>A.startsWith("element:"))&&(w.suggested=!1,w.reason="Default <input> styling; the project's inputs use a component or class");for(let w of I){let A=f.filter(E=>E.via!=="definition"&&(w.sources.includes(E.association??"")||!w.sources.length&&E.fingerprint===w.fingerprint));w.evidence={files:new Set(A.map(E=>E.path)).size,sites:A.slice(0,12).map(E=>({path:E.path,line:E.line}))}}I.sort((w,A)=>Number(A.suggested)-Number(w.suggested)||jd(w)-jd(A)||w.title.localeCompare(A.title)||w.fingerprint.localeCompare(A.fingerprint));let L=No(t,Aa(n),{classKeywords:["input","text-field","textfield"],prose:/\b(?:text\s+)?inputs?\b|\btext\s?fields?\b|\bform fields?\b/i},[]),D={},z=w=>{for(let A of w.matchAll(/var\(\s*(--[\w-]+)/g)){let E=A[1];E in D||!r.has(E)||(D[E]=r.get(E),z(D[E]))}};for(let w of[...I,...f])for(let A of w.states)for(let E of A.declarations)z(E.value);return{concept:"input",version:1,definitions:p.map(w=>w.info),candidates:I,usages:f,excluded:[...m].map(([w,A])=>({type:w,count:A})).sort((w,A)=>w.type.localeCompare(A.type)),native:g.slice(0,60),unknownProps:S,guidance:L,tokenValues:D,uncertain:i}}function jd(e){let t=e.sources[0]??"";return t.startsWith("component:")?0:t.startsWith("class:")?1:t.startsWith("element:")?2:3}function Dd(e,t){return La(Za(e),t)}function Pd(e){if(!e||typeof e!="object")return null;let{specs:t,merged:n}=e;return!Array.isArray(t)||!n||typeof n!="object"?null:t.every(o=>o&&typeof o.id=="string"&&typeof o.name=="string"&&typeof o.fingerprint=="string"&&Array.isArray(o.states)&&Array.isArray(o.sources)&&Array.isArray(o.sizes)&&o.render&&typeof o.render=="object")?{specs:t,merged:n}:null}var P0=e=>`${e.target} ${e.state}${e.context?` @ ${e.context}`:""}`;function Ld(e){let t=e.sources.find(s=>s.startsWith("component:")),n=e.sources.find(s=>s.startsWith("class:")),r=e.type==="text"?"":` type="${e.type}"`,o=t?(()=>{let[s,i]=t.slice(10).split("?"),l=i?i.split("&").map(a=>` ${a.replace("=",'="')}"`).join(""):"";return`<${s}${r}${l} />`})():n?`<input className="${n.slice(6).split(".").filter(Boolean).map(s=>s.split("#").pop()).join(" ")}"${r} />`:e.sources.includes("element:input")?`<input${r||' type="text"'} />`:"";return{name:e.name,use:o,structure:e.structure,sizes:e.sizes.map(s=>s.select?`${s.select.prop}="${s.select.value}"`:s.label),states:Object.fromEntries(e.states.map(s=>[P0(s),Object.fromEntries(s.declarations.map(i=>[i.property,i.value]))]))}}var Ir=/(^|\/)(node_modules|\.git|\.next|dist|build|out|coverage|vendor|\.turbo|\.cache|__pycache__|target|\.venv|venv|storybook-static)\//,L0=/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb?|Cargo\.lock|poetry\.lock|composer\.lock|Gemfile\.lock)$|\.min\.(js|css)$|\.map$/,N0=/\.(png|jpe?g|gif|webp|avif|ico|icns|bmp|tiff?|svgz|heic|heif|woff2?|ttf|otf|eot|mp[34]|m4[av]|mkv|avi|mpe?g|wmv|flv|3gp|ogv|wav|flac|aac|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,F0=3e5;function ln(e){return!e||Ir.test(`${e}/`)||L0.test(e)||N0.test(e)}function Nd(e,t){return!ln(e)&&t<=F0}var Fd=/^[a-z0-9-]{1,64}$/;var U0=["new","changed","missing-state","native","prop-unknown"],ss=/^[\w:-]{1,60}$/,zd=/^-{0,2}[a-z][\w-]{0,60}$/i,z0=new Set(["div","span","label","p","input","svg","i","small","strong","em","b","button","kbd","img","section","fieldset","legend"]),G0=/^(type|role|data-slot|data-size|data-variant|aria-hidden)$/,de=(e,t)=>typeof e=="string"&&e.length<=t?e:null,Nt=e=>!/[<>"`]/.test(e);function B0(e){if(!e||typeof e!="object")return null;let t=e,n=Array.isArray(t.classes)?t.classes.filter(o=>typeof o=="string"&&/^[\w-]{1,60}$/.test(o)).slice(0,8):[],r={};if(t.attrs&&typeof t.attrs=="object")for(let[o,s]of Object.entries(t.attrs).slice(0,8))/^[\w:-]{1,40}$/.test(o)&&typeof s=="string"&&s.length<=60&&Nt(s)&&(r[o]=s);return{classes:n,attrs:r}}function W0(e){if(!e||typeof e!="object")return null;let t=e,n=de(t.target,60),r=de(t.state,120),o=de(t.context,200);if(!n||!ss.test(n)||!r||!Nt(r)||o===null||/[{}<>]/.test(o)||!Array.isArray(t.declarations))return null;let s=t.declarations.slice(0,40).flatMap(l=>{let a=de(l?.property,60),c=de(l?.value,300),u=de(l?.via,120);return!a||!zd.test(a)||c===null||!ae(a,c)||/[{};]/.test(c)?[]:[{property:a,value:c,...u&&Nt(u)?{via:u}:{}}]}),i;if(t.markers&&typeof t.markers=="object"){i={};for(let[l,a]of Object.entries(t.markers).slice(0,6)){let c=B0(a);ss.test(l)&&c&&(i[l]=c)}}return{target:n,state:r,context:o,declarations:s,...i&&r!=="default"?{markers:i}:{}}}function Gd(e,t,n){if(!e||typeof e!="object"||t>8||n.n++>60)return null;let r=e,o=de(r.part,40),s=de(r.tag,20);if(!o||!ss.test(o)||!s||!z0.has(s))return null;let i={};if(r.attrs&&typeof r.attrs=="object")for(let[c,u]of Object.entries(r.attrs))G0.test(c)&&typeof u=="string"&&/^[\w -]{0,40}$/.test(u)&&(i[c]=u);if(s==="input"&&i.type&&!Nn.includes(i.type))return null;let l=de(r.text,40),a=Array.isArray(r.children)?r.children.flatMap(c=>{let u=Gd(c,t+1,n);return u?[u]:[]}):[];return{part:o,tag:s,attrs:i,...l&&Nt(l)?{text:l}:{},...r.conditional===!0?{conditional:!0}:{},children:a}}function Ud(e){if(!e||typeof e!="object")return null;let t=e,n=t.structure==="field"?"field":t.structure==="control"?"control":null,r=de(t.type,20);if(!n||!r||!Nn.includes(r))return null;let o=Gd(t.render?.root,0,{n:0});if(!o||!Array.isArray(t.states))return null;let s=t.states.slice(0,60).flatMap(l=>{let a=W0(l);return a?[a]:[]}),i={};if(t.tokenValues&&typeof t.tokenValues=="object")for(let[l,a]of Object.entries(t.tokenValues).slice(0,200))/^--[\w-]{1,80}$/.test(l)&&typeof a=="string"&&a.length<=300&&ae(l,a)&&!/[{};]/.test(a)&&(i[l]=a);return{structure:n,type:r,states:s,render:{root:o},tailwind:t.tailwind===!0,...Object.keys(i).length?{tokenValues:i}:{}}}function H0(e){if(!e||typeof e!="object")return null;let t=e,n=de(t.target,60),r=de(t.state,120),o=de(t.context,200),s=de(t.property,60),i=c=>c===null?null:typeof c=="string"&&c.length<=300?c:void 0,l=i(t.expected),a=i(t.found);return!n||!ss.test(n)||!r||o===null||!s||!zd.test(s)||l===void 0||a===void 0||l===null&&a===null?null:{target:n,state:r,context:o,property:s,expected:l,found:a}}var Ya=/^[\w:.-]{1,120}$/;function V0(e){if(!e||typeof e!="object")return null;let t=e,n=de(t.file,300),r=t.identity??{},o=de(r.type,20);if(!n||!Number.isInteger(t.line)||t.line<1||!o||!Nn.includes(o))return null;let s=(d,f,m)=>typeof d=="string"&&d.length<=m&&f.test(d)?d:void 0,i={type:o},l=s(r.id,Ya,120),a=s(r.name,Ya,120),c=s(r.dataSlot,Ya,120),u=typeof r.label=="string"&&r.label.length<=80&&Nt(r.label)?r.label:void 0,p=Array.isArray(r.classes)?r.classes.filter(d=>typeof d=="string"&&/^[A-Za-z_][\w-]{0,80}$/.test(d)).slice(0,8):[];return l&&(i.id=l),a&&(i.name=a),c&&(i.dataSlot=c),u&&(i.label=u),p.length&&(i.classes=p),{file:n,line:t.line,identity:i,structure:t.structure==="field"?"field":"control"}}function Bd(e){if(!e||typeof e!="object")return null;let t=e;if(!U0.includes(t.reason))return null;let n=de(t.fingerprint,16);if(!n||!/^[a-z0-9]+$/.test(n))return null;let r=null;if(t.spec!==null&&t.spec!==void 0){let p=t.spec,d=de(p.id,64),f=de(p.name,60);if(!d||!Fd.test(d)||!f||!Nt(f))return null;r={id:d,name:f}}let o=t.association===null||t.association===void 0?null:de(t.association,200);if(o!==null&&!/^(component|class|element):[^<>"\s]+$/.test(o))return null;let s=Array.isArray(t.diff)?t.diff.slice(0,Pa).flatMap(p=>{let d=H0(p);return d?[d]:[]}):[],i=Array.isArray(t.missing)?t.missing.filter(p=>typeof p=="string"&&p.length<=120&&Nt(p)).slice(0,20):void 0,l=t.size===void 0||t.size===null?void 0:de(t.size,60),a=Array.isArray(t.locators)?t.locators.slice(0,12).flatMap(p=>{let d=V0(p);return d?[d]:[]}):[],c=t.approved===void 0?null:Ud(t.approved),u=t.proposed===void 0?null:Ud(t.proposed);return{reason:t.reason,spec:r,association:o,diff:s,...i?.length?{missing:i}:{},...l&&Nt(l)?{size:l}:{},fingerprint:n,...a.length?{locators:a}:{},...c?{approved:c}:{},...u?{proposed:u}:{}}}function cn(e){let t=e.trim();if(!t)return null;try{let n=new URL(/^https?:\/\//i.test(t)?t:`https://${t}`);return!/^https?:$/.test(n.protocol)||!n.hostname.includes(".")?null:`${n.protocol}//${n.host}`}catch{return null}}function Wd(e){return e.replace(/^https?:\/\//,"").replace(/\/$/,"")}var q0="Repository not found, or you don't have access.";function Un(e){return e.includes(q0)||e.includes("GitHub blocked access to this repository")}function Hd(e,t){let n=(t??"").replace(/\\/g,"/").replace(/^\.\/?/,"").replace(/^\/+|\/+$/g,""),r=[...n?n.split("/"):[],...e.replace(/\\/g,"/").split("/")],o=[];for(let s of r)if(!(!s||s===".")){if(s===".."){o.pop();continue}o.push(s)}return o.join("/")}function is(e){return((e.split("/").pop()||e).replace(/\.git$/i,"").split(/[-_]/)[0]??"").toLowerCase().replace(/[^a-z]/g,"")}function Qa(e,t){if(!/^[a-z]+$/.test(t))return null;let n=new RegExp(`https?://(?:[a-z0-9-]+\\.)*${t}\\.[a-z]{2,24}(?![\\w.])`,"gi"),r=null;for(let o of e.matchAll(n)){let s=o[0].toLowerCase();if(s.startsWith("https://"))return s;r??=s}return r}function Jd(e,t){let n=[],r=l=>{let a=l?cn(l):null;!a||/\/\/(localhost|127\.|[^/]*github\.com)/i.test(a)||n.includes(a)||n.push(a)},o=t.get("CNAME")??t.get("public/CNAME");r(o?.split(/\s+/).find(Boolean));try{let l=JSON.parse(t.get("package.json")??"null");typeof l?.homepage=="string"&&r(l.homepage)}catch{}let s=is(e),i=null;for(let l of t.values()){let a=Qa(l,s);if(a){if(a.startsWith("https://")){i=a;break}i??=a}}return r(i),n.slice(0,3)}function Kd(e,t){let n=t.trim();if(!n)return{site:e};if(/^(none|skip)$/i.test(n))return{site:null};let r=cn(n);return r?{site:r}:null}function Xd(e,t,n){let r=n.trim();if(!r)return e;let o=Number(r);return Number.isInteger(o)&&o>=1&&o<=t?o-1:null}function el(e,t){let n=t.trim().toLowerCase();return n?n==="y"||n==="yes"?e?"keep":"on":n==="n"||n==="no"?e?"off":"keep":null:"keep"}function tl(e,t){return e==="off"?"remove":e==="on"||t?"install":"leave"}function Zd(e,t){return e||t}function Yd(e,t,n){return e==="off"?t?"remove":"leave":e==="on"||t||n?"install":"leave"}function Qd(e){let t=(e.split("/").pop()||e).replace(/\.git$/i,"");return t.length>80?t.slice(0,80).trim():t}function Vd(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),r=t?.[1]??n?.[1];if(!r)return null;let o=Number(r);return Number.isInteger(o)&&o>=1&&o<=65535&&o!==80&&o!==443?String(o):null}var J0=[[/\bnext\s+dev\b/,"3000"],[/\b(vite|react-router\s+dev|remix\s+vite:dev)\b/,"5173"],[/\bastro\s+dev\b/,"4321"],[/\bnuxt\s+dev\b/,"3000"],[/\breact-scripts\s+start\b/,"3000"],[/\bng\s+serve\b/,"4200"],[/\bgatsby\s+develop\b/,"8000"]];function qd(e){return J0.find(([t])=>t.test(e))?.[1]??null}function Er(e){let t={};try{t=JSON.parse(e).scripts??{}}catch{return null}let n=typeof t.dev=="string"?t.dev:"",r=typeof t.start=="string"?t.start:"",o=Vd(n)??Vd(r);return o?`http://localhost:${o}`:null}function ef(e){let t=Er(e);if(t)return t;let n={};try{n=JSON.parse(e).scripts??{}}catch{return null}let r=s=>typeof n[s]=="string"?n[s]:"",o=qd(r("dev"))??qd(r("start"));return o?`http://localhost:${o}`:null}var un=4e5,zn=25e4,ls=8,K0=/^data:image\/(?:jpeg|png|svg\+xml)(?:;charset=utf-8)?;base64,[A-Za-z0-9+/]+=*$/i;function Ft(e){return!!(e?.screenshot||e?.snapdom)}var X0=/\b(?:class|className)\s*=\s*(?:\{\s*)?[`"']([^`"']+)[`"']/,Z0=/<(button|a|input|select|textarea|label|h[1-6]|p|span|div|li|nav|header|footer|section|img|svg)\b/i,rl=/^[A-Za-z_][\w-]*$/;function Y0(e,t){let n=[];for(let r of e.matchAll(/<(button|a)\b[^>]*>([\s\S]*?)<\/\1>/gi)){let o=r[2]??"";if(o.includes("{")||o.includes("<"))continue;let s=o.replace(/\s+/g," ").trim();s.length<2||s.length>80||n.push({line:e.slice(0,r.index??0).split(`
|
|
49
|
+
`),startLine:r}}var Ja=e=>{let n=e.replace(/^\.|^class:/,"").replace(/([a-z\d])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).join(" ").toLowerCase();return n?n[0].toUpperCase()+n.slice(1):"Input"};function Za(e){let t=Ea(e),n=[...t.keys()].sort(),r=yd(t),o=new Set(r.keys()),s=bd(t,o),i=[],l=(w,R,I)=>{i.length<b0&&i.push({path:w,line:R,reason:I})},a=[];for(let w of n)if(!(!h0.test(w)&&!/\.tsx?$/.test(w)))for(let R of E0(w,t.get(w)))vd.test(R.name)&&!Sd.test(R.name)&&R.root&&a.push(R);let c=new Map,u=[...a];for(let w=0;w<5&&u.length;w++)for(let R=u.length-1;R>=0;R--){let I=u[R],N=os(I.path,t),F=new Map([...c.values()].filter(M=>M.path===I.path).map(M=>[M.name,M])),_=[];for(let M of Id(I.root)){if(M.tag==="input"){_.push({el:M,renders:"native"});continue}let U=N.imports.get(M.tag);if(U&&w0[U.from]?.includes(U.name)){_.push({el:M,renders:"primitive",primitive:U.from});continue}if(M.tag===I.name)continue;let K=Td(M.tag,N,F,c,t);K&&_.push({el:M,renders:"component",inner:K})}let P=Id(I.root).some(M=>/^[A-Z]/.test(M.tag)&&vd.test(M.tag)&&!Sd.test(M.tag)&&!_.some(U=>U.el===M));if(_.length===0&&P&&w<4)continue;if(u.splice(R,1),_.length!==1){_.length>1&&l(I.path,I.line,`${I.name} renders more than one input`);continue}let T=_[0],B=at(T.el,"type"),Y=je(B),me=!B&&(T.el.spreads.length>0||T.renders!=="native")||B?.kind==="expr"&&/^[\w$]+$/.test(B.value)&&(I.params.has(B.value)||I.rest),J;if(Y!==null)J=Y;else if(me)J=T.inner?T.inner.type:null;else if(!B)J="text";else{l(I.path,I.line,`${I.name}'s input type is set at runtime`);continue}if(J!==null&&!Ha(J))continue;let te=Fn(Be(T.el,"className","class"),N,t),C=te.recipe?.recipe,j={name:I.name,path:I.path,line:I.line,renders:T.renders,...T.primitive?{primitive:T.primitive}:{},...T.inner?{wraps:T.inner.name}:{},structure:T.el===I.root&&!T.inner?"control":T.el===I.root?T.inner.info.structure:"field",forwardsClassName:te.forwards||T.el.spreads.length>0&&!Be(T.el,"className"),axes:[...C?.axes.map(M=>({prop:M.prop,values:[...M.values.keys()],...I.params.get(M.prop)??M.defaultValue?{defaultValue:I.params.get(M.prop)??M.defaultValue}:{}}))??[],...T.inner?.info.axes.filter(M=>!C?.axes.some(U=>U.prop===M.prop))??[]]};c.set(`${I.path}#${I.name}`,{...I,info:j,control:T.el,type:J,ctx:N,...T.inner?{inner:T.inner}:{}})}let p=[...c.values()].sort((w,R)=>w.path.localeCompare(R.path)||w.line-R.line),d=p.length>0,f=[],m=new Map,g=[],S=[],h=new Map,b=(w,R)=>{let I=D0(w,R),N=JSON.stringify(I,(_,P)=>P instanceof Map?[...P].map(([T,B])=>[T,[...B]]):P),F=h.get(N);return F||h.set(N,F=kd(I,s,o,r)),F},k=(w,R,I,N,F={},_=[])=>({association:N,structure:R,type:I,states:w.states,render:w.render,fingerprint:w.fingerprint,tailwind:w.tailwind,uncertain:[...new Set([..._,...w.uncertain])].slice(0,20),...F}),y=(w,R,I,N,F)=>{let _=Md(w,R,I,t,c);O0(_.nodes);let P=_.type??"text",T=b(_.nodes,N),B=w.info.axes.find(J=>$d.test(J.prop)||J.values.every(te=>Cd.test(te))),Y=w.info.axes.filter(J=>J!==B).flatMap(J=>{let te=I[J.prop]??J.defaultValue;return te?[{prop:J.prop,value:te}]:[]}),me=B?(()=>{let J=I[B.prop]??B.defaultValue;return J?{label:Ja(J),select:{prop:B.prop,value:J}}:void 0})():void 0;return k(T,_.nodes[0]?.part==="field"?"field":"control",P,F+Y.map(J=>`${J===Y[0]?"?":"&"}${J.prop}=${J.value}`).join(""),{...me?{size:me}:{},...Y.length?{select:Y}:{}},_.uncertain)};for(let w of p){let R=y(w,{classes:an(),style:[],attrs:[],spreads:[]},{},[],`component:${w.name}`);f.push({...R,path:w.path,line:w.line,via:"definition",component:w.name,example:qa(w.ctx.source,w.control.start,w.control.end),identity:Va(w.control,R.type,null,[])})}for(let w of n){if(!m0.test(w))continue;let R=t.get(w);if(!/<input\b|<[A-Z]/.test(R))continue;let I=os(w,t),N=new Map(p.filter(P=>P.path===w).map(P=>[P.name,P])),F=P=>p.find(T=>T.path===w&&P>=T.start&&P<T.end),_=M0(R,I,t);for(let P of R.matchAll(/<(input|[A-Z][\w.]*)\b/g)){if(f.length>=y0)break;let T=Ln(R,P.index);if(!T)continue;let B=Ka(R,P.index);if(T.tag==="input"){if(F(P.index))continue;let j=at(T,"type"),M=j?je(j):"text";if(M===null){m.set("dynamic",(m.get("dynamic")??0)+1),l(w,B,"<input> type is set at runtime");continue}if(!Ha(M.toLowerCase())){m.set(M.toLowerCase(),(m.get(M.toLowerCase())??0)+1);continue}let U=Fn(Be(T,"className","class"),I,t),K=new Map;for(let be of U.modules)K.set(be.sheet,new Set([...K.get(be.sheet)??[],be.name]));let se=Xa(T),X={part:"control",tag:"input",classes:U.classes,modules:K,attrs:se,style:Ar(Be(T,"style")),parent:-1},fe=_(P.index),ie=b([X],fe),Ie=ie.controlRuleClasses.filter(be=>{let fo=be.includes("#")?be.slice(be.indexOf("#")+1):be;return x0.test(fo)&&!v0.test(fo)}),oe=Ie.length?`class:${Ie.map(be=>`.${be}`).join("")}`:ie.elementRules&&!ie.controlRuleClasses.length&&!ie.tailwind?"element:input":null,Oe=[...U.conditional.map(be=>`${be} (conditional)`),...U.dynamic?["className is built at runtime"]:[]],Rt=k(ie,"control",M.toLowerCase(),oe,{},Oe);f.push({...Rt,path:w,line:B,via:"native",example:qa(R,T.start,T.end),identity:Va(T,Rt.type,_d(R,T),[...U.classes,...U.modules.map(be=>be.name)])}),d&&g.push({path:w,line:B,snippet:ht(R.split(`
|
|
50
|
+
`)[B-1]??"<input>")});continue}let Y=Td(T.tag,I,N,c,t);if(!Y||F(P.index)?.control.start===P.index)continue;let me=at(T,"type");if(Y.type===null&&me){let j=je(me);if(j===null){m.set("dynamic",(m.get("dynamic")??0)+1),l(w,B,`<${T.tag}> type is set at runtime`);continue}if(!Ha(j.toLowerCase())){m.set(j.toLowerCase(),(m.get(j.toLowerCase())??0)+1);continue}}let J={};for(let j of Y.info.axes){let M=at(T,j.prop);if(!M)continue;let U=je(M);if(U===null){l(w,B,`<${T.tag} ${j.prop}> is chosen at runtime`);continue}if(!j.values.includes(U)){S.push({path:w,line:B,component:T.tag,prop:j.prop,value:U,known:[...j.values].sort()});continue}J[j.prop]=U}let te={classes:Fn(Be(T,"className"),I,t),style:Ar(Be(T,"style")),attrs:T.attrs,spreads:T.spreads};Y.info.forwardsClassName||(te.classes=an());let C=y(Y,te,J,_(P.index),`component:${Y.name}`);f.push({...C,path:w,line:B,via:"component",component:T.tag,example:qa(R,T.start,T.end),identity:Va(T,C.type,_d(R,T),te.classes.classes)})}}let x=new Map,v=new Map,$=(w,R,I,N,F,_)=>{let P=v.get(w.fingerprint);if(P)return R&&!P.sources.includes(R)&&P.sources.push(R),P.from.some(B=>B.path===N.path&&B.line===N.line)||P.from.push(N),F&&!P.suggested&&Object.assign(P,{suggested:F,reason:_,title:I}),P;let T={...w,sources:R?[R]:[],title:I,sizes:[],from:[N],evidence:{files:0,sites:[]},suggested:F,reason:_};return x.set(R??`look:${w.fingerprint}`,T),v.set(w.fingerprint,T),T};for(let w of p){let R=w.info.axes.find(F=>$d.test(F.prop)||F.values.every(_=>Cd.test(_))),I=w.info.axes.filter(F=>F!==R),N=[{}];for(let F of I){let _=[];for(let P of N)for(let T of F.values)_.length<8&&_.push({...P,[F.prop]:T});N=_}for(let F of N){let _=y(w,{classes:an(),style:[],attrs:[],spreads:[]},F,[],`component:${w.name}`),P=Object.values(F).filter(Y=>Y!=="default"),T=P.length?`${w.name} ${P.join(" ")}`:w.name,B=$(_,_.association,T,{path:w.path,line:w.line,label:w.name},!0,w.info.structure==="field"?`Field component ${w.name}`:`Component ${w.name}`);if(R)for(let Y of R.values){if(Y===(F[R.prop]??R.defaultValue)||B.sizes.some(J=>J.select?.value===Y))continue;let me=y(w,{classes:an(),style:[],attrs:[],spreads:[]},{...F,[R.prop]:Y},[],`component:${w.name}`);B.sizes.push({label:Ja(Y),select:{prop:R.prop,value:Y},states:me.states,fingerprint:me.fingerprint})}}}let A=new Map;for(let w of f)w.via==="native"&&w.association&&A.set(w.association,[...A.get(w.association)??[],w]);for(let[w,R]of[...A].sort(([I],[N])=>I.localeCompare(N))){let I=new Map;for(let C of R)I.set(C.type,(I.get(C.type)??0)+1);let N=[...I].sort((C,j)=>j[1]-C[1]||C[0].localeCompare(j[0]))[0][0],F=w.startsWith("class:")?w.slice(6).split(".").filter(Boolean):[],_=new Map,P=[];for(let C of F){let j=C.indexOf("#");j<0?P.push(C):_.set(C.slice(0,j),new Set([..._.get(C.slice(0,j))??[],C.slice(j+1)]))}let T=R[0],Y=R.find(C=>C.type===N&&C.render.root.attrs.type!==void 0)||N!=="text"?{type:N}:{},me=b([{part:"control",tag:"input",classes:P,modules:_,attrs:Y,style:[],parent:-1}],[]),J=k(me,"control",N,w),te=w==="element:input"?"Input element":Ja(F.map(C=>C.split("#").pop()).join(" "));$(J,w,te,{path:T.path,line:T.line,label:w.replace(/^class:/,"")},!0,w==="element:input"?"Styled by the input element's own rules":`Stylesheet class ${w.replace(/^class:/,"")}`)}for(let w of f)w.via!=="native"||w.association||$(w,null,`Input in ${w.path.split("/").pop()}`,{path:w.path,line:w.line,label:w.path},!1,"One-off classes on a raw <input>; not a shared pattern");let E=[...x.values()],O=E.some(w=>w.suggested&&w.sources.some(R=>!R.startsWith("element:")));for(let w of E)O&&w.sources.length&&w.sources.every(R=>R.startsWith("element:"))&&(w.suggested=!1,w.reason="Default <input> styling; the project's inputs use a component or class");for(let w of E){let R=f.filter(I=>I.via!=="definition"&&(w.sources.includes(I.association??"")||!w.sources.length&&I.fingerprint===w.fingerprint));w.evidence={files:new Set(R.map(I=>I.path)).size,sites:R.slice(0,12).map(I=>({path:I.path,line:I.line}))}}E.sort((w,R)=>Number(R.suggested)-Number(w.suggested)||jd(w)-jd(R)||w.title.localeCompare(R.title)||w.fingerprint.localeCompare(R.fingerprint));let L=No(t,Aa(n),{classKeywords:["input","text-field","textfield"],prose:/\b(?:text\s+)?inputs?\b|\btext\s?fields?\b|\bform fields?\b/i},[]),D={},z=w=>{for(let R of w.matchAll(/var\(\s*(--[\w-]+)/g)){let I=R[1];I in D||!r.has(I)||(D[I]=r.get(I),z(D[I]))}};for(let w of[...E,...f])for(let R of w.states)for(let I of R.declarations)z(I.value);return{concept:"input",version:1,definitions:p.map(w=>w.info),candidates:E,usages:f,excluded:[...m].map(([w,R])=>({type:w,count:R})).sort((w,R)=>w.type.localeCompare(R.type)),native:g.slice(0,60),unknownProps:S,guidance:L,tokenValues:D,uncertain:i}}function jd(e){let t=e.sources[0]??"";return t.startsWith("component:")?0:t.startsWith("class:")?1:t.startsWith("element:")?2:3}function Dd(e,t){return La(Za(e),t)}function Pd(e){if(!e||typeof e!="object")return null;let{specs:t,merged:n}=e;return!Array.isArray(t)||!n||typeof n!="object"?null:t.every(o=>o&&typeof o.id=="string"&&typeof o.name=="string"&&typeof o.fingerprint=="string"&&Array.isArray(o.states)&&Array.isArray(o.sources)&&Array.isArray(o.sizes)&&o.render&&typeof o.render=="object")?{specs:t,merged:n}:null}var P0=e=>`${e.target} ${e.state}${e.context?` @ ${e.context}`:""}`;function Ld(e){let t=e.sources.find(s=>s.startsWith("component:")),n=e.sources.find(s=>s.startsWith("class:")),r=e.type==="text"?"":` type="${e.type}"`,o=t?(()=>{let[s,i]=t.slice(10).split("?"),l=i?i.split("&").map(a=>` ${a.replace("=",'="')}"`).join(""):"";return`<${s}${r}${l} />`})():n?`<input className="${n.slice(6).split(".").filter(Boolean).map(s=>s.split("#").pop()).join(" ")}"${r} />`:e.sources.includes("element:input")?`<input${r||' type="text"'} />`:"";return{name:e.name,use:o,structure:e.structure,sizes:e.sizes.map(s=>s.select?`${s.select.prop}="${s.select.value}"`:s.label),states:Object.fromEntries(e.states.map(s=>[P0(s),Object.fromEntries(s.declarations.map(i=>[i.property,i.value]))]))}}var Ir=/(^|\/)(node_modules|\.git|\.next|dist|build|out|coverage|vendor|\.turbo|\.cache|__pycache__|target|\.venv|venv|storybook-static)\//,L0=/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb?|Cargo\.lock|poetry\.lock|composer\.lock|Gemfile\.lock)$|\.min\.(js|css)$|\.map$/,N0=/\.(png|jpe?g|gif|webp|avif|ico|icns|bmp|tiff?|svgz|heic|heif|woff2?|ttf|otf|eot|mp[34]|m4[av]|mkv|avi|mpe?g|wmv|flv|3gp|ogv|wav|flac|aac|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,F0=3e5;function ln(e){return!e||Ir.test(`${e}/`)||L0.test(e)||N0.test(e)}function Nd(e,t){return!ln(e)&&t<=F0}var Fd=/^[a-z0-9-]{1,64}$/;var U0=["new","changed","missing-state","native","prop-unknown"],ss=/^[\w:-]{1,60}$/,zd=/^-{0,2}[a-z][\w-]{0,60}$/i,z0=new Set(["div","span","label","p","input","svg","i","small","strong","em","b","button","kbd","img","section","fieldset","legend"]),G0=/^(type|role|data-slot|data-size|data-variant|aria-hidden)$/,de=(e,t)=>typeof e=="string"&&e.length<=t?e:null,Nt=e=>!/[<>"`]/.test(e);function B0(e){if(!e||typeof e!="object")return null;let t=e,n=Array.isArray(t.classes)?t.classes.filter(o=>typeof o=="string"&&/^[\w-]{1,60}$/.test(o)).slice(0,8):[],r={};if(t.attrs&&typeof t.attrs=="object")for(let[o,s]of Object.entries(t.attrs).slice(0,8))/^[\w:-]{1,40}$/.test(o)&&typeof s=="string"&&s.length<=60&&Nt(s)&&(r[o]=s);return{classes:n,attrs:r}}function W0(e){if(!e||typeof e!="object")return null;let t=e,n=de(t.target,60),r=de(t.state,120),o=de(t.context,200);if(!n||!ss.test(n)||!r||!Nt(r)||o===null||/[{}<>]/.test(o)||!Array.isArray(t.declarations))return null;let s=t.declarations.slice(0,40).flatMap(l=>{let a=de(l?.property,60),c=de(l?.value,300),u=de(l?.via,120);return!a||!zd.test(a)||c===null||!ae(a,c)||/[{};]/.test(c)?[]:[{property:a,value:c,...u&&Nt(u)?{via:u}:{}}]}),i;if(t.markers&&typeof t.markers=="object"){i={};for(let[l,a]of Object.entries(t.markers).slice(0,6)){let c=B0(a);ss.test(l)&&c&&(i[l]=c)}}return{target:n,state:r,context:o,declarations:s,...i&&r!=="default"?{markers:i}:{}}}function Gd(e,t,n){if(!e||typeof e!="object"||t>8||n.n++>60)return null;let r=e,o=de(r.part,40),s=de(r.tag,20);if(!o||!ss.test(o)||!s||!z0.has(s))return null;let i={};if(r.attrs&&typeof r.attrs=="object")for(let[c,u]of Object.entries(r.attrs))G0.test(c)&&typeof u=="string"&&/^[\w -]{0,40}$/.test(u)&&(i[c]=u);if(s==="input"&&i.type&&!Nn.includes(i.type))return null;let l=de(r.text,40),a=Array.isArray(r.children)?r.children.flatMap(c=>{let u=Gd(c,t+1,n);return u?[u]:[]}):[];return{part:o,tag:s,attrs:i,...l&&Nt(l)?{text:l}:{},...r.conditional===!0?{conditional:!0}:{},children:a}}function Ud(e){if(!e||typeof e!="object")return null;let t=e,n=t.structure==="field"?"field":t.structure==="control"?"control":null,r=de(t.type,20);if(!n||!r||!Nn.includes(r))return null;let o=Gd(t.render?.root,0,{n:0});if(!o||!Array.isArray(t.states))return null;let s=t.states.slice(0,60).flatMap(l=>{let a=W0(l);return a?[a]:[]}),i={};if(t.tokenValues&&typeof t.tokenValues=="object")for(let[l,a]of Object.entries(t.tokenValues).slice(0,200))/^--[\w-]{1,80}$/.test(l)&&typeof a=="string"&&a.length<=300&&ae(l,a)&&!/[{};]/.test(a)&&(i[l]=a);return{structure:n,type:r,states:s,render:{root:o},tailwind:t.tailwind===!0,...Object.keys(i).length?{tokenValues:i}:{}}}function H0(e){if(!e||typeof e!="object")return null;let t=e,n=de(t.target,60),r=de(t.state,120),o=de(t.context,200),s=de(t.property,60),i=c=>c===null?null:typeof c=="string"&&c.length<=300?c:void 0,l=i(t.expected),a=i(t.found);return!n||!ss.test(n)||!r||o===null||!s||!zd.test(s)||l===void 0||a===void 0||l===null&&a===null?null:{target:n,state:r,context:o,property:s,expected:l,found:a}}var Ya=/^[\w:.-]{1,120}$/;function V0(e){if(!e||typeof e!="object")return null;let t=e,n=de(t.file,300),r=t.identity??{},o=de(r.type,20);if(!n||!Number.isInteger(t.line)||t.line<1||!o||!Nn.includes(o))return null;let s=(d,f,m)=>typeof d=="string"&&d.length<=m&&f.test(d)?d:void 0,i={type:o},l=s(r.id,Ya,120),a=s(r.name,Ya,120),c=s(r.dataSlot,Ya,120),u=typeof r.label=="string"&&r.label.length<=80&&Nt(r.label)?r.label:void 0,p=Array.isArray(r.classes)?r.classes.filter(d=>typeof d=="string"&&/^[A-Za-z_][\w-]{0,80}$/.test(d)).slice(0,8):[];return l&&(i.id=l),a&&(i.name=a),c&&(i.dataSlot=c),u&&(i.label=u),p.length&&(i.classes=p),{file:n,line:t.line,identity:i,structure:t.structure==="field"?"field":"control"}}function Bd(e){if(!e||typeof e!="object")return null;let t=e;if(!U0.includes(t.reason))return null;let n=de(t.fingerprint,16);if(!n||!/^[a-z0-9]+$/.test(n))return null;let r=null;if(t.spec!==null&&t.spec!==void 0){let p=t.spec,d=de(p.id,64),f=de(p.name,60);if(!d||!Fd.test(d)||!f||!Nt(f))return null;r={id:d,name:f}}let o=t.association===null||t.association===void 0?null:de(t.association,200);if(o!==null&&!/^(component|class|element):[^<>"\s]+$/.test(o))return null;let s=Array.isArray(t.diff)?t.diff.slice(0,Pa).flatMap(p=>{let d=H0(p);return d?[d]:[]}):[],i=Array.isArray(t.missing)?t.missing.filter(p=>typeof p=="string"&&p.length<=120&&Nt(p)).slice(0,20):void 0,l=t.size===void 0||t.size===null?void 0:de(t.size,60),a=Array.isArray(t.locators)?t.locators.slice(0,12).flatMap(p=>{let d=V0(p);return d?[d]:[]}):[],c=t.approved===void 0?null:Ud(t.approved),u=t.proposed===void 0?null:Ud(t.proposed);return{reason:t.reason,spec:r,association:o,diff:s,...i?.length?{missing:i}:{},...l&&Nt(l)?{size:l}:{},fingerprint:n,...a.length?{locators:a}:{},...c?{approved:c}:{},...u?{proposed:u}:{}}}function cn(e){let t=e.trim();if(!t)return null;try{let n=new URL(/^https?:\/\//i.test(t)?t:`https://${t}`);return!/^https?:$/.test(n.protocol)||!n.hostname.includes(".")?null:`${n.protocol}//${n.host}`}catch{return null}}function Wd(e){return e.replace(/^https?:\/\//,"").replace(/\/$/,"")}var q0="Repository not found, or you don't have access.";function Un(e){return e.includes(q0)||e.includes("GitHub blocked access to this repository")}function Hd(e,t){let n=(t??"").replace(/\\/g,"/").replace(/^\.\/?/,"").replace(/^\/+|\/+$/g,""),r=[...n?n.split("/"):[],...e.replace(/\\/g,"/").split("/")],o=[];for(let s of r)if(!(!s||s===".")){if(s===".."){o.pop();continue}o.push(s)}return o.join("/")}function is(e){return((e.split("/").pop()||e).replace(/\.git$/i,"").split(/[-_]/)[0]??"").toLowerCase().replace(/[^a-z]/g,"")}function Qa(e,t){if(!/^[a-z]+$/.test(t))return null;let n=new RegExp(`https?://(?:[a-z0-9-]+\\.)*${t}\\.[a-z]{2,24}(?![\\w.])`,"gi"),r=null;for(let o of e.matchAll(n)){let s=o[0].toLowerCase();if(s.startsWith("https://"))return s;r??=s}return r}function Jd(e,t){let n=[],r=l=>{let a=l?cn(l):null;!a||/\/\/(localhost|127\.|[^/]*github\.com)/i.test(a)||n.includes(a)||n.push(a)},o=t.get("CNAME")??t.get("public/CNAME");r(o?.split(/\s+/).find(Boolean));try{let l=JSON.parse(t.get("package.json")??"null");typeof l?.homepage=="string"&&r(l.homepage)}catch{}let s=is(e),i=null;for(let l of t.values()){let a=Qa(l,s);if(a){if(a.startsWith("https://")){i=a;break}i??=a}}return r(i),n.slice(0,3)}function Kd(e,t){let n=t.trim();if(!n)return{site:e};if(/^(none|skip)$/i.test(n))return{site:null};let r=cn(n);return r?{site:r}:null}function Xd(e,t,n){let r=n.trim();if(!r)return e;let o=Number(r);return Number.isInteger(o)&&o>=1&&o<=t?o-1:null}function el(e,t){let n=t.trim().toLowerCase();return n?n==="y"||n==="yes"?e?"keep":"on":n==="n"||n==="no"?e?"off":"keep":null:"keep"}function tl(e,t){return e==="off"?"remove":e==="on"||t?"install":"leave"}function Zd(e,t){return e||t}function Yd(e,t,n){return e==="off"?t?"remove":"leave":e==="on"||t||n?"install":"leave"}function Qd(e){let t=(e.split("/").pop()||e).replace(/\.git$/i,"");return t.length>80?t.slice(0,80).trim():t}function Vd(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),r=t?.[1]??n?.[1];if(!r)return null;let o=Number(r);return Number.isInteger(o)&&o>=1&&o<=65535&&o!==80&&o!==443?String(o):null}var J0=[[/\bnext\s+dev\b/,"3000"],[/\b(vite|react-router\s+dev|remix\s+vite:dev)\b/,"5173"],[/\bastro\s+dev\b/,"4321"],[/\bnuxt\s+dev\b/,"3000"],[/\breact-scripts\s+start\b/,"3000"],[/\bng\s+serve\b/,"4200"],[/\bgatsby\s+develop\b/,"8000"]];function qd(e){return J0.find(([t])=>t.test(e))?.[1]??null}function Er(e){let t={};try{t=JSON.parse(e).scripts??{}}catch{return null}let n=typeof t.dev=="string"?t.dev:"",r=typeof t.start=="string"?t.start:"",o=Vd(n)??Vd(r);return o?`http://localhost:${o}`:null}function ef(e){let t=Er(e);if(t)return t;let n={};try{n=JSON.parse(e).scripts??{}}catch{return null}let r=s=>typeof n[s]=="string"?n[s]:"",o=qd(r("dev"))??qd(r("start"));return o?`http://localhost:${o}`:null}var un=4e5,zn=25e4,ls=8,K0=/^data:image\/(?:jpeg|png|svg\+xml)(?:;charset=utf-8)?;base64,[A-Za-z0-9+/]+=*$/i;function Ft(e){return!!(e?.screenshot||e?.snapdom)}var X0=/\b(?:class|className)\s*=\s*(?:\{\s*)?[`"']([^`"']+)[`"']/,Z0=/<(button|a|input|select|textarea|label|h[1-6]|p|span|div|li|nav|header|footer|section|img|svg)\b/i,rl=/^[A-Za-z_][\w-]*$/;function Y0(e,t){let n=[];for(let r of e.matchAll(/<(button|a)\b[^>]*>([\s\S]*?)<\/\1>/gi)){let o=r[2]??"";if(o.includes("{")||o.includes("<"))continue;let s=o.replace(/\s+/g," ").trim();s.length<2||s.length>80||n.push({line:e.slice(0,r.index??0).split(`
|
|
51
51
|
`).length,text:s})}if(n.length){if(typeof t=="number"){let r=n.find(o=>Math.abs(o.line-t)<=12);if(r)return r.text}return n.length===1?n[0].text:void 0}}function of(e,t,n){let r=t.locators??[],o=n?r.find(c=>c.file===n.file&&c.line===n.line):r[0];if(!o)return null;let{identity:s,structure:i}=o,l=(s.classes??[]).filter(c=>rl.test(c)).slice(0,6),a=nl({...s.type&&s.type!=="text"?{type:s.type}:{},...s.id?{id:s.id}:{},...s.name?{name:s.name}:{},...s.label?{label:s.label}:{},...s.dataSlot?{dataSlot:s.dataSlot}:{},...i==="field"?{field:!0}:{}});return!a||!l.length&&!a.id&&!a.name&&!a.label&&!a.dataSlot&&!a.type?null:{key:e.slice(0,200),classes:l,tag:"input",...l.length?{selector:`input${l.map(c=>`.${c}`).join("")}`}:{},input:a}}function Gn(e,t=()=>{}){if(e.input)return of(e.key,e.input);let n=[],r;for(let l of e.places){let a=X0.exec(l.snippet);if(a?.[1]&&(n=a[1].split(/\s+/).filter(c=>rl.test(c)).slice(0,6)),r=Z0.exec(l.snippet)?.[1]?.toLowerCase(),n.length||r)break}let o;for(let l of e.places.slice(0,4)){let a=t(l.file);if(o=a?Y0(a,l.line):void 0,o)break}let i=/^[a-z-]+$/.test(e.property)&&e.found&&!e.found.startsWith("--")&&!/var\(/.test(e.found)&&e.found.length<=180?{property:e.property,value:e.found}:void 0;return!n.length&&!o&&!i?null:{key:e.key.slice(0,200),classes:n,...r?{tag:r}:{},...o?{text:o}:{},...i?{style:i}:{}}}var Q0=/^[a-z]+(?:-[a-z]+)*$/;function ol(e,t,n){if(e.input)return of(e.key,e.input,t);if(!/\.html?$/.test(t.file)||t.line<1)return null;let r=n.split(`
|
|
52
52
|
`),o=r[t.line-1];if(!o||o.trim()!==t.snippet.trim())return null;let s=r.slice(0,t.line-1).join(`
|
|
53
53
|
`).length+(t.line>1?1:0),i=_t(n,s+o.indexOf("<")+1,[],t.file),l=i.kind==="markup"?i.element:null;if(!l)return null;let a=d=>/^[a-z][a-z0-9-]*$/.test(d.tag)?d.tag+d.classes.filter(f=>rl.test(f)).map(f=>`.${f}`).join(""):null,c=[...l.ancestors,l].map(a);if(c.some(d=>!d))return null;let u=c.join(" "),p=Gn({...e,places:[t]},()=>n);return p&&u.length<=1e3?{...p,selector:u}:null}function sf(e,t,n,r){let o=ol(e,t,n),s=o?pn({url:r,query:o}):null;if(!s)return null;let i=n.split(`
|
|
54
54
|
`),l=i.slice(0,t.line-1).join(`
|
|
55
|
-
`).length+(t.line>1?1:0),a=_t(n,l+i[t.line-1].indexOf("<")+1,[],t.file).element,c=[a,...[...a?.ancestors??[]].reverse()].find(g=>g?.attrs.id)?.attrs.id,u=n.slice(Math.max(0,l-8e3),l),d=[...u.slice(Math.max(0,u.lastIndexOf("<section"))).matchAll(/<h[1-6]\b[^>]*\bid=["']([A-Za-z][\w:-]*)["']/gi)].at(-1)?.[1],f=c&&/^[A-Za-z][\w:-]*$/.test(c)?c:d,m=new URL(s.url);return f&&(m.hash=f),{locate:s,pageHref:m.toString()}}function _r(e){let t=e;if(!t||typeof t!="object"||typeof t.key!="string"||!t.key||t.key.length>200||!Array.isArray(t.classes)||t.classes.length>40||t.classes.some(r=>typeof r!="string"||r.length>150||!/^[A-Za-z_][\w-]*$/.test(r))||t.tag!=null&&(typeof t.tag!="string"||!/^[a-z][a-z0-9-]*$/i.test(t.tag))||t.text!=null&&(typeof t.text!="string"||!t.text.trim()||t.text.length>80)||t.selector!=null&&(typeof t.selector!="string"||!t.selector||t.selector.length>1e3||!/^[a-zA-Z0-9_. -]+$/.test(t.selector))||t.style!=null&&(typeof t.style!="object"||typeof t.style.property!="string"||!Q0.test(t.style.property)||t.style.property.length>40||typeof t.style.value!="string"||!t.style.value||t.style.value.length>180)||t.input!=null&&!nl(t.input)||!t.classes.length&&!t.text&&!t.style&&!t.input)return null;let n=t.input!=null?nl(t.input):null;return{key:t.key,classes:t.classes,...t.tag?{tag:t.tag}:{},...t.text?{text:t.text}:{},...t.selector?{selector:t.selector}:{},...t.style?{style:{property:t.style.property,value:t.style.value}}:{},...n?{input:n}:{}}}var eS=/^[\w:.-]{1,120}$/;function nl(e){if(!e||typeof e!="object")return null;let t=e,n=a=>a===void 0?void 0:typeof a=="string"&&eS.test(a)?a:null,r=n(t.type),o=n(t.id),s=n(t.name),i=n(t.dataSlot),l=t.label===void 0?void 0:typeof t.label=="string"&&t.label.trim()&&t.label.length<=80&&!/[<>]/.test(t.label)?t.label:null;return[r,o,s,i,l].some(a=>a===null)||r&&!/^(text|email|password|search|tel|url)$/.test(r)||t.field!==void 0&&typeof t.field!="boolean"?null:{...r?{type:r}:{},...o?{id:o}:{},...s?{name:s}:{},...l?{label:l}:{},...i?{dataSlot:i}:{},...t.field===!0?{field:!0}:{}}}function pn(e){if(!e||typeof e!="object")return null;let t=e,n=
|
|
55
|
+
`).length+(t.line>1?1:0),a=_t(n,l+i[t.line-1].indexOf("<")+1,[],t.file).element,c=[a,...[...a?.ancestors??[]].reverse()].find(g=>g?.attrs.id)?.attrs.id,u=n.slice(Math.max(0,l-8e3),l),d=[...u.slice(Math.max(0,u.lastIndexOf("<section"))).matchAll(/<h[1-6]\b[^>]*\bid=["']([A-Za-z][\w:-]*)["']/gi)].at(-1)?.[1],f=c&&/^[A-Za-z][\w:-]*$/.test(c)?c:d,m=new URL(s.url);return f&&(m.hash=f),{locate:s,pageHref:m.toString()}}function _r(e){let t=e;if(!t||typeof t!="object"||typeof t.key!="string"||!t.key||t.key.length>200||!Array.isArray(t.classes)||t.classes.length>40||t.classes.some(r=>typeof r!="string"||r.length>150||!/^[A-Za-z_][\w-]*$/.test(r))||t.tag!=null&&(typeof t.tag!="string"||!/^[a-z][a-z0-9-]*$/i.test(t.tag))||t.text!=null&&(typeof t.text!="string"||!t.text.trim()||t.text.length>80)||t.selector!=null&&(typeof t.selector!="string"||!t.selector||t.selector.length>1e3||!/^[a-zA-Z0-9_. -]+$/.test(t.selector))||t.style!=null&&(typeof t.style!="object"||typeof t.style.property!="string"||!Q0.test(t.style.property)||t.style.property.length>40||typeof t.style.value!="string"||!t.style.value||t.style.value.length>180)||t.input!=null&&!nl(t.input)||!t.classes.length&&!t.text&&!t.style&&!t.input)return null;let n=t.input!=null?nl(t.input):null;return{key:t.key,classes:t.classes,...t.tag?{tag:t.tag}:{},...t.text?{text:t.text}:{},...t.selector?{selector:t.selector}:{},...t.style?{style:{property:t.style.property,value:t.style.value}}:{},...n?{input:n}:{}}}var eS=/^[\w:.-]{1,120}$/;function nl(e){if(!e||typeof e!="object")return null;let t=e,n=a=>a===void 0?void 0:typeof a=="string"&&eS.test(a)?a:null,r=n(t.type),o=n(t.id),s=n(t.name),i=n(t.dataSlot),l=t.label===void 0?void 0:typeof t.label=="string"&&t.label.trim()&&t.label.length<=80&&!/[<>]/.test(t.label)?t.label:null;return[r,o,s,i,l].some(a=>a===null)||r&&!/^(text|email|password|search|tel|url)$/.test(r)||t.field!==void 0&&typeof t.field!="boolean"?null:{...r?{type:r}:{},...o?{id:o}:{},...s?{name:s}:{},...l?{label:l}:{},...i?{dataSlot:i}:{},...t.field===!0?{field:!0}:{}}}function pn(e){if(!e||typeof e!="object")return null;let t=e,n=We(t.url),r=_r(t.query);if(!n||!r)return null;let o=new URL(n);return o.username||o.password?null:{url:o.origin+o.pathname+o.search,query:r}}function We(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:"?n.toString():null}catch{return null}}function Tr(e,t){let n=We(e);if(n)return n;if(typeof e!="string"||e.length>2e3)return null;try{let r=new URL(e.trim());if(r.protocol!=="file:"||r.host||/%(2f|5c)/i.test(r.pathname))return null;let o=decodeURIComponent(r.pathname),s=sl(t);return o===s||o.startsWith(`${s}/`)?r.toString():null}catch{return null}}var jr=e=>!!e&&/^file:/i.test(e);function sl(e){return`/${e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")}`}function kt(e,t,n){let r=e.trim();if(!r||r.includes("*"))return null;if(/^[a-z][a-z0-9+.-]*:/i.test(r)&&!/^[\w.-]+:\d/.test(r))return Tr(r,t);let o=sl(t),s=c=>c.split("/").map(encodeURIComponent).join("/"),i=`file://${s(o)}/`,a=(c=>{try{return decodeURIComponent(new URL(s(c),i).pathname)}catch{return null}})(r);if(a){let c=`${a.replace(/\/$/,"")}/index.html`,u=n(a)?a:n(c)?c:null;if(u||/^\.{0,2}\//.test(r))return Tr(`file://${s(u??a)}`,t)}return We(`http://${r}`)}function tf(e,t){let n=[];for(let r of e)if(!(t==="app"&&/^\(.*\)$/.test(r))){if(t==="app"&&r.startsWith("@")||/[[\]]/.test(r))return null;n.push(r)}return`/${n.join("/")}`}function af(e){let t=e.replace(/\\/g,"/").replace(/^\.\//,""),n=/(?:^|\/)app\/(.*)$/.exec(t);if(n&&/(?:^|\/)page\.(tsx|jsx|js|mdx)$/.test(n[1]))return tf(n[1].replace(/(?:^|\/)page\.(tsx|jsx|js|mdx)$/,"").split("/").filter(Boolean),"app");let r=/(?:^|\/)pages\/(.*)$/.exec(t);if(r&&/\.(tsx|jsx|js|mdx)$/.test(r[1])&&!/^api(\/|$)/.test(r[1])&&!/(?:^|\/)_/.test(r[1])){let o=r[1].replace(/\.(tsx|jsx|js|mdx)$/,"");return o==="index"?o="":o.endsWith("/index")&&(o=o.slice(0,-6)),tf(o.split("/").filter(Boolean),"pages")}return null}function Or(e){let t=[],n=r=>{r&&!t.includes(r)&&t.length<3&&t.push(r)};if(n(e.repoDir?Tr(e.pageUrl,e.repoDir):We(e.pageUrl)),e.onlyPage&&t.length)return t;if(e.site){let r=e.site.replace(/\/$/,"");n(`${r}/`);let o=e.places[0]?af(e.places[0].file):null;o&&n(o==="/"?`${r}/`:`${r}${o}`)}return t}function cs(e){let t=e.pageUrl?.trim();if(t)return{action:"open",url:t,onlyPage:!0,save:al(t)};if(e.live){let r=We(e.site);if(!r)return{action:"error",message:"No live site is configured for this project. Set it with grum setup, or pass the deployed page with --url."};let o=e.places?.[0]?af(e.places[0].file):null;return{action:"open",url:o?`${r.replace(/\/$/,"")}${o}`:r,onlyPage:!0,save:null}}if(e.saved&&!ll(e.saved,e.site))return{action:"open",url:e.saved,onlyPage:!0,save:null};let n=e.packageJson?Er(e.packageJson):null;return n?{action:"open",url:n,onlyPage:!0,save:n}:e.interactive?{action:"ask-person",suggested:null}:{action:"ask-agent"}}function lf(e,t,n){return n?"url":al(e)?"local":ll(e,t)?"live":"url"}function cf(e){if(!e||typeof e!="object")return null;let t=e,n=["local","live","url","none"].includes(t.source)?t.source:null,r=t.revision===null||t.revision===void 0?null:typeof t.revision=="string"&&/^[0-9a-f]{7,40}$/.test(t.revision)?t.revision:void 0,o=["clean","changed","unknown"].includes(t.worktree)?t.worktree:null;return!n||r===void 0||!o?null:{source:n,revision:r,worktree:o}}function il(e,t){return al(e)?"local app":ll(e,t)?"live site":"page"}function al(e){try{let t=new URL(e);return t.protocol==="file:"?e:["localhost","127.0.0.1","[::1]"].includes(t.hostname)||t.hostname.endsWith(".localhost")?`${t.origin}/`:null}catch{return null}}function ll(e,t){if(!t)return!1;let n=o=>{try{return new URL(o).hostname.replace(/^www\./,"")}catch{return null}},r=n(e);return r!==null&&r===n(t)}function uf(e,t,n){let r=t.trim();if(!r)return{url:e};if(/^(s|none|skip)$/i.test(r))return{url:null};let o=n(r);return o?{url:o}:null}function us(e,t){if(!jr(e))return e;try{let n=decodeURIComponent(new URL(e).pathname),r=sl(t);return n.startsWith(`${r}/`)?`.${n.slice(r.length)}`:e}catch{return e}}var pf=(e,t)=>`
|
|
56
56
|
Local app for ${e}, so reviewers see how a change renders before it ships.
|
|
57
57
|
A dev server like http://localhost:3000, or for a site with no server, its HTML file like ./index.html.
|
|
58
58
|
|
|
@@ -60,7 +60,7 @@ URL${t?` (${t})`:""}, 's' to skip: `,df='Grum could not tell which URL this app
|
|
|
60
60
|
What URL does this app run on locally, so Grum can show the reviewer how it renders?
|
|
61
61
|
No server? Type the path to its HTML file, like ./index.html.
|
|
62
62
|
|
|
63
|
-
URL: `;function as(e,t=un){return typeof e=="string"&&e.length<=t&&K0.test(e)?e:void 0}var tS=["no-url","no-browser","no-query","page-skipped","not-on-opened-pages","capture-failed","ambiguous","unsupported-client"];function nS(e){if(!e||typeof e!="object")return;let t=e,n=typeof t.state=="string"&&t.state.length<=120&&/^[\w-]+( \+ [\w-]+)*$/.test(t.state)?t.state:null,r=t.theme==="light"||t.theme==="dark"||t.theme==="unknown"?t.theme:null;return n&&r?{state:n,theme:r}:void 0}function rS(e){if(!e||typeof e!="object")return;let{width:t,height:n}=e;return Number.isInteger(t)&&Number.isInteger(n)&&t>0&&n>0&&t<=1e4&&n<=1e4?{width:t,height:n}:void 0}function dn(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.url=="string"&&t.url.length<=2e3?t.url:void 0,r=as(t.screenshot),o=as(t.viewport,zn),s=as(t.snapdom),i=tS.find(p=>p===t.miss),l=gf(t.examples);if(!n&&!r&&!o&&!s&&!i)return null;let a=nS(t.observed),c=rS(t.viewportSize),u=typeof t.capturedAt=="string"&&!Number.isNaN(Date.parse(t.capturedAt))&&t.capturedAt.length<=40?t.capturedAt:void 0;return{...n?{url:n}:{},...r?{screenshot:r}:{},...o?{viewport:o}:{},...s?{snapdom:s}:{},...i?{miss:i}:{},...l.length?{examples:l}:{},...a?{observed:a}:{},...c?{viewportSize:c}:{},...u?{capturedAt:u}:{}}}function gf(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e.slice(0,ls)){if(!r||typeof r!="object")continue;let o=
|
|
63
|
+
URL: `;function as(e,t=un){return typeof e=="string"&&e.length<=t&&K0.test(e)?e:void 0}var tS=["no-url","no-browser","no-query","page-skipped","not-on-opened-pages","capture-failed","ambiguous","unsupported-client"];function nS(e){if(!e||typeof e!="object")return;let t=e,n=typeof t.state=="string"&&t.state.length<=120&&/^[\w-]+( \+ [\w-]+)*$/.test(t.state)?t.state:null,r=t.theme==="light"||t.theme==="dark"||t.theme==="unknown"?t.theme:null;return n&&r?{state:n,theme:r}:void 0}function rS(e){if(!e||typeof e!="object")return;let{width:t,height:n}=e;return Number.isInteger(t)&&Number.isInteger(n)&&t>0&&n>0&&t<=1e4&&n<=1e4?{width:t,height:n}:void 0}function dn(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.url=="string"&&t.url.length<=2e3?t.url:void 0,r=as(t.screenshot),o=as(t.viewport,zn),s=as(t.snapdom),i=tS.find(p=>p===t.miss),l=gf(t.examples);if(!n&&!r&&!o&&!s&&!i)return null;let a=nS(t.observed),c=rS(t.viewportSize),u=typeof t.capturedAt=="string"&&!Number.isNaN(Date.parse(t.capturedAt))&&t.capturedAt.length<=40?t.capturedAt:void 0;return{...n?{url:n}:{},...r?{screenshot:r}:{},...o?{viewport:o}:{},...s?{snapdom:s}:{},...i?{miss:i}:{},...l.length?{examples:l}:{},...a?{observed:a}:{},...c?{viewportSize:c}:{},...u?{capturedAt:u}:{}}}function gf(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e.slice(0,ls)){if(!r||typeof r!="object")continue;let o=We(r.url),s=as(r.screenshot);if(typeof r.file!="string"||!r.file||r.file.length>300||!Number.isInteger(r.line)||r.line<1||!o||new URL(o).username||new URL(o).password||typeof r.capturedAt!="string"||!Number.isFinite(Date.parse(r.capturedAt))||!s||!/^data:image\/(png|jpeg);base64,/i.test(s))continue;let i=`${r.file}:${r.line}`;t.has(i)||(t.add(i),n.push({file:r.file,line:r.line,url:o,capturedAt:new Date(r.capturedAt).toISOString(),screenshot:s,...(()=>{let l=pn(r.locate),a=We(r.pageHref),c=u=>{let p=new URL(o),d=new URL(u);return p.origin===d.origin&&p.pathname===d.pathname&&p.search===d.search&&!d.username&&!d.password};return{...l&&c(l.url)&&l.query.selector?{locate:l}:{},...a&&c(a)?{pageHref:a}:{}}})()}))}return n}function mf(e){if(!e)return;if(/^data:image\/[^,]*;base64,/.test(e))return e;let t=e.indexOf(",");if(t<0||!e.slice(0,t).includes("image/svg+xml"))return;let n="";for(let r of new TextEncoder().encode(decodeURIComponent(e.slice(t+1))))n+=String.fromCharCode(r);return`data:image/svg+xml;base64,${btoa(n)}`}var oS=["image/png","image/jpeg","image/svg+xml"],sS=/^data:(image\/(?:png|jpeg|svg\+xml))(?:;charset=utf-8)?;base64,([A-Za-z0-9+/]+=*)$/i,hf=["screenshot","viewport","snapdom"],iS={screenshot:un,viewport:zn,snapdom:un};function nf(e){let t=sS.exec(e);if(!t)return null;let n=atob(t[2]),r=new Uint8Array(n.length);for(let o=0;o<n.length;o++)r[o]=n.charCodeAt(o);return{type:t[1].toLowerCase(),bytes:r}}function rf({type:e,bytes:t}){let n="";for(let r=0;r<t.length;r+=32768)n+=String.fromCharCode(...t.subarray(r,r+32768));return`data:${e};base64,${btoa(n)}`}function yf(e,t){We(t.url)&&e.set("url",t.url),t.miss&&e.set("miss",t.miss);let n={...t.observed?{observed:t.observed}:{},...t.viewportSize?{viewportSize:t.viewportSize}:{},...t.capturedAt?{capturedAt:t.capturedAt}:{}};Object.keys(n).length&&e.set("meta",JSON.stringify(n));for(let o of hf){let s=t[o]?nf(t[o]):null;s&&e.set(o,new Blob([s.bytes],{type:s.type}),o)}let r=gf(t.examples);return r.length&&(e.set("examples",JSON.stringify(r.map(({screenshot:o,...s})=>s))),r.forEach((o,s)=>{let i=nf(o.screenshot);e.set(`example-${s}`,new Blob([i.bytes],{type:i.type}),`example-${s}`)})),e}async function bf(e){let t={};for(let o of["url","miss"]){let s=e.get(o);typeof s=="string"&&(t[o]=s)}let n=e.get("meta");if(typeof n=="string"&&n.length<=2e3)try{let o=JSON.parse(n);for(let s of["observed","viewportSize","capturedAt"])o[s]!==void 0&&(t[s]=o[s])}catch{}for(let o of hf){let s=e.get(o);s instanceof Blob&&s.size<=iS[o]&&oS.includes(s.type)&&(t[o]=rf({type:s.type,bytes:new Uint8Array(await s.arrayBuffer())}))}let r=e.get("examples");if(typeof r=="string"&&r.length<=16e3)try{let o=JSON.parse(r);Array.isArray(o)&&(t.examples=await Promise.all(o.slice(0,ls).map(async(s,i)=>{let l=e.get(`example-${i}`);return l instanceof Blob&&l.size<=un&&["image/png","image/jpeg"].includes(l.type)?{...s,screenshot:rf({type:l.type,bytes:new Uint8Array(await l.arrayBuffer())})}:null})))}catch{}return t}function Mr(e){switch(e){case"no-url":return"No live URL. Pass the page where this renders with --url.";case"no-browser":return"Could not find Chrome to open the app and capture it.";case"no-query":return"Not enough to find this on a page.";case"page-skipped":return"The page did not open. Is the app running at that URL?";case"not-on-opened-pages":return"It 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.";case"ambiguous":return"More than one element on that page fits; none was captured. Pass the page where only one renders, or give the input an id or label.";case"unsupported-client":return"The capturing extension can't find inputs yet. Update the Grum extension, or capture with the local browser."}}function wf(e){return Ft(e)&&e.url?e.viewport?`Captured the rendered element, and the page around it, from ${e.url}.`:`Captured the rendered element from ${e.url}.`:Mr(e.miss??"capture-failed")}function cl(e){if(e.status===401||e.authenticationHeader||e.loginForm)return!0;try{let t=new URL(e.url);return/\/(?:login|log-in|signin|sign-in|sign_in|authenticate|authentication|authorize|oauth2?|sso|twofa|2fa|mfa|verify|verification|challenge)(?:\/|$)/i.test(t.pathname)||/^(?:accounts\.google\.com|login\.microsoftonline\.com)$/.test(t.hostname)}catch{return!1}}function kf(){return String.raw`(() => {
|
|
64
64
|
const visible = (node) => { const r = node.getBoundingClientRect(); const s = getComputedStyle(node); return r.width > 0 && r.height > 0 && s.display !== 'none' && s.visibility !== 'hidden'; };
|
|
65
65
|
const headings = Array.from(document.querySelectorAll('h1,h2,[role="heading"]')).filter(visible);
|
|
66
66
|
const signInHeading = headings.some((node) => /\b(sign in|log in|login|authenticate|authentication required|verify|verification|two-factor|2fa|mfa|security code|passkey)\b/i.test(node.textContent || ''));
|
|
@@ -136,8 +136,8 @@ ${yg(n,!1,!1,s)}`}}var Ll="Grum refreshes review decisions before each MCP check
|
|
|
136
136
|
${t.fix}`:""}`).join(`
|
|
137
137
|
`)}function Eg(e,t,n,r){let o=e?.profile,s=o?.info_cache;if(!s||typeof s!="object")return null;let i=new Set([...n,...r==="store"?[Nl]:[]]),l=Object.keys(s).sort((a,c)=>a===o?.last_used?-1:c===o?.last_used?1:0);for(let a of l)if((t[a]??[]).some(u=>{let p=u?.extensions?.settings;return!p||typeof p!="object"?!1:Object.entries(p).some(([d,f])=>f?.state!==0&&(i.has(d)||r==="dev"&&typeof f?.path=="string"&&/[\\/]extension[\\/]chrome[\\/]dist[\\/]?$/.test(f.path)))})){let u=s[a]?.name;return{dir:a,name:typeof u=="string"&&u?u:a}}return null}import{spawn as QS}from"node:child_process";import{existsSync as e$,readFileSync as t$}from"node:fs";import{homedir as Tg}from"node:os";import ke from"node:path";function n$(e,t){if(t){if(!/^(Default|Profile \d+)$/.test(t)||!e$(ke.join(e,t)))throw new Error("The selected Chrome profile does not exist.");return t}}async function _g(e,t){let n=ke.basename(e)==="open";await new Promise((r,o)=>{let s=QS(e,t,{detached:!0,stdio:["ignore","ignore",n?"pipe":"ignore"]}),i="";s.stderr?.on("data",l=>{i.length<500&&(i+=l.toString("utf8"))}),s.once("error",o),n?s.once("close",l=>l===0?r():o(new Error(`${ke.basename(e)} exited with code ${l}${i.trim()?`: ${i.trim()}`:""}`))):s.once("spawn",()=>{s.unref(),r()})})}async function jg(e,t={}){if((t.platform??process.platform)!=="darwin")throw new Error("Safari capture is supported on macOS only.");await(t.launch??_g)("/usr/bin/open",["-a","Safari",e])}async function Og(e,t={}){let n=t.env??process.env;if(n.GRUM_CAPTURE_OPEN==="manual")throw new Error("Automatic Chrome opening is disabled.");let r=t.platform??process.platform,o=t.home??Tg(),s=t.profileRoot??(r==="darwin"?ke.join(o,"Library","Application Support","Google","Chrome"):r==="win32"?ke.join(n.LOCALAPPDATA||ke.join(o,"AppData","Local"),"Google","Chrome","User Data"):ke.join(n.XDG_CONFIG_HOME||ke.join(o,".config"),"google-chrome")),i=n$(s,t.profile),l=i?[`--profile-directory=${i}`,"--ignore-profile-directory-if-not-exists"]:[],a=r==="darwin"?[{command:"/usr/bin/open",args:["-a","Google Chrome",e,...l.length?["--args",...l]:[]]}]:r==="win32"?[n.LOCALAPPDATA,n.PROGRAMFILES,n["PROGRAMFILES(X86)"]].filter(c=>!!c).map(c=>({command:ke.join(c,"Google","Chrome","Application","chrome.exe"),args:[...l,e]})):["google-chrome","google-chrome-stable"].map(c=>({command:c,args:[...l,e]}));for(let c of a)try{await(t.launch??_g)(c.command,c.args);return}catch{}throw new Error("Couldn't open your existing Chrome profile.")}function r$(e=process.platform,t=Tg(),n=process.env){return e==="darwin"?ke.join(t,"Library","Application Support","Google","Chrome"):e==="win32"?ke.join(n.LOCALAPPDATA||ke.join(t,"AppData","Local"),"Google","Chrome","User Data"):ke.join(n.XDG_CONFIG_HOME||ke.join(t,".config"),"google-chrome")}function Mg(e,t,n=r$()){let r=l=>{try{return JSON.parse(t$(l,"utf8"))}catch{return null}},o=r(ke.join(n,"Local State")),s=o?.profile?.info_cache;if(!s)return null;let i={};for(let l of Object.keys(s))i[l]=["Preferences","Secure Preferences"].map(a=>r(ke.join(n,l,a)));return Eg(o,i,e,t)}import Vg from"node:path";import{mkdirSync as u$,readFileSync as p$,rmSync as Wl,writeFileSync as Ug}from"node:fs";import Ce from"node:path";import{fileURLToPath as c$}from"node:url";import{chmodSync as o$,mkdirSync as s$,readdirSync as i$,readFileSync as Dg,rmSync as a$,writeFileSync as l$}from"node:fs";import{homedir as Zn}from"node:os";import Jr from"node:path";function Pg(e,t=process.env){let n=new URL(t.GRUM_API_ORIGIN?.trim()||e);if(!/^https?:$/.test(n.protocol)||n.username||n.password)throw new Error("GRUM_API_ORIGIN must be an http or https origin.");return n.origin}var Ns=(e=Zn())=>Jr.join(e,".config","grum");function zl(e,t=Zn()){return Jr.join(Ns(t),"credentials",`${e.replace(/[^a-z0-9]+/gi,"_")}.json`)}function Fs(e,t=process.env,n=Zn()){let r=t.GRUM_TOKEN?.trim();if(r)return{token:r,apiOrigin:e};try{let o=JSON.parse(Dg(zl(e,n),"utf8"));return typeof o.token=="string"&&o.token&&o.apiOrigin===e?{token:o.token,apiOrigin:e}:null}catch{return null}}function Lg(e,t=Zn()){let n=zl(e.apiOrigin,t);s$(Jr.dirname(n),{recursive:!0,mode:448}),l$(n,`${JSON.stringify(e,null,2)}
|
|
138
138
|
`,{mode:384}),o$(n,384)}function Ng(e,t=Zn()){a$(zl(e,t),{force:!0})}function Fg(e=Zn()){let t=Jr.join(Ns(e),"credentials"),n;try{n=i$(t).filter(r=>r.endsWith(".json"))}catch{return[]}return n.flatMap(r=>{try{let o=JSON.parse(Dg(Jr.join(t,r),"utf8"));return typeof o.token=="string"&&o.token&&typeof o.apiOrigin=="string"?[{token:o.token,apiOrigin:o.apiOrigin}]:[]}catch{return[]}})}var V=Pg("https://app.grum.so"),Yn=globalThis.__GRUM_VERSION__??"0.0.0-dev",Us="@grum-os/cli",Gl=`node ${c$(import.meta.url)}`,Bl=Us?{hook:`npx --no-install ${Us}`,mcp:`npx --yes ${Us}`,preCommit:`npx --yes ${Us}`}:{hook:Gl,mcp:Gl,preCommit:Gl},Q=Bl.mcp;function ne(e){try{return p$(e,"utf8")}catch{return null}}function vt(e){let t=ne(e);if(t===null)return null;try{return JSON.parse(t)}catch{return null}}function xe(e,t){u$(Ce.dirname(e),{recursive:!0}),Ug(e,t)}function yn(e,t,n){xe(Ce.join(e.stateDir,t),`${JSON.stringify(n,null,2)}
|
|
139
|
-
`);let r=Ce.join(e.repoDir,".gitignore"),o=Es(ne(r));o.changed&&Ug(r,o.text)}var
|
|
140
|
-
`,n);n=i<0?e.length:i;continue}if(s==="/"&&e[n+1]==="*"){let i=e.indexOf("*/",n+2);n=i<0?e.length:i+2;continue}t+=s,n++}try{return JSON.parse(t.replace(/,(\s*[}\]])/g,"$1"))}catch{return null}}function g$(e){return e==="package.json"?"":e.slice(0,-13)}function m$(e){let t=Kl(e);if(!t||typeof t!="object")return[];let n=t,r=[];for(let o of["dependencies","devDependencies","peerDependencies"]){let s=n[o];s&&typeof s=="object"&&r.push(...Object.keys(s))}return r}function h$(e){let t=new Map,n=[...e.keys()].filter(o=>!Zg(o)).sort(),r=0;for(let o of n){if(r>=f$)break;let s=e.get(o);if(!s)continue;r++;let i=Kl(s),l=i&&typeof i=="object"?i.name:null;typeof l!="string"||!l||t.has(l)||t.set(l,g$(o))}return t}function Jl(e,t){let n=`${e}/`;return t.some(r=>!Zg(r.path)&&r.path.startsWith(n)&&Xg.test(r.path))}function qs(e){let t=e.lastIndexOf("/");return t<0?"":e.slice(0,t)}function nr(e,t){let n=[...qs(e)?qs(e).split("/"):[],...t.split("/")],r=[];for(let o of n)if(!(!o||o===".")){if(o===".."){if(!r.length)return null;r.pop();continue}r.push(o)}return r.join("/")}function qg(e,t){let n=Ne(t);return n?e!==n&&!e.startsWith(`${n}/`):!1}function Jg(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=e.split("/");return e.startsWith("@")?t.length>=2?`${t[0]}/${t[1]}`:null:t[0]||null}function y$(e,t){let n=Xg.test(e)?qs(e):e;for(;n;){if(t.has(n))return n;let r=n.lastIndexOf("/");if(r<0)break;n=n.slice(0,r)}return t.has("")?"":null}function Vs(e,t,n,r){if(!e||!qg(e,t))return null;let o=y$(e,n);return!o||!qg(o,t)?null:Jl(o,r)?o:null}function b$(e){return[...e.matchAll(/["']([^"']+)["']/g)].map(t=>t[1]).filter(Boolean)}function w$(e){return qs(e)}function Yg(e,t,n,r){let o=Ne(e);if(!o)return[];let s=h$(n),i=new Set([...s.values()].filter(Boolean)),l=new Map,a=(f,m)=>{!f||l.has(f)||l.set(f,m)};if(n.get(`${o}/package.json`)){let f=new Set([o]),m=[{folder:o,via:null}];for(;m.length;){let g=m.shift(),S=n.get(g.folder?`${g.folder}/package.json`:"package.json");if(S)for(let h of m$(S)){let b=s.get(h);!b||f.has(b)||(f.add(b),Jl(b,t)&&a(b,g.via?`${o} depends on ${h} through ${g.via}`:`${o} depends on ${h}`),m.push({folder:b,via:h}))}}}let u=[...r.keys()].filter(f=>(f==="tsconfig.json"||f.endsWith("/tsconfig.json")||/(^|\/)tsconfig\.[^/]+\.json$/.test(f))&&(f===o||f.startsWith(`${o}/`)||!f.includes("/"))),p=new Set,d=u.filter(f=>f===`${o}/tsconfig.json`||f.startsWith(`${o}/tsconfig`));for(d.length||d.push(...u.filter(f=>f.startsWith(`${o}/`)));d.length;){let f=d.shift();if(p.has(f))continue;p.add(f);let m=r.get(f);if(!m)continue;let g=Kl(m);if(!g||typeof g!="object")continue;let S=g,h=S.extends,b=Array.isArray(h)?h:[h];for(let x of b){if(typeof x!="string")continue;let v=x.startsWith(".")?nr(f,x):(()=>{let $=Jg(x),R=$?s.get($):void 0;if(!R)return null;let I=x.slice($.length).replace(/^\//,"");return I?`${R}/${I}`:R})();v&&r.has(v)&&d.push(v)}let k=typeof S.compilerOptions?.baseUrl=="string"?nr(f,S.compilerOptions.baseUrl):w$(f),y=S.compilerOptions?.paths;if(y&&typeof y=="object"&&k!=null){for(let x of Object.values(y))if(Array.isArray(x))for(let v of x){if(typeof v!="string")continue;let $=nr(`${k}/x`,v.replace(/\*.*$/,"").replace(/\/$/,"")||".");$&&a(Vs($,o,i,t),`${o} references ${$} from tsconfig`)}}if(Array.isArray(S.references))for(let x of S.references){let v=x&&typeof x=="object"&&typeof x.path=="string"?x.path:null;if(!v)continue;let $=nr(f,v);$&&a(Vs($,o,i,t),`${o} references ${$} from tsconfig`)}}for(let[f,m]of r){if(!f.startsWith(`${o}/`))continue;let g=/\.(css|scss|less)$/i.test(f),S=/(^|\/)tailwind\.config\./.test(f),h=[];if(g)for(let b of m.matchAll(/@(?:import|use|forward|source|config|plugin)\s+(?:url\(\s*)?["']([^"']+)["']/g))h.push(b[1]);if(S)for(let b of["content","presets"]){let k=new RegExp(`${b}\\s*:\\s*\\[([\\s\\S]*?)\\]`).exec(m);k?.[1]&&h.push(...b$(k[1]))}for(let b of h){if(b.startsWith(".")){let x=nr(f,b),v=x?Vs(x,o,i,t):null;a(v,`${o} imports ${b}`);continue}let k=Jg(b),y=k?s.get(k):void 0;y&&Jl(y,t)&&a(y,`${o} imports ${b}`)}if(/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro)$/i.test(f))for(let b of m.matchAll(/(?:from\s+|import\s*\(\s*|require\(\s*)["'](\.[^"']+)["']/g)){let k=b[1],y=nr(f,k),x=y?Vs(y,o,i,t):null;a(x,`${o} imports ${k}`)}}return[...l.entries()].map(([f,m])=>({folder:f,reason:m})).sort((f,m)=>f.folder<m.folder?-1:1)}function Qg(e){if(e.flag!==void 0)return Ne(e.flag);let t=Ne(e.config??"");return t||Ne(e.projectRoot??"")}function Js(e){if(e.flag!==void 0)return Ne(e.flag);let t=ql.relative(e.repoDir,e.cwd);return!t||t==="."||t.startsWith("..")||ql.isAbsolute(t)?"":Ne(t.split(ql.sep).join("/"))}var em=4e7,Xl=5e3,Ks=15e3;function Zr(e,t){let n=Math.max(1,Math.round(e/1e3));return t||e>=Ks?{kind:"limit",seconds:n}:e>=Xl?{kind:"slow",seconds:n}:{kind:"ok"}}function Yr(e){return e.kind==="slow"?`Reading source took ${e.seconds}s. Grum skips videos and large images by name; a huge source tree or a slow disk can still take a while.`:e.kind==="limit"?"Reading source stopped at the 15s limit. Grum skips videos and large images by name, so this is a huge source tree, a slow disk, or a stalled git list. This used what it had so far.":null}var k$=/(^|\/)\.grum\//;function Zl(e){return!Ir.test(`${e}/`)&&!k$.test(`${e}/`)}function Yl(e,t){return Nd(e,t)}function tm(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}var x$=/\.(css|scss|sass|less|tsx?|jsx?|mjs|cjs|vue|svelte|astro|html?)$/i;function nm(e){return x$.test(e)}function rm(e,t,n){let r=new Map(e);for(let o of t){let s=Ht(o.path,n);s===null||!Zl(s.split("/").slice(0,-1).join("/")||".")||(o.content===null?r.delete(s):Yl(s,o.content.length)&&r.set(s,o.content))}return r}function om(e){let t=e.split("\0").filter(Boolean),n=[];for(let r=0;r<t.length;r++){let o=t[r];if(/^[RC]/.test(o)){let i=t[++r],l=t[++r];o.startsWith("R")&&i&&n.push({path:i,deleted:!0}),l&&n.push({path:l,deleted:!1});continue}let s=t[++r];s&&n.push({path:s,deleted:o.startsWith("D")})}return n}function Xs(e){let t=/^(?:git@|ssh:\/\/git@|https?:\/\/(?:[^@/]+@)?)github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(e.trim());return t?`${t[1]}/${t[2]}`:null}var sm=1,v$=["cursor","codex","claude","generic"],rr={cursor:"Cursor",codex:"Codex",claude:"Claude Code"};var S$={ready:0,"action-needed":2,error:1},$$="https://nodejs.org/en/download",Zs=22,C$="Give the person the URL in this result and ask them to open it. That Grum page checks the repository and walks them through it: Reconnect GitHub, then, if still blocked, Grum's Manage Access page on GitHub, where they grant the organization that owns the repository (or click Request when an org owner must approve). It says when Grum can read the repository. Grum is an OAuth app named Grum, not a GitHub App: do not send the person anywhere else on GitHub to hunt for it. Then run the same command again.";function R$(e){return e.scan==="failed"&&Un(e.scanMessage??"")}var A$=["blocked","needs-sign-in","needs-github","needs-workspace-create","needs-project-choice","needs-starter","needs-host-action","scan-running","needs-site","needs-extension","needs-local-app","ready"];function im(e){return S$[e.exit]}function Ql(e){let t=e.serverOrigin??"",n=d=>({ok:!1,result:P$(t,d)}),r=(e.agent??[]).map(d=>d.trim().toLowerCase());if(r.length!==1||!I$(r[0]))return n("Pass --agent with one of cursor, codex, claude or generic. generic can set up and check, and reports that automatic enforcement is unavailable.");let o=r[0];if((e.project?.length??0)>1)return n("Pass --project once, with the project id from the choices.");let s=e.project?.[0]?.trim()||null;if(e.project&&!s)return n("Pass --project with the project id from the choices.");let i=!!e.create,l=!!e.remove;if(i&&s)return n("Pass either --create or --project, not both.");if(i&&l)return n("Pass either --create or --remove, not both.");if(l&&e.switchServer)return n("Removing Grum from this repo is separate from switching servers. Run one, then the other.");if((e.name?.length??0)>1||(e.site?.length??0)>1)return n("Pass --name and --site at most once.");if((e.localUrl?.length??0)>1||(e.root?.length??0)>1)return n("Pass --local-url and --root at most once.");let a;if(e.site===void 0)a=void 0;else if(/^(none|skip)$/i.test(e.site[0]?.trim()??""))a=null;else{let d=cn(e.site[0]??"");if(!d)return n("Pass --site as an https URL or none. The live site is optional.");a=d}let c,u=null;if(e.localUrl===void 0)c=void 0;else{let d=E$(e.localUrl[0]??"");if(!d.ok)return n("Pass --local-url as an http(s) URL, a file in the repo such as ./index.html, or none.");c=d.url,u=d.kind}let p=(e.name?.[0]??"").trim().slice(0,80)||null;return e.probe&&(i||l||s||e.switchServer)?n("doctor only reports readiness. Run setup --agent to create, choose, switch or remove."):{ok:!0,request:{agent:o,projectId:s,create:i,remove:l,name:p,site:a,siteProvided:e.site!==void 0,localUrl:c,localProvided:e.localUrl!==void 0,localKind:u,root:e.root?.[0]?.trim()||null,switchServer:!!e.switchServer,dropPreCommit:!!e.dropPreCommit,probe:!!e.probe}}}function Re(e,t){let n=t.probe?null:T$(e,t);return{result:_$(e,t),mutation:n}}function am(e,t){let n=rr[t.agent==="generic"?"cursor":t.agent],r=t.dropPreCommit?" The pre-commit check was removed.":" The pre-commit check was left as it was.";return ye(e,t,{open:[],fault:!1,checks:[{id:"adapter",evidence:"observed",status:"ok",label:`Removed Grum from ${n}.${r} This computer's sign-in and the Grum workspace were kept.`}],actions:[]})}function I$(e){return v$.includes(e??"")}function E$(e){let t=e.trim();if(/^(none|skip)$/i.test(t))return{ok:!0,url:null,kind:"none"};if(/^https?:\/\//i.test(t))try{let n=new URL(t);return n.username||n.password?{ok:!1}:{ok:!0,url:n.href,kind:"url"}}catch{return{ok:!1}}return!t||t.includes("..")||t.startsWith("/")||t.includes("\\")||/^[a-z][a-z0-9+.-]*:/i.test(t)?{ok:!1}:{ok:!0,url:t,kind:"file"}}function ec(e){return!e.selectedId||!e.projects?null:e.projects.find(t=>t.id===e.selectedId)??null}function T$(e,t){if(!e.runtimeOk)return null;if(!!(e.repoServer&&e.repoServer!==e.serverOrigin))return t.switchServer?{kind:"switch-server"}:null;if(t.remove&&t.agent!=="generic")return{kind:"remove",agent:t.agent,dropPreCommit:t.dropPreCommit};if(e.offline||!e.signedIn||e.origin!=="github"||e.github==="missing"||e.github==="no-access")return null;let r=e.projects;if(!r)return null;let o=ec(e);if(t.projectId&&r.some(l=>l.id===t.projectId)&&o?.id!==t.projectId)return{kind:"select",projectId:t.projectId};let s=e.kit;if(s?.needsRepo&&t.projectId===s.project.id&&r.length===0&&s.project.role==="owner"&&e.repoName)return{kind:"link-repo",projectId:s.project.id,repo:e.repoName};if(t.create&&r.length===0)return{kind:"create",name:t.name,site:t.siteProvided?t.site??null:null};if(!o)return null;let i=s&&s.project.id===o.id&&s.state!=="pushed";return e.scan==="needed"&&o.role==="owner"&&i?s.state==="not-written"?{kind:"write-starter",projectId:o.id}:null:t.agent!=="generic"&&!e.adapterWritten&&!i?{kind:"install",agent:t.agent}:(e.scan==="needed"||R$(e))&&o.role==="owner"?{kind:"start-scan",projectId:o.id}:e.scan!=="done"?null:t.siteProvided&&o.role==="owner"&&(t.site??null)!==(o.site??null)?{kind:"set-site",projectId:o.id,site:t.site??null}:t.siteProvided&&t.site===null&&o.role==="owner"&&!o.site&&!e.siteSkipped?{kind:"skip-site",projectId:o.id}:t.localProvided&&(t.localUrl!==e.localSaved||t.localUrl===null&&!e.localSkipped)?{kind:"set-local",url:t.localUrl??null}:null}function _$(e,t){let n=[],r=[],o=[],s=!1,i=ec(e),l=rr[t.agent==="generic"?"cursor":t.agent];if(o.push({id:"runtime",evidence:"observed",status:e.runtimeOk?"ok":"missing",label:e.runtimeOk?`Node.js ${e.runtimeVersion} can run Grum.`:`Node.js ${e.runtimeVersion||"is missing"}; Grum needs ${Zs} or newer.`}),!e.runtimeOk)return n.push("blocked"),r.push({kind:"install-runtime",explanation:`Ask the person to install Node.js ${Zs} or newer from the browser, then restart the editor and run this again. Do not ask them to type a command.`,input:{url:$$,command:ve(e,t)}}),ye(e,t,{open:n,actions:r,checks:o,fault:!1});let a=!!(e.repoServer&&e.repoServer!==e.serverOrigin);if(o.push({id:"server",evidence:"observed",status:a?"blocked":"ok",label:a?`This repo is set up for ${ct(e.repoServer)} (${e.repoServer}), and this Grum is ${ct(e.serverOrigin)} (${e.serverOrigin}).`:`Grum ${ct(e.serverOrigin)} (${e.serverOrigin}).`}),a)return n.push("blocked"),r.push({kind:"switch-server",explanation:"Ask before switching. Nothing was changed. Switching sets the previous server's local Grum files aside and sets this repo up here.",input:{flag:"--switch-server",command:ve(e,{...t,probe:!1},["--switch-server"])}}),ye(e,t,{open:n,actions:r,checks:o,fault:!1});if(t.remove)return t.agent==="generic"&&(s=!0,n.push("blocked"),r.push({kind:"fix-error",explanation:`A generic agent has no Grum files to remove. To sign out this computer, run ${e.cli} logout.`})),ye(e,t,{open:n,actions:r,checks:o,fault:s});if(e.offline)return s=!0,n.push("blocked"),o.push({id:"server-reach",evidence:"observed",status:"blocked",label:e.offlineMessage??"Grum could not be reached. Nothing was marked ready."}),r.push({kind:"fix-error",explanation:"Grum could not be reached, so this run is not ready. The connection is down or too slow (the CLI waits 15 seconds). Try the same command again once it answers. An offline check can still use a contract already saved on this computer, and that result is not current.",input:{command:ve(e,t)}}),ye(e,t,{open:n,actions:r,checks:o,fault:s});if(e.origin==="absent"||e.origin==="unsupported")return s=!0,n.push("blocked"),o.push({id:"repository",evidence:"observed",status:"blocked",label:e.origin==="absent"?"This folder has no GitHub origin remote.":"This folder's origin remote is not a GitHub repository Grum can connect."}),r.push({kind:"fix-error",explanation:e.origin==="absent"?"Grum did not invent a git remote. Add the repository's GitHub origin, then run this again.":"Grum only connects a github.com origin. It did not change the remote."}),ye(e,t,{open:n,actions:r,checks:o,fault:s});if(o.push({id:"sign-in",evidence:"observed",status:e.signedIn?"ok":"missing",label:e.signedIn?"Signed in on this computer.":e.signInExpired?"The sign-in on this computer expired or was revoked.":"This computer is not signed in to Grum."}),!e.signedIn){n.push("needs-sign-in");let m=e.pendingLogin;return r.push({kind:"approve-sign-in",explanation:m?`Open this Grum page, sign in, and approve code ${m.code}. Then run the same command again.`:"Run setup so Grum can start a browser sign-in. Doctor does not start one. The next result has the code and the page.",input:{...m?{url:m.url,code:m.code,expiresAt:m.expiresAt}:{},command:ve(e,{...t,probe:!1})}}),ye(e,t,{open:n,actions:r,checks:o,fault:s})}let c=e.github==="no-access"?e.repoName:null;if(e.github==="missing"||e.github==="no-access")return n.push("needs-github"),o.push({id:"github",evidence:"observed",status:"missing",label:e.github==="no-access"?`This GitHub login cannot read ${c??"that repository"}: it is not found or access is denied.`:e.githubMessage??"GitHub is not connected for this account."}),r.push({kind:"connect-github",explanation:C$,input:{url:`${e.serverOrigin}${Xr(void 0,c??void 0)}`,command:ve(e,t)}}),ye(e,t,{open:n,actions:r,checks:o,fault:s});if(e.projects===null)return s=!0,n.push("blocked"),o.push({id:"project",evidence:"unknown",status:"unknown",label:"Grum did not return this repository's workspaces."}),r.push({kind:"fix-error",explanation:"Run the same command again. No workspace was created.",input:{command:ve(e,t)}}),ye(e,t,{open:n,actions:r,checks:o,fault:s});e.staleProjectId&&!i&&o.push({id:"project",evidence:"observed",status:"blocked",label:`The saved project ${e.staleProjectId} is not a workspace this account can use.`});let u=e.kit?.needsRepo===!0&&t.projectId===e.kit.project.id;if(t.projectId&&!u&&!e.projects.some(m=>m.id===t.projectId)){let m=e.projects.map(g=>({id:g.id,label:g.name}));return m.length||(s=!0),n.push(m.length?"needs-project-choice":"blocked"),r.push({kind:m.length?"choose-project":"fix-error",explanation:m.length?"That project id is not one this account can use for this repository. Ask which of these to use.":"That project id is not a workspace this account can use, and this repository has none yet.",input:m.length?{flag:"--project",choices:m,command:ve(e,t)}:void 0}),ye(e,t,{open:n,actions:r,checks:o,fault:s})}let p=u?e.kit:null;if(e.projects.length===0&&p){let m=p.project.name;return p.project.role!=="owner"?(s=!0,n.push("blocked"),o.push({id:"project",evidence:"observed",status:"blocked",label:`Only an owner of ${m} can connect a repository to it.`}),r.push({kind:"fix-error",explanation:`${e.repoName} is not connected to ${m}, and only an owner of that workspace can connect it. Ask an owner. Nothing was changed.`}),ye(e,t,{open:n,actions:r,checks:o,fault:s})):(n.push("needs-workspace-create"),o.push({id:"project",evidence:"observed",status:"missing",label:`${e.repoName} is not connected to the ${m} workspace yet.`}),r.push({kind:"link-workspace",explanation:`Connect ${e.repoName} to the ${m} workspace, which started from ${p.kit.name}. The person's request to set up this project already authorized it: say that you are connecting it, then run setup. A readiness check never connects it.`,input:{command:ve(e,{...t,probe:!1})}}),ye(e,t,{open:n,actions:r,checks:o,fault:s}))}if(e.projects.length===0)return n.push("needs-workspace-create"),o.push({id:"project",evidence:"observed",status:"missing",label:`No Grum workspace you can access is connected to ${e.repoName}.`}),r.push({kind:"create-workspace",explanation:t.create?`Creating a Grum workspace for ${e.repoName}.`:`Create a Grum workspace for ${e.repoName}. The person's explicit setup request already authorized this; state that you are creating it, then run setup with --create. A readiness check never creates one.`,input:{flag:"--create",command:ve(e,{...t,probe:!1,create:!0})}}),ye(e,t,{open:n,actions:r,checks:o,fault:s});if(!i)return n.push("needs-project-choice"),o.push({id:"project",evidence:"observed",status:"missing",label:`Several workspaces use ${e.repoName}. None is selected.`}),r.push({kind:"choose-project",explanation:"Ask which workspace to use. Pass its id as --project. Do not choose the first.",input:{flag:"--project",choices:e.projects.map(m=>({id:m.id,label:m.name})),command:ve(e,t)}}),ye(e,t,{open:n,actions:r,checks:o,fault:s});o.push({id:"project",evidence:"observed",status:"ok",label:`Linked to ${i.name} (${e.repoName}).`});let d=e.scan==="needed"&&e.kit?.project.id===i.id?e.kit:null;if(d&&d.state!=="pushed"){n.push("needs-starter");let m=M$(e,t,d,i.role);return o.push({id:"starter",evidence:"observed",status:"missing",label:m.label}),r.push(m.action),ye(e,t,{open:n,actions:r,checks:o,fault:s})}if(O$(e,t,l,n,r,o),e.scan==="failed"?(s=!0,n.push("blocked"),o.push({id:"scan",evidence:"observed",status:"blocked",label:e.scanMessage??"The first scan failed."}),r.push({kind:"fix-error",explanation:"The scan failed. Report that and stop. Do not start another scan unless the person asks."})):e.scan==="running"||e.scan==="needed"?(n.push("scan-running"),o.push({id:"scan",evidence:"observed",status:"missing",label:e.scan==="running"?`Grum is still reading ${e.repoName}.`:`Grum has not finished reading ${e.repoName}.`}),r.push({kind:"wait-for-scan",explanation:"The scan is on Grum's servers. A large repo or a slow GitHub connection can take a few minutes. Run the same command again shortly. Tell the person if it is still running after several tries. Do not block this chat, and do not hunt GitHub settings.",input:{command:ve(e,t)}})):e.scan==="done"?o.push({id:"code-check",evidence:"observed",status:"ok",label:"Code checks can run against the current contract. That is separate from capture."}):o.push({id:"code-check",evidence:"unknown",status:"unknown",label:"No contract has been checked on this run."}),e.scan!=="done")return ye(e,t,{open:n,actions:r,checks:o,fault:s});t.siteProvided&&i.role!=="owner"&&(t.site??null)!==(i.site??null)?o.push({id:"site",evidence:"observed",status:"blocked",label:"Only an owner can change the live site, so it was left as it is."}):i.site?o.push({id:"site",evidence:"observed",status:"ok",label:`Live site: ${i.site}.`}):e.siteSkipped?o.push({id:"site",evidence:"observed",status:"ok",label:"No live site, by choice. Grum checks the code only."}):i.role==="owner"&&(n.push("needs-site"),o.push({id:"site",evidence:"observed",status:"missing",label:"No live site is saved, so Grum checks the code but not the deployed pages."}),r.push({kind:"set-site",explanation:e.siteHints.length?"Ask the person for the live site's URL. Offer the URLs in input.uncertain, found in this repository and not checked, and let them type another. Pass --site with the answer, or none when there is no live site.":"Ask the person for the live site's URL. First look in the repository (README, deploy config, metadata) for a production URL to offer. Pass --site with the answer, or none when there is no live site.",input:{flag:"--site",...e.siteHints.length?{uncertain:e.siteHints}:{},command:ve(e,t)}})),e.extension===null?o.push({id:"extension",evidence:"unknown",status:"unknown",label:"Could not tell whether the Chrome extension is connected. The server is the source of that check, and it is not proof the extension is in the browser you have open."}):e.extension.connected?o.push({id:"extension",evidence:"observed",status:"ok",label:"Grum's server shows the Chrome extension connected for this workspace. That is not proof it is installed in the browser you have open."}):(n.push("needs-extension"),o.push({id:"extension",evidence:"observed",status:"missing",label:"The Chrome extension is not connected. Pages behind a sign-in need it. Code checks do not."}),r.push({kind:"connect-extension",explanation:"Open Grum's extension page in the Chrome profile the person uses, install or load the extension, and choose Connect for this workspace.",input:{url:e.extensionUrl}}));let f=!e.localSaved&&!e.localSkipped;if(e.localSkipped&&!e.localSaved)o.push({id:"local-app",evidence:"observed",status:"ok",label:"No local app URL was saved, by choice. A later review picture will need one."});else if(e.localSaved&&e.localStatus===void 0)o.push({id:"local-app",evidence:"unknown",status:"unknown",label:`A local app URL is saved (${e.localSaved}) and was not probed on this run.`});else if(e.localSaved&&e.localStatus!==null&&e.localStatus!==void 0&&e.localStatus<500)o.push({id:"local-app",evidence:"observed",status:"ok",label:`Local app answering at ${e.localSaved}.`});else if(f||e.localSaved){n.push("needs-local-app"),o.push({id:"local-app",evidence:"observed",status:"missing",label:e.localSaved?`Local app not answering at ${e.localSaved}.`:"No local app URL is saved, so a review cannot show how a change renders until one is set."});let m=e.localSuggestions.filter(S=>S.verified),g=e.localSuggestions.filter(S=>!S.verified).map(S=>S.url);r.push({kind:"set-local-app",explanation:e.localSaved?"The saved local app is not answering. Ask the person whether to start it (offer to run its dev command) or use another URL. Pass --local-url with a page that answers, or none to skip.":m.length||g.length?"Ask the person where the app runs locally while they edit. Offer input.choices (they answered just now) and input.uncertain (seen in the repository, not running), and let them type another. When the one they pick is not running, offer to start the dev command. Pass --local-url with their answer, or none to skip.":"Ask the person where the app runs locally while they edit. First look in the repository (package.json scripts, README, docker-compose, framework config) for a localhost URL or an HTML entry file to offer. When it is not running, offer to start the dev command. Pass --local-url with their answer, or none to skip.",input:{flag:"--local-url",...m.length?{choices:m.map(S=>({id:S.url,label:S.url}))}:{},...g.length?{uncertain:g}:{},command:ve(e,t)}})}return ye(e,t,{open:n,actions:r,checks:o,fault:s})}function j$(e,t){return e==="cursor"?`In Cursor, ${Ze} Then start a new chat so the tools load. Until then, use the CLI commands in this guide.`:e==="claude"?`In Claude Code, ${fl} Until then, use the CLI commands in this guide.`:e==="codex"?`In Codex, ${hs} Then ${$l} Start a new chat so Codex reloads them.`:`Run setup to write Grum's files for ${t}, then complete the editor step it reports. File presence is not the same as tools loaded.`}function O$(e,t,n,r,o,s){if(t.agent==="generic"){s.push({id:"enforcement",evidence:"observed",status:"missing",label:"Automatic enforcement is unavailable for this agent. Checks and review still run when asked. Hooks are not installed."});return}if(!e.adapterWritten){r.push("needs-host-action"),s.push({id:"adapter",evidence:"observed",status:"missing",label:`Grum is not configured in ${n} yet.`}),o.push({kind:"enable-host",explanation:`Run setup to write Grum's files for ${n}, then complete the editor step it reports. File presence is not the same as tools loaded.`,input:{command:ve(e,{...t,probe:!1})}});return}s.push({id:"adapter",evidence:"observed",status:"ok",label:`Grum's files are written for ${n}. That alone does not mean the tools are loaded.`});let i=e.tools==="on"||e.tools==="off";s.push({id:"tools",evidence:e.tools==="unknown"?"unknown":"observed",status:e.tools==="on"?"ok":e.tools==="off"?"missing":"unknown",label:e.tools==="on"?`Grum's tools are loaded in ${n}.`:e.tools==="off"?`Grum's tools are not on in ${n}.`:`Could not confirm that Grum's tools are loaded in ${n}.`});let l=e.hooks==="active"||e.hooks==="inactive";e.hooks!=="not-applicable"&&s.push({id:"hooks",evidence:l?"observed":"unknown",status:e.hooks==="active"?"ok":e.hooks==="inactive"?"missing":"unknown",label:e.hooks==="active"?`Grum's hooks have run in ${n}.`:e.hooks==="inactive"?`Grum's hooks have not been allowed in ${n}.`:`Could not confirm that Grum's hooks are active in ${n}.`}),!(t.agent==="codex"?e.hooks==="active":e.tools==="on")&&(i||e.tools==="unknown"||e.hooks!=="not-applicable")&&(r.push("needs-host-action"),o.push({kind:"enable-host",explanation:j$(t.agent,n),input:{command:ve(e,t,[],!0)}}))}function M$(e,t,n,r){let{createApp:o,install:s}=n.starter.commands,i=ve(e,{...t,probe:!1}),l=(c,u)=>({label:u,action:{kind:"run-commands",explanation:"Run input.commands in order from the repository root, with stdin closed. They ask nothing. Do not delete or move files to make them work: when one refuses because the folder already has files in it, tell the person and stop. When they finish, run the same command again.",input:{commands:c,command:i}}});if(n.state==="no-app")return l([...o,...s],`This folder has no app yet, and the ${n.kit.name} starter needs one.`);if(n.state==="not-installed")return l(s,`${n.kit.name} is not installed in this app yet.`);if(n.state==="not-written")return{label:`The contract's tokens are not written into ${n.starter.tokensFile} yet.`,action:{kind:"run-commands",explanation:r==="owner"?"Run setup. It writes the contract's tokens into the app and adds DESIGN.md, and changes nothing else.":"An owner of this workspace has to run setup to write the contract's tokens into the app. Nothing was changed.",input:{commands:[i],command:i}}};let a=n.defaultBranch??"the default branch";return{label:`The starter is written, but not on ${a} on GitHub, where Grum's scan reads it.`,action:{kind:"commit-and-push",explanation:`Grum scans ${a} on GitHub, so the work has to be there first. Run \`${e.cli} check\`: it should report no drift. Then tell the person what you will commit (the app, ${n.starter.tokensFile} and DESIGN.md) and that you will push it to ${a}, and ask. Only with their yes: commit, push to ${a}, then run the same command again. If the work is on another branch, ask whether to merge it into ${a}. Never force-push.`,input:{...n.defaultBranch?{branch:n.defaultBranch}:{},command:i}}}}function ye(e,t,n){let r=A$.filter(c=>n.open.includes(c)),o=r[0]??"ready",s=ec(e),i=o==="ready"?"ready":n.fault?"error":"action-needed",l=[...n.checks],a=D$(e);return a&&l.push(a),{schema:sm,state:o,open:r,server:e.serverOrigin?{origin:e.serverOrigin,label:ct(e.serverOrigin)}:null,repository:{name:e.repoName},project:s?{id:s.id,name:s.name}:null,checks:l,actions:n.actions,exit:i}}function D$(e){if(!e.sourceRead)return null;let t=Yr(Zr(e.sourceRead.ms,e.sourceRead.stalled));return t?{id:"source-read",evidence:"observed",status:e.sourceRead.stalled?"missing":"ok",label:t}:null}function P$(e,t){return{schema:sm,state:"blocked",open:["blocked"],server:e?{origin:e,label:ct(e)}:null,repository:null,project:null,checks:[{id:"request",evidence:"observed",status:"blocked",label:t}],actions:[{kind:"fix-error",explanation:t}],exit:"error"}}function ve(e,t,n=[],r=!1){let o=[e.cli,r||t.probe?"doctor":"setup","--agent",t.agent,"--json"];t.root&&o.push("--root",t.root),t.projectId&&o.push("--project",t.projectId),t.create&&o.push("--create"),t.name&&o.push("--name",t.name),t.siteProvided&&o.push("--site",t.site??"none"),t.localProvided&&o.push("--local-url",t.localUrl??"none");for(let s of n)o.includes(s)||o.push(s);return o.join(" ")}var lm=[" @@@@@@@ @@@@@@@","@@@@@@@@@ @@@@@@@@@","@@@@@@@@@ @@@@@@@@@"," @@@@@@@@@@@@@@@@@@"," @@@@@@@@"," @@@@@@ "," @@@@@@@@@@@@@@@@@@","@@@@@@@@@ @@@@@@@@@","@@@@@@@@@ @@@@@@@@@"," @@@@@@@ @@@@@@@"],L$=Math.max(...lm.map(e=>e.length)),N$=[" .d8888b."," d88P Y88b"," 888 888"," 888 888d888 888 888 88888b.d88b.",' 888 88888 888P" 888 888 888 "888 "88b'," 88 888 888 888 888 888 888 888"," 88b d88P 888 Y88b 888 888 888 888",' "Y8888P88 888 "Y88888 888 888 888'],cm=lm.map((e,t)=>{let n=N$[t-1];return n?`${e.padEnd(L$)} ${n}`:e}).join(`
|
|
139
|
+
`);let r=Ce.join(e.repoDir,".gitignore"),o=Es(ne(r));o.changed&&Ug(r,o.text)}var He=e=>ps(vt(Ce.join(e.stateDir,"contract.json"))),bn=(e,t)=>yn(e,"contract.json",t),Wt=e=>ug(vt(Ce.join(e.stateDir,"drift.json")),new Date().toISOString(),V),wn=(e,t)=>yn(e,"drift.json",{...t,apiOrigin:V});function Qn(e){let t=n=>{let r=vt(Ce.join(e.stateDir,n));return typeof r?.apiOrigin=="string"?r.apiOrigin:null};return Ig(t("contract.json"),t("drift.json"))}function zs(e){let t=["contract.json","drift.json","project.json"].flatMap(n=>{let r=Ce.join(e.stateDir,n),o=ne(r);return o===null?[]:[{file:r,text:o}]});for(let{file:n}of t)Wl(n,{force:!0});return()=>{for(let{file:n,text:r}of t)xe(n,r)}}var Gs=(e,t)=>Ce.join(e.stateDir,"edits",t.replace(/[^A-Za-z0-9_-]/g,"_")||"_"),zg=(e,t)=>Wl(Gs(e,t),{recursive:!0,force:!0});function Kr(e){let t=vt(Ce.join(e.stateDir,"project.json"));return typeof t?.id=="string"?t.id:null}var er=(e,t)=>yn(e,"project.json",{id:t});function Bs(e){return mg(vt(Ce.join(e.stateDir,"config.json")))}function St(e){let t=vt(Ce.join(e.stateDir,"local-app.json"));return Tr(t?.url,e.repoDir)}var tr=(e,t)=>yn(e,"local-app.json",{url:t}),Gg=e=>Wl(Ce.join(e.stateDir,"local-app.json"),{force:!0});function Bg(e){return vt(Ce.join(e.stateDir,"local-app.json"))?.skipped===!0&&!St(e)}var Wg=e=>yn(e,"local-app.json",{skipped:!0});function Hg(e,t){return vt(Ce.join(e.stateDir,"site.json"))?.skipped===t}var Hl=(e,t)=>yn(e,"site.json",{skipped:t});function Ws(e){let t=i=>vt(Ce.join(e.stateDir,i))??{},n=t("capture.json"),r=t("config.json"),o=[n.browser,r.captureBrowser].find(i=>i==="chrome"||i==="safari"),s=[n.chromeProfile,r.chromeProfile].find(i=>typeof i=="string");return{...o?{browser:o}:{},...s?{chromeProfile:s}:{}}}var Hs=(e,t)=>yn(e,"capture.json",t);function Vl(e,t){try{let n=Sg(r=>ne(Vg.join(e,r)),t);for(let r of n)xe(Vg.join(e,r.file),r.text);return n.map(r=>r.file)}catch{return[]}}function d$(e,t="/"){return typeof e=="string"&&e.startsWith("/")&&!e.startsWith("//")&&!e.startsWith("/\\")?e:t}function Xr(e,t){let n=new URLSearchParams({reconnect:"1"}),r=d$(e,"");return r&&n.set("next",r),t&&n.set("repo",t),`/sign-in?${n}`}import ql from"node:path";function Ve(e){return e.replace(/\\/g,"/").replace(/^\.\/?/,"").replace(/^\/+|\/+$/g,"")}function Ht(e,t){let n=Ve(t),r=e.replace(/\\/g,"/");return n?r.startsWith(`${n}/`)?r.slice(n.length+1):null:r}function Kg(e,t){let n=Ve(e).split("/").filter(Boolean),r=t.replace(/\\/g,"/").split("/").filter(Boolean),o=0;for(;o<n.length&&o<r.length&&n[o]===r[o];)o++;return[...Array(n.length-o).fill(".."),...r.slice(o)].join("/")}var Xg=/\.(css|scss|sass|less|tsx|jsx|vue|svelte|astro)$|(^|\/)tailwind\.config\.|\.tokens\.json$/i,f$=200;function Zg(e){return Ir.test(`${e}/`)}function Kl(e){let t="",n=0,r=!1,o=!1;for(;n<e.length;){let s=e[n];if(r){t+=s,o?o=!1:s==="\\"?o=!0:s==='"'&&(r=!1),n++;continue}if(s==='"'){r=!0,t+=s,n++;continue}if(s==="/"&&e[n+1]==="/"){let i=e.indexOf(`
|
|
140
|
+
`,n);n=i<0?e.length:i;continue}if(s==="/"&&e[n+1]==="*"){let i=e.indexOf("*/",n+2);n=i<0?e.length:i+2;continue}t+=s,n++}try{return JSON.parse(t.replace(/,(\s*[}\]])/g,"$1"))}catch{return null}}function g$(e){return e==="package.json"?"":e.slice(0,-13)}function m$(e){let t=Kl(e);if(!t||typeof t!="object")return[];let n=t,r=[];for(let o of["dependencies","devDependencies","peerDependencies"]){let s=n[o];s&&typeof s=="object"&&r.push(...Object.keys(s))}return r}function h$(e){let t=new Map,n=[...e.keys()].filter(o=>!Zg(o)).sort(),r=0;for(let o of n){if(r>=f$)break;let s=e.get(o);if(!s)continue;r++;let i=Kl(s),l=i&&typeof i=="object"?i.name:null;typeof l!="string"||!l||t.has(l)||t.set(l,g$(o))}return t}function Jl(e,t){let n=`${e}/`;return t.some(r=>!Zg(r.path)&&r.path.startsWith(n)&&Xg.test(r.path))}function qs(e){let t=e.lastIndexOf("/");return t<0?"":e.slice(0,t)}function nr(e,t){let n=[...qs(e)?qs(e).split("/"):[],...t.split("/")],r=[];for(let o of n)if(!(!o||o===".")){if(o===".."){if(!r.length)return null;r.pop();continue}r.push(o)}return r.join("/")}function qg(e,t){let n=Ve(t);return n?e!==n&&!e.startsWith(`${n}/`):!1}function Jg(e){if(!e||e.startsWith(".")||e.startsWith("/"))return null;let t=e.split("/");return e.startsWith("@")?t.length>=2?`${t[0]}/${t[1]}`:null:t[0]||null}function y$(e,t){let n=Xg.test(e)?qs(e):e;for(;n;){if(t.has(n))return n;let r=n.lastIndexOf("/");if(r<0)break;n=n.slice(0,r)}return t.has("")?"":null}function Vs(e,t,n,r){if(!e||!qg(e,t))return null;let o=y$(e,n);return!o||!qg(o,t)?null:Jl(o,r)?o:null}function b$(e){return[...e.matchAll(/["']([^"']+)["']/g)].map(t=>t[1]).filter(Boolean)}function w$(e){return qs(e)}function Yg(e,t,n,r){let o=Ve(e);if(!o)return[];let s=h$(n),i=new Set([...s.values()].filter(Boolean)),l=new Map,a=(f,m)=>{!f||l.has(f)||l.set(f,m)};if(n.get(`${o}/package.json`)){let f=new Set([o]),m=[{folder:o,via:null}];for(;m.length;){let g=m.shift(),S=n.get(g.folder?`${g.folder}/package.json`:"package.json");if(S)for(let h of m$(S)){let b=s.get(h);!b||f.has(b)||(f.add(b),Jl(b,t)&&a(b,g.via?`${o} depends on ${h} through ${g.via}`:`${o} depends on ${h}`),m.push({folder:b,via:h}))}}}let u=[...r.keys()].filter(f=>(f==="tsconfig.json"||f.endsWith("/tsconfig.json")||/(^|\/)tsconfig\.[^/]+\.json$/.test(f))&&(f===o||f.startsWith(`${o}/`)||!f.includes("/"))),p=new Set,d=u.filter(f=>f===`${o}/tsconfig.json`||f.startsWith(`${o}/tsconfig`));for(d.length||d.push(...u.filter(f=>f.startsWith(`${o}/`)));d.length;){let f=d.shift();if(p.has(f))continue;p.add(f);let m=r.get(f);if(!m)continue;let g=Kl(m);if(!g||typeof g!="object")continue;let S=g,h=S.extends,b=Array.isArray(h)?h:[h];for(let x of b){if(typeof x!="string")continue;let v=x.startsWith(".")?nr(f,x):(()=>{let $=Jg(x),A=$?s.get($):void 0;if(!A)return null;let E=x.slice($.length).replace(/^\//,"");return E?`${A}/${E}`:A})();v&&r.has(v)&&d.push(v)}let k=typeof S.compilerOptions?.baseUrl=="string"?nr(f,S.compilerOptions.baseUrl):w$(f),y=S.compilerOptions?.paths;if(y&&typeof y=="object"&&k!=null){for(let x of Object.values(y))if(Array.isArray(x))for(let v of x){if(typeof v!="string")continue;let $=nr(`${k}/x`,v.replace(/\*.*$/,"").replace(/\/$/,"")||".");$&&a(Vs($,o,i,t),`${o} references ${$} from tsconfig`)}}if(Array.isArray(S.references))for(let x of S.references){let v=x&&typeof x=="object"&&typeof x.path=="string"?x.path:null;if(!v)continue;let $=nr(f,v);$&&a(Vs($,o,i,t),`${o} references ${$} from tsconfig`)}}for(let[f,m]of r){if(!f.startsWith(`${o}/`))continue;let g=/\.(css|scss|less)$/i.test(f),S=/(^|\/)tailwind\.config\./.test(f),h=[];if(g)for(let b of m.matchAll(/@(?:import|use|forward|source|config|plugin)\s+(?:url\(\s*)?["']([^"']+)["']/g))h.push(b[1]);if(S)for(let b of["content","presets"]){let k=new RegExp(`${b}\\s*:\\s*\\[([\\s\\S]*?)\\]`).exec(m);k?.[1]&&h.push(...b$(k[1]))}for(let b of h){if(b.startsWith(".")){let x=nr(f,b),v=x?Vs(x,o,i,t):null;a(v,`${o} imports ${b}`);continue}let k=Jg(b),y=k?s.get(k):void 0;y&&Jl(y,t)&&a(y,`${o} imports ${b}`)}if(/\.(tsx?|jsx?|mjs|cjs|vue|svelte|astro)$/i.test(f))for(let b of m.matchAll(/(?:from\s+|import\s*\(\s*|require\(\s*)["'](\.[^"']+)["']/g)){let k=b[1],y=nr(f,k),x=y?Vs(y,o,i,t):null;a(x,`${o} imports ${k}`)}}return[...l.entries()].map(([f,m])=>({folder:f,reason:m})).sort((f,m)=>f.folder<m.folder?-1:1)}function Qg(e){if(e.flag!==void 0)return Ve(e.flag);let t=Ve(e.config??"");return t||Ve(e.projectRoot??"")}function Js(e){if(e.flag!==void 0)return Ve(e.flag);let t=ql.relative(e.repoDir,e.cwd);return!t||t==="."||t.startsWith("..")||ql.isAbsolute(t)?"":Ve(t.split(ql.sep).join("/"))}var em=4e7,Xl=5e3,Ks=15e3;function Zr(e,t){let n=Math.max(1,Math.round(e/1e3));return t||e>=Ks?{kind:"limit",seconds:n}:e>=Xl?{kind:"slow",seconds:n}:{kind:"ok"}}function Yr(e){return e.kind==="slow"?`Reading source took ${e.seconds}s. Grum skips videos and large images by name; a huge source tree or a slow disk can still take a while.`:e.kind==="limit"?"Reading source stopped at the 15s limit. Grum skips videos and large images by name, so this is a huge source tree, a slow disk, or a stalled git list. This used what it had so far.":null}var k$=/(^|\/)\.grum\//;function Zl(e){return!Ir.test(`${e}/`)&&!k$.test(`${e}/`)}function Yl(e,t){return Nd(e,t)}function tm(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}var x$=/\.(css|scss|sass|less|tsx?|jsx?|mjs|cjs|vue|svelte|astro|html?)$/i;function nm(e){return x$.test(e)}function rm(e,t,n){let r=new Map(e);for(let o of t){let s=Ht(o.path,n);s===null||!Zl(s.split("/").slice(0,-1).join("/")||".")||(o.content===null?r.delete(s):Yl(s,o.content.length)&&r.set(s,o.content))}return r}function om(e){let t=e.split("\0").filter(Boolean),n=[];for(let r=0;r<t.length;r++){let o=t[r];if(/^[RC]/.test(o)){let i=t[++r],l=t[++r];o.startsWith("R")&&i&&n.push({path:i,deleted:!0}),l&&n.push({path:l,deleted:!1});continue}let s=t[++r];s&&n.push({path:s,deleted:o.startsWith("D")})}return n}function Xs(e){let t=/^(?:git@|ssh:\/\/git@|https?:\/\/(?:[^@/]+@)?)github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(e.trim());return t?`${t[1]}/${t[2]}`:null}var sm=1,v$=["cursor","codex","claude","generic"],rr={cursor:"Cursor",codex:"Codex",claude:"Claude Code"};var S$={ready:0,"action-needed":2,error:1},$$="https://nodejs.org/en/download",Zs=22,C$="Give the person the URL in this result and ask them to open it. That Grum page checks the repository and walks them through it: Reconnect GitHub, then, if still blocked, Grum's Manage Access page on GitHub, where they grant the organization that owns the repository (or click Request when an org owner must approve). It says when Grum can read the repository. Grum is an OAuth app named Grum, not a GitHub App: do not send the person anywhere else on GitHub to hunt for it. Then run the same command again.";function R$(e){return e.scan==="failed"&&Un(e.scanMessage??"")}var A$=["blocked","needs-sign-in","needs-github","needs-workspace-create","needs-project-choice","needs-starter","needs-host-action","scan-running","needs-site","needs-extension","needs-local-app","ready"];function im(e){return S$[e.exit]}function Ql(e){let t=e.serverOrigin??"",n=d=>({ok:!1,result:P$(t,d)}),r=(e.agent??[]).map(d=>d.trim().toLowerCase());if(r.length!==1||!I$(r[0]))return n("Pass --agent with one of cursor, codex, claude or generic. generic can set up and check, and reports that automatic enforcement is unavailable.");let o=r[0];if((e.project?.length??0)>1)return n("Pass --project once, with the project id from the choices.");let s=e.project?.[0]?.trim()||null;if(e.project&&!s)return n("Pass --project with the project id from the choices.");let i=!!e.create,l=!!e.remove;if(i&&s)return n("Pass either --create or --project, not both.");if(i&&l)return n("Pass either --create or --remove, not both.");if(l&&e.switchServer)return n("Removing Grum from this repo is separate from switching servers. Run one, then the other.");if((e.name?.length??0)>1||(e.site?.length??0)>1)return n("Pass --name and --site at most once.");if((e.localUrl?.length??0)>1||(e.root?.length??0)>1)return n("Pass --local-url and --root at most once.");let a;if(e.site===void 0)a=void 0;else if(/^(none|skip)$/i.test(e.site[0]?.trim()??""))a=null;else{let d=cn(e.site[0]??"");if(!d)return n("Pass --site as an https URL or none. The live site is optional.");a=d}let c,u=null;if(e.localUrl===void 0)c=void 0;else{let d=E$(e.localUrl[0]??"");if(!d.ok)return n("Pass --local-url as an http(s) URL, a file in the repo such as ./index.html, or none.");c=d.url,u=d.kind}let p=(e.name?.[0]??"").trim().slice(0,80)||null;return e.probe&&(i||l||s||e.switchServer)?n("doctor only reports readiness. Run setup --agent to create, choose, switch or remove."):{ok:!0,request:{agent:o,projectId:s,create:i,remove:l,name:p,site:a,siteProvided:e.site!==void 0,localUrl:c,localProvided:e.localUrl!==void 0,localKind:u,root:e.root?.[0]?.trim()||null,switchServer:!!e.switchServer,dropPreCommit:!!e.dropPreCommit,probe:!!e.probe}}}function Re(e,t){let n=t.probe?null:T$(e,t);return{result:_$(e,t),mutation:n}}function am(e,t){let n=rr[t.agent==="generic"?"cursor":t.agent],r=t.dropPreCommit?" The pre-commit check was removed.":" The pre-commit check was left as it was.";return ye(e,t,{open:[],fault:!1,checks:[{id:"adapter",evidence:"observed",status:"ok",label:`Removed Grum from ${n}.${r} This computer's sign-in and the Grum workspace were kept.`}],actions:[]})}function I$(e){return v$.includes(e??"")}function E$(e){let t=e.trim();if(/^(none|skip)$/i.test(t))return{ok:!0,url:null,kind:"none"};if(/^https?:\/\//i.test(t))try{let n=new URL(t);return n.username||n.password?{ok:!1}:{ok:!0,url:n.href,kind:"url"}}catch{return{ok:!1}}return!t||t.includes("..")||t.startsWith("/")||t.includes("\\")||/^[a-z][a-z0-9+.-]*:/i.test(t)?{ok:!1}:{ok:!0,url:t,kind:"file"}}function ec(e){return!e.selectedId||!e.projects?null:e.projects.find(t=>t.id===e.selectedId)??null}function T$(e,t){if(!e.runtimeOk)return null;if(!!(e.repoServer&&e.repoServer!==e.serverOrigin))return t.switchServer?{kind:"switch-server"}:null;if(t.remove&&t.agent!=="generic")return{kind:"remove",agent:t.agent,dropPreCommit:t.dropPreCommit};if(e.offline||!e.signedIn||e.origin!=="github"||e.github==="missing"||e.github==="no-access")return null;let r=e.projects;if(!r)return null;let o=ec(e);if(t.projectId&&r.some(l=>l.id===t.projectId)&&o?.id!==t.projectId)return{kind:"select",projectId:t.projectId};let s=e.kit;if(s?.needsRepo&&t.projectId===s.project.id&&r.length===0&&s.project.role==="owner"&&e.repoName)return{kind:"link-repo",projectId:s.project.id,repo:e.repoName};if(t.create&&r.length===0)return{kind:"create",name:t.name,site:t.siteProvided?t.site??null:null};if(!o)return null;let i=s&&s.project.id===o.id&&s.state!=="pushed";return e.scan==="needed"&&o.role==="owner"&&i?s.state==="not-written"?{kind:"write-starter",projectId:o.id}:null:t.agent!=="generic"&&!e.adapterWritten&&!i?{kind:"install",agent:t.agent}:(e.scan==="needed"||R$(e))&&o.role==="owner"?{kind:"start-scan",projectId:o.id}:e.scan!=="done"?null:t.siteProvided&&o.role==="owner"&&(t.site??null)!==(o.site??null)?{kind:"set-site",projectId:o.id,site:t.site??null}:t.siteProvided&&t.site===null&&o.role==="owner"&&!o.site&&!e.siteSkipped?{kind:"skip-site",projectId:o.id}:t.localProvided&&(t.localUrl!==e.localSaved||t.localUrl===null&&!e.localSkipped)?{kind:"set-local",url:t.localUrl??null}:null}function _$(e,t){let n=[],r=[],o=[],s=!1,i=ec(e),l=rr[t.agent==="generic"?"cursor":t.agent];if(o.push({id:"runtime",evidence:"observed",status:e.runtimeOk?"ok":"missing",label:e.runtimeOk?`Node.js ${e.runtimeVersion} can run Grum.`:`Node.js ${e.runtimeVersion||"is missing"}; Grum needs ${Zs} or newer.`}),!e.runtimeOk)return n.push("blocked"),r.push({kind:"install-runtime",explanation:`Ask the person to install Node.js ${Zs} or newer from the browser, then restart the editor and run this again. Do not ask them to type a command.`,input:{url:$$,command:ve(e,t)}}),ye(e,t,{open:n,actions:r,checks:o,fault:!1});let a=!!(e.repoServer&&e.repoServer!==e.serverOrigin);if(o.push({id:"server",evidence:"observed",status:a?"blocked":"ok",label:a?`This repo is set up for ${ct(e.repoServer)} (${e.repoServer}), and this Grum is ${ct(e.serverOrigin)} (${e.serverOrigin}).`:`Grum ${ct(e.serverOrigin)} (${e.serverOrigin}).`}),a)return n.push("blocked"),r.push({kind:"switch-server",explanation:"Ask before switching. Nothing was changed. Switching sets the previous server's local Grum files aside and sets this repo up here.",input:{flag:"--switch-server",command:ve(e,{...t,probe:!1},["--switch-server"])}}),ye(e,t,{open:n,actions:r,checks:o,fault:!1});if(t.remove)return t.agent==="generic"&&(s=!0,n.push("blocked"),r.push({kind:"fix-error",explanation:`A generic agent has no Grum files to remove. To sign out this computer, run ${e.cli} logout.`})),ye(e,t,{open:n,actions:r,checks:o,fault:s});if(e.offline)return s=!0,n.push("blocked"),o.push({id:"server-reach",evidence:"observed",status:"blocked",label:e.offlineMessage??"Grum could not be reached. Nothing was marked ready."}),r.push({kind:"fix-error",explanation:"Grum could not be reached, so this run is not ready. The connection is down or too slow (the CLI waits 15 seconds). Try the same command again once it answers. An offline check can still use a contract already saved on this computer, and that result is not current.",input:{command:ve(e,t)}}),ye(e,t,{open:n,actions:r,checks:o,fault:s});if(e.origin==="absent"||e.origin==="unsupported")return s=!0,n.push("blocked"),o.push({id:"repository",evidence:"observed",status:"blocked",label:e.origin==="absent"?"This folder has no GitHub origin remote.":"This folder's origin remote is not a GitHub repository Grum can connect."}),r.push({kind:"fix-error",explanation:e.origin==="absent"?"Grum did not invent a git remote. Add the repository's GitHub origin, then run this again.":"Grum only connects a github.com origin. It did not change the remote."}),ye(e,t,{open:n,actions:r,checks:o,fault:s});if(o.push({id:"sign-in",evidence:"observed",status:e.signedIn?"ok":"missing",label:e.signedIn?"Signed in on this computer.":e.signInExpired?"The sign-in on this computer expired or was revoked.":"This computer is not signed in to Grum."}),!e.signedIn){n.push("needs-sign-in");let m=e.pendingLogin;return r.push({kind:"approve-sign-in",explanation:m?`Open this Grum page, sign in, and approve code ${m.code}. Then run the same command again.`:"Run setup so Grum can start a browser sign-in. Doctor does not start one. The next result has the code and the page.",input:{...m?{url:m.url,code:m.code,expiresAt:m.expiresAt}:{},command:ve(e,{...t,probe:!1})}}),ye(e,t,{open:n,actions:r,checks:o,fault:s})}let c=e.github==="no-access"?e.repoName:null;if(e.github==="missing"||e.github==="no-access")return n.push("needs-github"),o.push({id:"github",evidence:"observed",status:"missing",label:e.github==="no-access"?`This GitHub login cannot read ${c??"that repository"}: it is not found or access is denied.`:e.githubMessage??"GitHub is not connected for this account."}),r.push({kind:"connect-github",explanation:C$,input:{url:`${e.serverOrigin}${Xr(void 0,c??void 0)}`,command:ve(e,t)}}),ye(e,t,{open:n,actions:r,checks:o,fault:s});if(e.projects===null)return s=!0,n.push("blocked"),o.push({id:"project",evidence:"unknown",status:"unknown",label:"Grum did not return this repository's workspaces."}),r.push({kind:"fix-error",explanation:"Run the same command again. No workspace was created.",input:{command:ve(e,t)}}),ye(e,t,{open:n,actions:r,checks:o,fault:s});e.staleProjectId&&!i&&o.push({id:"project",evidence:"observed",status:"blocked",label:`The saved project ${e.staleProjectId} is not a workspace this account can use.`});let u=e.kit?.needsRepo===!0&&t.projectId===e.kit.project.id;if(t.projectId&&!u&&!e.projects.some(m=>m.id===t.projectId)){let m=e.projects.map(g=>({id:g.id,label:g.name}));return m.length||(s=!0),n.push(m.length?"needs-project-choice":"blocked"),r.push({kind:m.length?"choose-project":"fix-error",explanation:m.length?"That project id is not one this account can use for this repository. Ask which of these to use.":"That project id is not a workspace this account can use, and this repository has none yet.",input:m.length?{flag:"--project",choices:m,command:ve(e,t)}:void 0}),ye(e,t,{open:n,actions:r,checks:o,fault:s})}let p=u?e.kit:null;if(e.projects.length===0&&p){let m=p.project.name;return p.project.role!=="owner"?(s=!0,n.push("blocked"),o.push({id:"project",evidence:"observed",status:"blocked",label:`Only an owner of ${m} can connect a repository to it.`}),r.push({kind:"fix-error",explanation:`${e.repoName} is not connected to ${m}, and only an owner of that workspace can connect it. Ask an owner. Nothing was changed.`}),ye(e,t,{open:n,actions:r,checks:o,fault:s})):(n.push("needs-workspace-create"),o.push({id:"project",evidence:"observed",status:"missing",label:`${e.repoName} is not connected to the ${m} workspace yet.`}),r.push({kind:"link-workspace",explanation:`Connect ${e.repoName} to the ${m} workspace, which started from ${p.kit.name}. The person's request to set up this project already authorized it: say that you are connecting it, then run setup. A readiness check never connects it.`,input:{command:ve(e,{...t,probe:!1})}}),ye(e,t,{open:n,actions:r,checks:o,fault:s}))}if(e.projects.length===0)return n.push("needs-workspace-create"),o.push({id:"project",evidence:"observed",status:"missing",label:`No Grum workspace you can access is connected to ${e.repoName}.`}),r.push({kind:"create-workspace",explanation:t.create?`Creating a Grum workspace for ${e.repoName}.`:`Create a Grum workspace for ${e.repoName}. The person's explicit setup request already authorized this; state that you are creating it, then run setup with --create. A readiness check never creates one.`,input:{flag:"--create",command:ve(e,{...t,probe:!1,create:!0})}}),ye(e,t,{open:n,actions:r,checks:o,fault:s});if(!i)return n.push("needs-project-choice"),o.push({id:"project",evidence:"observed",status:"missing",label:`Several workspaces use ${e.repoName}. None is selected.`}),r.push({kind:"choose-project",explanation:"Ask which workspace to use. Pass its id as --project. Do not choose the first.",input:{flag:"--project",choices:e.projects.map(m=>({id:m.id,label:m.name})),command:ve(e,t)}}),ye(e,t,{open:n,actions:r,checks:o,fault:s});o.push({id:"project",evidence:"observed",status:"ok",label:`Linked to ${i.name} (${e.repoName}).`});let d=e.scan==="needed"&&e.kit?.project.id===i.id?e.kit:null;if(d&&d.state!=="pushed"){n.push("needs-starter");let m=M$(e,t,d,i.role);return o.push({id:"starter",evidence:"observed",status:"missing",label:m.label}),r.push(m.action),ye(e,t,{open:n,actions:r,checks:o,fault:s})}if(O$(e,t,l,n,r,o),e.scan==="failed"?(s=!0,n.push("blocked"),o.push({id:"scan",evidence:"observed",status:"blocked",label:e.scanMessage??"The first scan failed."}),r.push({kind:"fix-error",explanation:"The scan failed. Report that and stop. Do not start another scan unless the person asks."})):e.scan==="running"||e.scan==="needed"?(n.push("scan-running"),o.push({id:"scan",evidence:"observed",status:"missing",label:e.scan==="running"?`Grum is still reading ${e.repoName}.`:`Grum has not finished reading ${e.repoName}.`}),r.push({kind:"wait-for-scan",explanation:"The scan is on Grum's servers. A large repo or a slow GitHub connection can take a few minutes. Run the same command again shortly. Tell the person if it is still running after several tries. Do not block this chat, and do not hunt GitHub settings.",input:{command:ve(e,t)}})):e.scan==="done"?o.push({id:"code-check",evidence:"observed",status:"ok",label:"Code checks can run against the current contract. That is separate from capture."}):o.push({id:"code-check",evidence:"unknown",status:"unknown",label:"No contract has been checked on this run."}),e.scan!=="done")return ye(e,t,{open:n,actions:r,checks:o,fault:s});t.siteProvided&&i.role!=="owner"&&(t.site??null)!==(i.site??null)?o.push({id:"site",evidence:"observed",status:"blocked",label:"Only an owner can change the live site, so it was left as it is."}):i.site?o.push({id:"site",evidence:"observed",status:"ok",label:`Live site: ${i.site}.`}):e.siteSkipped?o.push({id:"site",evidence:"observed",status:"ok",label:"No live site, by choice. Grum checks the code only."}):i.role==="owner"&&(n.push("needs-site"),o.push({id:"site",evidence:"observed",status:"missing",label:"No live site is saved, so Grum checks the code but not the deployed pages."}),r.push({kind:"set-site",explanation:e.siteHints.length?"Ask the person for the live site's URL. Offer the URLs in input.uncertain, found in this repository and not checked, and let them type another. Pass --site with the answer, or none when there is no live site.":"Ask the person for the live site's URL. First look in the repository (README, deploy config, metadata) for a production URL to offer. Pass --site with the answer, or none when there is no live site.",input:{flag:"--site",...e.siteHints.length?{uncertain:e.siteHints}:{},command:ve(e,t)}})),e.extension===null?o.push({id:"extension",evidence:"unknown",status:"unknown",label:"Could not tell whether the Chrome extension is connected. The server is the source of that check, and it is not proof the extension is in the browser you have open."}):e.extension.connected?o.push({id:"extension",evidence:"observed",status:"ok",label:"Grum's server shows the Chrome extension connected for this workspace. That is not proof it is installed in the browser you have open."}):(n.push("needs-extension"),o.push({id:"extension",evidence:"observed",status:"missing",label:"The Chrome extension is not connected. Pages behind a sign-in need it. Code checks do not."}),r.push({kind:"connect-extension",explanation:"Open Grum's extension page in the Chrome profile the person uses, install or load the extension, and choose Connect for this workspace.",input:{url:e.extensionUrl}}));let f=!e.localSaved&&!e.localSkipped;if(e.localSkipped&&!e.localSaved)o.push({id:"local-app",evidence:"observed",status:"ok",label:"No local app URL was saved, by choice. A later review picture will need one."});else if(e.localSaved&&e.localStatus===void 0)o.push({id:"local-app",evidence:"unknown",status:"unknown",label:`A local app URL is saved (${e.localSaved}) and was not probed on this run.`});else if(e.localSaved&&e.localStatus!==null&&e.localStatus!==void 0&&e.localStatus<500)o.push({id:"local-app",evidence:"observed",status:"ok",label:`Local app answering at ${e.localSaved}.`});else if(f||e.localSaved){n.push("needs-local-app"),o.push({id:"local-app",evidence:"observed",status:"missing",label:e.localSaved?`Local app not answering at ${e.localSaved}.`:"No local app URL is saved, so a review cannot show how a change renders until one is set."});let m=e.localSuggestions.filter(S=>S.verified),g=e.localSuggestions.filter(S=>!S.verified).map(S=>S.url);r.push({kind:"set-local-app",explanation:e.localSaved?"The saved local app is not answering. Ask the person whether to start it (offer to run its dev command) or use another URL. Pass --local-url with a page that answers, or none to skip.":m.length||g.length?"Ask the person where the app runs locally while they edit. Offer input.choices (they answered just now) and input.uncertain (seen in the repository, not running), and let them type another. When the one they pick is not running, offer to start the dev command. Pass --local-url with their answer, or none to skip.":"Ask the person where the app runs locally while they edit. First look in the repository (package.json scripts, README, docker-compose, framework config) for a localhost URL or an HTML entry file to offer. When it is not running, offer to start the dev command. Pass --local-url with their answer, or none to skip.",input:{flag:"--local-url",...m.length?{choices:m.map(S=>({id:S.url,label:S.url}))}:{},...g.length?{uncertain:g}:{},command:ve(e,t)}})}return ye(e,t,{open:n,actions:r,checks:o,fault:s})}function j$(e,t){return e==="cursor"?`In Cursor, ${Ze} Then start a new chat so the tools load. Until then, use the CLI commands in this guide.`:e==="claude"?`In Claude Code, ${fl} Until then, use the CLI commands in this guide.`:e==="codex"?`In Codex, ${hs} Then ${$l} Start a new chat so Codex reloads them.`:`Run setup to write Grum's files for ${t}, then complete the editor step it reports. File presence is not the same as tools loaded.`}function O$(e,t,n,r,o,s){if(t.agent==="generic"){s.push({id:"enforcement",evidence:"observed",status:"missing",label:"Automatic enforcement is unavailable for this agent. Checks and review still run when asked. Hooks are not installed."});return}if(!e.adapterWritten){r.push("needs-host-action"),s.push({id:"adapter",evidence:"observed",status:"missing",label:`Grum is not configured in ${n} yet.`}),o.push({kind:"enable-host",explanation:`Run setup to write Grum's files for ${n}, then complete the editor step it reports. File presence is not the same as tools loaded.`,input:{command:ve(e,{...t,probe:!1})}});return}s.push({id:"adapter",evidence:"observed",status:"ok",label:`Grum's files are written for ${n}. That alone does not mean the tools are loaded.`});let i=e.tools==="on"||e.tools==="off";s.push({id:"tools",evidence:e.tools==="unknown"?"unknown":"observed",status:e.tools==="on"?"ok":e.tools==="off"?"missing":"unknown",label:e.tools==="on"?`Grum's tools are loaded in ${n}.`:e.tools==="off"?`Grum's tools are not on in ${n}.`:`Could not confirm that Grum's tools are loaded in ${n}.`});let l=e.hooks==="active"||e.hooks==="inactive";e.hooks!=="not-applicable"&&s.push({id:"hooks",evidence:l?"observed":"unknown",status:e.hooks==="active"?"ok":e.hooks==="inactive"?"missing":"unknown",label:e.hooks==="active"?`Grum's hooks have run in ${n}.`:e.hooks==="inactive"?`Grum's hooks have not been allowed in ${n}.`:`Could not confirm that Grum's hooks are active in ${n}.`}),!(t.agent==="codex"?e.hooks==="active":e.tools==="on")&&(i||e.tools==="unknown"||e.hooks!=="not-applicable")&&(r.push("needs-host-action"),o.push({kind:"enable-host",explanation:j$(t.agent,n),input:{command:ve(e,t,[],!0)}}))}function M$(e,t,n,r){let{createApp:o,install:s}=n.starter.commands,i=ve(e,{...t,probe:!1}),l=(c,u)=>({label:u,action:{kind:"run-commands",explanation:"Run input.commands in order from the repository root, with stdin closed. They ask nothing. Do not delete or move files to make them work: when one refuses because the folder already has files in it, tell the person and stop. When they finish, run the same command again.",input:{commands:c,command:i}}});if(n.state==="no-app")return l([...o,...s],`This folder has no app yet, and the ${n.kit.name} starter needs one.`);if(n.state==="not-installed")return l(s,`${n.kit.name} is not installed in this app yet.`);if(n.state==="not-written")return{label:`The contract's tokens are not written into ${n.starter.tokensFile} yet.`,action:{kind:"run-commands",explanation:r==="owner"?"Run setup. It writes the contract's tokens into the app and adds DESIGN.md, and changes nothing else.":"An owner of this workspace has to run setup to write the contract's tokens into the app. Nothing was changed.",input:{commands:[i],command:i}}};let a=n.defaultBranch??"the default branch";return{label:`The starter is written, but not on ${a} on GitHub, where Grum's scan reads it.`,action:{kind:"commit-and-push",explanation:`Grum scans ${a} on GitHub, so the work has to be there first. Run \`${e.cli} check\`: it should report no drift. Then tell the person what you will commit (the app, ${n.starter.tokensFile} and DESIGN.md) and that you will push it to ${a}, and ask. Only with their yes: commit, push to ${a}, then run the same command again. If the work is on another branch, ask whether to merge it into ${a}. Never force-push.`,input:{...n.defaultBranch?{branch:n.defaultBranch}:{},command:i}}}}function ye(e,t,n){let r=A$.filter(c=>n.open.includes(c)),o=r[0]??"ready",s=ec(e),i=o==="ready"?"ready":n.fault?"error":"action-needed",l=[...n.checks],a=D$(e);return a&&l.push(a),{schema:sm,state:o,open:r,server:e.serverOrigin?{origin:e.serverOrigin,label:ct(e.serverOrigin)}:null,repository:{name:e.repoName},project:s?{id:s.id,name:s.name}:null,checks:l,actions:n.actions,exit:i}}function D$(e){if(!e.sourceRead)return null;let t=Yr(Zr(e.sourceRead.ms,e.sourceRead.stalled));return t?{id:"source-read",evidence:"observed",status:e.sourceRead.stalled?"missing":"ok",label:t}:null}function P$(e,t){return{schema:sm,state:"blocked",open:["blocked"],server:e?{origin:e,label:ct(e)}:null,repository:null,project:null,checks:[{id:"request",evidence:"observed",status:"blocked",label:t}],actions:[{kind:"fix-error",explanation:t}],exit:"error"}}function ve(e,t,n=[],r=!1){let o=[e.cli,r||t.probe?"doctor":"setup","--agent",t.agent,"--json"];t.root&&o.push("--root",t.root),t.projectId&&o.push("--project",t.projectId),t.create&&o.push("--create"),t.name&&o.push("--name",t.name),t.siteProvided&&o.push("--site",t.site??"none"),t.localProvided&&o.push("--local-url",t.localUrl??"none");for(let s of n)o.includes(s)||o.push(s);return o.join(" ")}var lm=[" @@@@@@@ @@@@@@@","@@@@@@@@@ @@@@@@@@@","@@@@@@@@@ @@@@@@@@@"," @@@@@@@@@@@@@@@@@@"," @@@@@@@@"," @@@@@@ "," @@@@@@@@@@@@@@@@@@","@@@@@@@@@ @@@@@@@@@","@@@@@@@@@ @@@@@@@@@"," @@@@@@@ @@@@@@@"],L$=Math.max(...lm.map(e=>e.length)),N$=[" .d8888b."," d88P Y88b"," 888 888"," 888 888d888 888 888 88888b.d88b.",' 888 88888 888P" 888 888 888 "888 "88b'," 88 888 888 888 888 888 888 888"," 88b d88P 888 Y88b 888 888 888 888",' "Y8888P88 888 "Y88888 888 888 888'],cm=lm.map((e,t)=>{let n=N$[t-1];return n?`${e.padEnd(L$)} ${n}`:e}).join(`
|
|
141
141
|
`),F$="\x1B[38;2;203;52;81m",U$="\x1B[38;2;196;160;0m",Ys="\x1B[0m",um=e=>`${F$}${e}${Ys}`,z$=[{name:"check",blurb:"Check your changes against the design contract"},{name:"setup",blurb:"Sign in, link this repository, set up Cursor"}];function $t(e){return/GitHub rejected the token|GitHub session expired|Sign in with GitHub|Sign in to Grum with GitHub/.test(e)}function pm(e,t){let n=e.split("/")[0]??e;return[`Grum can't read ${e} with your GitHub login.`,`Fix it here: ${t}`,`That page reconnects GitHub and links to GitHub's Manage Access page, where you grant the ${n} organization (or request it from an owner).`,"Then run the same command again."].join(`
|
|
142
142
|
`)}function nc(e,t){if(e!==401)return null;let n=typeof t.error=="string"?t.error:"";return t.code==="no_github"||t.code==="needs_repo_scope"||$t(n)?"github":"grum"}function Qr(e){return[...z$,e?{name:"logout",blurb:"Sign out of Grum"}:{name:"login",blurb:"Sign in to Grum"}]}var dm="\u2191\u2193 move Enter select 1\u20133 jump q quit",fm=/^[A-Za-z0-9_-]{1,80}$/;function tc(e){if(!e||typeof e!="object")return null;let t=e,n=typeof t.repo=="string"?t.repo.trim():"",r=typeof t.workspace?.name=="string"?t.workspace.name.trim():"";if(!n||!r)return null;let o=t.workspace?.id,s=typeof t.site=="string"?t.site.trim():"";return{workspace:r,workspaceId:typeof o=="string"&&fm.test(o)?o:null,repo:n,site:s||null}}function G$(e){return e&&e.replace(/^https?:\/\//,"").replace(/\/$/,"")||null}function gm(e){let t=G$(e.site);return`${[e.workspace,e.repo,...t?[t]:[]].join(" \xB7 ")}`}function mm(e,t){return fm.test(t)?`${e.replace(/\/$/,"")}/${t}`:null}function hm(e,t){if(e===200||t.code==="not-scanned"){let o=tc(t.project);return o?{line:gm(o),workspaceId:o.workspaceId}:null}if(t.code!=="choose-project"||!Array.isArray(t.projects))return null;let n=t.projects.flatMap(o=>{let s=tc(o);return s?[s]:[]}),r=n[0];return r?{line:`Connected to ${n.map(o=>o.workspace).join(", ")} \xB7 ${r.repo}`,workspaceId:null}:null}function ym(e,t,n){if(!e||!t||e.apiOrigin!==n||e.project.repo.toLowerCase()!==t.toLowerCase())return null;let r=tc(e.project);return r?{line:gm(r),workspaceId:r.workspaceId}:null}var bm="\x1B[2m",B$=e=>`${bm}${e}${Ys}`;function W$(e){return`${bm}\x1B]8;;${e}\x1B\\${e}\x1B]8;;\x1B\\${Ys}`}function wm(e,t=null,n=!1,r=null){let o=[t,r].filter(a=>a),s=o.length?`${o.join(`
|
|
143
143
|
`)}
|
|
@@ -156,7 +156,7 @@ v${e} ${dm}
|
|
|
156
156
|
`)}function Cm(e){let t=e.trim().toLowerCase();return t==="y"||t==="yes"?"yes":["","n","no","q","quit"].includes(t)?"no":null}function Rm(e,t){let n=[],r=s=>n.push(` \u2713 ${s}`),o=s=>n.push(` \u2717 ${s}`);n.push(`This repository (${e.repo})`);for(let s of e.agents)r(`Removed Grum's ${s} files`);for(let s of e.failed)o(`Left Grum's ${s.agent} files in place: ${s.error}`);e.state&&r("Deleted .grum/"),!e.agents.length&&!e.failed.length&&!e.state&&r("Nothing of Grum's was here"),n.push("","This computer");for(let s of e.signIns)s.revoked?r(`Signed out of ${s.origin}`):o(`Couldn't reach ${s.origin} to end its sign-in. Remove it in Grum's Settings.`);return e.config?r(`Deleted ${e.config}`):e.signIns.length||r("Nothing of Grum's was here"),n.push("","Left for you:",` - Other repositories you set up keep their Grum files. Run \`${t} uninstall\` in each.`," - Installed globally? Run `npm uninstall -g @grum-os/cli`."," - The Grum Chrome extension: remove it in chrome://extensions."," - Cursor or Codex already open: reload the window so Grum's tools stop. Claude Code: start a new session."),`${n.join(`
|
|
157
157
|
`)}
|
|
158
158
|
`}var Am=e=>e.failed.length||e.signIns.some(t=>!t.revoked)?1:0;import{chmodSync as H$,mkdirSync as V$,readFileSync as q$,rmSync as J$,writeFileSync as K$}from"node:fs";import{homedir as eo}from"node:os";import Im from"node:path";function rc(e,t=eo()){return Im.join(t,".config","grum","pending-login",`${e.replace(/[^a-z0-9]+/gi,"_")}.json`)}function oc(e,t=eo(),n=Date.now()){try{let r=JSON.parse(q$(rc(e,t),"utf8")),o=Date.parse(r.expiresAt??"");return r.apiOrigin!==e||typeof r.poll!="string"||!r.poll||typeof r.code!="string"||typeof r.url!="string"||!Number.isFinite(o)||o<=n?(r.apiOrigin===e&&xn(e,t),null):{apiOrigin:e,poll:r.poll,code:r.code,url:r.url,expiresAt:new Date(o).toISOString()}}catch{return null}}function to(e,t=eo(),n=Date.now()){let r=oc(e,t,n);return r?{code:r.code,url:r.url,expiresAt:r.expiresAt}:null}function Em(e,t=eo()){let n=rc(e.apiOrigin,t);V$(Im.dirname(n),{recursive:!0,mode:448}),K$(n,`${JSON.stringify(e)}
|
|
159
|
-
`,{mode:384}),H$(n,384)}function xn(e,t=eo()){J$(rc(e,t),{force:!0})}import{existsSync as co,mkdirSync as hR,readFileSync as Rc,rmSync as yR,writeFileSync as Wh}from"node:fs";import
|
|
159
|
+
`,{mode:384}),H$(n,384)}function xn(e,t=eo()){J$(rc(e,t),{force:!0})}import{existsSync as co,mkdirSync as hR,readFileSync as Rc,rmSync as yR,writeFileSync as Wh}from"node:fs";import Fe from"node:path";var Tm="/* grum:kit begin */",sc="/* grum:kit end */",X$=/^(?:\.dark(?:-mode)?|html\.dark(?:-mode)?|:root\.dark(?:-mode)?|\[data-theme=["']?dark["']?\])$/,Z$=/^(?::root|html|@theme)$/;function Y$(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,"").trim();return Z$.test(t)?"light":X$.test(t)?"dark":null}function Q$(e,t){let n=0;for(let r=t;r<e.length;r++)if(e.startsWith("/*",r)){let o=e.indexOf("*/",r+2);if(o<0)return null;r=o+1}else if(e[r]==="{")n++;else if(e[r]==="}"&&--n===0)return r;return null}function eC(e,t,n){return e.replace(/(--[\w-]+)(\s*:\s*)([^;]*?)(\s*)(;|$)/g,(r,o,s,i,l,a)=>o in t?(n.add(o),`${o}${s}${t[o]}${l}${a}`):r)}function jm(e,t,n){let r="",o=0,s=0,i=0;for(;i<e.length;){if(e.startsWith("/*",i)){let u=e.indexOf("*/",i+2);i=u<0?e.length:u+2;continue}if(e[i]===";"){s=i+1,i++;continue}if(e[i]!=="{"){i++;continue}let l=Q$(e,i);if(l===null)break;let a=e.slice(s,i),c=Y$(a);c?(r+=e.slice(o,i+1)+eC(e.slice(i+1,l),t[c],n[c]),o=l):/^@layer\b/i.test(a.replace(/\/\*[\s\S]*?\*\//g,"").trim())&&(r+=e.slice(o,i+1)+jm(e.slice(i+1,l),t,n),o=l),s=l+1,i=l+1}return r+e.slice(o)}function _m(e,t){let n=Object.entries(t).map(([r,o])=>` ${r}: ${o};`);return`${e} {
|
|
160
160
|
${n.join(`
|
|
161
161
|
`)}
|
|
162
162
|
}`}function Om(e,t){let n=e.indexOf(Tm),r=e.indexOf(sc,n+1),o=n>=0&&r>n?e.slice(0,n).replace(/\s+$/,"")+e.slice(r+sc.length).replace(/^\s+$/,""):e,s={light:new Set,dark:new Set},i=jm(o,t,s),l=d=>Object.fromEntries(Object.entries(t[d]).filter(([f])=>!s[d].has(f))),a=l("light"),c=l("dark"),u=[...Object.keys(a).length?[_m(":root",a)]:[],...Object.keys(c).length?[_m(/\.dark-mode\b/.test(o)?".dark-mode":".dark",c)]:[]];if(u.length===0)return i;let p=i.replace(/\s+$/,"");return`${p}${p?`
|
|
@@ -166,7 +166,7 @@ ${u.join(`
|
|
|
166
166
|
|
|
167
167
|
`)}
|
|
168
168
|
${sc}
|
|
169
|
-
`}function Qs(e){if(typeof e!="string")return null;let t=e.replace(/\\/g,"/");if(!t||t.startsWith("/")||/^[A-Za-z]:/.test(t))return null;let n=t.split("/");return n.some(r=>r===""||r==="."||r===".."||r===".git")?null:n.join("/")}var ei=e=>Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null,Mm=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=Object.entries(e);return t.every(([n,r])=>/^--[\w-]+$/.test(n)&&typeof r=="string")?Object.fromEntries(t):null};function ic(e){if(!e||typeof e!="object")return null;let t=e,n=t.commands,r=t.markers,o=t.values,s=ei(n?.createApp),i=ei(n?.install),l=ei(r?.app)?.map(Qs),a=ei(r?.installed)?.map(Qs),c=Qs(t.tokensFile),u=Mm(o?.light),p=Mm(o?.dark);if(!Array.isArray(t.files))return null;let d=t.files.map(f=>{let m=f,g=Qs(m?.path);return!g||typeof m?.content!="string"||m.replaces!==void 0&&typeof m.replaces!="string"?null:{path:g,content:m.content,...m.replaces!==void 0?{replaces:m.replaces}:{}}});return!s||!i||!l||!a||!c||!u||!p||[...l,...a,...d].some(f=>f===null)?null:{commands:{createApp:s,install:i},markers:{app:l,installed:a},tokensFile:c,values:{light:u,dark:p},files:d}}function ac(e,t){return Om(t,e.values)}function Dm(e,t){return t!==null&&!(e.replaces&&t.includes(e.replaces))}function Pm(e,t){return t===null||!Dm(e,t)}function tC(e,t){let n=t.read(e.tokensFile),r=e.files.some(s=>s.path===e.tokensFile);return(n===null||r?r:ac(e,n)===n)&&e.files.every(s=>Dm(s,t.read(s.path)))}function Lm(e,t,n){if(!e.markers.app.every(s=>t.exists(s)))return"no-app";let r=e.files.some(s=>s.path===e.tokensFile);return e.markers.installed.length>0&&(!e.markers.installed.every(s=>t.exists(s))||!r&&!t.exists(e.tokensFile))?"not-installed":tC(e,t)?n.clean&&n.branch!==null&&n.branch===n.defaultBranch&&n.head!==null&&n.head===n.remote?"pushed":"not-pushed":"not-written"}import{execFile as oR}from"node:child_process";import{statSync as sR}from"node:fs";import no from"node:path";var e_=600*1e3,Nm=8;function Fm(e){if(!e||typeof e!="object")return null;let t=e,n=_r(t.query);if(typeof t.projectId!="string"||!t.projectId||t.projectId.length>100||typeof t.title!="string"||!t.title||t.title.length>500||!Array.isArray(t.pages)||!t.pages.length||t.pages.length>3||!n&&!Array.isArray(t.queries)&&!Array.isArray(t.items))return null;let r=t.pages.map(
|
|
169
|
+
`}function Qs(e){if(typeof e!="string")return null;let t=e.replace(/\\/g,"/");if(!t||t.startsWith("/")||/^[A-Za-z]:/.test(t))return null;let n=t.split("/");return n.some(r=>r===""||r==="."||r===".."||r===".git")?null:n.join("/")}var ei=e=>Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null,Mm=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=Object.entries(e);return t.every(([n,r])=>/^--[\w-]+$/.test(n)&&typeof r=="string")?Object.fromEntries(t):null};function ic(e){if(!e||typeof e!="object")return null;let t=e,n=t.commands,r=t.markers,o=t.values,s=ei(n?.createApp),i=ei(n?.install),l=ei(r?.app)?.map(Qs),a=ei(r?.installed)?.map(Qs),c=Qs(t.tokensFile),u=Mm(o?.light),p=Mm(o?.dark);if(!Array.isArray(t.files))return null;let d=t.files.map(f=>{let m=f,g=Qs(m?.path);return!g||typeof m?.content!="string"||m.replaces!==void 0&&typeof m.replaces!="string"?null:{path:g,content:m.content,...m.replaces!==void 0?{replaces:m.replaces}:{}}});return!s||!i||!l||!a||!c||!u||!p||[...l,...a,...d].some(f=>f===null)?null:{commands:{createApp:s,install:i},markers:{app:l,installed:a},tokensFile:c,values:{light:u,dark:p},files:d}}function ac(e,t){return Om(t,e.values)}function Dm(e,t){return t!==null&&!(e.replaces&&t.includes(e.replaces))}function Pm(e,t){return t===null||!Dm(e,t)}function tC(e,t){let n=t.read(e.tokensFile),r=e.files.some(s=>s.path===e.tokensFile);return(n===null||r?r:ac(e,n)===n)&&e.files.every(s=>Dm(s,t.read(s.path)))}function Lm(e,t,n){if(!e.markers.app.every(s=>t.exists(s)))return"no-app";let r=e.files.some(s=>s.path===e.tokensFile);return e.markers.installed.length>0&&(!e.markers.installed.every(s=>t.exists(s))||!r&&!t.exists(e.tokensFile))?"not-installed":tC(e,t)?n.clean&&n.branch!==null&&n.branch===n.defaultBranch&&n.head!==null&&n.head===n.remote?"pushed":"not-pushed":"not-written"}import{execFile as oR}from"node:child_process";import{statSync as sR}from"node:fs";import no from"node:path";var e_=600*1e3,Nm=8;function Fm(e){if(!e||typeof e!="object")return null;let t=e,n=_r(t.query);if(typeof t.projectId!="string"||!t.projectId||t.projectId.length>100||typeof t.title!="string"||!t.title||t.title.length>500||!Array.isArray(t.pages)||!t.pages.length||t.pages.length>3||!n&&!Array.isArray(t.queries)&&!Array.isArray(t.items))return null;let r=t.pages.map(We);if(r.some(i=>!i||new URL(i).username||new URL(i).password))return null;let o=Array.isArray(t.queries)?t.queries.map(_r):n?[n]:[];if(!o.length||o.length>Nm||o.some(i=>!i))return null;let s=Array.isArray(t.items)?t.items.map(i=>nC(i,r)):o.map(i=>({key:i.key,label:i.key,page:r[0],query:i,state:"waiting"}));return!s.length||s.length>Nm||s.some(i=>!i)||new Set(s.map(i=>i.key)).size!==s.length?null:{projectId:t.projectId,title:t.title,pages:r,query:n??o[0],...t.queries||t.items?{queries:o}:{},...t.queries||t.items?{items:s}:{},...t.authRequired===!0?{authRequired:!0}:{},...typeof t.extensionBatch=="boolean"?{extensionBatch:t.extensionBatch}:{},...typeof t.extensionInputs=="boolean"?{extensionInputs:t.extensionInputs}:{}}}var Um=e=>!!e.query.input||!!e.queries?.some(t=>t.input)||!!e.items?.some(t=>t.query.input);function nC(e,t){if(!e||typeof e!="object")return null;let n=e,r=_r(n.query),o=We(n.page),s=n.state??"waiting";return!r||typeof n.key!="string"||n.key!==r.key||typeof n.label!="string"||!n.label.trim()||n.label.length>300||!o||!t.includes(o)||!["waiting","scanning","done","missed"].includes(String(s))||n.reason!=null&&(typeof n.reason!="string"||n.reason.length>500)?null:{key:n.key,label:n.label,page:o,query:r,state:s,...typeof n.reason=="string"?{reason:n.reason}:{}}}function zm(e){return{done:e.filter(t=>t.state==="done"||t.state==="missed").length,total:e.length,current:e.find(t=>t.state==="scanning")??e.find(t=>t.state==="waiting")??null}}function Gm(e){let t=new Map;for(let n of e){let r=t.get(n.page);r?r.push(n):t.set(n.page,[n])}return[...t].map(([n,r])=>({page:n,items:r}))}function Bm(e,t){if(!t||typeof t!="object")return null;let n=t.captures;if(!n||typeof n!="object"||Array.isArray(n))return null;let r=e.items??[{key:e.query.key,label:e.query.key,page:e.pages[0],query:e.query,state:"waiting"}],o={},s={};for(let i of r){let l=n[i.key],a=dn(l);if(!a){s[i.key]="capture-failed";continue}if(a.miss){s[i.key]=a.miss;continue}let c=lc({...e,pages:[i.page],query:i.query},a);c?o[i.key]=c:s[i.key]="capture-failed"}return{captures:o,misses:s}}function rC(e,t){let n=We(t);return!!n&&!new URL(n).username&&!new URL(n).password&&e.pages.some(r=>new URL(r).origin===new URL(n).origin)}function lc(e,t){let n=dn(t);if(!n?.url||n.miss||!n.screenshot||!/^data:image\/(?:jpeg|png);base64,/.test(n.screenshot)||!rC(e,n.url))return null;let{viewport:r,...o}=n;return JSON.stringify(o).length>un?null:!r||JSON.stringify(n).length>un+zn+4e3?o:n}function Wm(e,t,n){return{x:e.x+t.x,y:e.y+t.y,width:e.width,height:e.height,scale:Math.min(2,Math.max(1,n))}}function Hm(e){return e instanceof Error&&e.name==="AbortError"&&(e.message==="Aborted with Ctrl+C"||e.message==="Aborted with Ctrl+D")}import{spawn as LC}from"node:child_process";import{existsSync as ch,mkdtempSync as NC,readFileSync as yh,rmSync as uh}from"node:fs";import{tmpdir as ph}from"node:os";import sr from"node:path";var oC=`const hex = (value) => {
|
|
170
170
|
const m = value.match(/rgba?\\(([^)]+)\\)/);
|
|
171
171
|
if (!m) return null;
|
|
172
172
|
const [r, g, b, a = "1"] = m[1].split(/[\\s,/]+/).filter(Boolean);
|
|
@@ -464,15 +464,15 @@ If ${h} didn't show it, open this URL:
|
|
|
464
464
|
${p}
|
|
465
465
|
|
|
466
466
|
`),f.start("Waiting for URL above to load"));let k=Math.min(Date.parse(c.expiresAt),Date.now()+(n.timeoutMs??600*1e3));for(;Date.now()<k;){n.signal?.throwIfAborted();let y=await o(u,{headers:{...i,Accept:e.items?"application/json":"multipart/form-data, application/json"},signal:n.signal,redirect:"error"}),x=await xC(y);if(!y.ok)throw new Error(x.error||"The capture is no longer available.");if(x.status==="complete"){if(e.items){let $=Bm(e,x.batch);if(!$)throw new Error("The extension returned an invalid batch capture. No review was sent.");return m=!0,$}let v=lc(e,x.capture);if(!v)throw new Error("The extension returned an invalid capture. No review was sent.");return m=!0,v}if(x.status!=="pending")throw new Error("Capture was cancelled or already used. No review was sent.");if(x.extensionReady&&f.start("Capture helper connected; waiting for Scan for review"),e.items&&x.extensionBatch===!1)throw new Error("The connected Grum extension doesn't support batch capture.");if(x.extensionReady&&Um(e)&&x.extensionInputs!==!0)throw new Error(Mr("unsupported-client"));if(x.items){let v=zm(x.items),$=`${v.done} of ${v.total} scanned`;$!==g&&(f.stop(),d(`${$}
|
|
467
|
-
`),g=$,f.start("Waiting for review capture"))}await(n.sleep??(v=>new Promise(($,
|
|
467
|
+
`),g=$,f.start("Waiting for review capture"))}await(n.sleep??(v=>new Promise(($,A)=>{if(n.signal?.aborted){A(n.signal.reason);return}let E=setTimeout(O,v);function O(){n.signal?.removeEventListener("abort",L),$()}function L(){clearTimeout(E),n.signal?.removeEventListener("abort",L),A(n.signal?.reason)}n.signal?.addEventListener("abort",L,{once:!0})})))(1500)}throw new Error(`Capture timed out. No review was sent. Start it again when ${h} is ready.`)}finally{f.stop(),m||await o(u,{method:"POST",headers:i,body:JSON.stringify({action:"cancel"}),signal:AbortSignal.timeout(5e3),redirect:"error"}).catch(()=>{})}}var Qm=(e,t)=>{let n=e.get(t);return n==="true"||n==="false"?{[t]:n==="true"}:{}};async function xC(e){if(!e.headers.get("content-type")?.startsWith("multipart/form-data"))return await e.json();let t=await e.formData(),n=t.get("status"),r=vC(t.get("items"));return{...typeof n=="string"?{status:n}:{},...t.get("extensionReady")==="true"?{extensionReady:!0}:{},...Qm(t,"extensionBatch"),...Qm(t,"extensionInputs"),...r?{items:r}:{},capture:await bf(t)}}async function eh(e,t,n={}){try{let r=await ti(e,t,n);if(!("captures"in r))throw new Error("The extension did not return a batch capture.");return r}catch(r){if(!(r instanceof Error)||!r.message.includes("doesn't support batch capture"))throw r;(n.write??(i=>process.stderr.write(i)))(`The connected Grum extension is older, so each item will open separately. Update it to capture this page set in one scan.
|
|
468
468
|
`);let o={},s={};for(let i of e.items)try{let l=await ti({projectId:e.projectId,title:i.label,pages:[i.page],query:i.query,authRequired:e.authRequired},t,n);"captures"in l?s[i.key]="capture-failed":l.miss?s[i.key]=l.miss:o[i.key]=l}catch{s[i.key]="capture-failed"}return{captures:o,misses:s}}}function vC(e){if(typeof e!="string")return null;try{let t=JSON.parse(e);return Array.isArray(t)?t:Array.isArray(t.items)?t.items:null}catch{return null}}import{execFileSync as SC}from"node:child_process";import{createHash as $C,randomUUID as CC}from"node:crypto";import{chmodSync as th,existsSync as RC,mkdirSync as cc,linkSync as nh,readdirSync as rh,readFileSync as AC,readlinkSync as IC,realpathSync as EC,renameSync as TC,rmSync as or,statSync as _C,writeFileSync as oh}from"node:fs";import{homedir as jC,hostname as OC}from"node:os";import et from"node:path";var uc=class extends Error{};function MC(e,t){let n=EC(e),r=$C("sha256").update(n).digest("hex");return et.join(t??et.join(jC(),".config","grum","capture"),r,"profile")}function vn(e){if(!e||!Number.isInteger(e)||e<1)return!1;try{return process.kill(e,0),!0}catch(t){return t.code!=="ESRCH"}}function pc(e){try{let t=JSON.parse(AC(e,"utf8"));return typeof t.id=="string"&&Number.isInteger(t.pid)&&t.pid>0?t:null}catch{return null}}function sh(e,t){if(!vn(e))return!1;try{return SC("ps",["-p",String(e),"-o","command="],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).includes(`--user-data-dir=${t}`)}catch{return!1}}var DC=e=>Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e);function ih(e,t){for(let n of["SIGTERM","SIGKILL"]){if(!sh(e,t))return;try{process.kill(e,n)}catch{return}for(let r=0;r<3e3&&vn(e);r+=100)DC(100)}}function dc(e){try{let t=IC(et.join(e,"SingletonLock")),n=t.lastIndexOf("-");return t.slice(0,n)!==OC()||vn(Number(t.slice(n+1)))}catch{return!1}}function fc(e,t){let n=MC(e,t),r=et.dirname(n);cc(r,{recursive:!0,mode:448}),th(r,448);let o=et.join(r,"active.json"),s=et.join(r,"recovering"),i={id:CC(),pid:process.pid},l=()=>new uc("Grum's capture browser is already in use for this repository. Close that capture or wait for it to finish, then try again."),a=et.join(r,`${i.id}.json`);oh(a,JSON.stringify(i),{mode:384,flag:"wx"});try{try{nh(a,o)}catch(p){if(p.code!=="EEXIST")throw p;try{cc(s,{mode:448})}catch{throw l()}try{let d=pc(o);if(d&&!vn(d.pid)&&ih(d.chromePid,n),!d||vn(d.pid)||vn(d.chromePid)||dc(n))throw l();or(o),nh(a,o)}finally{or(s,{recursive:!0,force:!0})}}}finally{or(a,{force:!0})}let c=!1,u=()=>{c||(c=!0,pc(o)?.id===i.id&&or(o,{force:!0}))};try{if(dc(n))throw l();cc(n,{recursive:!0,mode:448}),th(n,448)}catch(p){throw u(),p}return{profile:n,setChromePid(p){i.chromePid=p;let d=et.join(r,`${i.id}.json`);oh(d,JSON.stringify(i),{mode:384}),TC(d,o)},release:u}}var PC=6e4;function ah(e,t,n=Date.now()){let r;try{r=rh(e).filter(o=>o.startsWith(t))}catch{return}for(let o of r){let s=et.join(e,o);try{if(n-_C(s).mtimeMs<PC)continue;rh(s).some(l=>{let a=pc(et.join(s,l,"active.json"));if(a&&vn(a.pid))return!0;let c=et.join(s,l,"profile");return ih(a?.chromePid,c),sh(a?.chromePid,c)||dc(c)})||or(s,{recursive:!0,force:!0})}catch{}}}function lh(e,t){let n=fc(e,t);try{RC(n.profile)&&or(n.profile,{recursive:!0,force:!0})}finally{n.release()}}var FC=e=>`(${qm()})(${JSON.stringify(e)})`,bh=2e4,wh=8e3;function dh(){return process.env.GRUM_CAPTURE_MODE==="extension"}async function gc(e,t={}){let n=t.sandboxed===void 0?mc():t.sandboxed;if(n)throw new Error(ys(n));let r=Or({site:e.site,pageUrl:e.pageUrl,places:e.finding.places,onlyPage:e.onlyPage,repoDir:e.repoDir}),o=Gn(e.finding,a=>mh(e.repoDir,a));if(!o)throw new Error("There isn't enough in the code to find this on a page. Nothing was captured.");if(!r.length)throw new Error("Pass the live page URL to capture with --url.");if(!dh()){let a=new qe;a.start("Capturing the rendered element");let c;try{c=await(t.automatic??gh)(r,o,e.repoDir)}finally{a.stop()}if(c.capture){let u=[];if(e.finding.places.length>1){a.start("Capturing the affected locations");try{for(let p of e.finding.places.slice(0,ls)){let d=mh(e.repoDir,p.file),f=d?ol(e.finding,p,d):null;if(!f)continue;let m=Or({site:e.site,pageUrl:e.pageUrl,places:[p],onlyPage:e.onlyPage,repoDir:e.repoDir}),g=await(t.automatic??gh)(m,f,e.repoDir).catch(()=>({}));g.capture?.screenshot&&g.capture.url&&/^https?:\/\//.test(g.capture.url)&&u.push({file:p.file,line:p.line,url:g.capture.url,capturedAt:new Date().toISOString(),screenshot:g.capture.screenshot,...sf(e.finding,p,d,g.capture.url)})}}finally{a.stop()}}return{...c.capture,...u.length?{examples:u}:{}}}if(c.browserFailed){if(!r.some(u=>!jr(u)))throw new Error(`${c.browserFailed} A file page is captured only in the background, so start a server for this site to capture it another way.`);process.stderr.write(`A background Chrome couldn't start here. Opening your own Chrome instead.
|
|
469
469
|
`)}else if(!c.authRequired)throw new Error(c.error||"It wasn't found on that page. Pass the page where it appears with --url.")}let s=r.filter(a=>!jr(a));if(!s.length)throw new Error("A file page is captured only in the background. Start a server for this site to capture it another way.");let i=new AbortController,l=()=>i.abort(Object.assign(new Error("Aborted with Ctrl+C"),{name:"AbortError"}));process.once("SIGINT",l),process.once("SIGTERM",l);try{return await(t.extension??ti)({projectId:e.bridge.projectId,title:e.finding.title,pages:s,query:o,authRequired:!dh()},e.bridge,{signal:i.signal,browser:e.browser,chromeProfile:e.chromeProfile})}finally{process.off("SIGINT",l),process.off("SIGTERM",l)}}var mc=(e=process.env)=>e.CURSOR_SANDBOX?.trim()?"cursor":e.CODEX_SANDBOX?.trim()?"codex":null,fh="grum-public-review-";async function gh(e,t,n,r={}){let o=new Set;for(let p of e)if(!jr(p))try{let d=await(r.fetch??fetch)(p,{signal:AbortSignal.timeout(8e3),redirect:"follow",headers:{Accept:"text/html"}});await d.body?.cancel(),cl({url:d.url||p,requestedUrl:p,status:d.status,authenticationHeader:d.headers.has("www-authenticate")})&&o.add(p)}catch{}if(o.size===e.length)return{authRequired:!0};let s=(r.chrome??HC)();if(!s)return{error:"Chrome is needed to capture this page. Install Chrome and try again."};ah(ph(),fh);let i=NC(sr.join(ph(),fh)),l;try{l=await(r.launch??VC)(s,!1,n,i)}catch(p){return uh(i,{recursive:!0,force:!0}),{browserFailed:p instanceof Error?p.message:String(p)}}let a=o.size>0,c=!1,u=!1;try{for(let p of e){if(o.has(p))continue;let d=await l.open(p),f=await l.location();if(d){c=!0;let g=await UC(l,t,WC(),d,!1);if(g&&Ft(g))return{capture:g};g?.miss==="ambiguous"&&(u=!0)}let m=await l.evaluate(kf(),!1);cl({url:f||p,requestedUrl:p,loginForm:m===!0})&&(a=!0)}return a?{authRequired:!0}:u?{error:Mr("ambiguous")}:c?{error:"It wasn't found on that page. Use --url with the page where it appears."}:{error:`Could not reach ${e[0]??"the requested page"}.
|
|
470
470
|
Start the app or check that this URL is available, then try again.`}}finally{await l.close(),uh(i,{recursive:!0,force:!0})}}async function UC(e,t,n,r,o=!0){if(n)try{await e.evaluate(`(() => { ${n}
|
|
471
|
-
; return 0; })()`,!1)}catch{}let s;try{s=await e.evaluate(FC(t),!0)}catch{return null}let i=GC(s);if(!i)return BC(s)?{miss:"ambiguous"}:null;let l=await e.screenshot(i.box,i.dpr),a;if(l){let u=`(${Jm()})`;try{i.mark&&await e.evaluate(`${u}(${JSON.stringify(i.mark)})`,!1),a=await zC(e)}finally{i.mark&&await e.evaluate(`${u}(null)`,!1)}}let c=dn({...r?{url:r}:{},screenshot:l||(o?await e.screenshotViewport():void 0),viewport:a,snapdom:mf(i.snapdom),observed:i.observed,viewportSize:i.viewport,capturedAt:new Date().toISOString()});return c&&Ft(c)?c:null}function mh(e,t){if(!(!t||t.includes("..")||sr.isAbsolute(t)))try{let n=sr.resolve(e,t),r=sr.resolve(e);if(n!==r&&!n.startsWith(r+sr.sep))return;let o=yh(n,"utf8");return o.length>2e5?void 0:o}catch{return}}async function zC(e){for(let t of[55,35]){let n=await e.screenshotViewport(t);if(n&&n.length<=zn)return n}}function hh(e){let t=e,n=Number(t?.x),r=Number(t?.y),o=Number(t?.width),s=Number(t?.height);return![n,r,o,s].every(i=>Number.isFinite(i))||o<1||s<1?null:{x:n,y:r,width:o,height:s}}function GC(e){if(!e||typeof e!="object")return null;let t=e;if(t.found!==!0)return null;let n=hh(t.box);return n?{box:n,mark:hh(t.mark),snapdom:typeof t.snapdom=="string"?t.snapdom:"",dpr:Number(t.dpr)||1,observed:t.observed,viewport:t.viewport}:null}function BC(e){return e&&typeof e=="object"&&e.miss==="ambiguous"?"ambiguous":null}function WC(){return'/*\n* SnapDOM\n* v3.2.0\n* License: MIT\n*/\n"use strict";(()=>{var oc=Object.defineProperty;var lt=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(r){throw n=[r],r}};var we=(t,e)=>{for(var n in e)oc(t,n,{get:e[n],enumerable:!0})};function Ko(t){return t===!1||typeof t=="string"&&t.toLowerCase().trim()==="disabled"?"disabled":"soft"}function Qo(t="soft"){t==="disabled"&&(L.computedStyle=new WeakMap,L.measureHints=new WeakMap,L.baseStyle=new ut(50),L.defaultStyle=new ut(64),L.image=new ut(100),L.background=new ut(100),L.resource=new ut(150),L.compress=new ut(50))}var ut,L,mt=lt(()=>{"use strict";ut=class extends Map{constructor(e=100,...n){super(...n),this._maxSize=e}set(e,n){if(this.size>=this._maxSize&&!this.has(e)){let r=this.keys().next().value;r!==void 0&&this.delete(r)}return super.set(e,n)}},L={image:new ut(100),background:new ut(100),resource:new ut(150),defaultStyle:new ut(64),baseStyle:new ut(50),compress:new ut(50),computedStyle:new WeakMap,measureHints:new WeakMap,warnedReconcile:!1}});function ee(t){let e=t.match(/url\\(([\'"]?)(.*?)(\\1)\\)/);if(!e)return null;let n=e[2].trim();return n.startsWith("#")?null:n}function sc(t){let e=[],n=0,r=0,i="";for(let o=0;o<t.length;o++){let s=t[o];if(s==="\\\\"){o++;continue}i?s===i&&(i=""):s===\'"\'||s==="\'"?i=s:s==="("?r++:s===")"?r--:s===","&&r===0&&(e.push(t.slice(n,o)),n=o+1)}return e.push(t.slice(n)),e}function qe(t,e=1){let n=t.match(/^\\s*-?(?:webkit-)?image-set\\(([\\s\\S]*)\\)\\s*$/i);if(!n)return null;let r=[];for(let o of sc(n[1])){let s=o.match(/url\\(([\'"]?)(.*?)(\\1)\\)/);if(!s)continue;let a=o.match(/type\\(\\s*["\']([^"\']+)["\']\\s*\\)/i);if(a&&!ic.test(a[1].trim()))continue;let c=o.replace(/url\\(([\'"]?)[\\s\\S]*?\\1\\)/," ").match(/(\\d+(?:\\.\\d+)?)\\s*(x|dpi|dppx)\\b/i),f=1;if(c){let l=parseFloat(c[1]);f=/dpi/i.test(c[2])?l/96:l}r.push({url:s[2].trim(),dppx:f})}return r.length?(r.sort((o,s)=>o.dppx-s.dppx),(r.find(o=>o.dppx>=e)||r[r.length-1]).url):null}function vr(t){if(!t||t==="none")return"";let e=t.replace(/translate[XY]?\\([^)]*\\)/g,"");return e=e.replace(/matrix\\(([^)]+)\\)/g,(n,r)=>{let i=r.split(",").map(o=>o.trim());return i.length!==6?`matrix(${r})`:(i[4]="0",i[5]="0",`matrix(${i.join(", ")})`)}),e=e.replace(/matrix3d\\(([^)]+)\\)/g,(n,r)=>{let i=r.split(",").map(o=>o.trim());return i.length!==16?`matrix3d(${r})`:(i[12]="0",i[13]="0",`matrix3d(${i.join(", ")})`)}),e.trim().replace(/\\s{2,}/g," ")}function Vt(t){if(/%[0-9A-Fa-f]{2}/.test(t))return t;try{return encodeURI(t)}catch{return t}}function kr(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}}function Ge(t){return!!t&&t.tagName==="INPUT"&&(t.getAttribute("type")||"").toLowerCase()==="password"}function Cr(t){return"\\u2022".repeat(String(t??"").length)}function st(t,e){return t?.nodeType===1&&t.localName===e}function Rt(t){return t?.nodeType===1&&t.namespaceURI===ac}function It(t){return t?.nodeType===1&&t.namespaceURI===cc}function Wt(t){return t?.nodeType===11&&!!t.host}function Ar(t){return t?.nodeType===9}var xr,ic,ac,cc,kt=lt(()=>{"use strict";xr=/^image\\/(jpeg|jpg|png|gif|webp|avif|apng|svg\\+xml|bmp|x-icon|vnd\\.microsoft\\.icon)\\s*(;|$)/i,ic=xr;ac="http://www.w3.org/1999/xhtml",cc="http://www.w3.org/2000/svg"});function lc(t="[snapDOM]",{ttlMs:e=5*6e4,maxEntries:n=12}={}){let r=new Map,i=0;function o(s,a,c){if(i>=n)return;let f=Date.now();(r.get(a)||0)>f||(r.set(a,f+e),i++,s==="warn"&&console&&console.warn?console.warn(`${t} ${c}`):console&&console.error&&console.error(`${t} ${c}`))}return{warnOnce(s,a){o("warn",s,a)},errorOnce(s,a){o("error",s,a)},reset(){r.clear(),i=0}}}function ti(t,e,n){if(Ot.size>=Zo){let r=Date.now();for(let[i,o]of Ot)o.until<=r&&Ot.delete(i);for(;Ot.size>=Zo;)Ot.delete(Ot.keys().next().value)}Ot.set(t,{until:Date.now()+n,result:e})}function fc(t){return/^data:|^blob:|^about:blank$/i.test(t)}function uc(t,e){try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",r=e.split(/\\{url(?:Raw)?\\}/)[0],i=new URL(r||".",n);if(new URL(t,n).origin===i.origin)return!0}catch{}return!1}function dc(t,e){if(!e||fc(t)||uc(t,e))return!1;try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",r=new URL(t,n);return typeof location<"u"?r.origin!==location.origin:!0}catch{return!!e}}function pc(t,e){if(!e)return t;if(/\\{url(?:Raw)?\\}/.test(e))return e.replace("{urlRaw}",()=>Vt(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}${Vt(t)}`;let n=e.includes("?")?"&":"?";return`${e}${n}url=${encodeURIComponent(t)}`}function ei(t){return new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result||"")),r.onerror=()=>n(new Error("read_failed")),r.readAsDataURL(t)})}function hc(t,e){return new Headers(e.headers||{}).keys().next().done?JSON.stringify([e.as||"blob",e.timeout??3e3,e.useProxy||"",e.errorTTL??8e3,e.credentials||"",t]):null}function ni(t){try{return new URL(t,globalThis.location?.href||"http://localhost/").origin}catch{return"invalid-url"}}function _r(t,e){try{t.onError?.(e)}catch{}}async function dt(t,e={}){let n=e.as??"blob",r=e.timeout??3e3,i=e.useProxy||"",o=e.errorTTL??8e3,s=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[,g="",y=""]=String(t).match(/^data:([^,]*),(.*)$/)||[],S=/;base64/i.test(g)?atob(y):decodeURIComponent(y),k=new Uint8Array([...S].map(w=>w.charCodeAt(0))),v=new Blob([k],{type:(g||"").split(";")[0]||""});return{ok:!0,data:v,status:200,url:t,fromCache:!1,mime:v.type||""}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(t))try{let g=await fetch(t);if(!g.ok)return{ok:!1,data:null,status:g.status,url:t,fromCache:!1,reason:"http_error"};let y=await g.blob(),b=y.type||g.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await ei(y),blob:y,status:g.status,url:t,fromCache:!1,mime:b}:n==="text"?{ok:!0,data:await y.text(),status:g.status,url:t,fromCache:!1,mime:b}:{ok:!0,data:y,status:g.status,url:t,fromCache:!1,mime:b}}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;try{c=hc(t,{as:n,timeout:r,useProxy:i,errorTTL:o,credentials:e.credentials,headers:s})}catch{let g={ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"network"};return _r(e,g),g}let f=Ot.get(c);if(f&&f.until>Date.now())return{...f.result,fromCache:!0};f&&Ot.delete(c);let l=Mr.get(c);if(l)return l;let u=dc(t,i)?pc(t,i):t,p=e.credentials;if(!p)try{let g=typeof location<"u"&&location.href?location.href:"http://localhost/",y=new URL(t,g);p=typeof location<"u"&&y.origin===location.origin?"include":"omit"}catch{p="omit"}let h=new AbortController,m=setTimeout(()=>h.abort("timeout"),r),d=(async()=>{try{let g=await fetch(u,{signal:h.signal,credentials:p,headers:s});if(!g.ok){let S={ok:!1,data:null,status:g.status,url:u,fromCache:!1,reason:"http_error"};if(c!==null&&o>0&&ti(c,S,o),!a){let k=`${g.status} ${g.statusText||""}`.trim();Jo.warnOnce(`http:${g.status}:${n}:${ni(t)}`,`HTTP ${k} fetching ${n}: ${t}`)}return _r(e,S),S}if(n==="text")return{ok:!0,data:await g.text(),status:g.status,url:u,fromCache:!1};let y=await g.blob(),b=y.type||g.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await ei(y),blob:y,status:g.status,url:u,fromCache:!1,mime:b}:{ok:!0,data:y,status:g.status,url:u,fromCache:!1,mime:b}}catch(g){let y=h.signal.aborted?h.signal.reason==="timeout"?"timeout":"abort":g&&typeof g=="object"&&g.name==="AbortError"?"abort":"network",b={ok:!1,data:null,status:0,url:u,fromCache:!1,reason:y};if(c!==null&&!/^blob:/i.test(t)&&o>0&&ti(c,b,o),!a){let S=`${y}:${n}:${ni(t)}`,k=y==="timeout"?`Timeout (${r}ms): ${t}. Increase timeout or use a proxy`:y==="abort"?`Aborted fetching ${n}: ${t}`:`Network/CORS fetching ${n}: ${t}. Try useProxy`;Jo.errorOnce(S,k)}return _r(e,b),b}finally{clearTimeout(m),Mr.delete(c)}})();return c!==null&&Mr.set(c,d),d}var Jo,Mr,Zo,Ot,Se=lt(()=>{"use strict";kt();Jo=lc("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),Mr=new Map,Zo=50,Ot=new Map});async function xe(t,e={}){if(/^\\s*url\\(\\s*[\'"]?data:/i.test(t)||/^((repeating-)?(linear|radial|conic)-gradient)\\(/i.test(t)||t.trim()==="none")return t;let r=qe(t,typeof devicePixelRatio<"u"&&devicePixelRatio||1)??ee(t);if(!r)return t;let i=kr(r),o=Vt(i),s=(e.useProxy||"")+"|"+o;if(L.background.has(s)){let a=L.background.get(s);return a?`url("${a}")`:"none"}try{let a=await dt(o,{as:"dataURL",useProxy:e.useProxy});return a.ok?(L.background.set(s,a.data),`url("${a.data}")`):(L.background.set(s,null),"none")}catch{return L.background.set(s,null),"none"}}var ri=lt(()=>{"use strict";mt();kt();Se()});function Sc(t){let e=t.replace(wc,"").trim();return e?e.replace(/(^|,)(\\s*)(?=,|$)/g,"$1$2*"):"*"}function si(t,e,n,r){for(let i=0;i<t.length;i++){if(--r.budget<0)return!1;let o=t[i],s=o.style;if(s){let c=!!o.selectorText&&yc.test(o.selectorText);for(let f=0;f<s.length;f++){let l=s[f];if(e.add(l),c&&r.pseudoProps.add(l),s.getPropertyPriority(l)&&r.importantProps.add(l),l.length>5&&(l[0]==="m"||l[0]==="p")){let u=l.startsWith("margin")?"marginUnstable":l.startsWith("padding")?"paddingUnstable":null;u&&!r[u]&&bc.test(s.getPropertyValue(l))&&(r[u]=!0)}}}let a=o.selectorText;if(a&&a.includes(":has(")&&(r.usesHas=!0),a&&a.includes("&"))for(let c=o.parentRule;c&&a.includes("&");c=c.parentRule)c.selectorText&&(a=a.replace(/&/g,`:is(${c.selectorText})`));if(a&&(r.inContainer||ii.test(a)||a.includes("+")||a.includes("~")))for(let c of Fr(a,",")){let f=c.trim();f&&(r.inContainer||ii.test(f)||f.includes("+")||f.includes("~"))&&r.shareUnsafeSels.add(f)}if(a&&a.includes(":"))for(let c in oi)oi[c].test(a)&&n[c].push(Sc(a));if(o.styleSheet){if(!yn(o.styleSheet,e,n,r))return!1}else if(o.cssRules&&o.cssRules.length){let c=o.constructor?.name==="CSSContainerRule";c&&r.inContainer++;let f=si(o.cssRules,e,n,r);if(c&&r.inContainer--,!f)return!1}}return!0}function yn(t,e,n,r){let i;try{i=t.cssRules}catch{return!1}return i?si(i,e,n,r):!1}function Rr(t,e){for(let n of t){let r=n.effect?.getKeyframes?.()||[];for(let i of r)for(let o of Object.keys(i))o==="offset"||o==="easing"||o==="composite"||o==="computedOffset"||e.add(o.replace(/[A-Z]/g,s=>"-"+s.toLowerCase()))}}function ai(t){let e=new Set;return yn(t,e,{before:[],after:[],firstLetter:[],marker:[],firstLine:[]},{budget:2e4,usesHas:!1,shareUnsafeSels:new Set,inContainer:0,marginUnstable:!1,paddingUnstable:!1,importantProps:new Set,pseudoProps:new Set})?e:null}function Fr(t,e){if(!t.includes(e))return[t];let n=[],r=0,i=null,o=0;for(let s=0;s<t.length;s++){let a=t[s];if(a==="\\\\"){s++;continue}if(i){a===i&&(i=null);continue}a===\'"\'||a==="\'"?i=a:a==="("||a==="["?r++:a===")"||a==="]"?r--:r===0&&a===e&&(n.push(t.slice(o,s)),o=s+1)}return n.push(t.slice(o)),n}function xc(t){let e=0,n=null,r=0;for(let l=0;l<t.length;l++){let u=t[l];if(n){u===n&&t[l-1]!=="\\\\"&&(n=null);continue}u===\'"\'||u==="\'"?n=u:u==="("||u==="["?e++:u===")"||u==="]"?e--:e===0&&(u===" "||u===">"||u==="+"||u==="~")&&(r=l+1)}let i="",o=0;for(let l of t.slice(r))l==="("||l==="["?o++:l===")"||l==="]"?o--:o===0&&(i+=l);let s=l=>!l||/\\\\[0-9a-fA-F]/.test(l)?null:l.replace(/\\\\(.)/g,"$1"),a=s((i.match(/\\.((?:\\\\.|[\\w-])+)/)||[])[1]);if(a)return"c"+a;let c=s((i.match(/#((?:\\\\.|[\\w-])+)/)||[])[1]);if(c)return"i"+c;let f=(i.match(/^([a-zA-Z][\\w-]*)/)||[])[1];return f?"t"+f.toLowerCase():null}function ci(t,e){if(!e.length)return"";if(e.some(r=>r.includes("&")))return null;let n=e.join(",");try{return t.matches(n),n}catch{return null}}function vc(t,e){let n=t.createElement("div"),r={};for(let i in e){let o=e[i];(i==="before"||i==="after")&&o.push("q"),r[i]=ci(n,o)}return r}function li(t){let e={universe:null,pseudoUniverse:null,usesHas:!0,shareGate:null,marginUnstable:!0,paddingUnstable:!0,importantProps:null,pseudoGates:{before:null,after:null,firstLetter:null,marker:null,firstLine:null}};try{let n=new Set(Er),r={before:[],after:[],firstLetter:[],marker:[],firstLine:[]},i={budget:2e4,usesHas:!1,shareUnsafeSels:new Set,inContainer:0,marginUnstable:!1,paddingUnstable:!1,importantProps:new Set,pseudoProps:new Set};for(let f of t.styleSheets)if(!yn(f,n,r,i))return e;let o=t.adoptedStyleSheets;if(Array.isArray(o)){for(let f of o)if(!yn(f,n,r,i))return e}typeof t.getAnimations=="function"&&Rr(t.getAnimations(),n);let s=Array.from(i.shareUnsafeSels),a=ci(t.createElement("div"),s)===null?null:s.map(f=>({sel:f,key:xc(f)})),c=new Set(gc);for(let f of mc)n.has(f)&&c.add(f);for(let f of i.pseudoProps)c.add(f);return{universe:n,pseudoUniverse:c,pseudoGates:vc(t,r),usesHas:i.usesHas,shareGate:a,marginUnstable:i.marginUnstable,paddingUnstable:i.paddingUnstable,importantProps:i.importantProps}}catch{return e}}var Er,mc,gc,yc,bc,oi,wc,ii,bn=lt(()=>{"use strict";Er=["display","position","top","right","bottom","left","float","clear","z-index","box-sizing","width","height","min-width","min-height","max-width","max-height","margin-top","margin-right","margin-bottom","margin-left","padding-top","padding-right","padding-bottom","padding-left","overflow-x","overflow-y","visibility","opacity","content-visibility","vertical-align","border-top-width","border-right-width","border-bottom-width","border-left-width","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-left-radius","border-top-right-radius","border-bottom-right-radius","border-bottom-left-radius","flex-direction","flex-wrap","flex-grow","flex-shrink","flex-basis","order","align-items","align-self","align-content","justify-content","justify-items","justify-self","row-gap","column-gap","grid-template-columns","grid-template-rows","grid-auto-flow","grid-auto-columns","grid-auto-rows","grid-column-start","grid-column-end","grid-row-start","grid-row-end","color","font-family","font-size","font-weight","font-style","font-stretch","line-height","letter-spacing","word-spacing","white-space","text-align","text-transform","text-indent","text-overflow","text-shadow","direction","unicode-bidi","writing-mode","text-orientation","word-break","overflow-wrap","tab-size","list-style-type","list-style-position","list-style-image","counter-reset","counter-increment","counter-set","background-color","background-image","background-size","background-position","background-repeat","background-clip","background-origin","background-attachment","box-shadow","outline-width","outline-style","outline-color","outline-offset","transform","transform-origin","rotate","scale","translate","filter","mix-blend-mode","clip-path","object-fit","object-position","border-collapse","border-spacing","table-layout","caption-side","empty-cells"],mc=["color","font-family","font-size","font-weight","font-style","font-stretch","font-variant","font-kerning","font-feature-settings","font-variation-settings","line-height","letter-spacing","word-spacing","white-space","text-align","text-align-last","text-indent","text-transform","text-shadow","text-rendering","direction","unicode-bidi","word-break","overflow-wrap","writing-mode","text-orientation","hyphens","tab-size","visibility","list-style-type","list-style-position","list-style-image","border-collapse","border-spacing","caption-side","empty-cells","quotes","color-scheme","-webkit-text-fill-color","-webkit-font-smoothing","image-rendering"],gc=["display","width","height","min-width","min-height"],yc=/::?(?:before|after|first-letter|first-line|marker)/,bc=/%|\\bauto\\b|calc\\(|var\\(/i,oi={before:/::?before\\b/,after:/::?after\\b/,firstLetter:/::?first-letter\\b/,marker:/::marker\\b/,firstLine:/::?first-line\\b/},wc=/::?(?:before|after|first-letter|first-line|marker)\\b/g;ii=/:(nth-|first-child|last-child|only-|first-of-type|last-of-type|empty|hover|focus|active|target|checked|indeterminate|disabled|enabled|read-only|read-write|placeholder-shown|autofill|valid|invalid|user-valid|user-invalid|in-range|out-of-range|required|optional|default|link|any-link|scope|defined|modal|fullscreen|picture-in-picture|playing|paused|dir\\(|lang\\(|has\\()/});function tt(t){return fi.add(t),t.setAttribute("data-snapdom-internal",""),t}function qt(t){return fi.has(t)}var fi,Ct=lt(()=>{"use strict";fi=new WeakSet});function $r(t){if(t=String(t).toLowerCase(),Xe.has(t)){let o={};return L.defaultStyle.set(t,o),o}if(L.defaultStyle.has(t))return L.defaultStyle.get(t);let e=[...document.querySelectorAll("#snapdom-sandbox")].find(qt);e||(e=document.createElement("div"),tt(e),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.includes("-")?"span":t);n.style.all="initial",e.appendChild(n);let r=getComputedStyle(n),i={};for(let o of r){if(ve(o))continue;let s=r.getPropertyValue(o);i[o]=s}for(let o of Er)!(o in i)&&!ve(o)&&(i[o]=r.getPropertyValue(o));return e.removeChild(n),L.defaultStyle.set(t,i),i}function ve(t){let e=ui.get(t);if(e===void 0){let n=String(t).toLowerCase();e=Ac.has(n)||Cc.test(n)||kc.test(n),ui.set(t,e)}return e}function pi(t,e){let n=Fc.get(t);if(n===void 0||e[n]!==e[t])return!1;let r=e["writing-mode"];if(r&&r!=="horizontal-tb")return!1;let i=e.direction;return!(i&&i!=="ltr")}function wn(t,e){return!_c.has(t)&&(e==="inline"||Mc.has(t)||di.has(t))}function Pr(t,e,n){let r=(e.display||"").toLowerCase();if(r==="inline"||di.has(t))return!1;if(n)return!0;if((e.float||"none").toLowerCase()!=="none")return!1;let o=(e.position||"static").toLowerCase();return o==="absolute"||o==="fixed"?!1:!$c.has(r)}function ke(t,e,n=!0,r=!1){if(e=String(e||"").toLowerCase(),Xe.has(e))return"";let i=[],o=$r(e),s=(t.display||"").toLowerCase(),a=s==="inline",c=wn(e,s),f=t["text-wrap-mode"]||t["white-space"]||"",l=f==="nowrap"||f==="pre",p=c&&n&&!(c&&n&&!a&&l),h=!1;for(let m in t){if(ve(m)||pi(m,t))continue;let d=t[m];if(p){if(Ec.has(m))continue;if(Rc.has(m)){d&&d!==o[m]&&(i.push(`${m}:${d}`),d!=="auto"&&(h=!0));continue}}if(d&&d!==o[m]){if(!l&&(m==="width"||m==="inline-size")&&d.endsWith("px")&&d.includes(".")){let g=parseFloat(d);if(Number.isFinite(g)){i.push(`${m}:${(g+Tc).toFixed(3)}px`);continue}}i.push(`${m}:${d}`)}}if(p&&!a&&!r&&!h){let m=t.width;m&&m!=="auto"&&m!==o.width&&i.push(`min-width:${m}`)}return i.sort(),i.join(";")}function Nr(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 Lr(t,e=null){let n=new Map;for(let s of t){let a=$r(s);if(!a)continue;let l=(e?Object.entries(a).filter(([p])=>e.has(p)):Object.entries(a)).filter(([p])=>!pi(p,a)).map(([p,h])=>`${p}:${h};`).sort(),u=l.join("");u&&(n.has(u)||n.set(u,{tagList:[],declarations:l}),n.get(u).tagList.push(s))}let r=[...n.values()],i=null;for(let{declarations:s}of r){let a=new Set(s);if(!i){i=a;continue}for(let c of i)a.has(c)||i.delete(c)}i??(i=new Set);let o="";if(i.size&&r.length>1){let s=r.flatMap(a=>a.tagList);o+=`${s.join(",")} { ${[...i].join("")} }\n`}for(let{tagList:s,declarations:a}of r){let c=r.length>1?a.filter(l=>!i.has(l)):a;if(!c.length)continue;let f=c.join("");o+=`${s.join(",")} { ${f} }\n`}return o}function Ye(t){let e=Array.from(new Set(t.values())).filter(Boolean).sort(),n=new Map,r=1;for(let i of e)n.set(i,`c${r++}`);return n}function Pc(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 r=0;r<window.frames.length;r++)try{if(window.frames[r]?.document===e)return window.frames[r]}catch{}}catch{}return typeof window<"u"?window:null}function O(t,e=null){let n=()=>{let o={length:0,getPropertyValue:()=>"",item:()=>""};return o[Symbol.iterator]=function*(){},o};if(t?.nodeType!==1){let o=typeof window<"u"?window:null;if(o&&typeof o.getComputedStyle=="function")try{return o.getComputedStyle(t,e)||n()}catch{return n()}return n()}let r=L.computedStyle.get(t);r||(r=new Map,L.computedStyle.set(t,r));let i=r.get(e);if(!i){let o=Pc(t),s=null;try{s=o&&typeof o.getComputedStyle=="function"?o.getComputedStyle(t,e):null}catch{}if(!s&&typeof window<"u"&&typeof window.getComputedStyle=="function")try{t.ownerDocument===document&&(s=window.getComputedStyle(t,e))}catch{}i=s||n(),r.set(e,i)}return i}function Ce(t,e=null){let n={};for(let r of e||t){let i=t.getPropertyValue(r);i&&(n[r]=i)}for(let r of Nc){let i=n[`border-${r}-style`],o=n[`border-${r}-width`];(i==="none"||i==="hidden"||o==="0px")&&(delete n[`border-${r}-style`],delete n[`border-${r}-width`],delete n[`border-${r}-color`])}return n}function Gt(t){let e=[],n=0,r=0;for(let i=0;i<t.length;i++){let o=t[i];o==="("&&n++,o===")"&&n--,o===","&&n===0&&(e.push(t.slice(r,i).trim()),r=i+1)}return e.push(t.slice(r).trim()),e}var Tr,Xe,kc,Cc,Ac,ui,Mc,di,_c,Ec,Rc,Fc,Tc,$c,Nc,Ae=lt(()=>{"use strict";mt();bn();Ct();Tr=new Set(["meta","script","noscript","title","link","template"]),Xe=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"]);kc=/(?:^|-)(animation|transition)(?:-|$)/i,Cc=/^(--.+|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,Ac=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"]),ui=new Map;Mc=new Set(["span","small","em","strong","b","i","u","s","code","cite","mark","sub","sup"]),di=new Set(["table","thead","tbody","tfoot","tr","td","th"]),_c=new Set(["img","video","canvas","svg","iframe","embed","object","input","textarea","select"]),Ec=new Set(["width","max-width","inline-size","max-inline-size"]),Rc=new Set(["min-width","min-inline-size"]),Fc=new Map(Object.entries({"block-size":"height","inline-size":"width","min-block-size":"min-height","min-inline-size":"min-width","max-block-size":"max-height","max-inline-size":"max-width","margin-block-start":"margin-top","margin-block-end":"margin-bottom","margin-inline-start":"margin-left","margin-inline-end":"margin-right","padding-block-start":"padding-top","padding-block-end":"padding-bottom","padding-inline-start":"padding-left","padding-inline-end":"padding-right","inset-block-start":"top","inset-block-end":"bottom","inset-inline-start":"left","inset-inline-end":"right","border-block-start-width":"border-top-width","border-block-start-style":"border-top-style","border-block-start-color":"border-top-color","border-block-end-width":"border-bottom-width","border-block-end-style":"border-bottom-style","border-block-end-color":"border-bottom-color","border-inline-start-width":"border-left-width","border-inline-start-style":"border-left-style","border-inline-start-color":"border-left-color","border-inline-end-width":"border-right-width","border-inline-end-style":"border-right-style","border-inline-end-color":"border-right-color","border-start-start-radius":"border-top-left-radius","border-start-end-radius":"border-top-right-radius","border-end-start-radius":"border-bottom-left-radius","border-end-end-radius":"border-bottom-right-radius","overflow-block":"overflow-y","overflow-inline":"overflow-x","overscroll-behavior-block":"overscroll-behavior-y","overscroll-behavior-inline":"overscroll-behavior-x","contain-intrinsic-block-size":"contain-intrinsic-height","contain-intrinsic-inline-size":"contain-intrinsic-width"}));Tc=.001;$c=new Set(["inline-block","inline-flex","inline-grid","inline-table","inline-flow-root","table"]);Nc=["top","right","bottom","left"]});function gt(t=1e3){return typeof requestAnimationFrame!="function"||typeof document<"u"&&document.visibilityState==="hidden"?Promise.resolve():new Promise(e=>{let n=!1,r=()=>{n||(n=!0,e())};try{requestAnimationFrame(r)}catch{r();return}setTimeout(r,t)})}function mi(t){if(t!==!1&&t!=="auto")return null;let e=performance.now()+(t==="auto"?Lc:hi),n=null,r={yielded:!1,due:()=>performance.now()>=e,pause:()=>n||(n=new Promise(i=>{let o=()=>{n=null,r.yielded=!0,e=performance.now()+hi,i()},s=new MessageChannel;s.port1.onmessage=o,s.port2.postMessage(0)}))};return r}function Ke(){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 X(){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"),r=/applewebkit/i.test(t),i=/mobile/i.test(t),o=!/safari/i.test(t),s=r&&i&&o,a=/(micromessenger|wxwork|wecom|windowswechat|macwechat)/i.test(t),c=/(baiduboxapp|baidubrowser|baidusearch|baiduboxlite)/i.test(e),f=/ipad|iphone|ipod/.test(e)&&r;return n||s||a||c||f}function $t(){return typeof navigator>"u"?!1:(navigator.userAgent||"").toLowerCase().includes("firefox")}var hi,Lc,yt=lt(()=>{"use strict";hi=16,Lc=40});function H(t,e,n){let r=t&&typeof t=="object"&&(t.options||t);r&&r.debug&&(n!==void 0?console.warn("[snapdom]",e,n):console.warn("[snapdom]",e))}function At(t,e,n,r){let i=t&&t.warnings;i&&i.length<Ic&&i.push(r===void 0?{code:e,message:n}:{code:e,message:n,detail:r})}var Ic,ne=lt(()=>{"use strict";Ic=50});var bt=lt(()=>{"use strict";ri();Ae();yt();kt();ne()});var ja={};we(ja,{MAX_RASTER_AREA:()=>ue,MAX_RASTER_SIDE:()=>Ut,cropSvgText:()=>pr,decodeSvgFromDataURL:()=>de,encodeSvgToDataURL:()=>pe,fixSafariShadows:()=>mr,peekSvgHeader:()=>hr,toCanvas:()=>zt});function ad(t,e){try{let n=t.match(/<svg\\b[^>]*>/i);if(!n)return t;let r=n[0],i=parseFloat((r.match(/\\bwidth="([\\d.]+)/i)||[])[1]),o=parseFloat((r.match(/\\bheight="([\\d.]+)/i)||[])[1]);if(!Number.isFinite(i)||!Number.isFinite(o)||i<=0||o<=0)return t;let s=Math.min(1,Ut/i,Ut/o,Math.sqrt(ue/(i*o)));if(s>=1)return t;let a=Math.max(1,Math.floor(i*s)),c=Math.max(1,Math.floor(o*s));return At(e,"raster-clamp",`capture ${Math.round(i)}x${Math.round(o)}px exceeds decode limits; downscaled to ${a}x${c}px`),console.warn(`[snapdom] Decode limit: ${Math.round(i)}\\xD7${Math.round(o)} \\u2192 ${a}\\xD7${c}. Use ${typeof CompressionStream=="function"?"PNG Blob, ":""}SVG or crop.`),t.replace(r,r.replace(/(\\bwidth=")[\\d.]+/i,`$1${a}`).replace(/(\\bheight=")[\\d.]+/i,`$1${c}`))}catch{return t}}function pr(t,e){let n=["x","y","width","height"].map(w=>Number(e?.[w]));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 r=t.match(/<svg\\b[^>]*>/i);if(!r)throw new Error("[snapdom] cannot crop a non-SVG capture");let i=r[0],o=(i.match(/\\bviewBox="([^"]+)"/i)||[])[1],s=String(o||"").trim().split(/[\\s,]+/).map(Number);if(s.length!==4||!s.every(Number.isFinite)||s[2]<=0||s[3]<=0)throw new Error("[snapdom] cannot crop an SVG without a finite viewBox");let[a,c,f,l]=s,u=Math.max(a,n[0]),p=Math.max(c,n[1]),h=Math.min(a+f,n[0]+n[2]),m=Math.min(c+l,n[1]+n[3]);if(!(h>u)||!(m>p))throw new RangeError("[snapdom] canvas crop does not intersect the SVG viewBox");let d=parseFloat((i.match(/\\bwidth="([\\d.]+)/i)||[])[1]),g=parseFloat((i.match(/\\bheight="([\\d.]+)/i)||[])[1]),y=Number.isFinite(d)&&d>0?d/f:1,b=Number.isFinite(g)&&g>0?g/l:1,S=Math.max(1,(h-u)*y),k=Math.max(1,(m-p)*b),v=i.replace(/(\\bwidth=")[^"]*/i,`$1${S}`).replace(/(\\bheight=")[^"]*/i,`$1${k}`).replace(/(\\bviewBox=")[^"]*/i,`$1${u} ${p} ${h-u} ${m-p}`);return t.replace(i,v)}function Oo(t){return typeof t=="string"&&/^data:image\\/svg\\+xml/i.test(t)}function de(t){let e=t.indexOf(",");return e>=0?decodeURIComponent(t.slice(e+1)):""}function hr(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 pe(t){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}function za(t){let e=[],n="",r=0;for(let i=0;i<t.length;i++){let o=t[i];o==="("&&r++,o===")"&&(r=Math.max(0,r-1)),o===";"&&r===0?(e.push(n),n=""):n+=o}return n.trim()&&e.push(n),e.map(i=>i.trim()).filter(Boolean)}function cd(t){let e=[],n="",r=0;for(let o=0;o<t.length;o++){let s=t[o];s==="("&&r++,s===")"&&(r=Math.max(0,r-1)),s===","&&r===0?(e.push(n.trim()),n=""):n+=s}n.trim()&&e.push(n.trim());let i=[];for(let o of e){if(/\\binset\\b/i.test(o))continue;let s=o.match(/-?\\d+(?:\\.\\d+)?px/gi)||[],[a="0px",c="0px",f="0px"]=s;f=`${parseFloat(f)/2}px`;let l=o.replace(/-?\\d+(?:\\.\\d+)?px/gi,"").replace(/\\binset\\b/ig,"").trim().replace(/\\s{2,}/g," "),u=!!l&&l!==",";i.push(`drop-shadow(${a} ${c} ${f}${u?` ${l}`:""})`)}return i.join(" ")}function Ha(t){let e=za(t),n=null,r=null,i=null,o=[];for(let a of e){let c=a.indexOf(":");if(c<0)continue;let f=a.slice(0,c).trim().toLowerCase(),l=a.slice(c+1).trim();f==="box-shadow"?i=l:f==="filter"?n=l:f==="-webkit-filter"?r=l:o.push([f,l])}if(i){let a=cd(i);a&&(n=n?`${n} ${a}`:a,r=r?`${r} ${a}`:a)}let s=[...o];return n&&s.push(["filter",n]),r&&s.push(["-webkit-filter",r]),s.map(([a,c])=>`${a}:${c}`).join(";")}function ld(t){return t.replace(/([^{}]+)\\{([^}]*)\\}/g,(e,n,r)=>`${n}{${Ha(r)}}`)}function fd(t){return t=t.replace(/<style[^>]*>([\\s\\S]*?)<\\/style>/gi,(e,n)=>e.replace(n,ld(n))),t=t.replace(/style=([\'"])([\\s\\S]*?)\\1/gi,(e,n,r)=>`style=${n}${Ha(r)}${n}`),t}function ud(){return fr||(fr=(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 r=n.getContext("2d",{willReadFrequently:!0});r.drawImage(e,0,0);let i=r.getImageData(2,18,1,1).data[3]>128,o=r.getImageData(2,2,1,1).data[3]>128;return{native:i||o,flippedY:o&&!i}}catch{return{native:!1,flippedY:!1}}})(),fr)}function dd(t){let e=[],n=0,r=0;for(let i=0;i<t.length;i++){let o=t[i];o==="("?n++:o===")"?n=Math.max(0,n-1):o===","&&n===0&&(e.push(t.slice(r,i)),r=i+1)}return e.push(t.slice(r)),e.map(i=>{let o=0,s=0,a="",c=0;for(;c<i.length;){let f=i[c];if(f==="("?o++:f===")"&&(o=Math.max(0,o-1)),o===0&&(c===0||i[c-1]===" ")){let l=/^-?\\d*\\.?\\d+px/.exec(i.slice(c));if(l){s++,a+=s===2?`${-parseFloat(l[0])}px`:l[0],c+=l[0].length;continue}}a+=f,c++}return a}).join(",")}function pd(t,e){let n=r=>za(r).map(i=>{let o=i.indexOf(":");if(o<0)return i;let s=i.slice(0,o).trim().toLowerCase();return s==="text-shadow"||e&&s==="box-shadow"?`${s}:${dd(i.slice(o+1))}`:i}).join(";");return t=t.replace(/<style[^>]*>([\\s\\S]*?)<\\/style>/gi,(r,i)=>r.replace(i,i.replace(/([^{}]+)\\{([^}]*)\\}/g,(o,s,a)=>`${s}{${n(a)}}`))),t=t.replace(/style=([\'"])([\\s\\S]*?)\\1/gi,(r,i,o)=>`style=${i}${n(o)}${i}`),t}async function mr(t){if(!/(?:box-shadow|text-shadow)\\s*:[^;"}]*px/i.test(t))return{svg:t,naturalOnly:!1};let{native:n,flippedY:r}=await ud();try{let i=t;return n||(i=fd(i)),r&&(i=pd(i,n)),{svg:i,naturalOnly:!0}}catch{return{svg:t,naturalOnly:!0}}}function hd(){let t=document.createElement("canvas");t.width=16,t.height=16;let e=t.getContext("2d",{willReadFrequently:!0});return e?n=>{e.clearRect(0,0,16,16),e.drawImage(n,0,0,16,16);let r=e.getImageData(0,0,16,16).data;for(let i=3;i<r.length;i+=4)if(r[i]>0)return!0;return!1}:null}async function md(t,e,n){tt(t),t.style.cssText="position:fixed;left:-99999px;top:-99999px;pointer-events:none",document.body.appendChild(t);try{if(!n)return await ur(),await ur(),!1;let r=performance.now()+(e?600:150);for(;;){let i;try{i=n(t)}catch{return!1}if(i)return!0;if(performance.now()>r)return!1;await ur()}}finally{try{t.remove()}catch{}}}function Da(t){if(typeof document>"u"||!document.body)return new Image;if(Et&&!Et.contentDocument){try{Et.remove()}catch{}Et=null}if(Et&&dr>gd&&pn===0){try{Et.remove()}catch{}Et=null}if(!Et){let n=document.createElement("iframe");tt(n),n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;left:-9999px;top:0;width:0;height:0;border:0;visibility:hidden;pointer-events:none";try{document.body.appendChild(n)}catch{}if(n.contentDocument)Et=n,dr=0;else{try{n.remove()}catch{}return new Image}}dr+=t.length,pn+=1;let e=Et.contentDocument.createElement("img");return e.__snapdomDecodeFrame=!0,e}function Bo(t,e=!1){!t||!t.__snapdomDecodeFrame||(t.__snapdomDecodeFrame=!1,pn=Math.max(0,pn-1),e&&(Do=!0),Do&&pn===0&&(Et?.remove(),Et=null,dr=0,Do=!1))}function Ba(t,e){return t.loading="eager",t.decoding="sync",t.crossOrigin="anonymous",t.src=e,t.decode()}function xd(t){if(typeof t!="string")return!1;let e=t.indexOf(",")+1,n=Math.max(48,Math.floor((t.length-e)/200)),r=0,i=0;for(let o=e;o+48<=t.length;o+=n){let s=t.slice(o,o+48);r++,Sd.some(a=>s.includes(a))||i++}return i*2>r}function Ua(t,e,n,r,i){if(!e.naturalWidth){t.drawImage(e,0,0,n,r);return}let o=n*r,s=o>yd&&!xd(i)?Math.min(wd,Math.ceil(o/bd)):1;if(s===1){t.drawImage(e,0,0,n,r);return}let a=e.naturalWidth,c=e.naturalHeight/r;for(let f=0;f<s;f++){let l=Math.round(f*r/s),u=f===s-1?r:Math.round((f+1)*r/s);t.drawImage(e,0,l*c,a,(u-l)*c,0,l,n,u-l)}}async function zt(t,e){let{width:n,height:r,scale:i=1,dpr:o=1,meta:s={},backgroundColor:a,crop:c=null}=e,f=typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?t:null,l=t,u=!1,p=!1;if(c&&!Oo(t))throw new RangeError("[snapdom] canvas crop requires an SVG capture payload");if(Oo(t)){let m=(hr(t).match(/<svg\\b[^>]*>/i)||[])[0]||"",d=parseFloat((m.match(/\\bwidth="([\\d.]+)/i)||[])[1]),g=parseFloat((m.match(/\\bheight="([\\d.]+)/i)||[])[1]),y=Number.isFinite(d)&&Number.isFinite(g)&&d>0&&g>0&&Math.min(1,Ut/d,Ut/g,Math.sqrt(ue/(d*g)))<1;if(c||y||X())try{let b=de(t);if(c&&(b=pr(b,c)),X()){let S=await mr(b);b=S.svg,u=S.naturalOnly,p=/@font-face|data:image\\//i.test(b)}(y||c)&&(b=ad(b,e.__session)),l=pe(b)}catch(b){if(c)throw b;l=t}}let h=f||Da(l);try{f||await Ba(h,l)}catch(m){if(!h.__snapdomDecodeFrame)throw m;let d=h;h=Da(l),Bo(d);try{await Ba(h,l)}catch(g){throw Bo(h,e.__releaseDecodeFrame),g}}try{!f&&!X()&&!$t()&&Oo(l)&&/(?:%40|@)font-face/i.test(l)&&await new Promise(T=>{let I=new MessageChannel;I.port1.onmessage=()=>{I.port1.close(),I.port2.close(),T()},I.port2.postMessage(0)});let m=X()&&!f?hd():null,d=!1;m&&(d=await md(h,p,m));let g=f?f.width:h.naturalWidth,y=f?f.height:h.naturalHeight,b=c?g:Number.isFinite(s.vbW)?s.vbW:Number.isFinite(s.w0)?s.w0:g,S=c?y:Number.isFinite(s.vbH)?s.vbH:Number.isFinite(s.h0)?s.h0:y,k,v,w=Number.isFinite(n),M=Number.isFinite(r);if(w&&M)k=Math.max(1,n),v=Math.max(1,r);else if(w){let T=n/Math.max(1,b);k=n,v=S*T}else if(M){let T=r/Math.max(1,S);v=r,k=b*T}else{let T=f&&Number.isFinite(s.vbW)&&Number.isFinite(s.vbH);k=T?s.vbW:g,v=T?s.vbH:y}!w&&!M&&(k=k*i,v=v*i);let A=k*o,C=v*o,x=Math.max(A/Ut,C/Ut,Math.sqrt(A*C/ue));x>1&&(At(e.__session,"canvas-clamp",`output ${Math.round(A)}x${Math.round(C)}px exceeds canvas limits; downscaled`),console.warn(`[snapdom] Canvas limit: reducing ${Math.round(A)}\\xD7${Math.round(C)}. Use ${typeof CompressionStream=="function"?"PNG Blob, ":""}SVG or crop.`),k/=x,v/=x);let _=Rt(e.canvas)&&st(e.canvas,"canvas")?e.canvas:document.createElement("canvas");_.width=Math.max(1,k*o),_.height=Math.max(1,v*o),_.style.width=`${k}px`,_.style.height=`${v}px`;let R=_.getContext("2d");if(!R)throw new Error("[snapdom] toCanvas: the target canvas has no 2d context");let $=()=>{if(o!==1&&R.scale(o,o),a&&(R.save(),R.fillStyle=a,R.fillRect(0,0,k,v),R.restore()),u&&(Math.round(k*o)!==g||Math.round(v*o)!==y)){let T=document.createElement("canvas");T.width=g,T.height=y,Ua(T.getContext("2d"),h,g,y,l),R.drawImage(T,0,0,k,v)}else R.save(),R.setTransform(1,0,0,1,0,0),Ua(R,h,k*o,v*o,l),R.restore()};if($(),m&&d&&p){let T=!0;try{T=m(h)}catch{}if(!T){let I=performance.now()+600;do{await ur();try{T=m(h)}catch{break}}while(!T&&performance.now()<I);_.width=_.width,$()}}return _}finally{Bo(h,e.__releaseDecodeFrame)}}var Ut,ue,fr,ur,gd,Et,dr,pn,Do,yd,bd,wd,Sd,he=lt(()=>{"use strict";yt();ne();kt();Ct();Ut=X()?16384:32767,ue=16384*16384;fr=null;ur=()=>new Promise(t=>{requestAnimationFrame(t),setTimeout(t,50)});gd=24*1024*1024,Et=null,dr=0,pn=0,Do=!1;yd=4e6,bd=2e6,wd=8,Sd=["%3C","%3E","%20","%7B","%7D","%3B"]});var hn={};we(hn,{rasterize:()=>Uo});async function Uo(t,e){let n=await zt(t,e),o=n.width*n.height<=2e6?n.toDataURL(`image/${e.format}`,e.quality):await new Promise(a=>{let c=()=>a(n.toDataURL(`image/${e.format}`,e.quality));try{n.toBlob(f=>{if(!f)return c();let l=new FileReader;l.onload=()=>a(String(l.result||"")),l.onerror=c,l.readAsDataURL(f)},`image/${e.format}`,e.quality)}catch{c()}}),s=new Image;return s.src=o,X()?await s.decode():await new Promise((a,c)=>{if(s.complete&&s.naturalWidth)return a();s.onload=a,s.onerror=c}),s.style.width=`${n.width/e.dpr}px`,s.style.height=`${n.height/e.dpr}px`,s}var je=lt(()=>{"use strict";he();yt()});var zo={};we(zo,{toImg:()=>vd,toSvg:()=>vd});async function vd(t,e){let{scale:n=1,width:r,height:i,meta:o={}}=e,s=Number.isFinite(r),a=Number.isFinite(i),c=Number.isFinite(n)&&n!==1||s||a;if(X()&&c)try{let{svg:p}=await mr(de(t)),h=(p.match(/<svg\\b[^>]*>/i)||[])[0]||"",m=parseFloat((h.match(/\\bwidth="([\\d.]+)/i)||[])[1]),d=parseFloat((h.match(/\\bheight="([\\d.]+)/i)||[])[1]);if(!Number.isFinite(m)||!Number.isFinite(d))throw new Error("svg without dimensions");let g=Number.isFinite(o.vbW)?o.vbW:Number.isFinite(o.w0)?o.w0:m,y=Number.isFinite(o.vbH)?o.vbH:Number.isFinite(o.h0)?o.h0:d,b,S;s&&a?(b=r,S=i):s?(b=r,S=Math.max(1,Math.round(y*(r/Math.max(1,g))))):a?(S=i,b=Math.max(1,Math.round(g*(i/Math.max(1,y))))):(b=Math.max(1,Math.round(m*n)),S=Math.max(1,Math.round(d*n)));let k=p.replace(/width="[^"]*"/,`width="${b}"`).replace(/height="[^"]*"/,`height="${S}"`),v=new Image;return v.decoding="sync",v.loading="eager",v.src=pe(k),await v.decode(),v.style.width=`${b}px`,v.style.height=`${S}px`,v}catch(p){return At(e.__session,"safari-png-fallback","Safari vector toImg failed; using PNG",p),H(e,"Safari vector toImg failed; using PNG",p),Uo(t,{...e,format:"png",quality:1,meta:o})}let f=t,l=!1;if(!s&&!a&&n!==1&&typeof t=="string"&&t.startsWith("data:image/svg+xml"))try{let p=de(t),h=(p.match(/<svg\\b[^>]*>/i)||[])[0]||"",m=Number((h.match(/\\bwidth="([\\d.]+)"/i)||[])[1]),d=Number((h.match(/\\bheight="([\\d.]+)"/i)||[])[1]);if(m>0&&d>0){let g=h.replace(/\\bwidth="[^"]*"/i,`width="${Math.max(1,Math.round(m*n))}"`).replace(/\\bheight="[^"]*"/i,`height="${Math.max(1,Math.round(d*n))}"`);f=pe(p.replace(h,g)),l=!0}}catch{}let u=new Image;u.decoding="sync",u.loading="eager",u.src=f;try{await u.decode()}catch(p){if(!l)throw p;u.src=t,l=!1,await u.decode()}if(s&&a)u.style.width=`${r}px`,u.style.height=`${i}px`;else if(s){let p=Number.isFinite(o.vbW)?o.vbW:Number.isFinite(o.w0)?o.w0:u.naturalWidth,h=Number.isFinite(o.vbH)?o.vbH:Number.isFinite(o.h0)?o.h0:u.naturalHeight,m=r/Math.max(1,p);u.style.width=`${r}px`,u.style.height=`${Math.max(1,Math.round(h*m))}px`}else if(a){let p=Number.isFinite(o.vbW)?o.vbW:Number.isFinite(o.w0)?o.w0:u.naturalWidth,h=Number.isFinite(o.vbH)?o.vbH:Number.isFinite(o.h0)?o.h0:u.naturalHeight,m=i/Math.max(1,h);u.style.height=`${i}px`,u.style.width=`${Math.max(1,Math.round(p*m))}px`}else{let p=Math.max(1,Math.round(u.naturalWidth*(l?1:n))),h=Math.max(1,Math.round(u.naturalHeight*(l?1:n)));if(u.style.width=`${p}px`,u.style.height=`${h}px`,!l&&n!==1&&typeof t=="string"&&t.startsWith("data:image/svg+xml"))try{let d=decodeURIComponent(t.split(",")[1]).replace(/width="[^"]*"/,`width="${p}"`).replace(/height="[^"]*"/,`height="${h}"`);u.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(d)}`,await u.decode()}catch(m){H(e,"toImg SVG sizing failed",m),u.src!==t&&(u.src=t,await u.decode().catch(()=>{}))}}return u}var Ho=lt(()=>{"use strict";bt();ne();je();he()});var qa={};we(qa,{encodePng:()=>kd});function gr(t,e=new Uint8Array(0)){let n=new Uint8Array(e.length+12),r=new DataView(n.buffer);r.setUint32(0,e.length);for(let o=0;o<4;o++)n[o+4]=t.charCodeAt(o);n.set(e,8);let i=4294967295;for(let o=4;o<n.length-4;o++)i=Va[(i^n[o])&255]^i>>>8;return r.setUint32(n.length-4,(i^4294967295)>>>0),n}async function kd(t,e,n){if(![t,e].every(d=>Number.isInteger(d)&&d>0&&d<=2147483647))throw new RangeError("[snapdom] PNG dimensions must be integers from 1 to 2147483647");let r=new Uint8Array(13),i=new DataView(r.buffer);i.setUint32(0,t),i.setUint32(4,e),r[8]=8,r[9]=6;let o=[new Uint8Array([137,80,78,71,13,10,26,10]),gr("IHDR",r),gr("sRGB",new Uint8Array([0]))],s=t*4,a=Math.max(1,Math.floor(65536/(s+1))),c=new Uint8Array(s),f=0,l=new CompressionStream("deflate"),u=l.writable.getWriter(),p=l.readable.getReader(),h,m=(async()=>{try{for(;;){let{done:d,value:g}=await p.read();if(d)return;o.push(gr("IDAT",g))}}catch(d){h=d,await u.abort(d).catch(()=>{})}})();try{for await(let d of n){if(!(d instanceof Uint8Array||d instanceof Uint8ClampedArray)||!d.length||d.length%s)throw new RangeError("[snapdom] PNG input must contain complete RGBA rows");let g=d.length/s;if(f+g>e)throw new RangeError("[snapdom] PNG input exceeds the declared height");for(let y=0;y<g;y+=a){let b=Math.min(g,y+a),S=new Uint8Array((b-y)*(s+1));for(let k=y;k<b;k++){let v=d.subarray(k*s,(k+1)*s),w=(k-y)*(s+1),M=0,A=0;for(let C=0;C<s;C++){let x=v[C]-(C<4?0:v[C-4])&255,_=v[C]-c[C]&255;M+=Math.min(x,256-x),A+=Math.min(_,256-_),S[w+C+1]=_}if(S[w]=A<=M?2:1,M<A)for(let C=0;C<s;C++)S[w+C+1]=v[C]-(C<4?0:v[C-4]);c=v}await u.write(S)}c=c.slice(),f+=g}if(f!==e)throw new RangeError("[snapdom] PNG input does not match the declared height");if(await u.close(),await m,h)throw h;return o.push(gr("IEND")),new Blob(o,{type:"image/png"})}catch(d){throw await Promise.allSettled([u.abort(d),p.cancel(d)]),await m,d}finally{u.releaseLock(),p.releaseLock()}}var Va,Ga=lt(()=>{"use strict";Va=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;Va[t]=e}});function yr(t,e){if(typeof t!="string"||!t.startsWith("data:image/svg+xml"))return null;let n=hr(t).match(/<svg\\b[^>]*>/i)?.[0];if(!n)return null;let r=e.crop?pr(n,e.crop):n,i=parseFloat(r.match(/\\bwidth="([^"]+)/i)?.[1]),o=parseFloat(r.match(/\\bheight="([^"]+)/i)?.[1]),s=(r.match(/\\bviewBox="([^"]+)/i)?.[1]||"").trim().split(/[\\s,]+/).map(Number);if(!(i>0&&o>0)||s.length!==4||!s.every(Number.isFinite)||!(s[2]>0&&s[3]>0))return null;let a=Number.isFinite(e.width),c=Number.isFinite(e.height),f=e.meta||{},l=Math.max(1,Math.floor(i)),u=Math.max(1,Math.floor(o)),p=e.crop?l:Number.isFinite(f.vbW)?f.vbW:Number.isFinite(f.w0)?f.w0:l,h=e.crop?u:Number.isFinite(f.vbH)?f.vbH:Number.isFinite(f.h0)?f.h0:u,m=e.dpr??1,d=e.scale??1,g=(a&&c?Math.max(1,e.width):a?e.width:c?e.height*p/Math.max(1,h):l*d)*m,y=(a&&c?Math.max(1,e.height):c?e.height:a?e.width*h/Math.max(1,p):u*d)*m;if(Math.max(i,o,g,y)<=Ut&&i*o<=ue&&g*y<=ue||typeof CompressionStream!="function")return null;return b();async function b(){let{encodePng:S}=await Promise.resolve().then(()=>(Ga(),qa)),k=Math.max(1,Math.floor(g)),v=Math.max(1,Math.floor(y)),w=de(t),M=w.slice(w.indexOf(n)+n.length,w.lastIndexOf("</svg>")),A=r.match(/\\bpreserveAspectRatio="([^"]*)"/i)?.[1]||"xMidYMid meet",C=i/s[2],x=o/s[3],_=0,R=0;/\\bnone\\b/.test(A)||(C=x=/\\bslice\\b/.test(A)?Math.max(C,x):Math.min(C,x),_=(i-s[2]*C)*(/xMin/.test(A)?0:/xMax/.test(A)?1:.5),R=(o-s[3]*x)*(/YMin/.test(A)?0:/YMax/.test(A)?1:.5)),_-=s[0]*C,R-=s[1]*x;let $=r.replace(/\\s(?:width|height|preserveAspectRatio)="[^"]*"/gi,"").slice(0,-1),T=X()&&/(?:box-shadow|text-shadow)\\s*:[^;"}]*px/i.test(w),I=i/g,B=o/y,E=Math.max(1,Math.min(8192,Math.floor(4*1024*1024/k),T?Math.floor(2046/B):8192)),N=Math.max(1,Math.min(8192,k,T?Math.floor(2046/I):8192));async function*P(){for(let F=0;F<v;F+=E){let z=Math.min(E,v-F),V=new Uint8Array(k*z*4);for(let j=0;j<k;j+=N){let D=Math.min(N,k-j),K=T?Math.max(0,Math.floor(j*I)-1):j*I,ht=T?Math.max(0,Math.floor(F*B)-1):F*B,St=T?Math.min(l,Math.ceil((j+D)*I)+1)-K:D,ft=T?Math.min(u,Math.ceil((F+z)*B)+1)-ht:z,at=St/s[2],ct=ft/s[3],xt=T?1:1/I,U=T?1:1/B,G=`matrix(${C*xt/at},0,0,${x*U/ct},${(_-K)*xt/at+s[0]},${(R-ht)*U/ct+s[1]})`,q=`${$} width="${St}" height="${ft}" preserveAspectRatio="none"><g style="all:unset!important;transform:${G}!important;transform-origin:0 0!important">${M}</g></svg>`,nt=await zt(pe(q),{width:St,height:ft,dpr:1,backgroundColor:T?null:e.backgroundColor,__session:e.__session,__releaseDecodeFrame:!0}),rt=nt;try{if(T){rt=document.createElement("canvas"),rt.width=D,rt.height=z;let J=rt.getContext("2d");e.backgroundColor&&(J.fillStyle=e.backgroundColor,J.fillRect(0,0,D,z)),J.drawImage(nt,j*I-K,F*B-ht,D*I,z*B,0,0,D,z)}let me=rt.getContext("2d").getImageData(0,0,D,z).data;for(let J=0;J<z;J++)V.set(me.subarray(J*D*4,(J+1)*D*4),(J*k+j)*4)}finally{nt.width=nt.height=0,rt!==nt&&(rt.width=rt.height=0)}}yield V}}return S(k,v,P())}}var jo=lt(()=>{"use strict";he();yt()});var Xa={};we(Xa,{toBlob:()=>Vo});async function Vo(t,e){let n=e.format||e.type||"svg";if(n==="svg"){if(typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement)throw new Error("[snapdom] toBlob: engine:\'html-in-canvas\' produces a raster capture; ask for png/jpeg/webp");let o=decodeURIComponent(t.split(",")[1]);return new Blob([o],{type:"image/svg+xml"})}let r=n==="png"&&yr(t,e);if(r)return r;let i=await zt(t,e);return new Promise(o=>i.toBlob(s=>o(s),`image/${n==="jpg"?"jpeg":n}`,e.quality))}var qo=lt(()=>{"use strict";he();jo()});var Ka={};we(Ka,{download:()=>Cd});async function Ya(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(r){if(r.name!=="AbortError")return!1}return!0}async function Cd(t,e){let n=new Set(["png","jpeg","jpg","webp","svg"]),r=(e?.type||"").toLowerCase(),i=n.has(r)?r:"",o=(e?.format||i||"").toLowerCase(),s=o==="jpg"?"jpeg":o||"png",a=e?.filename||"snapdom",c=/\\.(png|jpe?g|webp|svg)$/i.test(a)?a:`${a}.${s}`,f={...e||{},format:s,type:s};f.dpr=1;let l=Ke(),u=s==="png"&&yr(t,f);if(s==="svg"||u){let m=u?await u:await Vo(t,{...f,type:"svg"});if(l&&await Ya(m,c))return;let d=URL.createObjectURL(m),g=document.createElement("a");g.href=d,g.download=c,document.body.appendChild(g),g.click(),setTimeout(()=>URL.revokeObjectURL(d),1e3),g.remove();return}let p=await zt(t,f);if(l){let m=`image/${s}`,d=await new Promise(g=>p.toBlob(g,m,e?.quality));if(d&&await Ya(d,c))return}let h=document.createElement("a");h.href=p.toDataURL(`image/${s}`,e?.quality),h.download=c,document.body.appendChild(h),h.click(),h.remove()}var Qa=lt(()=>{"use strict";qo();he();jo();yt()});bt();bt();yt();mt();bn();Ct();var re=new WeakMap,gi=["margin-top","margin-right","margin-bottom","margin-left","margin-block-start","margin-block-end","margin-inline-start","margin-inline-end"],Ir=new Map,Wc=2e3,_e=0;function Pt(){_e++}function Sn(t){let e=t&&(t.nodeType===1?t:t.parentElement);for(;e;){if(qt(e))return!0;if(e.parentElement)e=e.parentElement;else{let n=e.getRootNode?.();e=n&&n.host?n.host:null}}return!1}function vn(t){for(let e of t)if(ie(e))return!0;return!1}function ie(t){if(Sn(t.target))return!1;if(t.type==="childList"){let e=!0;for(let n of t.addedNodes)if(!Sn(n)){e=!1;break}if(e){for(let n of t.removedNodes)if(!Sn(n)){e=!1;break}}if(e)return!1}return!0}var Me=new WeakMap;function vi(t){for(let e of t){if(!ie(e))continue;let n=e.target.ownerDocument||document;Me.set(n,(Me.get(n)||0)+1);let r=e.target.nodeType===1?e.target:e.target.parentElement||e.target.host;for(;r;r=r.parentElement||r.getRootNode?.()?.host)Me.set(r,(Me.get(r)||0)+1)}}function tn(t){let e=t.ownerDocument||document;return Fe(e),(Me.get(e)||0)-(Me.get(t)||0)}var Ft=0;function Ee(t=document){return Fe(t),Ft}function Dt(){return Fe(),_e}function en(t){return t?(Fe(t.ownerDocument||document),kn(t,Hr(t))):0}function Re(){Pt(),Ft++}var oe=new WeakMap,Xt=0,Yt=0;function Oc(t){oe.set(t,++Xt)}function Ur(t){if(!t||t.nodeType!==1)return;Xt++,oe.set(t,Xt);let e=t.querySelectorAll("*");for(let n=0;n<e.length;n++)oe.set(e[n],Xt)}function zr(t){Ur(t.parentElement||t);for(let e=t.parentElement;e;e=e.parentElement)Oc(e)}function kn(t,e=null){let n=oe.get(t)||0;if(e)for(let r of e)n=Math.max(n,oe.get(r)||0);return Yt*1e9+n}function Hr(t){let e=t.getRootNode?.();if(!e?.host)return null;let n=[];for(;e?.host;)e.mode==="open"&&Vr(e),n.push(e.host),e=e.host.getRootNode?.();return n}var Wr=new WeakMap;function jr(t){t=t||document;let e=Wr.get(t);if(!e||e.env!==Ft){let n=!0;try{n=Kt(t).usesHas}catch{}e={env:Ft,usesHas:n},Wr.set(t,e)}return!e.usesHas}function Dc(t){let e=n=>n?.nodeType===1&&(n.matches?.("style,link")||n.querySelector?.("style,link"));for(let n of t){let r=n.target,i=r&&(r.nodeType===1?r:r.parentElement);if(i&&(i.tagName==="STYLE"||i.tagName==="LINK"))return i.ownerDocument||document;for(let o of n.addedNodes)if(e(o))return o.ownerDocument||document;for(let o of n.removedNodes)if(e(o))return o.ownerDocument||r&&r.ownerDocument||document}return null}var Or=new WeakSet,Qe=[];function ki(t){if(!vn(t))return;vi(t),Pt();let e=new Set;for(let n of t){if(!ie(n))continue;let r=n.target.getRootNode&&n.target.getRootNode();if(!r||r.nodeType!==11||e.has(r))continue;e.add(r),r.host?Ur(r.host):Xt++;let i=r.querySelectorAll("*");for(let o=0;o<i.length;o++)oe.set(i[o],Xt)}}function Vr(t){if(!(!t||Or.has(t))){Or.add(t);try{let e=new MutationObserver(ki);e.observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0}),Qe.push({o:e,root:t})}catch{}}}function Ci(t){if(!vn(t))return;vi(t),Pt();let e=Dc(t);if(e){Wr.delete(e),Ft++,Yt++;return}let n=new Set;for(let r of t){if(!ie(r))continue;let i=r.target.nodeType===1?r.target:r.target.parentElement;if(!i)continue;let o=i.ownerDocument||document;if(!jr(o)){Yt++;return}if(i===o.documentElement||i===o.body){Yt++;return}let s=i.parentElement||i;n.has(s)||(n.add(s),zr(i))}}var Dr=new WeakSet,Je=null,Ze=[];function Fe(t=document){if(t===Je||!t||t.nodeType!==9)return;if(Dr.has(t)){Je=t;return}Dr.add(t),Je=t;let e=t.defaultView,n=i=>{vn(i)&&(Pt(),Ft++)},r=()=>{Pt(),Ft++};try{let i=new MutationObserver(Ci);i.observe(t.documentElement,{subtree:!0,childList:!0,characterData:!0,attributes:!0}),Ze.push({o:i,env:!1,doc:t})}catch{}try{let i=new MutationObserver(n);i.observe(t.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0}),Ze.push({o:i,env:!0,doc:t})}catch{}try{e?.addEventListener("resize",r,{passive:!0})}catch{}try{let i=o=>{Pt();let s=o.composedPath?.()[0]||o.target;s&&s.nodeType===1&&!Sn(s)&&jr(s.ownerDocument||t)?zr(s):Yt++};t.addEventListener("focusin",i,{capture:!0,passive:!0}),t.addEventListener("focusout",i,{capture:!0,passive:!0}),t.addEventListener("change",i,{capture:!0,passive:!0}),t.addEventListener("pointerdown",i,{capture:!0,passive:!0}),t.addEventListener("pointerup",i,{capture:!0,passive:!0}),t.addEventListener("pointercancel",i,{capture:!0,passive:!0}),t.addEventListener("keydown",i,{capture:!0,passive:!0}),t.addEventListener("keyup",i,{capture:!0,passive:!0}),t.addEventListener("beforetoggle",i,{capture:!0,passive:!0}),t.addEventListener("toggle",i,{capture:!0,passive:!0}),e?.addEventListener("hashchange",()=>{Pt(),Yt++},{passive:!0})}catch{}try{let i=t.fonts;i&&(i.addEventListener?.("loadingdone",r),i.status==="loading"&&i.ready?.then(r).catch(()=>{}))}catch{}}var yi=new WeakMap;function bi(t,e){if(!t?.querySelectorAll)return;let n;try{n=Array.from(t.querySelectorAll(":hover"))}catch{return}let r=yi.get(t)||[];if(r.length===n.length&&r.every((o,s)=>o===n[s]))return;if(yi.set(t,n),Pt(),t.nodeType===11){t.host?Ur(t.host):Xt++;for(let o of t.querySelectorAll("*"))oe.set(o,Xt);return}let i=r.filter(o=>!n.includes(o)).concat(n.filter(o=>!r.includes(o)));for(let o of i)if(o.isConnected)if(jr(e))zr(o);else{Yt++;return}}function Cn(t,e=null){if(!t)return;bi(t,t);let n=e||Qe.filter(({root:r})=>r.host?.isConnected).map(({root:r})=>r);for(let r of n)bi(r,t)}function Tt(){Fe();try{for(let t=Ze.length-1;t>=0;t--){let{o:e,env:n,doc:r}=Ze[t];if(r!==document&&!r.defaultView){try{e.disconnect()}catch{}Dr.delete(r),Je===r&&(Je=null),Ze.splice(t,1);continue}let i=e.takeRecords();i.length&&(n?vn(i)&&(Pt(),Ft++):Ci(i))}for(let t=Qe.length-1;t>=0;t--){let{o:e,root:n}=Qe[t];if(!n.host||!n.host.isConnected){try{e.disconnect()}catch{}Or.delete(n),Qe.splice(t,1);continue}let r=e.takeRecords();r.length&&ki(r)}}catch{}}function se(t){if(!(!t||t.nodeType!==1)){re.delete(t);try{let e=(t.ownerDocument||document).createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;e.nextNode();)re.delete(e.currentNode)}catch{}}}var Bc=["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 qr(t){let e=re.get(t);if(e&&Gr(e,t)){let n=e.snapshot&&e.snapshot.__needsBgInline;if(n!==void 0)return n}return!0}function Ai(t){let e=re.get(t);if(!e||!Gr(e,t))return null;let n=e.snapshot;return!n||n.__bgClipTextFix?null:n}var wi=new WeakMap;function Kt(t){let e=wi.get(t);if(!e||e.epoch!==_e){let n=e&&e.universe;e={epoch:_e,...li(t)};let r=e.universe;if(n&&r&&n.size===r.size){let i=!0;for(let o of r)if(!n.has(o)){i=!1;break}i&&(e.universe=n)}wi.set(t,e)}return e}function Mi(t){try{let e=Kt(t.ownerDocument||document).shareGate;if(e===null)return!1;if(!e.length)return!0;let n=new Set,r=s=>{n.add("t"+s.localName),s.id&&n.add("i"+s.id);let a=s.classList;for(let c=0;c<a.length;c++)n.add("c"+a[c])};r(t);for(let s of t.querySelectorAll("*"))r(s);let i=[];for(let{sel:s,key:a}of e)(a===null||n.has(a))&&i.push(s);if(!i.length)return!0;let o=i.join(",");return!t.matches(o)&&t.querySelector(o)===null}catch{return!1}}function Uc(t){let e=t.ownerDocument||document;return t.getRootNode&&t.getRootNode()!==e?null:Kt(e).importantProps}function nn(t,e){let n=t.ownerDocument||document,r=t.getRootNode?t.getRootNode():n;return r===n?Kt(n).universe:e&&Wt(r)?zc(t,r,n,e):null}var Si=new WeakMap;function zc(t,e,n,r){let i=r.__shadowUniverse;if(i===null)return null;if(!i){let a=Kt(n).universe;if(!a)return r.__shadowUniverse=null;i=r.__shadowUniverse={universe:new Set(a),roots:new Set}}let o=a=>{for(;Wt(a)&&!i.roots.has(a);a=a.host.getRootNode()){i.roots.add(a);for(let c of[...a.styleSheets,...a.adoptedStyleSheets||[]]){let f=Si.get(c);if((!f||f.epoch!==_e)&&Si.set(c,f={epoch:_e,props:ai(c)}),!f.props)return!1;for(let l of f.props)i.universe.add(l)}Rr(a.getAnimations(),i.universe)}return!0},s=o(e)&&(!t.shadowRoot||o(t.shadowRoot));for(let a=t.assignedSlot;s&&a;a=a.assignedSlot)s=o(a.getRootNode());return s?i.universe:r.__shadowUniverse=null}function xn(t){let e=t.ownerDocument||document;return t.getRootNode&&t.getRootNode()!==e?null:Kt(e).pseudoUniverse}var Hc={before:null,after:null,firstLetter:null,marker:null,firstLine:null};function Te(t){let e=t.ownerDocument||document;return t.getRootNode&&t.getRootNode()!==e?Hc:Kt(e).pseudoGates}function jc(t,e={},n=null,r=null){let i={},o=e.excludeStyleProps,s=h=>{if(i[h]!==void 0||ve(h)||o&&(o instanceof RegExp&&o.test(h)||typeof o=="function"&&o(h)))return;let m=t.getPropertyValue(h);m&&((h==="background-image"||h==="content")&&m.includes("url(")&&!m.includes("data:")&&(m="none"),i[h]=m)};if(r){for(let m of r)s(m);let h=n&&n.style;if(h&&h.length)for(let m=0;m<h.length;m++)s(h[m])}else for(let h=0;h<t.length;h++)s(t[h]);let a=["text-decoration-line","text-decoration-color","text-decoration-style","text-decoration-thickness","text-underline-offset","text-decoration-skip-ink"];for(let h of a)if(!i[h])try{let m=t.getPropertyValue(h);m&&(i[h]=m)}catch{}let c=["-webkit-text-stroke","-webkit-text-stroke-width","-webkit-text-stroke-color","paint-order"];for(let h of c)if(!i[h])try{let m=t.getPropertyValue(h);m&&(i[h]=m)}catch{}if(e.embedFonts){let h=["font-feature-settings","font-variation-settings","font-kerning","font-variant","font-variant-ligatures","font-optical-sizing"];for(let m of h)if(!i[m])try{let d=t.getPropertyValue(m);d&&(i[m]=d)}catch{}}try{(i["content-visibility"]||t.getPropertyValue("content-visibility"))==="hidden"&&(i["content-visibility"]="hidden")}catch{}Object.defineProperty(i,"__needsBgInline",{value:_i(t),enumerable:!1});let f=parseFloat(t.getPropertyValue("border-top-width")||0)||0,l=parseFloat(t.getPropertyValue("border-right-width")||0)||0,u=parseFloat(t.getPropertyValue("border-bottom-width")||0)||0,p=parseFloat(t.getPropertyValue("border-left-width")||0)||0;if(f===0&&l===0&&u===0&&p===0){let h=(t.getPropertyValue("border-image-source")||"").trim(),m=h&&h!=="none",d=["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","border-block-start","border-block-start-width","border-block-start-style","border-block-start-color","border-block-end","border-block-end-width","border-block-end-style","border-block-end-color","border-inline-start","border-inline-start-width","border-inline-start-style","border-inline-start-color","border-inline-end","border-inline-end-width","border-inline-end-style","border-inline-end-color"];for(let g of d)delete i[g];m||(i.border="none")}return Vc(i),i}function Vc(t){if(!$t())return;let e=t["background-clip"]||t["-webkit-background-clip"];if(!e||!e.includes("text"))return;let n=o=>o==="transparent"||o==="rgba(0, 0, 0, 0)",r=t["-webkit-text-fill-color"];if(!n(r!==void 0?r:t.color))return;let i=qc(t["background-image"],t["background-color"]);i&&(n(t.color)&&(t.color=i),r!==void 0&&(t["-webkit-text-fill-color"]=i),t["background-image"]="none",t["background-color"]="transparent",delete t["background-clip"],delete t["-webkit-background-clip"],Object.defineProperty(t,"__bgClipTextFix",{value:i,enumerable:!1}))}function qc(t,e){let n=o=>{let s=[],a=/rgba?\\(\\s*(\\d+)[,\\s]+(\\d+)[,\\s]+(\\d+)(?:[,\\s/]+([\\d.]+%?))?\\s*\\)/g,c;for(;c=a.exec(o||"");){let f=c[4];(f===void 0?1:parseFloat(f)/(f.endsWith("%")?100:1))>.05&&s.push([+c[1],+c[2],+c[3]])}return s},r=n(t);if(r.length||(r=n(e)),!r.length)return null;let i=[0,0,0];for(let[o,s,a]of r)i[0]+=o,i[1]+=s,i[2]+=a;return`rgb(${i.map(o=>Math.round(o/r.length)).join(", ")})`}function _i(t){let e=t.getPropertyValue("background-image");if(e&&e!=="none")return!0;let n=t.getPropertyValue("background-color");if(n&&n!=="rgba(0, 0, 0, 0)"&&n!=="transparent")return!0;for(let i of Bc){let o=t.getPropertyValue(i);if(o&&o!=="none")return!0}let r=t.getPropertyValue("background");return!!(r&&/url\\s*\\(/i.test(r))}function Gc(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=O(e).position;if(n!=="absolute"&&n!=="fixed")return!0}}return!1}function Xc(t,e,n){try{if(typeof t.computedStyleMap=="function"){let i=t.computedStyleMap().get("width");if(i!=null)return!xi(String(i).trim().toLowerCase())}}catch{}let r=t.style&&(t.style.width||t.style.inlineSize);return r&&!xi(String(r).trim().toLowerCase())?!0:Kc(t,e)?n||Qc(t,e):!1}var Yc=new Set(["auto","min-content","max-content","stretch","fill-available","-webkit-fill-available"]);function xi(t){return Yc.has(t)||t.startsWith("fit-content")}function Kc(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 r=1/0,i=-1/0,o=null;for(let s=t.firstChild;s;s=s.nextSibling){let a;if(s.nodeType===3){if(!/\\S/.test(s.nodeValue||"")||(o=o||document.createRange(),o.selectNode(s),a=o.getBoundingClientRect(),!a.width&&!a.height))continue}else if(s.nodeType===1){let c=O(s);if(c.display==="none"||c.position==="absolute"||c.position==="fixed")continue;a=s.getBoundingClientRect()}else continue;a.left<r&&(r=a.left),a.right>i&&(i=a.right)}return i===-1/0?!1:i-r<n-.5}function Qc(t,e){let n=t.parentElement;if(!n)return!1;let r=O(n),i=n.getBoundingClientRect().width-(parseFloat(r.paddingLeft)||0)-(parseFloat(r.paddingRight)||0)-(parseFloat(r.borderLeftWidth)||0)-(parseFloat(r.borderRightWidth)||0)-(parseFloat(e.marginLeft)||0)-(parseFloat(e.marginRight)||0);return i>0?Math.abs(t.getBoundingClientRect().width-i)>.5:!1}var Br=new WeakMap;function Jc(t,e){let n=Br.get(t);if(n)return n;let r=[e];for(let i in t)r.push(i,t[i]);return n=r.join(""),Br.set(t,n),n}function Gr(t,e){return t.env===Ft&&t.stamp===kn(e,t.hosts)}var Zc=/^(width|height|inline-size|block-size|top|right|bottom|left|transform-origin|perspective-origin)$|^inset-/,tl=/(margin|padding)[a-z-]*\\s*:[^;]*(%|\\bauto\\b|calc\\(|var\\()/i,el=new Set(["INPUT","TEXTAREA","SELECT","OPTION","OPTGROUP","PROGRESS","METER","BUTTON","DATALIST"]);function nl(t){let e=t.__styleShare;return e||(e=t.__styleShare={ids:new WeakMap,intern:new Map,snaps:new Map,rootSeen:!1}),e}function rl(t,e){let n=e.ids.get(t);if(n!==void 0)return n;let r=t.parentElement,i;if(!r)i="R";else if(i=e.ids.get(r),i===void 0){if(e.rootSeen)return e.ids.set(t,-1),-1;i="R"}if(e.rootSeen=!0,i===-1)return e.ids.set(t,-1),-1;let o="",s=t.attributes;if(s&&s.length)if(s.length===1)o=s[0].name+"="+s[0].value;else{let c=[];for(let f=0;f<s.length;f++)c.push(s[f].name+"="+s[f].value);c.sort(),o=c.join("")}let a=i+"|"+t.tagName+"|"+o;return n=e.intern.get(a),n===void 0&&(n=e.intern.size,e.intern.set(a,n)),e.ids.set(t,n),n}function Ei(t,e){let n=t.snap,r=t.snap={...n};Object.defineProperty(r,"__needsBgInline",{value:n.__needsBgInline,enumerable:!1}),n.__bgClipTextFix!==void 0&&Object.defineProperty(r,"__bgClipTextFix",{value:n.__bgClipTextFix,enumerable:!1});let i=Kt(e.ownerDocument||document),o=e.getAttribute&&e.getAttribute("style")||"",s=o&&tl.test(o),a=!!i.marginUnstable||s&&/margin/i.test(o),c=!!i.paddingUnstable||s&&/padding/i.test(o),f=r.display!==void 0&&r.display.includes("grid"),l=r.transform!==void 0&&r.transform!=="none",u=[];for(let m in r)(Zc.test(m)||f&&(m==="grid-template-columns"||m==="grid-template-rows")||l&&m==="transform"||a&&m.charCodeAt(0)===109&&m.startsWith("margin-")||c&&m.charCodeAt(0)===112&&m.startsWith("padding-"))&&u.push(m);t.h&&!("height"in r)&&u.push("height"),t.b&&!("block-size"in r)&&u.push("block-size");let p=new Set(u),h=[e.tagName.toLowerCase()];for(let m in r)p.has(m)||h.push(m,r[m]);return t.rr=u,t.sig=h.join("")+""+u.join(""),u}function Ri(t,e,n,r,i){let o=i&&i.__styleShare?r&&r.__styleShare:null,s=o?o.ids.get(t):void 0;if(s===void 0||s===-1||t.shadowRoot||t.assignedSlot)return Ce(n,xn(t));let a=s+e,c=o.pseudo||(o.pseudo=new Map),f=c.get(a);if(f){let u={...f.snap},p=f.rr||Ei(f,t);for(let h=0;h<p.length;h++){let m=n.getPropertyValue(p[h]);m?u[p[h]]=m:delete u[p[h]]}return u}let l=Ce(n,xn(t));return c.set(a,{snap:l,rr:null,sig:null,h:"height"in l,b:"block-size"in l}),l}function ol(t,e=null,n={},r=null,i=null){let o=re.get(t),s=!!(n&&n.embedFonts),a=n&&n.excludeStyleProps||null;if(typeof a!="function"&&o&&Gr(o,t)&&o.embedFonts===s&&o.excludeStyleProps===a)return o.snapshot;let c=e||getComputedStyle(t),f,l=null,u=r&&r.st.snaps.get(r.id);if(u){f={...u.snap};let d=u.rr||Ei(u,t);l=[];for(let g=0;g<d.length;g++){let y=d[g],b=c.getPropertyValue(y);b?f[y]=b:delete f[y],l.push(b)}Object.defineProperty(f,"__needsBgInline",{value:u.snap.__needsBgInline,enumerable:!1}),u.snap.__bgClipTextFix!==void 0&&Object.defineProperty(f,"__bgClipTextFix",{value:u.snap.__bgClipTextFix,enumerable:!1})}else f=jc(c,n,t,nn(t,i)),r&&r.st.snaps.set(r.id,{snap:f,rr:null,sig:null,h:"height"in f,b:"block-size"in f});let p=!1;if(typeof t.computedStyleMap=="function"){let d;for(let g of gi)if(f[g]==="0px")try{d||(d=t.computedStyleMap()),d.get(g)?.toString()==="auto"&&(f[g]="auto",p=!0)}catch{}}bl(t,c,f);let h=ul(t,c,f);l!==null&&(p&&l.push("",...gi.map(d=>f[d])),h&&l.push(""+h),Br.set(f,u.sig+""+l.join("")+("height"in f?"":"")+("block-size"in f?"":"")));let m=Hr(t);return re.set(t,{env:Ft,stamp:kn(t,m),hosts:m,snapshot:f,embedFonts:s,excludeStyleProps:a}),f}function il(t,e){if(t&&t.session&&t.persist)return t;if(t&&(t.styleMap||t.styleCache||t.nodeMap)){let n=t.__ctx;return(!n||t.__ctxOpts!==e)&&(n={session:t,persist:{snapshotKeyCache:Ir,defaultStyle:L.defaultStyle,baseStyle:L.baseStyle,image:L.image,resource:L.resource,background:L.background},options:e||{}},t.__ctx=n,t.__ctxOpts=e),n}return{session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map},persist:{snapshotKeyCache:Ir,defaultStyle:L.defaultStyle,baseStyle:L.baseStyle,image:L.image,resource:L.resource,background:L.background},options:t||e||{}}}var sl=/%|[\\d.](?:em|rem|ex|ch|cap|ic|lh|rlh|v[whib]|vmin|vmax|cq[whbi]|cqmin|cqmax)\\b|\\b(?:calc|var|min|max|clamp|env|attr)\\(|\\b(?:auto|inherit|initial|unset|revert|currentcolor|-webkit-fill-available|fit-content|min-content|max-content)\\b/i,al=t=>t.tagName==="INPUT"||t.tagName==="TEXTAREA";function cl(t,e,n){if(!t.style||t.style.length===0)return;let r=Uc(t),i=r!=null&&!sl.test(t.getAttribute("style")||"");for(let o=0;o<t.style.length;o++){let s=t.style[o];if(i&&!r.has(s)&&!(s.startsWith("background")&&al(t)))continue;let a=n.getPropertyValue(s);a&&e.style.setProperty(s,a,t.style.getPropertyPriority(s))}}function pt(t,e,n,r){if(t.tagName==="STYLE")return;let i=il(n,r),o=i.options&&i.options.cache||"soft";o!=="disabled"&&Fe(t.ownerDocument),o==="disabled"&&!i.session.__bumpedForDisabled&&(Pt(),Ir.clear(),i.session.__bumpedForDisabled=!0);let{session:s,persist:a}=i;if(!s.styleCache.has(t)){let y=null;try{y=getComputedStyle(t)}catch{}s.styleCache.set(t,y||getComputedStyle((t.ownerDocument||document).documentElement))}let c=s.styleCache.get(t);t.getAttribute?.("style")&&cl(t,e,c);let f=c.getPropertyValue("animation-name");e&&e.style&&f&&f!=="none"&&e.style.setProperty("animation","none","important");let l=t.tagName?.toLowerCase()||"div";if(Xe.has(l)){let y={};Object.defineProperty(y,"__needsBgInline",{value:_i(c),enumerable:!1});let b=Hr(t);re.set(t,{env:Ft,stamp:kn(t,b),hosts:b,snapshot:y,embedFonts:!!(i.options&&i.options.embedFonts),excludeStyleProps:i.options&&i.options.excludeStyleProps||null}),s.styleMap.set(e,"");return}let u=null;if(i.options&&i.options.__styleShare&&s.styleMap){let y=nl(s),b=rl(t,y),S=t.ownerDocument||document,k=S.activeElement;b!==-1&&!el.has(t.tagName)&&!(k&&k!==S.body&&k!==S.documentElement&&k===t)&&(!t.getRootNode||t.getRootNode()===S)&&!t.shadowRoot&&!t.assignedSlot&&(u={st:y,id:b})}let p=ol(t,c,i.options,u,s);if(t.getAttribute?.("style"))for(let y of["top","right","bottom","left"]){let b=`margin-${y}`;p[b]==="auto"&&e.style.setProperty(b,"auto","important")}p.__bgClipTextFix&&e&&e.style&&(e.style.setProperty("background-image","none","important"),e.style.setProperty("background-color","transparent","important"),e.style.setProperty("color",p.__bgClipTextFix,"important"),e.style.setProperty("-webkit-text-fill-color",p.__bgClipTextFix,"important")),ll(t,c,p),e.style?.length&&p["box-sizing"]==="border-box"&&c.getPropertyValue("box-sizing")!=="border-box"&&hl(t,e,p);let h=Ti(t);if(h){let y=c.getPropertyValue("min-width");(!y||y==="auto"||y==="0px")&&(p["min-width"]="0px")}let m=Jc(p,l),d=!0;if(wn(l,(p.display||"").toLowerCase())){d=Gc(t),d&&Pr(l,p,h)&&Xc(t,c,h)&&(d=!1),m=`${m}${d?"|c":""}${h?"|f":""}`;let y=p["text-wrap-mode"]||p["white-space"]||"";d&&y!=="nowrap"&&y!=="pre"&&(s.reconcileRisk=(s.reconcileRisk||0)+1)}let g=a.snapshotKeyCache.get(m);g===void 0&&(g=ke(p,l,d,h),a.snapshotKeyCache.size>=Wc&&a.snapshotKeyCache.delete(a.snapshotKeyCache.keys().next().value),a.snapshotKeyCache.set(m,g)),s.styleMap.set(e,g)}function ll(t,e,n){let r=e.getPropertyValue("overflow-x"),i=e.getPropertyValue("overflow-y");if((r==="visible"||!r)&&(i==="visible"||!i)||e.getPropertyValue("box-sizing")==="border-box"||typeof t.clientWidth!="number"||!t.offsetWidth)return;let o=f=>parseFloat(f)||0,s=t.offsetWidth-t.clientWidth-o(e.getPropertyValue("border-left-width"))-o(e.getPropertyValue("border-right-width")),a=t.offsetHeight-t.clientHeight-o(e.getPropertyValue("border-top-width"))-o(e.getPropertyValue("border-bottom-width")),c=(f,l)=>{let u=n[f];if(!u||!u.endsWith("px"))return;let p=parseFloat(u);Number.isFinite(p)&&(n[f]=`${Math.round((p+l)*1e3)/1e3}px`)};s>=2&&(c("width",s),c("inline-size",s)),a>=2&&(c("height",a),c("block-size",a))}var fl=["border-top-width","border-right-width","border-bottom-width","border-left-width"],Fi=["width","inline-size","height","block-size"];function ul(t,e,n){if(!fl.some(c=>n[c]?.includes("."))||e.getPropertyValue("box-sizing")==="border-box"||n.display==="inline")return"";for(let c of["width","height"]){let f=n[`min-${c}`],l=n[`max-${c}`];if(f&&f!=="0px"&&f!=="auto"||l&&l!=="none")return""}let r=c=>parseFloat(n[c])||0,i=r("padding-left")+r("padding-right")+r("border-left-width")+r("border-right-width"),o=r("padding-top")+r("padding-bottom")+r("border-top-width")+r("border-bottom-width"),s=(n["writing-mode"]||"horizontal-tb")!=="horizontal-tb";for(let c of Fi){let f=n[c];if(!f||!f.endsWith("px"))continue;let u=c==="width"||c==="inline-size"&&!s||c==="block-size"&&s?i:o;n[c]=`${Math.round((parseFloat(f)+u)*1e3)/1e3}px`}n["box-sizing"]="border-box";let a="";if(e.getPropertyValue("overflow-x")==="auto"){let c=t.scrollWidth<=t.clientWidth;n["overflow-x"]=c?"hidden":"auto",c&&(a+="x")}if(e.getPropertyValue("overflow-y")==="auto"){let c=t.scrollHeight<=t.clientHeight;n["overflow-y"]=c?"hidden":"auto",c&&(a+="y")}return a}var dl=["box-sizing",...Fi,"overflow-x","overflow-y"],pl=/(?:box-sizing|width|height|inline-size|block-size|overflow(?:-[xy])?)\\s*:/i;function hl(t,e,n){if(pl.test(t.getAttribute("style")))for(let r of dl)e.style.getPropertyValue(r)&&n[r]&&e.style.setProperty(r,n[r],e.style.getPropertyPriority(r))}function ml(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 Ti(t){let e=t.parentElement;if(!e)return!1;let n=O(e).display||"";return n.includes("flex")||n.includes("grid")}function gl(t){for(let r=t.firstChild;r;r=r.nextSibling)if(r.nodeType===3&&/\\S/.test(r.nodeValue))return!0;let e=t.firstElementChild,n=t.lastElementChild;if(e&&e.tagName==="BR"||n&&n.tagName==="BR")return!0;for(let r=t.firstElementChild;r;r=r.nextElementSibling){let i=O(r);if(i.display==="none")continue;let o=i.position;if(o!=="absolute"&&o!=="fixed")return!0}return!1}function yl(t){let e=t.getBoundingClientRect().top,n=-1/0,r=null;for(let i=t.firstChild;i;i=i.nextSibling){if(i.nodeType===3){if(!/\\S/.test(i.nodeValue||""))continue;r=r||document.createRange(),r.selectNode(i);let a=r.getBoundingClientRect();(a.width||a.height)&&(n=Math.max(n,a.bottom));continue}if(i.nodeType!==1)continue;let o=O(i);if(o.display==="none")continue;let s=o.position;s==="absolute"||s==="fixed"||o.float&&o.float!=="none"||(n=Math.max(n,i.getBoundingClientRect().bottom))}return n===-1/0?NaN:n-e}function bl(t,e,n){if(Rt(t)&&t.style&&t.style.height)return;let r=t.tagName&&t.tagName.toLowerCase();if(!r||!["div","section","article","main","aside","header","footer","nav"].includes(r)||e.aspectRatio&&e.aspectRatio!=="none"&&e.aspectRatio!=="auto")return;let o=e.display||"";if(o.includes("flex")||o.includes("grid"))return;let s=e.position;if(s==="absolute"||s==="fixed"||s==="sticky"||e.transform!=="none"||ml(e)||Ti(t))return;let a=e.overflowX||e.overflow||"visible",c=e.overflowY||e.overflow||"visible";if(a!=="visible"||c!=="visible")return;let f=e.clip;if(f&&f!=="auto"&&f!=="rect(auto, auto, auto, auto)"||e.visibility==="hidden"||e.opacity==="0"||!gl(t))return;let l=parseFloat(e.height),u=yl(t);Number.isFinite(l)&&Number.isFinite(u)&&Math.abs(l-u)>2||(delete n.height,delete n["block-size"])}Ae();var wl=new Set(["symbol","defs","pattern","marker","linearGradient","radialGradient","filter"]),Xr=new WeakMap,$i=-1;function An(t){let e=Dt();return e!==$i&&(Xr=new WeakMap,$i=e),Pi(t)}function Pi(t){let e=Xr.get(t);if(e!==void 0)return e;let n;if(t.namespaceURI==="http://www.w3.org/2000/svg"&&(t.localName==="mask"||t.localName==="clipPath"?n=!1:wl.has(t.localName)&&(n=!0)),n===void 0){let r=t.parentNode;n=!!(r&&r.nodeType===1)&&Pi(r)}return Xr.set(t,n),n}function Ni(t,e){if(t?.nodeType!==1||e?.nodeType!==1||An(t))return;let n=t.getAttribute?.("style"),r=!!(n&&n.includes("var("));if(!r&&t.attributes?.length){let o=t.attributes;for(let s=0;s<o.length;s++){let a=o[s];if(a&&typeof a.value=="string"&&!a.value.startsWith("data:")&&a.value.includes("var(")){r=!0;break}}}let i=null;if(r)try{i=getComputedStyle(t)}catch{}if(r){let o=t.style;if(o&&o.length){let s=new Set;for(let a=0;a<o.length;a++){let c=o[a];if(s.has(c))continue;s.add(c);let f=o.getPropertyValue(c);if(!f||!f.includes("var("))continue;let l=i&&i.getPropertyValue(c);if(l)try{e.style.setProperty(c,l.trim(),o.getPropertyPriority(c))}catch{}}}}if(r&&t.attributes?.length){let o=t.attributes;for(let s=0;s<o.length;s++){let a=o[s];if(!a||typeof a.value!="string"||a.value.startsWith("data:")||!a.value.includes("var("))continue;let c=a.name,f=i&&i.getPropertyValue(c);if(f)try{e.style.setProperty(c,f.trim())}catch{}}}}bt();bt();mt();Se();bn();kt();function $e(t){return!!(!t||t.startsWith("data:")||t.startsWith("blob:"))}function Pe(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 r=[];for(let o of t.split(",")){let s=o.trim().split(/\\s+/);if(!s[0])continue;let a=s[1]||"",c=1;/^\\d*\\.?\\d+x$/i.test(a)?c=parseFloat(a):/^\\d+w$/i.test(a)&&(c=parseInt(a,10)/n),r.push({url:s[0],d:c})}if(!r.length)return null;r.sort((o,s)=>o.d-s.d);let i=window.devicePixelRatio||1;return(r.find(o=>o.d>=i)||r[r.length-1]).url}function Li(t,e){let n=t.currentSrc||"";if(n&&!$e(n))return n;let r=e.querySelectorAll("source[srcset]"),i=null;for(let o of r){let s=o.getAttribute("srcset");if(!s||$e(s))continue;let a=o.getAttribute("type");if(a&&!xr.test(a.trim()))continue;let c=o.getAttribute("media");if(c)try{if(window.matchMedia(c).matches)return Pe(s,t)}catch{}i||(i=Pe(s,t))}return i}function Ii(t){let e=[t.getAttribute("data-src"),t.getAttribute("data-lazy-src"),t.getAttribute("data-original"),t.getAttribute("data-hi-res-src")];for(let r of e)if(r&&!$e(r))return r;let n=t.getAttribute("data-srcset")||t.getAttribute("data-lazy-srcset");if(n){let r=n.split(",")[0].trim().split(/\\s+/)[0];if(r&&!$e(r))return r}return null}Ct();function Sl(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})`}var xl=/::[a-zA-Z-]+(?:\\([^)]*\\))?$|:(?:before|after|first-letter|first-line)$/,vl=/^::?(?:before|after|first-letter)$/;function kl(t,e,n=!0,r){return Fr(t,",").map(i=>i.trim()).filter(Boolean).map(i=>{if(i.startsWith(":where(")&&i.includes("data-sd")||i.startsWith("@"))return i;let o=i.match(xl);if(o&&vl.test(o[0]))return":not(*)";let s=o?i.slice(0,o.index).trim():i,a=n?Sl(s,r):s;return`:where(${e} ${a})${o?o[0]:""}`}).join(", ")}function Oi(t,e,n){return t?(t=t.replace(/:host-context\\(([^)]+)\\)/g,(r,i)=>`:where(:where(${i.trim()}) ${e})`),t=t.replace(/:host\\(([^)]+)\\)/g,(r,i)=>`:where(${e}:is(${i.trim()}))`),t=t.replace(/:host\\b/g,`:where(${e})`),t=t.replace(/::slotted\\(([^)]+)\\)/g,(r,i)=>`:where(${e} ${i.trim()})`),t=t.replace(/(^|})(\\s*)([^@}{]+){/g,(r,i,o,s)=>{let a=kl(s,e,!0,n);return`${i}${o}${a}{`}),t):""}function Di(t){return t.shadowScopeSeq=(t.shadowScopeSeq||0)+1,`s${t.shadowScopeSeq}`}function ae(t){let e="";for(let n of t)if(n.media&&n.cssRules){let r=!1;try{r=window.matchMedia(n.conditionText||n.media.mediaText).matches}catch{}r&&(e+=ae(n.cssRules))}else if(n.constructor?.name==="CSSSupportsRule")e+=`@supports ${n.conditionText}{${ae(n.cssRules)}}`;else if(n.cssRules&&n.cssRules.length&&/@media/i.test(n.cssText)){let r=n.cssText.slice(0,n.cssText.indexOf("{")+1);e+=r+(n.style?n.style.cssText:"")+ae(n.cssRules)+"}"}else e+=n.cssText+`\n`;return e}function Bi(t){let e="";try{t.querySelectorAll("style").forEach(r=>{let i=null;try{i=r.sheet&&r.sheet.cssRules}catch{}e+=(i?ae(i):r.textContent||"")+`\n`});let n=t.adoptedStyleSheets||[];for(let r of n)try{r&&r.cssRules&&(e+=ae(r.cssRules))}catch{}}catch{}return e}function Ui(t,e,n){if(!e)return;let r=document.createElement("style");r.setAttribute("data-sd",n),r.textContent=e,t.insertBefore(r,t.firstChild||null)}function zi(t,e,n={}){try{let r=null,i=O(t).content;if(i&&i.includes("url(")){let f=i.match(/url\\(["\']?([^"\')]+)["\']?\\)/);f&&(r=f[1])}let o=t.closest?.("picture"),s=t.getAttribute("src")||"",a=t.getAttribute("srcset")||"",c=r||(o?Li(t,o):!a.trim()&&s.startsWith("data:")?s:t.currentSrc)||Pe(a,t)||t.src||"";if((!c||$e(c))&&n.resolvePicturePlaceholders!==!1){let f=Ii(t);f&&(c=f)}if(!c)return;e.getAttribute("src")!==c&&e.setAttribute("src",c),e.removeAttribute("srcset"),e.removeAttribute("sizes"),e.loading="eager",e.decoding="sync"}catch{}}function Hi(t){let e=new Set;if(!t)return e;let n=/var\\(\\s*(--[A-Za-z0-9_-]+)\\b/g,r;for(;r=n.exec(t);)e.add(r[1]);return e}function Cl(t,e){try{let r=getComputedStyle(t).getPropertyValue(e).trim();if(r)return r}catch{}try{let r=getComputedStyle(document.documentElement).getPropertyValue(e).trim();if(r)return r}catch{}return""}function ji(t,e,n){let r=[];for(let i of e){let o=Cl(t,i);o&&r.push(`${i}: ${o};`)}return r.length?`${n}{${r.join("")}}\n`:""}function Vi(t,e){if(!t)return;let n=r=>{let i=r.getAttribute("data-sd-slotted")||"";e?` ${i} `.includes(` ${e} `)||r.setAttribute("data-sd-slotted",i?`${i} ${e}`:e):r.setAttribute("data-sd-slotted",i)};t.nodeType===Node.ELEMENT_NODE&&n(t),t.querySelectorAll?.("*").forEach(n)}async function Al(t,e=3){let n=()=>{try{return t.contentDocument||t.contentWindow?.document||null}catch{return null}},r=n(),i=0;for(;i<e&&(!r||!r.body&&!r.documentElement);)await new Promise(o=>setTimeout(o,0)),r=n(),i++;return r&&(r.body||r.documentElement)?r:null}function Ml(t){let e=t.getBoundingClientRect(),n=0,r=0,i=0,o=0;try{let c=getComputedStyle(t);n=parseFloat(c.borderLeftWidth)||0,r=parseFloat(c.borderRightWidth)||0,i=parseFloat(c.borderTopWidth)||0,o=parseFloat(c.borderBottomWidth)||0}catch{}let s=Math.max(0,Math.round(e.width-(n+r))),a=Math.max(0,Math.round(e.height-(i+o)));return{contentWidth:s,contentHeight:a,rect:e}}function wt(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 r=getComputedStyle(t);if(e===0){let i=parseFloat(r.width);!isNaN(i)&&i>0&&(e=i)}if(n===0){let i=parseFloat(r.height);!isNaN(i)&&i>0&&(n=i)}}catch{}if(e===0||n===0)try{if(e===0){let r=parseFloat(t.getAttribute("width"));!isNaN(r)&&r>0&&(e=r)}if(n===0){let r=parseFloat(t.getAttribute("height"));!isNaN(r)&&r>0&&(n=r)}}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 _l(t,e,n){let r=t.defaultView,i=r?r.scrollX:0,o=r?r.scrollY:0,s=t.body?t.body.scrollLeft:0,a=t.body?t.body.scrollTop:0,c=t.documentElement?t.documentElement.scrollLeft:0,f=t.documentElement?t.documentElement.scrollTop:0,l=0,u=0,p=0,h=0;try{let d=r&&t.body?r.getComputedStyle(t.body):null;d&&(l=(parseFloat(d.marginTop)||0)+(parseFloat(d.paddingTop)||0),u=(parseFloat(d.marginRight)||0)+(parseFloat(d.paddingRight)||0),p=(parseFloat(d.marginBottom)||0)+(parseFloat(d.paddingBottom)||0),h=(parseFloat(d.marginLeft)||0)+(parseFloat(d.paddingLeft)||0))}catch{}let m=t.createElement("style");if(m.setAttribute("data-sd-iframe-pin",""),tt(m),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 ${u}px ${p}px ${h}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),se(t.documentElement),i||o)try{t.body&&(t.body.scrollLeft=i,t.body.scrollTop=o),t.documentElement&&(t.documentElement.scrollLeft||(t.documentElement.scrollLeft=i),t.documentElement.scrollTop||(t.documentElement.scrollTop=o))}catch{}return()=>{try{m.remove()}catch{}try{r&&typeof r.scrollTo=="function"&&r.scrollTo(i,o),t.body&&(t.body.scrollLeft=s,t.body.scrollTop=a),t.documentElement&&(t.documentElement.scrollLeft=c,t.documentElement.scrollTop=f)}catch{}se(t.documentElement)}}async function Yr(t,e,n){let r=await Al(t,3);if(!r)throw new Error("iframe document not accessible/ready");let{contentWidth:i,contentHeight:o,rect:s}=Ml(t),a=n?.snap;if(!a||typeof a.toPng!="function")throw new Error("[snapdom] iframe capture requires the snapdom entrypoints on options.snap \\u2014 capture through snapdom(el) (set automatically) or pass options.snap.");let c={...n,scale:1,clip:null,__pinned:!0},f=_l(r,i,o),l;try{l=await a.toPng(r.documentElement,c)}finally{f()}l.style.display="block",l.style.width=`${i}px`,l.style.height=`${o}px`;let u=document.createElement("div");return e.nodeMap.set(u,t),pt(t,u,e,n),u.style.overflow="hidden",u.style.display="block",u.style.width||(u.style.width=`${Math.round(s.width)}px`),u.style.height||(u.style.height=`${Math.round(s.height)}px`),u.appendChild(l),u}function qi(t){try{let e=t&&t.accentColor;if(e&&e!=="auto"&&e!=="none")return e;let n=t&&t.color;if(n)return n}catch{}return"#0a6ed1"}function Gi(t){let{width:e,height:n}=wt(t),r=t.getBoundingClientRect(),i;try{i=window.getComputedStyle(t)}catch{}let o=i?parseFloat(i.width):NaN,s=i?parseFloat(i.height):NaN,a=Number.isFinite(o)&&o>0?o:e||r.width||128,c=Number.isFinite(s)&&s>0?s:n||r.height||16,f=Number.parseFloat(t.min)||0,l=Number.isFinite(Number.parseFloat(t.max))?Number.parseFloat(t.max):100,u=Number.parseFloat(t.value),p=l-f,h=p>0&&Number.isFinite(u)?Math.min(1,Math.max(0,(u-f)/p)):.5,m="middle";try{i&&i.verticalAlign&&(m=i.verticalAlign)}catch{}let d=document.createElement("div");d.setAttribute("data-snapdom-input-replacement","range"),d.style.cssText=`display:inline-block;width:${a}px;height:${c}px;vertical-align:${m};flex-shrink:0;line-height:0;`;let g=document.createElementNS("http://www.w3.org/2000/svg","svg");g.setAttribute("width",String(a)),g.setAttribute("height",String(c)),g.setAttribute("viewBox",`0 0 ${a} ${c}`),g.style.overflow="visible",d.appendChild(g);function y(){let b=qi(i),S=!!t.disabled,k=Math.max(2,Math.min(4,c)),v=(c-k)/2,w=Math.max(10,Math.min(14,Math.max(c,10))),M=w/2,A=M+h*Math.max(0,a-w);g.innerHTML="";let C=(_,R,$,T)=>{let I=document.createElementNS("http://www.w3.org/2000/svg","rect");I.setAttribute("x",String(_)),I.setAttribute("y",String(v)),I.setAttribute("width",String(Math.max(0,R))),I.setAttribute("height",String(k)),I.setAttribute("rx",String(k/2)),I.setAttribute("fill",$),T&&I.setAttribute("fill-opacity",T),g.appendChild(I)};C(0,a,"#808080","0.4"),C(0,A,b);let x=document.createElementNS("http://www.w3.org/2000/svg","circle");x.setAttribute("cx",String(A)),x.setAttribute("cy",String(c/2)),x.setAttribute("r",String(M)),x.setAttribute("fill",b),g.appendChild(x),S&&g.setAttribute("opacity","0.5"),d.style.setProperty("width",`${a}px`,"important"),d.style.setProperty("height",`${c}px`,"important"),d.style.setProperty("min-width",`${a}px`,"important"),d.style.setProperty("min-height",`${c}px`,"important")}return y(),{el:d,applyVisual:y}}function Xi(t){let{width:e,height:n}=wt(t),r=t.getBoundingClientRect(),i;try{i=window.getComputedStyle(t)}catch{}let o=i?parseFloat(i.width):NaN,s=i?parseFloat(i.height):NaN,a=Math.round(e||r.width||0),c=Math.round(n||r.height||0),f=Number.isFinite(o)&&o>0?Math.round(o):Math.max(12,a||16),l=Number.isFinite(s)&&s>0?Math.round(s):Math.max(12,c||16),u=(t.type||"text").toLowerCase()==="checkbox",p=!!t.checked,h=!!t.indeterminate,d=Math.max(Math.min(f,l),12),g="middle";try{i&&i.verticalAlign&&(g=i.verticalAlign)}catch{}let y=document.createElement("div");y.setAttribute("data-snapdom-input-replacement",t.type||"checkbox"),y.style.cssText=`display:inline-block;width:${d}px;height:${d}px;vertical-align:${g};flex-shrink:0;line-height:0;`;let b=document.createElementNS("http://www.w3.org/2000/svg","svg");b.setAttribute("width",String(d)),b.setAttribute("height",String(d)),b.setAttribute("viewBox",`0 0 ${d} ${d}`),y.appendChild(b);function S(){let k=qi(i),v=2,w=v/2,M=d-v;if(b.innerHTML="",u){let A=document.createElementNS("http://www.w3.org/2000/svg","rect");if(A.setAttribute("x",String(w)),A.setAttribute("y",String(w)),A.setAttribute("width",String(M)),A.setAttribute("height",String(M)),A.setAttribute("rx","2"),A.setAttribute("ry","2"),A.setAttribute("fill",p?k:"none"),A.setAttribute("stroke",k),A.setAttribute("stroke-width",String(v)),b.appendChild(A),p){let C=document.createElementNS("http://www.w3.org/2000/svg","path");C.setAttribute("d",`M ${w+2} ${d/2} L ${d/2-1} ${d-w-2} L ${d-w-2} ${w+2}`),C.setAttribute("stroke","white"),C.setAttribute("stroke-width",String(Math.max(1.5,v))),C.setAttribute("fill","none"),C.setAttribute("stroke-linecap","round"),C.setAttribute("stroke-linejoin","round"),b.appendChild(C)}else if(h){let C=document.createElementNS("http://www.w3.org/2000/svg","rect"),x=Math.max(6,M-4);C.setAttribute("x",String((d-x)/2)),C.setAttribute("y",String((d-v)/2)),C.setAttribute("width",String(x)),C.setAttribute("height",String(v)),C.setAttribute("fill",k),C.setAttribute("rx","1"),b.appendChild(C)}}else{let A=document.createElementNS("http://www.w3.org/2000/svg","circle");if(A.setAttribute("cx",String(d/2)),A.setAttribute("cy",String(d/2)),A.setAttribute("r",String((d-v)/2)),A.setAttribute("fill",p?k:"none"),A.setAttribute("stroke",k),A.setAttribute("stroke-width",String(v)),b.appendChild(A),p){let C=document.createElementNS("http://www.w3.org/2000/svg","circle"),x=Math.max(2,(d-v*2)*.35);C.setAttribute("cx",String(d/2)),C.setAttribute("cy",String(d/2)),C.setAttribute("r",String(x)),C.setAttribute("fill","white"),b.appendChild(C)}}y.style.setProperty("width",`${d}px`,"important"),y.style.setProperty("height",`${d}px`,"important"),y.style.setProperty("min-width",`${d}px`,"important"),y.style.setProperty("min-height",`${d}px`,"important")}return S(),{el:y,applyVisual:S}}var rn=new ut(80);async function El(t){if(L.resource?.has(t))return L.resource.get(t);if(rn.has(t))return rn.get(t);let e=(async()=>{let n=await dt(t,{as:"dataURL",silent:!0});if(!n.ok||typeof n.data!="string")throw new Error(`[snapDOM] Failed to read blob URL: ${t}`);return L.resource?.set(t,n.data),n.data})();rn.set(t,e);try{let n=await e;return rn.set(t,n),n}catch(n){throw rn.delete(t),n}}var Wi=/\\bblob:[^)"\'\\s]+/g;function Mn(t){return typeof t=="string"&&t.startsWith("blob:")}function Rl(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 Fl(t){return t.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(", ")}function on(t,e){let n=t.querySelectorAll?Array.from(t.querySelectorAll(e)):[];return t.matches?.(e)&&n.unshift(t),n}async function _n(t,e=null){if(!t)return;let n=e,r=new Set,i=[],o=new Map,s=(d,g,y,b)=>{r.add(y),i.push(()=>{o.has(y)&&(d.setAttribute(g,o.get(y)),b?.())})},a=(d,g)=>{if(!d||!d.includes("blob:"))return;let y=d.match(Wi)||[];if(y.length){for(let b of y)r.add(b);i.push(()=>{let b=d.replace(Wi,S=>o.get(S)||S);b!==d&&g(b)})}},c=on(t,"img");for(let d of c)try{let y=d.getAttribute("src")||d.currentSrc||"";Mn(y)&&s(d,"src",y);let b=d.getAttribute("srcset");if(b&&b.includes("blob:")){let S=Rl(b);for(let k of S)Mn(k.url)&&r.add(k.url);i.push(()=>{let k=!1;for(let v of S)o.has(v.url)&&(v.url=o.get(v.url),k=!0);k&&d.setAttribute("srcset",Fl(S))})}}catch(g){H(n,"resolveBlobUrls for img failed",g)}let f=on(t,"image");for(let d of f)try{let g="http://www.w3.org/1999/xlink",y=d.getAttribute("href")||d.getAttributeNS?.(g,"href");Mn(y)&&s(d,"href",y,()=>d.removeAttributeNS?.(g,"href"))}catch(g){H(n,"resolveBlobUrls for SVG image href failed",g)}let l=on(t,"[style*=\'blob:\']");for(let d of l)try{let g=d.getAttribute("style");a(g,y=>d.setAttribute("style",y))}catch(g){H(n,"replaceBlobUrls in inline style failed",g)}let u=on(t,"style");for(let d of u)try{let g=d.textContent||"";a(g,y=>{d.textContent=y})}catch(g){H(n,"replaceBlobUrls in style tag failed",g)}let p=["poster"];for(let d of p){let g=on(t,`[${d}^=\'blob:\']`);for(let y of g)try{let b=y.getAttribute(d);Mn(b)&&s(y,d,b)}catch(b){H(n,`resolveBlobUrls for ${d} failed`,b)}}if(!r.size)return;let h=[...r],m=0;await Promise.all(Array.from({length:Math.min(4,h.length)},async()=>{for(;m<h.length;){let d=h[m++];try{o.set(d,await El(d))}catch(g){H(n,"blobUrlToDataUrl failed; keeping original URL",g)}}}));for(let d of i)try{d()}catch(g){H(n,"resolved blob URL write failed",g)}}yt();var Yi=new Set(["rgba(0, 0, 0, 0)","transparent"]),Kr="Highlight";function Ki(t){let n=(t.ownerDocument||document).getSelection?.();if(!n||n.isCollapsed||n.rangeCount===0)return null;let r=[];for(let i=0;i<n.rangeCount;i+=1){let o=n.getRangeAt(i);if(!o.collapsed)try{o.intersectsNode(t)&&r.push(o)}catch{}}return r.length?{ranges:r,styles:new Map}:null}function Tl(t,e){if(e.styles.has(t))return e.styles.get(t);let n;try{let r=getComputedStyle(t);if(r.userSelect==="none"||r.webkitUserSelect==="none"||r.getPropertyValue("-webkit-user-select")==="none")return e.styles.set(t,null),null;let i=getComputedStyle(t,"::selection"),o=[],s=i.backgroundColor,a=s&&!Yi.has(s)&&s!==r.backgroundColor;o.push(`background-color:${a?s:Kr}`),i.color&&i.color!==r.color&&o.push(`color:${i.color}`,`-webkit-text-fill-color:${i.color}`),i.textShadow&&i.textShadow!==r.textShadow&&o.push(`text-shadow:${i.textShadow}`),i.textDecorationLine&&i.textDecorationLine!=="none"&&i.textDecorationLine!==r.textDecorationLine&&o.push(`text-decoration:${i.textDecorationLine} ${i.textDecorationStyle||"solid"} ${i.textDecorationColor||"currentcolor"}`),n=o.join(";")}catch{n=`background-color:${Kr}`}return e.styles.set(t,n),n}function Qi(t,e){let n=t.data;if(!n)return null;let r=t.parentElement;if(!r)return null;let i=[];for(let f of e.ranges){let l=!1;try{l=f.intersectsNode(t)}catch{}if(!l)continue;let u=f.startContainer===t?f.startOffset:0,p=f.endContainer===t?f.endOffset:n.length;p>u&&i.push([u,p])}if(i.length===0)return null;let o=Tl(r,e);if(!o)return null;i.sort((f,l)=>f[0]-l[0]);let s=t.ownerDocument||document,a=s.createDocumentFragment(),c=0;for(let[f,l]of i){f>c&&a.append(s.createTextNode(n.slice(c,f)));let u=s.createElement("span");u.setAttribute("data-snapdom-selection",""),u.setAttribute("style",`all:unset;${o}`),u.textContent=n.slice(f,l),a.append(u),c=l}return c<n.length&&a.append(s.createTextNode(n.slice(c))),a}var En=t=>Number.parseFloat(t)||0,$l=["font-family","font-size","font-weight","font-style","font-variant","font-stretch","letter-spacing","word-spacing","text-transform","text-indent","text-align","line-height","tab-size","direction"];function Pl(t,e){try{let r=getComputedStyle(t,"::selection").backgroundColor;if(r&&!Yi.has(r)&&r!==e.backgroundColor)return r}catch{}return Kr}function Ji(t,e){let n=t.ownerDocument||document;if(n.activeElement!==t)return;let r=null,i=null;try{r=t.selectionStart,i=t.selectionEnd}catch{return}if(r==null||i==null||r===i)return;let o=t.value||"";if(t.localName==="input"&&t.type==="password"&&(o="\\u2022".repeat(o.length)),!o)return;let s=getComputedStyle(t),a=t.localName==="textarea",c=En(s.paddingLeft),f=En(s.paddingTop),l=t.clientWidth-c-En(s.paddingRight),u=t.clientHeight-f-En(s.paddingBottom),p=n.createElement("div");p.style.cssText="position:absolute;top:0;left:-99999px;visibility:hidden;margin:0;border:0;padding:0;box-sizing:content-box;";for(let g of $l)p.style.setProperty(g,s.getPropertyValue(g));a?(p.style.whiteSpace="pre-wrap",p.style.overflowWrap="break-word",p.style.width=`${Math.max(0,l)}px`):p.style.whiteSpace="pre";let h=n.createElement("span");h.textContent=o.slice(r,i),p.append(n.createTextNode(o.slice(0,r)),h,n.createTextNode(o.slice(i))),n.body.appendChild(p);let m=[];try{let g=p.getBoundingClientRect(),y=-t.scrollLeft,b=-t.scrollTop;if(!a){b+=Math.max(0,(u-g.height)/2);let S=s.direction==="rtl",k=s.textAlign;k==="start"?k=S?"right":"left":k==="end"&&(k=S?"left":"right");let v=l-g.width;v>0&&(k==="right"?y+=v:k==="center"&&(y+=v/2))}for(let S of h.getClientRects())S.width<=0||S.height<=0||m.push({x:c+(S.left-g.left)+y,y:f+(S.top-g.top)+b,width:S.width,height:S.height})}finally{p.remove()}if(m.length===0)return;let d=Pl(t,s);e.__snapdomFieldSelection={images:m.map(()=>`linear-gradient(${d},${d})`),positions:m.map(g=>`${g.x}px ${g.y}px`),sizes:m.map(g=>`${g.width}px ${g.height}px`),repeats:m.map(()=>"no-repeat"),origins:m.map(()=>"padding-box"),clips:m.map(()=>"padding-box"),base:{image:s.backgroundImage,position:s.backgroundPosition,size:s.backgroundSize,repeat:s.backgroundRepeat,origin:s.backgroundOrigin,clip:s.backgroundClip}}}function Zi(t){for(let e of t.keys()){let n=e.__snapdomFieldSelection;if(!n)continue;delete e.__snapdomFieldSelection;let{images:r,positions:i,sizes:o,repeats:s,origins:a,clips:c,base:f}=n,l=e.style.backgroundImage||f.image;l&&l!=="none"?(r.push(l),i.push(e.style.backgroundPosition||f.position),o.push(e.style.backgroundSize||f.size),s.push(e.style.backgroundRepeat||f.repeat),a.push(e.style.backgroundOrigin||f.origin),c.push(e.style.backgroundClip||f.clip)):(r.push("linear-gradient(transparent,transparent)"),i.push("0% 0%"),o.push("auto"),s.push("repeat"),a.push(f.origin||"padding-box"),c.push(f.clip||"border-box")),e.style.backgroundImage=r.join(","),e.style.backgroundPosition=i.join(","),e.style.backgroundSize=o.join(","),e.style.backgroundRepeat=s.join(","),e.style.backgroundOrigin=a.join(","),e.style.backgroundClip=c.join(",")}}Ct();var Qr=new Map,ts=new Set(["IFRAME"]);function Ne(t,e){Qr.set(String(t).toUpperCase(),e)}function Rn(t){let e=O(t),n=e.display;if(n==="none")return null;let r=/^(block|inline-block|flow-root|flex|inline-flex|grid|inline-grid|list-item)$/.test(n),i=h=>parseFloat(h)||0,o=(h,m,d,g,y)=>{if(!r||!h?.endsWith("px"))return null;let b=parseFloat(h);if(!Number.isFinite(b)||b<0)return null;if(e.boxSizing==="border-box")return b;let S=g-y-d;return b+m+d+(S>0&&b+m<y+S/2?S:0)},[s,a,c,f]=/scroll|auto/.test(e.overflow)?[t.offsetWidth,t.clientWidth,t.offsetHeight,t.clientHeight]:[0,0,0,0],l=o(e.width,i(e.paddingLeft)+i(e.paddingRight),i(e.borderLeftWidth)+i(e.borderRightWidth),s,a),u=o(e.height,i(e.paddingTop)+i(e.paddingBottom),i(e.borderTopWidth)+i(e.borderBottomWidth),c,f);if(l===null||u===null){let{width:h,height:m}=wt(t),d=h,g=m;if(l===null&&!d||u===null&&!g){let y=t.getBoundingClientRect();d||(d=y.width||0),g||(g=y.height||0)}l??(l=d),u??(u=g)}let p=document.createElement("div");return p.style.cssText=`display:${n==="inline"?"inline-block":n};box-sizing:border-box;width:${l}px;height:${u}px;visibility:hidden;`,p}var Nl=new Set(["style","option","optgroup"]),Fn=200,Ll=new Set(["img","canvas","video","iframe","object","embed"]);function es(t,e){return t.right>=e.left-Fn&&t.left<=e.right+Fn&&t.bottom>=e.top-Fn&&t.top<=e.bottom+Fn}function Il(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 r=O(t);if(r.display==="inline"&&!Ll.has((t.localName||"").toLowerCase()))return!1;let i=e.rect,o=t.scrollWidth||0,s=t.scrollHeight||0,a={left:r.direction==="rtl"?Math.min(n.left,n.right-o):n.left,top:n.top,right:Math.max(n.right,n.left+o),bottom:Math.max(n.bottom,n.top+s)},c=r.writingMode||"";if((c.startsWith("vertical")||c.startsWith("sideways"))&&(a.top=Math.min(n.top,n.bottom-s),a.left=Math.min(a.left,n.right-o)),es(a,i))return!1;let f=(t.ownerDocument||document).createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;f.nextNode();){let l=f.currentNode.getBoundingClientRect();if((l.width>0||l.height>0)&&es(l,i))return!1}return!0}function Wl(t,e,n){let r=t.cloneNode(!1);t.tagName==="IMG"&&(r.removeAttribute("src"),r.removeAttribute("srcset"),r.removeAttribute("sizes")),pt(t,r,e,n);let{width:i,height:o}=wt(t);i>0&&(r.style.width=`${i}px`,r.style.minWidth=`${i}px`,r.style.maxWidth=`${i}px`),o>0&&(r.style.height=`${o}px`,r.style.minHeight=`${o}px`,r.style.maxHeight=`${o}px`),r.style.visibility="hidden";let s=t.parentElement?O(t.parentElement).display:"",a=O(t).position;if(!/flex|grid|table/.test(s)&&(a==="static"||a==="relative")){let c=p=>{let h=O(p);return h.display!=="none"&&h.position!=="absolute"&&h.position!=="fixed"},f=t.getBoundingClientRect(),l=t.previousElementSibling;for(;l&&!c(l);)l=l.previousElementSibling;if(l){let p=f.top-l.getBoundingClientRect().bottom;p>=0&&(r.style.marginTop=`${p}px`)}let u=t.nextElementSibling;for(;u&&!c(u);)u=u.nextElementSibling;if(u){let p=u.getBoundingClientRect().top-f.bottom;p>=0&&(r.style.marginBottom=`${p}px`)}}return r.style.boxSizing="border-box",r}async function Qt(t,e,n){if(!t)throw new Error("Invalid node");e.slicer?.due()&&await e.slicer.pause();let r=new Set,i=null,o=null;if(t.nodeType===Node.ELEMENT_NODE){let l=(t.localName||t.tagName||"").toLowerCase(),u=qt(t);if(u&&(t.id==="snapdom-sandbox"||t.hasAttribute("data-snapdom-sandbox"))||t!==n.element&&u||Tr.has(l))return null;if(l==="foreignobject"&&t.parentElement?.closest?.("foreignObject"))return H(e,"Nested <foreignObject> unsupported; skipped"),null;if(l==="source"&&t.parentElement?.localName==="picture")return null}if(t.nodeType===Node.TEXT_NODE){if(e.selection){let l=Qi(t,e.selection);if(l)return l}return t.cloneNode(!0)}if(t.nodeType!==Node.ELEMENT_NODE)return t.cloneNode(!0);if(t.getAttribute("data-capture")==="exclude"){if(n.excludeMode==="hide")return Rn(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 Rn(t);if(n.excludeMode==="remove")return null}}catch(u){console.warn(`Invalid exclude selector: ${l}`,u)}if(n.excludePredicates)for(let l of n.excludePredicates)try{if(l(t))return n.excludeMode==="remove"?null:Rn(t)}catch(u){console.warn("Error in exclude predicate:",u)}if(typeof n.filter=="function")try{if(!n.filter(t)){if(n.filterMode==="hide")return Rn(t);if(n.filterMode==="remove")return null}}catch(l){console.warn("Error in filter function:",l)}if(t!==n.element&&!Nl.has(t.localName)&&!It(t)&&O(t).display==="none"){let l=t.cloneNode(!1);t.tagName==="IMG"&&(l.removeAttribute("src"),l.removeAttribute("srcset")),l.style.setProperty("display","none","important");for(let u of t.querySelectorAll("style")){let p=await Qt(u,e,n);p&&l.appendChild(p)}return l}if(e.clip&&Il(t,e.clip))return Wl(t,e,n);if(n.__resolveNodeHooks)for(let l of n.__resolveNodeHooks){let u;try{u=await l(t,n)}catch(p){H(e,"resolveNode plugin hook failed",p)}if(u===null)return null;if(u?.nodeType)return u.nodeType===Node.ELEMENT_NODE&&(e.nodeMap.set(u,t),pt(t,u,e,n)),u}{let l=ts.has(t.tagName)&&Qr.get(t.tagName);if(l){let u=await l(t,e,n);if(u!==void 0)return u}}if(t.getAttribute("data-capture")==="placeholder"){let l=t.cloneNode(!1);e.nodeMap.set(l,t),pt(t,l,e,n);let u=document.createElement("div");return u.textContent=t.getAttribute("data-placeholder-text")||"",u.style.cssText="color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;",l.appendChild(u),l}{let l=!ts.has(t.tagName)&&Qr.get(t.tagName);if(l){let u=await l(t,e,n);if(u!==void 0)return u}}let s;try{if(s=t.cloneNode(!1),Ni(t,s),e.nodeMap.set(s,t),t.tagName==="IMG"){zi(t,s,n);try{let l=window.getComputedStyle(t),u=parseFloat(l.width),p=parseFloat(l.height);if(!(u>0)||!(p>0)){let d=wt(t),g=b=>parseFloat(l.getPropertyValue(b))||0,y=l.getPropertyValue("box-sizing")==="border-box";u>0||(u=d.width-(y?0:g("padding-left")+g("padding-right")+g("border-left-width")+g("border-right-width"))),p>0||(p=d.height-(y?0:g("padding-top")+g("padding-bottom")+g("border-top-width")+g("border-bottom-width")))}let h=Math.round((u||0)*1e3)/1e3,m=Math.round((p||0)*1e3)/1e3;h&&(s.dataset.snapdomWidth=String(h)),m&&(s.dataset.snapdomHeight=String(m))}catch(l){H(e,"IMG measurement failed",l)}try{let l=t.getAttribute("style")||"",u=window.getComputedStyle(t),p=S=>{let k=l.match(new RegExp(`${S}\\\\s*:\\\\s*([^;]+)`,"i")),v=k?k[1].trim():u.getPropertyValue(S);return/%|auto/i.test(String(v||""))},h=parseFloat(s.dataset.snapdomWidth||"0")||0,m=parseFloat(s.dataset.snapdomHeight||"0")||0,d=p("width")||!(h>0),g=p("height")||!(m>0);d&&h>0&&(s.style.width=`${h}px`),g&&m>0&&(s.style.height=`${m}px`);let y=u.getPropertyValue("object-fit"),b=u.getPropertyValue("object-position");y&&y!=="fill"?(s.style.objectFit=y,b&&(s.style.objectPosition=b)):(h>0&&(s.style.minWidth=`${h}px`),m>0&&(s.style.minHeight=`${m}px`))}catch(l){H(e,"IMG dimension freeze failed",l)}}}catch(l){throw console.error("[Snapdom] Failed to clone node:",t,l),l}let a=null;if(st(t,"textarea")){let{width:l,height:u}=wt(t),p=l||t.getBoundingClientRect().width||0,h=u||t.getBoundingClientRect().height||0;p&&(s.style.width=`${p}px`),h&&(s.style.height=`${h}px`)}if(st(t,"input")){let l=(t.type||"text").toLowerCase();if((l==="checkbox"||l==="radio")&&($t()||t.indeterminate)){let{el:p,applyVisual:h}=Xi(t);e.nodeMap.set(p,t),a=h,s=p}else if(l==="range"&&($t()||X())){let{el:p,applyVisual:h}=Gi(t);e.nodeMap.set(p,t),a=h,s=p}else if(l==="color"&&X()){let p=s,h=t.value||"#000000";a=()=>{p.style.setProperty("background-color",h,"important"),p.style.setProperty("color","transparent","important"),p.style.setProperty("-webkit-text-fill-color","transparent","important"),p.style.setProperty("appearance","none","important"),p.style.setProperty("-webkit-appearance","none","important")},p.removeAttribute("value")}else if((l==="date"||l==="time"||l==="datetime-local")&&($t()||X())){s.setAttribute("type","text");let p=t.value;l==="date"&&t.valueAsDate&&(p=t.valueAsDate.toLocaleDateString(void 0,{timeZone:"UTC"})),s.value=p,s.setAttribute("value",p)}else{let p=Ge(t)?Cr(t.value):t.value;s.value=p,s.setAttribute("value",p),t.checked!==void 0&&(s.checked=t.checked,t.checked?s.setAttribute("checked",""):s.removeAttribute("checked"),t.indeterminate&&(s.indeterminate=t.indeterminate))}}if((st(t,"input")||st(t,"textarea"))&&!t.value&&t.placeholder)try{let l=window.getComputedStyle(t,"::placeholder"),u=l&&l.color;if(u&&u!=="rgba(0, 0, 0, 0)"){let p="snapdom-ph-"+(Math.random()*1e6|0);s.classList.add(p);let h=document.createElement("style");h.textContent=`.${p}::placeholder{color:${u}!important;opacity:${l.opacity||"1"}!important;-webkit-text-fill-color:${u}!important;}`,s.prepend(h)}}catch{}if(st(t,"select")&&(i=new Set(Array.from(t.options).filter(l=>l.selected))),st(t,"textarea")&&(o=t.value),st(t,"input")||st(t,"textarea")||st(t,"select")){t.disabled&&s.setAttribute("disabled",""),t.required&&s.setAttribute("required",""),t.readOnly&&s.setAttribute("readonly","");let l=t;l.min!==void 0&&l.min!==""&&s.setAttribute("min",l.min),l.max!==void 0&&l.max!==""&&s.setAttribute("max",l.max),l.pattern!==void 0&&l.pattern!==""&&s.setAttribute("pattern",l.pattern);let u=t.getAttribute("aria-invalid");u!==null&&s.setAttribute("aria-invalid",u)}if(An(t)||pt(t,s,e,n),a&&a(),n.captureSelection&&(st(t,"input")||st(t,"textarea")))try{Ji(t,s)}catch(l){H(e,"inlineTextFieldSelection failed",l)}if(It(t)&&!An(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","color"];try{let u=window.getComputedStyle(t);for(let p of l){let h=u.getPropertyValue(p);h&&s.style.setProperty(p,h)}}catch{}}if(t.shadowRoot){Vr(t.shadowRoot);try{let b=t.shadowRoot.querySelectorAll("slot");for(let S of b){let k=S.assignedNodes?.()||[];for(let v of k)r.add(v)}}catch{}let l=Di(e),u=`[data-sd="${l}"]`;e.shadowScopes||(e.shadowScopes=new WeakMap),e.shadowScopes.set(t.shadowRoot,l);try{s.setAttribute("data-sd",l)}catch{}let p=Bi(t.shadowRoot);!e.__shadowPseudo&&/::?(?:before|after|first-l|marker)|counter/.test(p)&&(e.__shadowPseudo=!0);let h=Oi(p,u,l),m=Hi(p),d=ji(t,m,u);Ui(s,d+h,l);let g=document.createDocumentFragment(),y=await Promise.all(Array.from(t.shadowRoot.childNodes).map(b=>b.nodeType===Node.ELEMENT_NODE&&b.tagName==="STYLE"?null:Qt(b,e,n).catch(()=>null)));g.append(...y.filter(b=>!!b)),s.appendChild(g)}if(t.tagName==="SLOT"){let l=e.shadowScopes?.get(t.getRootNode()),u=t.assignedNodes?.()||[],p=u.length?t.assignedNodes?.({flatten:!0})||u:[],h=p.length?p:Array.from(t.childNodes),m=document.createDocumentFragment(),d=await Promise.all(h.map(g=>Qt(g,e,n).then(y=>(y&&u.length&&Vi(y,l),y||null)).catch(()=>null)));return m.append(...d.filter(g=>!!g)),m}let c=l=>r.has(l)||t.shadowRoot&&!l.assignedSlot,f=await Promise.all(Array.from(t.childNodes).map(l=>c(l)?null:Qt(l,e,n).catch(()=>null)));if(s.append(...f.filter(l=>!!l)),i&&st(s,"select")){let l=!1;for(let u of s.options){let p=i.has(e.nodeMap.get(u));u.selected=p,p?u.setAttribute("selected",""):u.removeAttribute("selected"),l||(l=p)}if(!l&&!s.multiple){let u=s.ownerDocument.createElement("option");u.hidden=!0,u.style.setProperty("display","none","important"),u.setAttribute("selected",""),u.value="",s.appendChild(u)}}return o!==null&&st(s,"textarea")&&(s.textContent=o),s}async function Ol(t,e,n){let r=!1;try{r=!!(t.contentDocument||t.contentWindow?.document)}catch(i){H(e,"iframe same-origin probe failed",i)}if(r)try{return await Yr(t,e,n)}catch(i){console.warn("[SnapDOM] iframe rasterization failed, fallback:",i)}if(r||console.warn("[snapdom] Unreadable cross-origin <iframe>; keeping its box. Use { placeholders: false } to hide it.",t),n.placeholders){let{width:i,height:o}=wt(t),s=document.createElement("div");return s.style.cssText=`width:${i}px;height:${o}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;`,pt(t,s,e,n),s}else{let{width:i,height:o}=wt(t),s=document.createElement("div");return s.style.cssText=`display:inline-block;width:${i}px;height:${o}px;visibility:hidden;`,pt(t,s,e,n),s}}function sn(t){try{let e=Math.max(1,Math.min(32,t.width)),n=Math.max(1,Math.min(32,t.height)),r=document.createElement("canvas");r.width=e,r.height=n;let i=r.getContext("2d",{willReadFrequently:!0});if(!i)return!1;i.drawImage(t,0,0,e,n);let o=i.getImageData(0,0,e,n).data;for(let s=3;s<o.length;s+=4)if(o[s]!==0)return!1;return!0}catch{return!1}}var Dl=.95;function Bl(t,e,n){try{let r=t.getImageData(0,0,e,n).data;for(let i=3;i<r.length;i+=4)if(r[i]!==255)return!1;return!0}catch{return!1}}async function Ul(t,e,n){let r="";try{let a=sn(t);a&&(await gt(),a=sn(t));let c=null;if(!a){c=t.getContext("2d",{willReadFrequently:!0});try{c&&c.getImageData(0,0,1,1)}catch{}X()&&await gt()}if(r=t.toDataURL("image/png"),!r||r==="data:,"){try{c&&c.getImageData(0,0,1,1)}catch{}if(await gt(),r=t.toDataURL("image/png"),!r||r==="data:,"){let f=document.createElement("canvas");f.width=t.width,f.height=t.height;let l=f.getContext("2d");l&&(l.drawImage(t,0,0),r=f.toDataURL("image/png"))}}}catch(a){H(e,"Canvas toDataURL failed; using fallback",a)}n&&n.debug&&r&&sn(t)&&H(e,"Empty canvas; capture after its first frame",t);let i=document.createElement("img");try{i.decoding="sync",i.loading="eager"}catch(a){H(e,"img decoding/loading hints failed",a)}r&&(i.src=r),i.width=t.width,i.height=t.height;let{width:o,height:s}=wt(t);return o>0&&(i.style.width=`${o}px`),s>0&&(i.style.height=`${s}px`),e.nodeMap.set(i,t),pt(t,i,e,n),i}async function zl(t,e,n){let r="",i=t.poster&&t.paused&&!t.currentTime&&!t.played.length,o=document.createElement("img");try{o.decoding="sync",o.loading="eager"}catch{}if(!i)try{let c=document.createElement("canvas");c.width=t.videoWidth||t.offsetWidth||320,c.height=t.videoHeight||t.offsetHeight||240;let f=c.getContext("2d");f&&(f.drawImage(t,0,0,c.width,c.height),r=c.toDataURL(Bl(f,c.width,c.height)?"image/jpeg":"image/png",Dl),(!r||r==="data:,")&&(r=""))}catch(c){H(e,"Video capture failed; using poster",c)}r?o.src=r:t.poster&&(o.src=t.poster),o.width=t.videoWidth||t.offsetWidth||0,o.height=t.videoHeight||t.offsetHeight||0;let{width:s,height:a}=wt(t);return s>0&&(o.style.width=`${s}px`),a>0&&(o.style.height=`${a}px`),o.style.objectFit="contain",e.nodeMap.set(o,t),pt(t,o,e,n),o}async function Hl(t,e,n){if(!t.controls)return;let{width:r,height:i}=wt(t),o=Math.round(r||t.offsetWidth||300),s=Math.round(i||t.offsetHeight||54),a=s/2,c=Math.max(4,s*.16),f=s*.34,l=o-s*.34,u=f+c+s*.55,p=Math.max(0,l-s*.7-u),h=Math.max(9,Math.round(s*.24)),m=`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${s}" viewBox="0 0 ${o} ${s}"><rect width="${o}" height="${s}" rx="${Math.min(s/2,10)}" fill="#f1f3f4"/><path d="M ${f} ${a-c} L ${f+c} ${a} L ${f} ${a+c} Z" fill="#5f6368"/><rect x="${u}" y="${a-1.5}" width="${p}" height="3" rx="1.5" fill="#bdc1c6"/><circle cx="${u}" cy="${a}" r="${Math.max(3,s*.09)}" fill="#5f6368"/><text x="${l}" y="${a}" fill="#5f6368" font-family="sans-serif" font-size="${h}" text-anchor="end" dominant-baseline="central">0:00</text></svg>`,d=document.createElement("img");try{d.decoding="sync",d.loading="eager"}catch{}return d.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(m)}`,d.width=o,d.height=s,d.style.width=`${o}px`,d.style.height=`${s}px`,e.nodeMap.set(d,t),pt(t,d,e,n),d}async function ns(t,e,n){let r=t.getAttribute("data")||t.getAttribute("src")||"",i=(t.getAttribute("type")||"").toLowerCase(),o=/^image\\//.test(i)||/\\.(png|jpe?g|gif|webp|avif|bmp|ico|svg)(\\?|#|$)/i.test(r);if(r&&o){let a=document.createElement("img");try{a.decoding="sync",a.loading="eager"}catch{}a.src=r;let{width:c,height:f}=wt(t);return c>0&&(a.style.width=`${c}px`),f>0&&(a.style.height=`${f}px`),e.nodeMap.set(a,t),pt(t,a,e,n),a}let s=null;try{s=t.contentDocument}catch{}if(s)try{let a=await Yr(t,e,n);if(a)return a}catch{}r&&console.warn(`[snapdom] <${t.localName}> capture failed (${i||"unknown type"}); using fallback children`)}Ne("IFRAME",Ol);Ne("CANVAS",Ul);Ne("VIDEO",zl);Ne("AUDIO",Hl);Ne("OBJECT",ns);Ne("EMBED",ns);bt();kt();Ae();mt();Ct();var jl=[/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],Le=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__||{});function Vl(t){return t.replace(/[.*+?^${}()|[\\]\\\\]/g,"\\\\$&")}function rs(t){let e=Array.isArray(t)?t:t?[t]:[],n=[];for(let r of e)r instanceof RegExp?n.push(r):typeof r=="string"?n.push(new RegExp(Vl(r),"i")):console.warn("[snapdom] Ignored invalid iconFont value:",r);return n}function Nt(t,e){let n=typeof t=="string"?t:"";for(let r of jl)if(r.test(n))return!0;if(e){for(let r of e)if(r instanceof RegExp&&r.test(n))return!0}return!!(/icon/i.test(n)||/glyph/i.test(n)||/symbols/i.test(n)||/feather/i.test(n)||/fontawesome/i.test(n))}function Jr(t,e){if(typeof t!="string"||!t)return!1;let n;try{n=new URL(t,typeof location<"u"?location.href:void 0)}catch{return Nt(t,e)}let r=n.searchParams.getAll("family").flatMap(i=>i.split("|")).map(i=>i.split(":")[0].trim()).filter(Boolean);return r.length?r.every(i=>Nt(i,e)):Nt(t,e)}function ql(t=""){let e=String(t).toLowerCase();return/\\bmaterial\\s*icons\\b/.test(e)||/\\bmaterial\\s*symbols\\b/.test(e)}var Tn=new Map;function Gl(t=""){let e=Object.create(null),n=String(t||""),r=/[\'"]?\\s*([A-Za-z]{3,4})\\s*[\'"]?\\s*([+-]?\\d+(?:\\.\\d+)?)\\s*/g,i;for(;i=r.exec(n);)e[i[1].toUpperCase()]=Number(i[2]);return e}async function Xl(t,e,n){let r=String(t||""),i=r.toLowerCase(),o=String(e||"").toLowerCase();if(/\\bmaterial\\s*icons\\b/.test(i)&&!/\\bsymbols\\b/.test(i))return{familyForMeasure:r,familyForCanvas:r};if(!/\\bmaterial\\s*symbols\\b/.test(i))return{familyForMeasure:r,familyForCanvas:r};let a=n&&(n.FILL??n.fill),c="outlined";/\\brounded\\b/.test(o)||/\\bround\\b/.test(o)?c="rounded":/\\bsharp\\b/.test(o)?c="sharp":/\\boutlined\\b/.test(o)&&(c="outlined");let f=a===1,l=null;if(f&&(c==="outlined"&&Le.materialIconsFilled?l={url:Le.materialIconsFilled,alias:"snapdom-mi-filled"}:c==="rounded"&&Le.materialIconsRound?l={url:Le.materialIconsRound,alias:"snapdom-mi-round"}:c==="sharp"&&Le.materialIconsSharp&&(l={url:Le.materialIconsSharp,alias:"snapdom-mi-sharp"})),!l)return{familyForMeasure:r,familyForCanvas:r};if(!Tn.has(l.alias))try{let p=new FontFace(l.alias,`url(${l.url})`,{style:"normal",weight:"400"});await p.load(),document.fonts.add(p),Tn.set(l.alias,!0)}catch{return Tn.set(l.alias,!1),{familyForMeasure:r,familyForCanvas:r}}if(Tn.get(l.alias)===!1)return{familyForMeasure:r,familyForCanvas:r};let u=`"${l.alias}"`;return{familyForMeasure:u,familyForCanvas:u}}async function Yl(t="Material Icons",e=24){try{await Promise.all([document.fonts.load(`400 ${e}px "${String(t).replace(/["\']/g,"")}"`),document.fonts.ready])}catch{}}function Kl(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 r=t.color?.trim();return r&&r!=="inherit"?r:"#000"}async function Ql(t,{family:e="Material Icons",weight:n="normal",fontSize:r=32,color:i="#000",variation:o="",className:s=""}={}){let a=String(e||"").replace(/^[\'"]+|[\'"]+$/g,""),c=window.devicePixelRatio||1,f=Gl(o),{familyForMeasure:l,familyForCanvas:u}=await Xl(a,s,f);await Yl(u.replace(/^["\']+|["\']+$/g,""),r);let p=document.createElement("span");tt(p),p.textContent=t,p.style.position="absolute",p.style.visibility="hidden",p.style.left="-99999px",p.style.whiteSpace="nowrap",p.style.fontFamily=l,p.style.fontWeight=String(n||"normal"),p.style.fontSize=`${r}px`,p.style.lineHeight="1",p.style.margin="0",p.style.padding="0",p.style.fontFeatureSettings="\'liga\' 1",p.style.fontVariantLigatures="normal",p.style.color=i,document.body.appendChild(p);let h=p.getBoundingClientRect(),m=Math.max(1,Math.ceil(h.width)),d=Math.max(1,Math.ceil(h.height));document.body.removeChild(p);let g=document.createElement("canvas");g.width=m*c,g.height=d*c;let y=g.getContext("2d");y.scale(c,c),y.font=`${n?`${n} `:""}${r}px ${u}`,y.textAlign="left",y.textBaseline="top",y.fillStyle=i;try{y.fontKerning="normal"}catch{}return y.fillText(t,0,0),{dataUrl:g.toDataURL(),width:m,height:d}}async function $n(t,e,n=new Map){if(t?.nodeType!==1)return 0;let r=\'.material-icons, [class*="material-symbols"]\',i=Array.from(t.querySelectorAll(r)).filter(a=>a&&a.textContent&&a.textContent.trim());if(t.matches?.(r)&&t.textContent&&t.textContent.trim()&&i.unshift(t),i.length===0)return 0;let o=e?.nodeType===1?Array.from(e.querySelectorAll(r)).filter(a=>a&&a.textContent&&a.textContent.trim()):[];e?.nodeType===1&&e.matches?.(r)&&e.textContent&&e.textContent.trim()&&o.unshift(e);let s=0;for(let a=0;a<i.length;a++){let c=i[a],f=n&&n.get(c)||o[a]||null;try{let l=getComputedStyle(f||c),u=l.fontFamily||"Material Icons";if(!ql(u))continue;let p=(f||c).textContent.trim();if(!p)continue;let h=parseInt(l.fontSize,10)||24,m=l.fontWeight&&l.fontWeight!=="normal"?l.fontWeight:"normal",d=Kl(l),g=l.fontVariationSettings&&l.fontVariationSettings!=="normal"?l.fontVariationSettings:"",y=(f||c).className||"",{dataUrl:b,width:S,height:k}=await Ql(p,{family:u,weight:m,fontSize:h,color:d,variation:g,className:y});c.textContent="";let v=c.ownerDocument.createElement("img");v.src=b,v.alt=p,v.style.height=`${h}px`,v.style.width=`${Math.max(1,Math.round(S/k*h))}px`,v.style.objectFit="contain",v.style.verticalAlign=getComputedStyle(c).verticalAlign||"baseline",c.appendChild(v),s++}catch{}}return s}Se();yt();Ct();async function as(t,e,n,r=32,i="#000",o="normal"){e=e.replace(/^[\'"]+|[\'"]+$/g,"");let s=window.devicePixelRatio||1;try{await document.fonts.ready}catch{}let a=document.createElement("span");tt(a),a.textContent=t,a.style.position="absolute",a.style.visibility="hidden",a.style.fontFamily=`"${e}"`,a.style.fontWeight=n||"normal",a.style.fontStyle=o||"normal",a.style.fontSize=`${r}px`,a.style.lineHeight="1",a.style.whiteSpace="nowrap",a.style.padding="0",a.style.margin="0",document.body.appendChild(a);let c=a.getBoundingClientRect(),f=Math.ceil(c.width),l=Math.ceil(c.height);document.body.removeChild(a);let u=document.createElement("canvas");u.width=Math.max(1,f*s),u.height=Math.max(1,l*s);let p=u.getContext("2d");return p.scale(s,s),p.font=`${o||"normal"} ${n||"normal"} ${r}px "${e}"`,p.textAlign="left",p.textBaseline="top",p.fillStyle=i,p.fillText(t,0,0),{dataUrl:u.toDataURL(),width:f,height:l}}var cs=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","emoji","math","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]),Jl=["katex","mathjax","mathml"];function eo(t){if(!t)return"";for(let e of t.split(",")){let n=e.trim().replace(/^[\'"]+|[\'"]+$/g,"");if(n&&!cs.has(n.toLowerCase()))return n}return""}function Zl(t){if(!t)return[];let e=[];for(let n of t.split(",")){let r=n.trim().replace(/^[\'"]+|[\'"]+$/g,"");r&&(cs.has(r.toLowerCase())||e.push(r))}return e}function Pn(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 Nn(t){let e=String(t??"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function tf(t){let e=String(t??"100%").match(/(\\d+(?:\\.\\d+)?)\\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}function ef(t){let e=String(t||"400").trim(),n=e.match(/^(\\d{2,3})\\s+(\\d{2,3})$/);if(n){let i=Pn(n[1]),o=Pn(n[2]);return{min:Math.min(i,o),max:Math.max(i,o)}}let r=Pn(e);return{min:r,max:r}}function nf(t){let e=String(t||"normal").trim().toLowerCase();return e==="italic"?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}function rf(t){let e=String(t||"100%").trim(),n=e.match(/(\\d+(?:\\.\\d+)?)\\s*%\\s+(\\d+(?:\\.\\d+)?)\\s*%/);if(n){let o=parseFloat(n[1]),s=parseFloat(n[2]);return{min:Math.min(o,s),max:Math.max(o,s)}}let r=e.match(/(\\d+(?:\\.\\d+)?)\\s*%/),i=r?parseFloat(r[1]):100;return{min:i,max:i}}function of(t){return!t||typeof t!="string"?"":t.replace(/\\s+(variable|vf|v[0-9]+)$/i,"").trim().toLowerCase().replace(/\\s+/g,"-")}function sf(t,e,n=[]){if(!t)return!1;try{let r=new URL(t,location.href);if(r.origin===location.origin)return!0;let o=r.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=>o.endsWith(c))||n.some(c=>o===c.toLowerCase()||o.endsWith("."+c.toLowerCase())))return!0;let a=(r.pathname+r.search).toLowerCase();if(/\\bfont(s)?\\b/.test(a)||/\\.woff2?(\\b|$)/.test(a)||Jl.some(c=>a.includes(c)))return!0;for(let c of e){let f=c.toLowerCase().replace(/\\s+/g,"+"),l=c.toLowerCase().replace(/\\s+/g,"-"),u=of(c);if(a.includes(f)||a.includes(l)||u&&a.includes(u))return!0}return!1}catch{return!1}}function af(t){let e=new Set;for(let n of t||[]){let r=String(n).split("__")[0]?.trim();r&&e.add(r)}return e}function os(t,e){return t&&t.replace(/url\\(\\s*([\'"]?)([^)\'"]+)\\1\\s*\\)/g,(n,r,i)=>{let o=(i||"").trim();if(!o||/^data:|^blob:|^https?:|^file:|^about:/i.test(o))return n;let s=o;try{s=new URL(o,e||location.href).href}catch{}return`url("${s}")`})}var ls=/@import\\s+(?:url\\(\\s*([\'"]?)([^)"\']+)\\1\\s*\\)|([\'"])([^"\']+)\\3)([^;]*);/g,Ln=4;async function cf(t,e,n){if(!t)return t;let r=new Set;function i(a,c){try{return new URL(a,c||location.href).href}catch{return a}}async function o(a,c,f=0){if(f>Ln)return console.warn(`[snapDOM] @import depth exceeded (${Ln}) at ${c}`),a;let l="",u=0,p,h=new RegExp(ls.source,"g");for(;p=h.exec(a);){l+=a.slice(u,p.index),u=h.lastIndex;let m=(p[2]||p[4]||"").trim(),d=i(m,c);if(r.has(d)){console.warn(`[snapDOM] Skipping circular @import: ${d}`);continue}r.add(d);let g="";try{let y=await dt(d,{as:"text",useProxy:n,silent:!0});y.ok&&typeof y.data=="string"&&(g=y.data)}catch{}g?(g=os(g,d),g=await o(g,d,f+1),l+=`\n/* inlined: ${d} */\n${g}\n`):l+=p[0]}return l+=a.slice(u),l}let s=os(t,e||location.href);return s=await o(s,e||location.href,0),s}var fs=/url\\((["\']?)([^"\')]+)\\1\\)/g,lf=/@font-face[^{}]*\\{[^}]*\\}/g;function Mt(t,e,n=""){return(t.match(new RegExp(`${e}\\\\s*:\\\\s*([^;}]+)[;}]`,"i"))?.[1]||n).trim()}function us(t){if(!t)return[];let e=[],n=t.split(",").map(r=>r.trim()).filter(Boolean);for(let r of n){let i=r.match(/^U\\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!i)continue;let o=i[1],s=i[2],a=c=>{if(!c.includes("?"))return parseInt(c,16);let f=parseInt(c.replace(/\\?/g,"0"),16),l=parseInt(c.replace(/\\?/g,"F"),16);return[f,l]};if(s){let c=a(o),f=a(s),l=Array.isArray(c)?c[0]:c,u=Array.isArray(f)?f[1]:f;e.push([Math.min(l,u),Math.max(l,u)])}else{let c=a(o);Array.isArray(c)?e.push([c[0],c[1]]):e.push([c,c])}}return e}function ds(t,e){if(!e.length||!t||t.size===0)return!0;for(let n of t)for(let[r,i]of e)if(n>=r&&n<=i)return!0;return!1}function no(t,e){let n=[];if(!t)return n;for(let r of t.matchAll(fs)){let i=(r[2]||"").trim();if(!(!i||i.startsWith("data:"))){if(!/^https?:/i.test(i))try{i=new URL(i,e||location.href).href}catch{}n.push(i)}}return n}async function Zr(t,e,n=""){let r=t;for(let i of t.matchAll(fs)){let o=ee(i[0]);if(!o)continue;let s=o;if(!s.startsWith("http")&&!s.startsWith("data:"))try{s=new URL(s,e||location.href).href}catch{}if(L.resource?.has(s)){r=r.replace(i[0],`url(${L.resource.get(s)})`);continue}try{let a=await dt(s,{as:"dataURL",useProxy:n,silent:!0});if(a.ok&&typeof a.data=="string"){let c=a.data;L.resource?.set(s,c),r=r.replace(i[0],`url(${c})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",s)}}return r}function ff(t){if(!t.length)return null;let e=(a,c)=>t.some(([f,l])=>!(l<a||f>c)),n=e(0,255)||e(305,305),r=e(256,591)||e(7680,7935),i=e(880,1023),o=e(1024,1279);return e(7840,7929)||e(258,259)||e(416,417)||e(431,432)?"vietnamese":o?"cyrillic":i?"greek":r?"latin-ext":n?"latin":null}function is(t={}){let e=new Set((t.families||[]).map(i=>String(i).toLowerCase())),n=new Set((t.domains||[]).map(i=>String(i).toLowerCase())),r=new Set((t.subsets||[]).map(i=>String(i).toLowerCase()));return(i,o)=>{if(e.size&&e.has(i.family.toLowerCase()))return!0;if(n.size)for(let s of i.srcUrls)try{if(n.has(new URL(s).host.toLowerCase()))return!0}catch{}if(r.size){let s=ff(o);if(s&&r.has(s))return!0}return!1}}function uf(t){if(!t)return t;let e=/@font-face[^{}]*\\{[^}]*\\}/gi,n=new Set,r=[];for(let o of t.match(e)||[]){let s=Mt(o,"font-family"),a=eo(s),c=Mt(o,"font-weight","400"),f=Mt(o,"font-style","normal"),l=Mt(o,"font-stretch","100%"),u=Mt(o,"unicode-range"),p=Mt(o,"src"),h=no(p,location.href),m=h.length?h.map(g=>String(g).toLowerCase()).sort().join("|"):p.toLowerCase(),d=[String(a||"").toLowerCase(),c,f,l,u.toLowerCase(),m].join("|");n.has(d)||(n.add(d),r.push(o))}if(r.length===0)return t;let i=0;return t.replace(e,()=>r[i++]||"")}var ss=new WeakMap,df=0;function pf(t){let e=ss.get(t);return e===void 0&&(e=df++,ss.set(t,e)),e}function hf(t,e,n,r,i,o,s,a,c){let f=Array.from(t||[]).sort().join("|"),l=0,u=0;for(let b of s||[]){let S=Math.imul(b,2654435761);S^=S>>>15,S=Math.imul(S,2246822507),S^=S>>>13,l=l+S|0,u++}let p=e?JSON.stringify({families:(e.families||[]).map(b=>String(b).toLowerCase()).sort(),domains:(e.domains||[]).map(b=>String(b).toLowerCase()).sort(),subsets:(e.subsets||[]).map(b=>String(b).toLowerCase()).sort()}):"",h=(n||[]).map(b=>`${(b.family||"").toLowerCase()}::${b.weight||"normal"}::${b.style||"normal"}::${b.stretchPct??100}::${b.src||""}`).sort().join("|"),m=r||"",d=(i||[]).map(b=>String(b).toLowerCase()).sort().join("|"),g=pf(o||document),y=(a||[]).map(b=>String(b)).sort().join("|");return`fonts-embed-css::req=${f}::ex=${p}::lf=${h}::px=${m}::fd=${d}::doc=${g}::cp=${l}::n=${u}::ic=${y}::env=${c}`}async function to(t,e,n,r){let i=r.doc?.defaultView||window;if(t.disabled||t.media?.mediaText&&!i.matchMedia(t.media.mediaText).matches)return;let o;try{o=t.cssRules||[]}catch{return}let s=(a,c)=>{try{return new URL(a,c||location.href).href}catch{return a}};for(let a of o){if(a.type===CSSRule.IMPORT_RULE&&a.styleSheet){let c=a.href?s(a.href,e):e;if(r.depth>=Ln){console.warn(`[snapDOM] CSSOM import depth exceeded (${Ln}) at ${c}`);continue}if(c&&r.visitedSheets.has(c)){console.warn(`[snapDOM] Skipping circular CSSOM import: ${c}`);continue}c&&r.visitedSheets.add(c);let f={...r,depth:(r.depth||0)+1};await to(a.styleSheet,c,n,f);continue}if(a.cssRules?.length){if(a.type===CSSRule.MEDIA_RULE&&!i.matchMedia(a.conditionText).matches||a.type===CSSRule.SUPPORTS_RULE&&!i.CSS.supports(a.conditionText))continue;await to(a,e,n,r);continue}if(a.type===CSSRule.FONT_FACE_RULE){let c=(a.style.getPropertyValue("font-family")||"").trim(),f=eo(c);if(!f||Nt(f,r.iconMatchers))continue;let l=(a.style.getPropertyValue("font-weight")||"").trim(),u=(a.style.getPropertyValue("font-style")||"").trim(),p=(a.style.getPropertyValue("font-stretch")||"").trim(),h=(a.style.getPropertyValue("font-variation-settings")||"").trim(),m=(a.style.getPropertyValue("src")||"").trim(),d=(a.style.getPropertyValue("unicode-range")||"").trim(),g=l||"400",y=u||"normal",b=p||"100%",S=(u?`font-style:${u};`:"")+(l?`font-weight:${l};`:"")+(p?`font-stretch:${p};`:"")+(h?`font-variation-settings:${h};`:"")+(d?`unicode-range:${d};`:""),k=r.faceMatchesRequired(f,y,g,b);if(!k&&!r.requiredIndex.has(f.toLowerCase()))continue;let v=us(d);if(!ds(r.usedCodepoints,v))continue;let w={family:f,weightSpec:g,styleSpec:y,stretchSpec:b,unicodeRange:d,srcRaw:m,srcUrls:no(m,e||location.href),href:e||location.href};if(r.simpleExcluder&&r.simpleExcluder(w,v))continue;if(!k){r.provisionalFaces.push({family:f.toLowerCase(),block:`@font-face{font-family:${f};src:${m};${S}}`,srcRaw:m,baseHref:e||location.href});continue}r.coveredFamilies.add(f.toLowerCase());let M=`"${String(f).replace(/^\\s*["\']|["\']\\s*$/g,"").replace(/(["\\\\])/g,"\\\\$1")}"`;if(/url\\(/i.test(m)){let A=await Zr(m,e||location.href,r.useProxy);await n(`@font-face{font-family:${M};src:${A};${S}}`)}else await n(`@font-face{font-family:${M};src:${m};${S}}`)}}}async function ps({required:t,usedCodepoints:e,exclude:n=void 0,localFonts:r=[],useProxy:i="",fontStylesheetDomains:o=[],iconMatchers:s=[],doc:a=document}={}){t instanceof Set||(t=new Set),e instanceof Set||(e=new Set);let c=new Map;for(let w of t){let[M,A,C,x]=String(w).split("__");if(!M)continue;let _=M.toLowerCase(),R=c.get(_)||[];R.push({w:parseInt(A,10),s:C,st:parseInt(x,10)}),c.set(_,R)}function f(w,M,A,C){let x=String(w).toLowerCase();if(!c.has(x))return!1;let _=c.get(x),R=ef(A),$=nf(M),T=rf(C),I=R.min!==R.max,B=R.min,E=P=>$.kind==="normal"&&P==="normal"||$.kind!=="normal"&&(P==="italic"||P==="oblique"),N=!1;for(let P of _){let F=I?P.w>=R.min&&P.w<=R.max:P.w===B,z=E(Nn(P.s)),V=P.st>=T.min&&P.st<=T.max;if(F&&z&&V){N=!0;break}}if(N)return!0;if(!I)for(let P of _){let F=E(Nn(P.s)),z=P.st>=T.min&&P.st<=T.max;if(Math.abs(B-P.w)<=300&&F&&z)return!0}if(!I&&$.kind==="normal"&&_.some(F=>Nn(F.s)!=="normal"))for(let F of _){let z=Math.abs(B-F.w)<=300,V=F.st>=T.min&&F.st<=T.max;if(z&&V)return!0}return!1}let l=is(n);Ee(a),Tt();let u=hf(t,n,r,i,o,a,e,s,Ee(a));if(L.resource?.has(u))return L.resource.get(u);let p=af(t),h=[],m=ls;for(let w of a.querySelectorAll("style")){let M=w.textContent||"";for(let A of M.matchAll(m)){let C=(A[2]||A[4]||"").trim();if(!C||Jr(C,s))continue;a.querySelector(`link[rel="stylesheet"][href="${C}"]`)||h.push(C)}}let d=[];h.length&&await Promise.all(h.map(w=>new Promise(M=>{if(a.querySelector(`link[rel="stylesheet"][href="${w}"]`))return M(null);let A=a.createElement("link");A.rel="stylesheet",A.href=w,tt(A),A.setAttribute("data-snapdom","injected-import");let C=setTimeout(()=>M(null),3e3),x=_=>{clearTimeout(C),M(_)};A.onload=()=>x(A),A.onerror=()=>x(null),a.head.appendChild(A),d.push(A)})));let g="",y=new Set,b=[],S=Array.from(a.querySelectorAll(\'link[rel="stylesheet"]\')).filter(w=>!!w.href);for(let w of d)try{w.remove()}catch{}for(let w of S)try{if(Jr(w.href,s))continue;let M="",A=!1;try{A=new URL(w.href,location.href).origin===location.origin}catch{}if(!A){let x=Array.isArray(o)?o:[];if(!sf(w.href,p,x))continue}if(A){let x=Array.from(a.styleSheets).find(_=>_.href===w.href);if(x)try{let _=x.cssRules||[];M=Array.from(_).map(R=>R.cssText).join("")}catch{}}if(!M){let x=await dt(w.href,{as:"text",useProxy:i});x?.ok&&typeof x.data=="string"&&(M=x.data)}M=await cf(M,w.href,i);let C="";for(let x of M.match(lf)||[]){let _=Mt(x,"font-family"),R=eo(_);if(!R||Nt(R,s))continue;let $=Mt(x,"font-weight","400"),T=Mt(x,"font-style","normal"),I=Mt(x,"font-stretch","100%"),B=Mt(x,"unicode-range"),E=Mt(x,"src"),N=no(E,w.href),P=f(R,T,$,I);if(!P&&!c.has(R.toLowerCase()))continue;let F=us(B);if(!ds(e,F))continue;let z={family:R,weightSpec:$,styleSpec:T,stretchSpec:I,unicodeRange:B,srcRaw:E,srcUrls:N,href:w.href};if(n&&l(z,F))continue;if(!P){b.push({family:R.toLowerCase(),block:x,srcRaw:E,baseHref:w.href});continue}y.add(R.toLowerCase());let V=/url\\(/i.test(E)?await Zr(x,w.href,i):x;C+=V}C.trim()&&(g+=C)}catch{console.warn("[snapDOM] Failed to process stylesheet:",w.href)}let k={doc:a,requiredIndex:c,usedCodepoints:e,faceMatchesRequired:f,coveredFamilies:y,provisionalFaces:b,simpleExcluder:n?is(n):null,useProxy:i,iconMatchers:s,visitedSheets:new Set,depth:0},v=new Set([...a.styleSheets,...a.adoptedStyleSheets||[]]);for(let w of v)if(!(w.href&&S.some(M=>M.href===w.href)))try{let M=w.href||a.baseURI||location.origin+"/";M&&k.visitedSheets.add(M),await to(w,M,async A=>{g+=A},k)}catch{}for(let w of b)y.has(w.family)||(g+=/url\\(/i.test(w.srcRaw)?await Zr(w.block,w.baseHref,i):w.block);try{for(let w of a.fonts||[]){if(!w||!w.family||w.status!=="loaded"||!w._snapdomSrc)continue;let M=String(w.family).replace(/^[\'"]+|[\'"]+$/g,"");if(Nt(M,s)||!c.has(M.toLowerCase())||n?.families&&n.families.some(C=>String(C).toLowerCase()===M.toLowerCase()))continue;let A=w._snapdomSrc;if(!String(A).startsWith("data:"))if(L.resource?.has(w._snapdomSrc))A=L.resource.get(w._snapdomSrc);else try{let C=await dt(w._snapdomSrc,{as:"dataURL",useProxy:i,silent:!0});if(C.ok&&typeof C.data=="string")A=C.data,L.resource?.set(w._snapdomSrc,A);else continue}catch{console.warn("[snapDOM] Failed to fetch dynamic font src:",w._snapdomSrc);continue}g+=`@font-face{font-family:\'${M}\';src:url(${A});font-style:${w.style||"normal"};font-weight:${w.weight||"normal"};}`}}catch{}for(let w of r){if(!w||typeof w!="object")continue;let M=String(w.family||"").replace(/^[\'"]+|[\'"]+$/g,"");if(!M||Nt(M,s)||!c.has(M.toLowerCase())||n?.families&&n.families.some($=>String($).toLowerCase()===M.toLowerCase()))continue;let A=w.weight!=null?String(w.weight):"normal",C=w.style!=null?String(w.style):"normal",x=w.stretchPct!=null?`${w.stretchPct}%`:"100%",_=String(w.src||""),R=_;if(!R.startsWith("data:"))if(L.resource?.has(_))R=L.resource.get(_);else try{let $=await dt(_,{as:"dataURL",useProxy:i,silent:!0});if($.ok&&typeof $.data=="string")R=$.data,L.resource?.set(_,R);else continue}catch{console.warn("[snapDOM] Failed to fetch localFonts src:",_);continue}g+=`@font-face{font-family:\'${M}\';src:url(${R});font-style:${C};font-weight:${A};font-stretch:${x};}`}return g&&(g=uf(g),L.resource?.set(u,g)),g}function In(t,e){let n=new Set,r=new Set;if(!t)return{required:n,usedCodepoints:r};let i=l=>{if(l)for(let u of l)r.add(u.codePointAt(0))},o=l=>{let u=Zl(l.fontFamily);if(u.length)for(let p of u)n.add(`${p}__${Pn(l.fontWeight)}__${Nn(l.fontStyle)}__${tf(l.fontStretch)}`)},s=Te(t),a=t.getRootNode(),c=l=>{o(O(l));let u=l.getRootNode()===a?s:Te(l);for(let p of["::before","::after"]){let h=p==="::before"?u.before:u.after;if(h!==null){if(h==="")continue;try{if(!l.matches(h))continue}catch{}}let m=O(l,p),d=m&&m.content;if(!(!d||d==="none"||d==="normal"))if(o(m),/^["\']/.test(d))i(d.slice(1,-1));else{let g=d.match(/\\\\[0-9A-Fa-f]{1,6}/g);if(g)for(let y of g)try{r.add(parseInt(y.slice(1),16))}catch{}}}},f=[t];for(let l=0;l<f.length;l++){let u=f[l];u.nodeType===Node.ELEMENT_NODE&&c(u),u.shadowRoot&&f.push(u.shadowRoot);let p=(t.ownerDocument||document).createTreeWalker(u,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;p.nextNode();){let h=p.currentNode;if(h.nodeType===Node.TEXT_NODE){if(e&&h.parentElement&&!e(h.parentElement))continue;i(h.nodeValue||"")}else{if(e&&!e(h))continue;c(h),h.shadowRoot&&f.push(h.shadowRoot)}}}return{required:n,usedCodepoints:r}}async function Wn(t,e=2,n=document){try{await n.fonts.ready}catch{}let r=Array.from(t||[]).filter(Boolean);if(r.length===0)return;let i=()=>{let o=n.createElement("div");tt(o),o.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;opacity:0!important;pointer-events:none!important;contain:layout size style;";for(let s of r){let a=n.createElement("span");a.textContent="AaBbGg1234\\xC1\\xC9\\xCD\\xD3\\xDA\\xE7\\xF1\\u2014\\u221E",a.style.fontFamily=`"${s}"`,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",o.appendChild(a)}n.body.appendChild(o),o.offsetWidth,n.body.removeChild(o)};for(let o=0;o<Math.max(1,e);o++)i(),await gt(),await gt()}kt();function ys(t){return/\\bcounter\\s*\\(|\\bcounters\\s*\\(/.test(t||"")}function hs(t,e=!1){let n="",r=Math.max(1,t);for(;r>0;)r--,n=String.fromCharCode(97+r%26)+n,r=Math.floor(r/26);return e?n.toUpperCase():n}function ms(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"]],r=Math.max(1,Math.min(3999,t)),i="";for(let[o,s]of n)for(;r>=o;)i+=s,r-=o;return e?i:i.toLowerCase()}function gs(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":case"lower-latin":return hs(t,!1);case"upper-alpha":case"upper-latin":return hs(t,!0);case"lower-roman":return ms(t,!1);case"upper-roman":return ms(t,!0);default:return String(t)}}function an(t,e){let n=(t||"").trim().split(/[\\s,]+/).filter(Boolean),r=[];for(let i=0;i<n.length;i++){let o=n[i];if(o==="none")continue;let s=n[i+1],a=s!==void 0&&Number.isFinite(Number(s));r.push([o,a?Number(s):e]),a&&i++}return r}function bs(t){let e=new WeakMap,n=Ar(t)?t.documentElement:t,r=f=>f&&f.tagName==="LI",i=new WeakMap,o=f=>{let l=new Map;for(let[u,p]of f)l.set(u,p.slice());return l},s=(f,l,u)=>{let p=o(f),h;try{h=getComputedStyle(u)}catch{h=u.style}let m;try{m=h?.counterReset}catch{}if(m&&m!=="none")for(let[y,b]of an(m,0)){let S=l.get(y);if(S&&S.length){let k=S.slice();k.push(b),p.set(y,k)}else p.set(y,[b])}let d;try{d=h?.counterSet}catch{}if(d&&d!=="none")for(let[y,b]of an(d,0)){let S=p.get(y)||[];S.length===0&&S.push(0),S[S.length-1]=b,p.set(y,S)}let g;try{g=h?.counterIncrement}catch{}if(g&&g!=="none")for(let[y,b]of an(g,1)){let S=p.get(y)||[];S.length===0&&S.push(0),S[S.length-1]+=b,p.set(y,S)}try{if(h?.display==="list-item"&&r(u)){let y=u.parentElement,b=y&&i.get(y),S=y?.tagName==="OL"?parseInt(y.getAttribute("start"),10):NaN,k=b===void 0?Number.isFinite(S)?S:1:b+1,v=y?.tagName==="OL"?parseInt(u.getAttribute("value"),10):NaN;Number.isFinite(v)&&(k=v),y&&i.set(y,k);let w=p.get("list-item")||[];w.length===0&&w.push(0),w[w.length-1]=k,p.set("list-item",w)}}catch{}return p},a=(f,l,u)=>{let p=s(u,l,f);e.set(f,p);let h=p;for(let d of f.children)h=a(d,p,h);let m=new Map;for(let[d,g]of u){let y=g.length,b=h.get(d);m.set(d,b&&b.length?b.slice(0,y):g.slice())}for(let[d,g]of h)!m.has(d)&&g.length&&!l.has(d)&&m.set(d,g.slice(0,1));return m},c=new Map;return a(n,c,c),{get(f,l){let u=e.get(f)?.get(l);return u&&u.length?u[u.length-1]:0},getStack(f,l){let u=e.get(f)?.get(l);return u?u.slice():[]}}}function ws(t,e,n){if(!t||t==="none")return t;try{let r=/\\b(counter|counters)\\s*\\(([^)]+)\\)/g;return t.replace(r,(i,o,s)=>{let a=String(s).split(",").map(c=>c.trim());if(o==="counter"){let c=a[0]?.replace(/^["\']|["\']$/g,""),f=(a[1]||"decimal").toLowerCase(),l=n.get(e,c);return gs(l,f)}else{let c=a[0]?.replace(/^["\']|["\']$/g,""),f=a[1]?.replace(/^["\']|["\']$/g,"")??"",l=(a[2]||"decimal").toLowerCase(),u=n.getStack(e,c);return u.length?u.map(h=>gs(h,l)).join(f):""}})}catch{return"- "}}Se();var Ie=new WeakMap,Ss=1e3;function mf(t,e){let n=Cs(t);return e?(e.__pseudoPreflightFp!==n&&(Tt(),e.__pseudoPreflight=xs(t,n),e.__pseudoPreflightFp=n),!!e.__pseudoPreflight):(Tt(),xs(t,n))}function On(t){try{return t&&t.cssRules?t.cssRules:null}catch{return null}}function Cs(t){let e=t.querySelectorAll(\'style,link[rel~="stylesheet"]\'),n=`n:${e.length}|`,r=0;for(let s=0;s<e.length;s++){let a=e[s];if(a.tagName==="STYLE"){let c=a.textContent?a.textContent.length:0;n+=`S${c}|`;let f=a.sheet,l=f?On(f):null;l&&(r+=l.length)}else{let c=a.getAttribute("href")||"",f=a.getAttribute("media")||"all";n+=`L${c}|m:${f}|`;let l=a.sheet,u=l?On(l):null;u&&(r+=u.length)}}let i=t.adoptedStyleSheets,o=0;if(Array.isArray(i))for(let s of i){let a=On(s);a&&(o+=a.length)}return n+=`ass:${Array.isArray(i)?i.length:0}/${o}|tr:${r}`,n}function ro(t,e,n){let r=On(t);if(!r)return!1;for(let i=0;i<r.length;i++){if(n.budget<=0)return!1;let o=r[i],s=o&&o.cssText?o.cssText:"";n.budget--;for(let a of e)if(s.includes(a))return!0;if(o&&o.styleSheet&&ro(o.styleSheet,e,n))return!0;if(o&&o.cssRules&&o.cssRules.length)for(let a=0;a<o.cssRules.length&&n.budget>0;a++){let c=o.cssRules[a],f=c&&c.cssText?c.cssText:"";n.budget--;for(let l of e)if(f.includes(l))return!0}if(n.budget<=0)return!1}return!1}function xs(t=document,e=Cs(t)){let n=Ie.get(t);if(n&&n.fingerprint===e)return n.result;let r=a=>(a.match(/\\|ass:[^|]*/)||[""])[0];n&&r(e)!==r(n.fingerprint)&&Re();let i=["::before","::after","::first-letter","::marker","::first-line",":before",":after",":first-letter",":first-line","counter(","counters(","counter-increment","counter-reset"],o=t.querySelectorAll("style");for(let a=0;a<o.length;a++){let c=o[a].textContent||"";for(let f of i)if(c.includes(f))return Ie.set(t,{fingerprint:e,result:!0}),!0}let s=t.adoptedStyleSheets;if(Array.isArray(s)&&s.length){let a={budget:Ss};try{for(let c of s)if(ro(c,i,a))return Ie.set(t,{fingerprint:e,result:!0}),!0}catch{}}{let a=t.querySelectorAll(\'style,link[rel~="stylesheet"]\'),c={budget:Ss};for(let f=0;f<a.length&&c.budget>0;f++){let l=a[f],u=null;if(l.tagName,u=l.sheet||null,u&&ro(u,i,c))return Ie.set(t,{fingerprint:e,result:!0}),!0}}return t.querySelector(\'[style*="counter("], [style*="counters("]\')?(Ie.set(t,{fingerprint:e,result:!0}),!0):(Ie.set(t,{fingerprint:e,result:!1}),!1)}function vs(t){for(let e of["Top","Right","Bottom","Left"]){let n=parseFloat(t[`border${e}Width`])||0,r=t[`border${e}Style`];if(n>0&&r&&r!=="none"&&r!=="hidden")return!0}return!1}function gf(t,e){let n=null,r=()=>{if(!n)try{n=bs(t)}catch(i){H(e,"buildCounterContext failed",i),n={get:()=>0,getStack:()=>[]}}return n};return{get(i,o){return r().get(i,o)},getStack(i,o){return r().getStack(i,o)}}}function yf(t){let e=!1;for(let n=0;n<t.length;n++){let r=t[n];if(r===\'"\')e=!e;else if(r==="/"&&!e)return t.slice(0,n).trim()}return t}function bf(t){return t.replace(/\\\\(?:([0-9a-fA-F]{1,6})[ \\t\\n]?|([\\s\\S]))/g,(e,n,r)=>{if(n){let i=parseInt(n,16);return i===0||i>1114111?"\\uFFFD":String.fromCodePoint(i)}return r===`\n`?"":r})}function wf(t){if(!t)return"";let e=[],n=/"((?:\\\\[\\s\\S]|[^"\\\\])*)"|\'((?:\\\\[\\s\\S]|[^\'\\\\])*)\'/g,r=0,i;for(;i=n.exec(t);){let s=t.slice(r,i.index).trim();s&&e.push(s),e.push(bf(i[1]!==void 0?i[1]:i[2])),r=n.lastIndex}let o=t.slice(r).trim();return o&&e.push(o),e.join("")}function oo(t,e,n){let r=t.parentElement,i=r&&n?n.get(r):null;return i?{get(o,s){let a=e.get(o,s),c=i.get(s);return typeof c=="number"?Math.max(a,c):a},getStack(o,s){let a=e.getStack(o,s);if(!a.length)return a;let c=i.get(s);if(typeof c=="number"){let f=a.slice();return f[f.length-1]=Math.max(f[f.length-1],c),f}return a}}:e}function io(t,e,n){let r=new Map,i=(f,l)=>an(f,l).map(([u,p])=>({name:u,num:p})),o=i(e?.counterReset,0),s=i(e?.counterSet,0),a=i(e?.counterIncrement,1);function c(f){if(r.has(f))return r.get(f).slice();let l=n.getStack(t,f);l=l.length?l.slice():[];let u=o.find(m=>m.name===f);if(u){let m=Number.isFinite(u.num)?u.num:0;l=l.length?[...l,m]:[m]}let p=s.find(m=>m.name===f);if(p){let m=Number.isFinite(p.num)?p.num:0;l.length===0&&(l=[0]),l[l.length-1]=m}let h=a.find(m=>m.name===f);if(h){let m=Number.isFinite(h.num)?h.num:1;l.length===0&&(l=[0]),l[l.length-1]+=m}return r.set(f,l.slice()),l}return{get(f,l){let u=c(l);return u.length?u[u.length-1]:0},getStack(f,l){return c(l)},__incs:a}}var Sf=["color","-webkit-text-fill-color","font-family","font-size","font-weight","font-style","letter-spacing","line-height"],xf=["color","-webkit-text-fill-color","font-family","font-size","font-weight","font-style","font-variant","letter-spacing","word-spacing","text-transform","text-decoration-line","text-decoration-color","text-decoration-style","line-height","background-color","vertical-align"];function ks(t,e,n,r,i,o){try{if(r===null){if(t.getRootNode()!==(t.ownerDocument||document))return;let u=O(t).display||"";if(i==="::marker"?!u.includes("list-item"):!(u==="block"||u==="flow-root"||u==="list-item"||u==="inline-block"||u==="table-cell"||u==="table-caption"))return}else if(!t.matches(r))return;if(i==="::marker"&&!(O(t).display||"").includes("list-item"))return;let s=O(t,i),a=O(t);if(!s)return;let c="";for(let u of o){let p=s.getPropertyValue(u);p&&p!==a.getPropertyValue(u)&&!(u==="background-color"&&p==="rgba(0, 0, 0, 0)")&&!(u==="vertical-align"&&p==="baseline")&&(c+=`${u}:${p};`)}if(i==="::marker"){let u=s.getPropertyValue("content");u&&u!=="normal"&&u!=="none"&&(c+=`content:${u};`)}if(!c)return;let l=`data-sd-p${n.__pseudoRuleSeq=(n.__pseudoRuleSeq||0)+1}`;e.setAttribute(l,""),n.__pseudoCSS=(n.__pseudoCSS||"")+`[${l}]${i}{${c}}`}catch{}}function vf(t,e){if(!/\\b(?:no-)?(?:open|close)-quote\\b/.test(t))return t;let n="\\u201C",r="\\u201D";try{let i=O(e).quotes;if(i==="none")n="",r="";else if(i&&i!=="auto"){let o=i.match(/"[^"]*"|\'[^\']*\'/g);o&&o.length>=2&&(n=o[0].slice(1,-1),r=o[1].slice(1,-1))}}catch{}return n=n.replace(/"/g,""),r=r.replace(/"/g,""),t.replace(/"[^"]*"|\\b(no-open-quote|no-close-quote|open-quote|close-quote)\\b/g,(i,o)=>o?o==="open-quote"?`"${n}"`:o==="close-quote"?`"${r}"`:\'""\':i)}function kf(t,e,n,r){let i;try{i=O(t,e)}catch{}let o=i?.content;if(!o||o==="none"||o==="normal")return{text:"",incs:[]};o=yf(o),o=vf(o,t);let s=oo(t,n,r),a=io(t,i,s),c=ys(o)?ws(o,t,a):o;return{text:wf(c),incs:a.__incs||[]}}function Cf(t,e){if(e.__shadowPseudo)return!1;let n=Te(t),r=[];for(let o of["before","after","firstLetter","marker","firstLine"]){let s=n[o];if(s===null)return!1;s&&r.push(s)}if(!r.length)return!0;let i=r.join(",");try{return!t.matches(i)&&t.querySelector(i)===null}catch{return!1}}async function We(t,e,n,r,i=!1){if(t?.nodeType!==1||e?.nodeType!==1||(n.slicer?.due()&&await n.slicer.pause(),t.tagName==="TEXTAREA"))return;let o=t.ownerDocument||document;if(!i&&!mf(o,n)&&!n.__shadowPseudo||!i&&Cf(t,n))return;n.__siblingCounters||(n.__siblingCounters=new WeakMap),n.__counterCtx||(n.__counterCtx=gf(t.ownerDocument||document,n));let s=n.__counterCtx,a=Te(t);a.marker!==""&&ks(t,e,n,a.marker,"::marker",Sf),a.firstLine!==""&&ks(t,e,n,a.firstLine,"::first-line",xf);for(let f of["::before","::after","::first-letter"]){let l=a[f==="::before"?"before":f==="::after"?"after":"firstLetter"];if(l!==null){if(l==="")continue;try{if(!t.matches(l))continue}catch{}}try{let u=O(t,f);if(!u||u.content==="none"&&u.backgroundImage==="none"&&(u.backgroundColor==="transparent"||u.backgroundColor==="rgba(0, 0, 0, 0)")&&!vs(u)&&(!u.transform||u.transform==="none")&&u.display==="inline")continue;if(u.display==="none"||f!=="::first-letter"&&(u.content==="none"||u.content==="normal")){f==="::before"&&(e.dataset.snapdomHasBefore="1"),f==="::after"&&(e.dataset.snapdomHasAfter="1");continue}if(f==="::first-letter"){let U=O(t),G=(U?.display||"").toLowerCase();if(G.includes("flex")||G.includes("grid"))continue;let q=Ht=>u[Ht]!==U[Ht]&&(parseFloat(u[Ht])||0)!==0;if(!(u.color!==U.color||u.fontSize!==U.fontSize||u.fontWeight!==U.fontWeight||u.fontFamily!==U.fontFamily||u.fontStyle!==U.fontStyle||u.textTransform!==U.textTransform||u.float!==U.float&&u.float!=="none"||q("paddingTop")||q("paddingRight")||q("paddingBottom")||q("paddingLeft")||q("marginTop")||q("marginRight")||q("marginBottom")||q("marginLeft")))continue;let rt=Array.from(e.childNodes).find(Ht=>Ht.nodeType===Node.TEXT_NODE&&Ht.textContent?.trim().length>0);if(!rt)continue;let me=rt.textContent,J=/^\\s*/.exec(me)[0],vt=me.slice(J.length),ge=vt.match(/^([^\\p{L}\\p{N}\\s]*[\\p{L}\\p{N}](?:[\'\u2019])?)/u)?.[0],ye=vt.slice(ge?.length||0);if(!ge||/[\\uD800-\\uDFFF]/.test(ge))continue;let be=document.createElement("span");be.textContent=ge,be.dataset.snapdomPseudo="::first-letter";let wr=Ce(u,xn(t)),mn=ke(wr,"span");n.styleMap.set(be,mn);let gn=document.createTextNode(ye);e.replaceChild(gn,rt),e.insertBefore(be,gn),J&&e.insertBefore(document.createTextNode(J),be);continue}let m=u.content??"",d=m===""||m==="none"||m==="normal",{text:g,incs:y}=kf(t,f,s,n.__siblingCounters),b=u.backgroundImage,S=u.backgroundColor,k=u.fontFamily,v=parseInt(u.fontSize)||32,w=parseInt(u.fontWeight)||!1,M=u.fontStyle||"normal",A=u.color||"#000",C=u.transform,x=Nt(k,r?.__iconMatchers),_=!d&&g!=="",R=b&&b!=="none",$=S&&S!=="transparent"&&S!=="rgba(0, 0, 0, 0)",T=vs(u),I=C&&C!=="none",B=m!=="none"&&m!=="normal",E=/^inline-/.test(u.display||""),N=B&&((parseFloat(u.width)||0)>0||(parseFloat(u.height)||0)>0||E),P=B&&u.boxShadow&&u.boxShadow!=="none",F=B&&u.outlineStyle&&u.outlineStyle!=="none"&&(parseFloat(u.outlineWidth)||0)>0;if(!(_||R||$||T||I||N||P||F)){if(y&&y.length&&t.parentElement){let U=n.__siblingCounters.get(t.parentElement)||new Map;for(let{name:G}of y){if(!G)continue;let q=oo(t,s,n.__siblingCounters),rt=io(t,O(t,f),q).get(t,G);U.set(G,rt)}n.__siblingCounters.set(t.parentElement,U)}continue}let V=g.startsWith("url(")||/^-?(?:webkit-)?image-set\\(/i.test(g),j=!1;if(_&&!x&&g.length>1&&!V){let U=O(t),G=parseFloat(U.fontSize)||16,q=parseFloat(U.lineHeight);Number.isFinite(q)||(q=G*1.5),t.getBoundingClientRect().height<q*1.6&&(e.style.whiteSpace="nowrap",j=!0)}let D=document.createElement("span");D.dataset.snapdomPseudo=f,D.style.pointerEvents="none",j&&(D.style.whiteSpace="nowrap");let K=Ri(t,f,u,n,r),ht=(O(t).display||"").toLowerCase(),St=ht.includes("flex")||ht.includes("grid");if(St){let U=K["min-width"];(!U||U==="auto"||U==="0px")&&(K["min-width"]="0px")}let ft=ke(K,"span",_,St);if(n.styleMap.set(D,ft),x&&g&&g.length===1){let{dataUrl:U,width:G,height:q}=await as(g,k,w,v,A,M),nt=document.createElement("img");nt.src=U,nt.style=`height:${v}px;width:${G/q*v}px;object-fit:contain;`,D.appendChild(nt),e.dataset.snapdomHasIcon="true"}else if(g&&V){let U=qe(g,typeof devicePixelRatio<"u"&&devicePixelRatio||1)??ee(g);if(U?.trim())try{let G=await dt(Vt(U),{as:"dataURL",useProxy:r.useProxy});if(G?.ok&&typeof G.data=="string"){let q=document.createElement("img");q.src=G.data,q.style=`width:${v}px;height:auto;object-fit:contain;`,D.appendChild(q)}}catch(G){console.error(`[snapdom] Error in pseudo ${f} for`,t,G)}}else!x&&_&&(D.textContent=g);D.style.backgroundImage="none","maskImage"in D.style&&(D.style.maskImage="none"),"webkitMaskImage"in D.style&&(D.style.webkitMaskImage="none");try{D.style.backgroundRepeat=u.backgroundRepeat,D.style.backgroundSize=u.backgroundSize,u.backgroundPositionX&&u.backgroundPositionY?(D.style.backgroundPositionX=u.backgroundPositionX,D.style.backgroundPositionY=u.backgroundPositionY):D.style.backgroundPosition=u.backgroundPosition,D.style.backgroundOrigin=u.backgroundOrigin,D.style.backgroundClip=u.backgroundClip,D.style.backgroundAttachment=u.backgroundAttachment,D.style.backgroundBlendMode=u.backgroundBlendMode}catch{}if(R)try{let U=Gt(b),G=await Promise.all(U.map(q=>xe(q,r)));D.style.backgroundImage=G.join(", ")}catch(U){console.warn(`[snapdom] ${f} background-image inline failed`,U)}$&&(D.style.backgroundColor=S);let at=u.maskImage||u.webkitMaskImage;if(at&&at!=="none")try{let G=(await Promise.all(Gt(at).map(q=>xe(q,r)))).join(", ");D.style.maskImage=G,D.style.webkitMaskImage=G;for(let q of["maskSize","maskRepeat","maskPosition","maskMode","maskComposite","maskOrigin","maskClip"])u[q]&&(D.style[q]=u[q])}catch(U){console.warn(`[snapdom] ${f} mask-image inline failed`,U)}let xt=D.childNodes.length>0||D.textContent?.trim()!==""||R||$||T||I||N||P||F;if(y&&y.length&&t.parentElement){let U=n.__siblingCounters.get(t.parentElement)||new Map,G=oo(t,s,n.__siblingCounters),q=io(t,O(t,f),G);for(let{name:nt}of y){if(!nt)continue;let rt=q.get(t,nt);U.set(nt,rt)}n.__siblingCounters.set(t.parentElement,U)}if(!xt)continue;f==="::before"?(e.dataset.snapdomHasBefore="1",e.insertBefore(D,e.firstChild)):(e.dataset.snapdomHasAfter="1",e.appendChild(D))}catch(u){console.warn(`[snapdom] Failed to capture ${f} for`,t,u)}}let c=Array.from(e.children).filter(f=>!f.dataset.snapdomPseudo);if(n.nodeMap)for(let f of c){let l=n.nodeMap.get(f);l?.nodeType===1&&await We(l,f,n,r,!0)}else{let f=Array.from(t.children);for(let l=0;l<Math.min(f.length,c.length);l++)await We(f[l],c[l],n,r,!0)}}kt();function As(t,e,n){if(!t||t?.nodeType!==1)return;let r=t.ownerDocument||document,i=e||r,o=It(t)&&t.localName==="svg"?[t]:Array.from(t.querySelectorAll("svg")),s=/url\\(\\s*["\']?\\s*#([^)"\']+)/g,a=["fill","stroke","filter","clip-path","mask","marker","marker-start","marker-mid","marker-end"],c=w=>window.CSS&&CSS.escape?CSS.escape(w):w.replace(/[^a-zA-Z0-9_-]/g,"\\\\$&"),f="http://www.w3.org/1999/xlink",l=w=>{if(!w||!w.getAttribute)return null;let M=w.getAttribute("href")||w.getAttribute("xlink:href")||(typeof w.getAttributeNS=="function"?w.getAttributeNS(f,"href"):null);if(M)return M;let A=w.attributes;if(!A)return null;for(let C=0;C<A.length;C++){let x=A[C];if(!x||!x.name)continue;if(x.name==="href")return x.value;let _=x.name.indexOf(":");if(_!==-1&&x.name.slice(_+1)==="href")return x.value}return null},u=new Set(Array.from(t.querySelectorAll("[id]")).map(w=>w.id)),p=new Set,h=!1,m=(w,M=null)=>{if(!w)return;s.lastIndex=0;let A;for(;A=s.exec(w);){h=!0;let C=(A[1]||"").trim();C&&(u.has(C)||(p.add(C),M&&!M.has(C)&&M.add(C)))}},d=w=>{let M=w.querySelectorAll("use");for(let x of M){let _=l(x);if(!_||!_.startsWith("#"))continue;h=!0;let R=_.slice(1).trim();R&&!u.has(R)&&p.add(R)}let A=\'*[style*="url("],*[fill^="url("], *[stroke^="url("],*[filter^="url("],*[clip-path^="url("],*[mask^="url("],*[marker^="url("],*[marker-start^="url("],*[marker-mid^="url("],*[marker-end^="url("]\';m(w.getAttribute("style")||"");for(let x of a)m(w.getAttribute(x));let C=w.querySelectorAll(A);for(let x of C){m(x.getAttribute("style")||"");for(let _ of a)m(x.getAttribute(_))}},g=w=>{if(!w||w.nodeType!==1||!w.querySelectorAll)return;let M="filter[id],clipPath[id],mask[id],linearGradient[id],radialGradient[id],pattern[id]",A=!1;try{A=!!(i.querySelector&&i.querySelector(M))}catch{return}if(!A)return;let C=["filter","clipPath","mask","maskImage","webkitMaskImage"],x=_=>{if(It(_))return;let R;try{R=getComputedStyle(_)}catch{return}for(let $ of C){let T=R[$];T&&T.includes("url(")&&m(T)}};x(w);for(let _ of w.querySelectorAll("*"))x(_)};for(let w of o)d(w);if(g(n),!h)return;let y=t.querySelector("svg.inline-defs-container");y||(y=r.createElementNS("http://www.w3.org/2000/svg","svg"),y.classList.add("inline-defs-container"),y.setAttribute("aria-hidden","true"),y.setAttribute("style","position:absolute;width:0;height:0;overflow:hidden"),t.insertBefore(y,t.firstChild||null));let b=y.querySelector("defs")||null,S=w=>{if(!w||u.has(w))return null;let M=c(w),A=C=>{let x=i.querySelector(C);return x&&!t.contains(x)?x:null};return A(`svg defs > *#${M}`)||A(`svg > symbol#${M}`)||A(`*#${M}`)};if(!p.size)return;let k=new Set(p),v=new Set;for(;k.size;){let w=k.values().next().value;if(k.delete(w),!w||u.has(w)||v.has(w))continue;let M=S(w);if(!M){v.add(w);continue}b||(b=r.createElementNS("http://www.w3.org/2000/svg","defs"),y.appendChild(b));let A=M.cloneNode(!0);A.id||A.setAttribute("id",w),b.appendChild(A),v.add(w),u.add(w);let C=[A,...A.querySelectorAll("*")];for(let x of C){let _=l(x);if(_&&_.startsWith("#")){let $=_.slice(1).trim();$&&!u.has($)&&!v.has($)&&k.add($)}let R=x.getAttribute?.("style")||"";R&&m(R,k);for(let $ of a){let T=x.getAttribute?.($);T&&m(T,k)}}}}kt();var so=new WeakMap,ao=new WeakMap;function Dn(t,e,n){let r=n.get(t),i=t.style;if(!r){let s=i.cssText,a=t.hasAttribute("style");r={users:0,saved:e.map(([f,l])=>{let u={property:f,value:i.getPropertyValue(f),priority:i.getPropertyPriority(f)};return i.setProperty(f,l,"important"),u.forcedValue=i.getPropertyValue(f),u}),originalCSS:s,forcedCSS:i.cssText,hadStyle:a},n.set(t,r)}r.users++;let o=!1;return()=>{if(!o&&(o=!0,!--r.users)){if(n.delete(t),i.cssText===r.forcedCSS)i.cssText=r.originalCSS;else for(let s of r.saved)i.getPropertyValue(s.property)!==s.forcedValue||i.getPropertyPriority(s.property)!=="important"||(s.value?i.setProperty(s.property,s.value,s.priority):i.removeProperty(s.property));!r.hadStyle&&!i.length&&(t.getAttribute("style"),t.removeAttribute("style"))}}}function Ms(t){if(so.has(t))return Dn(t,[],so);let e=getComputedStyle(t),n=e.outlineStyle,r=e.outlineWidth,i=n!=="none"&&parseFloat(r)>0,o=parseFloat(e.borderTopWidth)===0&&parseFloat(e.borderRightWidth)===0&&parseFloat(e.borderBottomWidth)===0&&parseFloat(e.borderLeftWidth)===0;if(i&&o){let s=[];for(let a of["top","right","bottom","left"])s.push([`border-${a}-width`,r],[`border-${a}-style`,"solid"],[`border-${a}-color`,"transparent"]);return Dn(t,s,so)}return()=>{}}function Bn(t,e=null){let n=[],r=i=>{if(!Rt(i))return;if(ao.has(i)){n.push(Dn(i,[],ao));return}let o=getComputedStyle(i);(o.contentVisibility||o.getPropertyValue("content-visibility")||"")==="auto"&&n.push(Dn(i,[["content-visibility","visible"]],ao))};try{if(e){let o=s=>{let a;try{a=s.getBoundingClientRect()}catch{return}if(!((a.width>0||a.height>0)&&(a.right<e.left-200||a.left>e.right+200||a.bottom<e.top-200||a.top>e.bottom+200))){r(s);for(let c=s.firstElementChild;c;c=c.nextElementSibling)o(c)}};o(t)}else{for(let i of t.querySelectorAll("*"))r(i);r(t)}}catch{}return()=>{for(let i of n)try{i()}catch{}}}bt();mt();Ct();Ae();Ct();function lo(t){return Es(t.boxShadow)}function fo(t){return Es(t.textShadow)}function Es(t){if(!t||t==="none")return{top:0,right:0,bottom:0,left:0};let e=[],n="",r=0;for(let c=0;c<t.length;c++){let f=t[c];f==="("?r++:f===")"&&(r=Math.max(0,r-1)),f===","&&r===0?(e.push(n),n=""):n+=f}n.trim()&&e.push(n);let i=0,o=0,s=0,a=0;for(let c of e){if(/\\binset\\b/i.test(c))continue;let f=c.match(/-?\\d+(\\.\\d+)?px/g)?.map(g=>parseFloat(g))||[];if(f.length<2)continue;let[l,u,p=0,h=0]=f,m=Math.abs(l)+p+h,d=Math.abs(u)+p+h;o=Math.max(o,m+Math.max(l,0)),a=Math.max(a,m+Math.max(-l,0)),s=Math.max(s,d+Math.max(u,0)),i=Math.max(i,d+Math.max(-u,0))}return{top:Math.ceil(i),right:Math.ceil(o),bottom:Math.ceil(s),left:Math.ceil(a)}}function uo(t){let e=t.filter&&t.filter!=="none"?t.filter:t.webkitFilter||"",n=/blur\\(\\s*([0-9.]+)px\\s*\\)/gi,r=0,i;for(;i=n.exec(e);)r+=parseFloat(i[1])||0;let o=Math.ceil(r*2);return{top:o,right:o,bottom:o,left:o}}function po(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,r=e+Math.max(0,Math.ceil(n));return{top:r,right:r,bottom:r,left:r}}function ho(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)||[],r=0,i=0,o=0,s=0,a=!1;for(let c of n){a=!0;let f=c.match(/-?\\d+(?:\\.\\d+)?px/gi)?.map(d=>parseFloat(d))||[],[l=0,u=0,p=0]=f,h=Math.abs(l)+p,m=Math.abs(u)+p;i=Math.max(i,h+Math.max(l,0)),s=Math.max(s,h+Math.max(-l,0)),o=Math.max(o,m+Math.max(u,0)),r=Math.max(r,m+Math.max(-u,0))}return{bleed:{top:W(r),right:W(i),bottom:W(o),left:W(s)},has:a}}function Af(t){let e=lo(t),n=fo(t),r=uo(t),i=po(t),o=ho(t);return{top:Math.max(e.top,n.top)+r.top+i.top+o.bleed.top,right:Math.max(e.right,n.right)+r.right+i.right+o.bleed.right,bottom:Math.max(e.bottom,n.bottom)+r.bottom+i.bottom+o.bleed.bottom,left:Math.max(e.left,n.left)+r.left+i.left+o.bleed.left}}function Mf(t){return t.boxShadow&&t.boxShadow!=="none"||t.textShadow&&t.textShadow!=="none"||(t.outlineStyle||"none")!=="none"||t.filter&&t.filter!=="none"?!0:!!t.webkitFilter&&t.webkitFilter!=="none"}function _s(t){let e=t.overflowX||t.overflow||"visible",n=t.overflowY||t.overflow||"visible",r=!!t.contain&&/\\b(paint|content|strict)\\b/.test(t.contain)||!!t.clipPath&&t.clipPath!=="none";return{x:r||e!=="visible",y:r||n!=="visible"}}function Rs(t,e,n,r=1,i=1){let o=0,s=0,a=0,c=0,f=_s(n.get(t)||O(t));if(f.x&&f.y)return{top:0,right:0,bottom:0,left:0};let l=t.getBoundingClientRect();for(let u of e.values()){if(u===t||u.nodeType!==1||u.ownerDocument!==t.ownerDocument)continue;let p=n.get(u);if(!p||!Mf(p))continue;let h=Af(p);if(!(h.top||h.right||h.bottom||h.left))continue;let m=u.getBoundingClientRect(),d={left:m.left-h.left/r,top:m.top-h.top/i,right:m.right+h.right/r,bottom:m.bottom+h.bottom/i};for(let g=u.parentElement;g;g=g.parentElement){let y=_s(n.get(g)||O(g));if(y.x||y.y){let b=g.getBoundingClientRect();y.x&&(d.left=Math.max(d.left,b.left),d.right=Math.min(d.right,b.right)),y.y&&(d.top=Math.max(d.top,b.top),d.bottom=Math.min(d.bottom,b.bottom))}if(g===t)break}f.x||(c=Math.max(c,(l.left-d.left)*r),s=Math.max(s,(d.right-l.right)*r)),f.y||(o=Math.max(o,(l.top-d.top)*i),a=Math.max(a,(d.bottom-l.bottom)*i))}return{top:Math.max(0,Math.ceil(o)),right:Math.max(0,Math.ceil(s)),bottom:Math.max(0,Math.ceil(a)),left:Math.max(0,Math.ceil(c))}}function Fs(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 r=n.transform||"none";if(!r||r==="none"){let c=null;try{c=ce(t).scale}catch{}try{e.style.transform="none"}catch{}if(!c)return{a:1,b:0,c:0,d:1};let f=Jt({scale:c});return{a:f.a,b:f.b,c:f.c,d:f.d}}function i(c,f,l,u){let p=Math.sqrt(c*c+f*f)||0,h=0,m=0;if(p>0){let d=c/p,g=f/p;h=d*l+g*u;let y=l-d*h,b=u-g*h;m=Math.sqrt(y*y+b*b)||0,m>0?h=h/m:h=0}return{a:p,b:0,c:h*m,d:m}}let o=c=>{let f=ce(t).scale;if(!f)return c;let l=Jt({scale:f,baseTransform:`matrix(${c.a},${c.b},${c.c},${c.d},0,0)`});return{a:l.a,b:l.b,c:l.c,d:l.d}},s=r.match(/^matrix\\(\\s*([^)]+)\\)$/i);if(s){let c=s[1].split(",").map(f=>parseFloat(f.trim()));if(c.length===6&&c.every(Number.isFinite)){let[f,l,u,p]=c,h=i(f,l,u,p);try{e.style.transform=`matrix(${h.a}, ${h.b}, ${h.c}, ${h.d}, 0, 0)`}catch{}return o(h)}}let a=r.match(/^matrix3d\\(\\s*([^)]+)\\)$/i);if(a){let c=a[1].split(",").map(f=>parseFloat(f.trim()));if(c.length===16&&c.every(Number.isFinite)){let f=c[0],l=c[1],u=c[4],p=c[5],h=i(f,l,u,p);try{e.style.transform=`matrix(${h.a}, ${h.b}, ${h.c}, ${h.d}, 0, 0)`}catch{}return o(h)}}try{let c=new DOMMatrix(r),f=i(c.a,c.b,c.c,c.d);try{e.style.transform=`matrix(${f.a}, ${f.b}, ${f.c}, ${f.d}, 0, 0)`}catch{}return o(f)}catch{return null}}function Oe(t,e,n,r,i){let o=n.a,s=n.b,a=n.c,c=n.d,f=n.e||0,l=n.f||0;function u(y,b){let S=y-r,k=b-i,v=o*S+a*k,w=s*S+c*k;return v+=r+f,w+=i+l,[v,w]}let p=[u(0,0),u(t,0),u(0,e),u(t,e)],h=1/0,m=1/0,d=-1/0,g=-1/0;for(let[y,b]of p)y<h&&(h=y),b<m&&(m=b),y>d&&(d=y),b>g&&(g=b);return{minX:h,minY:m,maxX:d,maxY:g,width:d-h,height:g-m}}function cn(t,e,n){let r=(t.transformOrigin||"0 0").trim().split(/\\s+/),[i,o]=[r[0]||"0",r[1]||"0"],s=(a,c)=>{let f=a.toLowerCase();return f==="left"||f==="top"?0:f==="center"?c/2:f==="right"||f==="bottom"?c:f.endsWith("px")?parseFloat(f)||0:f.endsWith("%")?(parseFloat(f)||0)*c/100:/^-?\\d+(\\.\\d+)?$/.test(f)&&parseFloat(f)||0};return{ox:s(i,e),oy:s(o,n)}}function ce(t){let e={rotate:"0deg",scale:null,translate:null},n=null;try{n=typeof t.computedStyleMap=="function"?t.computedStyleMap():null}catch{}if(n){let i=c=>{try{return typeof n.has=="function"&&!n.has(c)||typeof n.get!="function"?null:n.get(c)}catch{return null}},o=i("rotate");if(o)if(o.angle){let c=o.angle;e.rotate=c.unit==="rad"?c.value*180/Math.PI+"deg":c.value+c.unit,o.is2D===!1&&o.x&&o.y&&o.z&&(e.rotate=`${o.x.value} ${o.y.value} ${o.z.value} ${e.rotate}`)}else o.unit?e.rotate=o.unit==="rad"?o.value*180/Math.PI+"deg":o.value+o.unit:e.rotate=String(o);else{let c=getComputedStyle(t);e.rotate=c.rotate&&c.rotate!=="none"?c.rotate:"0deg"}let s=i("scale");if(s){let c=f=>f&&f.value!=null?`${f.value}${f.unit==="percent"?"%":""}`:null;"x"in s&&s.x?.value!=null?e.scale=[c(s.x),c(s.y)??c(s.x),...s.is2D===!1?[c(s.z)??"1"]:[]].join(" "):Array.isArray(s)?e.scale=s.map(c).join(" "):e.scale=String(s)}else{let c=getComputedStyle(t);e.scale=c.scale&&c.scale!=="none"?c.scale:null}let a=i("translate");if(a){let c=f=>f&&f.value!=null?`${f.value}${f.unit==="percent"?"%":f.unit||"px"}`:null;"x"in a&&a.x?.value!=null?e.translate=[c(a.x),c(a.y)??"0px",...a.is2D===!1?[c(a.z)??"0px"]:[]].join(" "):Array.isArray(a)?e.translate=a.map(c).join(" "):e.translate=String(a)}else{let c=getComputedStyle(t);e.translate=c.translate&&c.translate!=="none"?c.translate:null}return(!e.rotate||e.rotate==="none")&&(e.rotate="0deg"),(!e.scale||e.scale==="none")&&(e.scale=null),(!e.translate||e.translate==="none")&&(e.translate=null),e}let r=getComputedStyle(t);return e.rotate=r.rotate&&r.rotate!=="none"?r.rotate:"0deg",e.scale=r.scale&&r.scale!=="none"?r.scale:null,e.translate=r.translate&&r.translate!=="none"?r.translate:null,e}var co=null;function _f(){if(co?.isConnected)return co;let t=document.createElement("div");return t.id="snapdom-measure-slot",t.setAttribute("aria-hidden","true"),tt(t),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),co=t,t}function Jt(t){let e=o=>{let s=[],a=0,c=0,f=String(o).trim();for(let l=0;l<f.length;l++)f[l]==="("?a++:f[l]===")"?a--:/\\s/.test(f[l])&&!a&&(l>c&&s.push(f.slice(c,l)),c=l+1);return c<f.length&&s.push(f.slice(c)),s},n=o=>o&&o!=="none",r=[];if(n(t.translate)){let o=e(t.translate);for(let s=0;s<2&&s<o.length;s++){let a=s===0?t.width:t.height;/^[+-]?(?:\\d*\\.)?\\d+%$/.test(o[s])&&Number.isFinite(a)&&(o[s]=`${parseFloat(o[s])*a/100}px`)}r.push(o.length>2?`translate3d(${o.join(",")})`:`translate(${o.join(",")})`)}if(n(t.rotate)&&t.rotate!=="0deg"){let o=e(t.rotate);o.length===4?r.push(`rotate3d(${o.join(",")})`):o.length===2&&/^[xyz]$/i.test(o[0])?r.push(`rotate${o[0].toUpperCase()}(${o[1]})`):r.push(`rotate(${o.join(" ")})`)}if(n(t.scale)){let o=e(t.scale).map(s=>/%$/.test(s)?String(parseFloat(s)/100):s);r.push(o.length>2?`scale3d(${o.join(",")})`:`scale(${o.join(",")})`)}if(n(t.baseTransform)&&r.push(t.baseTransform),!r.length)return new DOMMatrix;let i=r.join(" ");try{if(i.includes("%"))throw new Error("Transform needs a reference box");return new DOMMatrix(i)}catch{let o=_f(),s=document.createElement("div");if(s.style.cssText="all:initial!important;display:block!important;transform-origin:0 0!important",s.style.setProperty("width",`${Number.isFinite(t.width)?t.width:0}px`,"important"),s.style.setProperty("height",`${Number.isFinite(t.height)?t.height:0}px`,"important"),s.style.setProperty("transform",i,"important"),!s.style.transform)throw new Error("Invalid transform composition");o.appendChild(s);try{return Ef(s)}finally{s.remove()}}}function Ts(t){let e=O(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 i=e.rotate&&e.rotate!=="none"&&e.rotate!=="0deg",o=e.scale&&e.scale!=="none"&&e.scale!=="1",s=e.translate&&e.translate!=="none"&&e.translate!=="0px 0px";return!!(i||o||s)}function Ef(t){let e=getComputedStyle(t).transform;if(!e||e==="none")return new DOMMatrix;try{return new DOMMatrix(e)}catch{return new WebKitCSSMatrix(e)}}var Ls=new WeakSet;function Un(t,e){if(!e)return null;let n=t.ownerDocument||document,r=n.defaultView||window,i,o,s,a;if(e==="viewport")i=0,o=0,s=n.documentElement?.clientWidth||r.innerWidth,a=n.documentElement?.clientHeight||r.innerHeight;else if(typeof e=="object")i=(Number(e.x)||0)-(r.scrollX||0),o=(Number(e.y)||0)-(r.scrollY||0),s=Number(e.width),a=Number(e.height);else return null;return s>0&&a>0?{left:i,top:o,width:s,height:a,right:i+s,bottom:o+a}:null}function mo(t){if(t.parentElement)return t.parentElement;let e=t.getRootNode&&t.getRootNode();return Wt(e)?e.host:null}function Rf(t,e){for(let n=e;n;n=mo(n))if(n===t)return!0;return!1}function Ff(t,e){for(let n=mo(t);n&&n!==e&&n?.nodeType===1;n=mo(n)){let r=O(n);if(r.position!=="static"||r.transform&&r.transform!=="none"||r.filter&&r.filter!=="none"||r.backdropFilter&&r.backdropFilter!=="none"||r.perspective&&r.perspective!=="none"||/transform|perspective|filter/.test(r.willChange||"")||/layout|paint|strict|content/.test(r.contain||""))return n}return null}function yo(t,e){try{return Jt({baseTransform:t,rotate:e?.rotate,scale:e?.scale})}catch{return null}}function Is(t,e,n,r,i){let o=t.getBoundingClientRect();Rt(e)&&O(t).position==="static"&&(e.style.position="relative");let s=[];for(let[a,c]of n){if(!Rt(a)||c?.nodeType!==1||c===t||!Rf(t,c))continue;let f=r.get(c)||O(c),l=f.position;if(l!=="fixed"&&l!=="sticky"&&l!=="-webkit-sticky"||a.style.position==="absolute")continue;let u=c.getBoundingClientRect();if(!(u.width>0&&u.height>0))continue;Ls.add(a);let p=f.transform&&f.transform!=="none"?f.transform:"",h=ce(c),m=!!(p||h.rotate!=="0deg"||h.scale||h.translate),d=m?yo(p,h):null,g=!d||!d.is2D||d.a===1&&d.b===0&&d.c===0&&d.d===1,y=u.width,b=u.height;g||(y=c.offsetWidth||u.width,b=c.offsetHeight||u.height);let S=c.getRootNode&&Wt(c.getRootNode()),k=o,v=t.clientLeft||0,w=t.clientTop||0;if(S){let _=Ff(c,t);_&&(k=_.getBoundingClientRect(),v=_.clientLeft||0,w=_.clientTop||0)}let M=u.left-k.left-v,A=u.top-k.top-w;if(m)if(a.style.translate="none",a.style.rotate="none",a.style.scale="none",g)a.style.transform="none";else{a.style.transform=`matrix(${d.a},${d.b},${d.c},${d.d},0,0)`;let{ox:_,oy:R}=cn(f,y,b),$=Oe(y,b,{a:d.a,b:d.b,c:d.c,d:d.d,e:0,f:0},_,R);M-=$.minX,A-=$.minY}if(l!=="fixed"){let _=a.cloneNode(!1);_.setAttribute("data-snap-ph","1"),_.style.position="static",_.style.visibility="hidden",_.style.width=`${y}px`,_.style.height=`${b}px`,_.style.boxSizing="border-box",a.parentElement?.insertBefore(_,a)}let C=y+2,x=b;i&&(Math.abs(A-i.y)<.5&&(A-=1,x+=1),Math.abs(M-i.x)<.5&&(M-=1,C+=1)),a.style.position="absolute",a.style.left=`${M}px`,a.style.top=`${A}px`,a.style.right="auto",a.style.bottom="auto",a.style.margin="0",a.style.width=`${C}px`,a.style.height=`${x}px`,a.style.boxSizing="border-box",S||s.push(a)}for(let a of s)e.appendChild(a)}function Ws(t,e,n={}){if(!t||!e||!e.style)return;let r=getComputedStyle(t);try{e.style.boxShadow="none"}catch(s){H(n,"stripRootShadows boxShadow",s)}try{e.style.textShadow="none"}catch(s){H(n,"stripRootShadows textShadow",s)}try{e.style.outline="none"}catch(s){H(n,"stripRootShadows outline",s)}let o=(r.filter||"").replace(/\\bdrop-shadow\\((?:[^()]|\\([^()]*\\))*\\)\\s*/gi,"").trim().replace(/\\s+/g," ");try{e.style.filter=o.length?o:"none"}catch(s){H(n,"stripRootShadows filter",s)}}function Os(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 $s(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",r=t.overflowY||t.overflow||"visible";return!!(n!=="visible"||r!=="visible"||t.contain&&/\\b(layout|content|paint|strict)\\b/.test(t.contain))}function Tf(t,e){let n=Array.from(t.childNodes),r=e==="top"?n:n.reverse();for(let i of r){if(i.nodeType===Node.TEXT_NODE){if(/\\S/.test(i.textContent||""))return null;continue}if(i.nodeType!==Node.ELEMENT_NODE)continue;let o=getComputedStyle(i),s=String(o.display||"");if(!(s==="none"||s==="contents")&&!(o.position==="absolute"||o.position==="fixed"))return o.float&&o.float!=="none"||s.startsWith("inline")?null:i}return null}function Ds(t,e,n){if(!t||!e||!e.style)return;let r=getComputedStyle(t);if(!$s(r))for(let i of["top","bottom"]){let o=i==="top"?"Top":"Bottom";if((parseFloat(r[`border${o}Width`])||0)>0||(parseFloat(r[`padding${o}`])||0)>0)continue;let s=t,a=e;for(;s&&a;){let c=Tf(s,i);if(!c)break;let f=n?Array.from(a.children).find(p=>n.get(p)===c)||null:a.children[Array.from(s.children).indexOf(c)]||null,l=getComputedStyle(c),u=parseFloat(l[`margin${o}`])||0;if(f&&f.style&&u>0&&(f.style[`margin${o}`]="0px"),$s(l)||(parseFloat(l[`border${o}Width`])||0)>0||(parseFloat(l[`padding${o}`])||0)>0)break;s=c,a=f}}}var $f=new Set(["xml","xlink"]);function Pf(t,e){if(t.startsWith("*")||t.includes("@"))return!0;if(t.includes(":")){let n=t.split(":",1)[0];if(!$f.has(n))return!0}return e?t.startsWith("x-")||t.startsWith("v-")||t.startsWith(":")||t.startsWith("on:")||t.startsWith("bind:")||t.startsWith("let:")||t.startsWith("class:"):!1}var Nf=/[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\uD800-\\uDFFF\\uFFFE\\uFFFF]/g,Ps=t=>t.replace(Nf,e=>e.length===2?e:""),Lf=/^data:[^,]{0,120};base64,/;function zn(t,e={}){if(!t)return;let{stripFrameworkDirectives:n=!0}=e,r=a=>{for(let c of Array.from(a.attributes)){if(Pf(c.name,n)){a.removeAttribute(c.name);continue}if(Lf.test(c.value))continue;let f=Ps(c.value);if(f!==c.value)try{a.setAttribute(c.name,f)}catch{}}};t.nodeType===Node.ELEMENT_NODE&&r(t);let i=[],o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT|NodeFilter.SHOW_COMMENT),s;for(;s=o.nextNode();)if(s.nodeType===Node.ELEMENT_NODE)r(s);else if(s.nodeType===Node.COMMENT_NODE)i.push(s);else{let a=Ps(s.data);a!==s.data&&(s.data=a)}for(let a of i)a.remove()}function If(t){try{let e=t.getAttribute?.("style")||"";return/\\b(height|width|block-size|inline-size)\\s*:/.test(e)}catch{return!1}}var Wf=new Set(["img","canvas","video","iframe","object","embed"]);function Of(t){return It(t)||Wf.has(t?.localName)}function Df(t,e){if(t?.nodeType!==1||If(t)||Of(t))return!1;let n=e.position;if(n==="absolute"||n==="fixed"||n==="sticky")return!1;let r=e.display||"";return!(r.includes("flex")||r.includes("grid")||r.startsWith("table")||e.transform&&e.transform!=="none")}function Bs(t,e,n=new Map,r=null){function i(o,s){if(o?.nodeType!==1||s?.nodeType!==1)return;let a=o.childElementCount>s.childElementCount,c=n.get(o)||getComputedStyle(o);if(n.has(o)||n.set(o,c),a&&Df(o,c)){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=c.overflowY||c.overflowBlock||"visible",u=c.overflowX||c.overflowInline||"visible";(l!=="visible"||u!=="visible")&&(s.style.overflow="visible")}let f=Array.from(s.children);if(r)for(let l of f){let u=r.get(l);u&&u.nodeType===1&&i(u,l)}else{let l=Array.from(o.children);for(let u=0;u<Math.min(l.length,f.length);u++)i(l[u],f[u])}}i(t,e)}function Bf(t){let e=getComputedStyle(t);return!(e.display==="none"||e.position==="absolute"||e.position==="fixed")}function Uf(t,e){if(t?.nodeType!==1)return!1;if(t.getAttribute("data-capture")==="exclude")return e?.excludeMode==="remove";if(Array.isArray(e?.exclude))for(let n of e.exclude)try{if(t.matches(n))return e.excludeMode==="remove"}catch(r){H(e,"exclude selector match failed",r)}if(Array.isArray(e?.excludePredicates))for(let n of e.excludePredicates)try{if(n(t))return e.excludeMode==="remove"}catch(r){H(e,"exclude predicate failed",r)}if(typeof e?.filter=="function"&&e.filterMode==="remove")try{if(!e.filter(t))return!0}catch(n){H(e,"filter function failed",n)}return!1}function bo(t,e){let n=getComputedStyle(t),r=t.getBoundingClientRect(),i=1/0,o=-1/0,s=!1,a=Array.from(t.children);for(let h of a){if(Uf(h,e)||!Bf(h))continue;let m=h.getBoundingClientRect(),d=m.top-r.top,g=m.bottom-r.top;g<=d||(d<i&&(i=d),g>o&&(o=g),s=!0)}let c=s?Math.max(0,o-i):0,f=parseFloat(n.borderTopWidth)||0,l=parseFloat(n.borderBottomWidth)||0,u=parseFloat(n.paddingTop)||0,p=parseFloat(n.paddingBottom)||0;return f+l+u+p+c}var W=(t,e=3)=>Number.isFinite(t)?Math.round(t*10**e)/10**e:t,De=.75;function Us(t,e,n,r,i,o){let s=t.ownerDocument||document,a=t.getBoundingClientRect(),c=i>0&&a.width>0?a.width/i:1,f=o>0&&a.height>0?a.height/o:1;if(Math.abs(c-f)>.02)return 0;let l=s.createElement("div");tt(l),l.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;width:"+i+"px!important;overflow:visible!important;visibility:hidden!important;";let u=l.attachShadow({mode:"open"}),p=s.createElement("style");p.textContent=n,u.appendChild(p);let h=e.cloneNode(!0);u.appendChild(h),s.body.appendChild(l);let m=0,d=(g,y,b)=>{let S=O(g),k=S.boxSizing==="border-box",v=(w,M,...A)=>{let C=parseFloat(w);if(!Number.isFinite(C))return M;let x=C+(k?0:A.reduce((_,R)=>_+(parseFloat(R)||0),0));return Math.abs(x-M)<=.51?x:M};return{width:v(S.width,y,S.paddingLeft,S.paddingRight,S.borderLeftWidth,S.borderRightWidth),height:v(S.height,b,S.paddingTop,S.paddingBottom,S.borderTopWidth,S.borderBottomWidth)}};try{let g=h.getBoundingClientRect(),y=h.offsetWidth||i,b=h.offsetHeight||o,S=y>0&&g.width>0?g.width/y:1,k=b>0&&g.height>0?g.height/b:1,v=(w,M,A=!1)=>{let C=w.children,x=M.children,_=Math.min(C.length,x.length);for(let R=0;R<_;R++){let $=C[R],T=x[R],I=r.get($),B=A||Ls.has($);if(I?.nodeType===1&&Rt($)&&$.style&&I.isConnected){let E=I.getBoundingClientRect();if(E.width>0&&E.height>0){let N=T.getBoundingClientRect(),P=E.width/c,F=E.height/f,z=N.width,V=N.height,j=I.offsetWidth||P,D=I.offsetHeight||F,K=T.offsetWidth||z,ht=T.offsetHeight||V,St=Math.abs(P-j)>De||Math.abs(F-D)>De||Math.abs(z-K)>De||Math.abs(V-ht)>De;if(B){let ct=d(T,K,ht);P=z>0?P*S*ct.width/z:P,F=V>0?F*k*ct.height/V:F,z=ct.width,V=ct.height}else if(St){let ct=d(I,j,D),xt=d(T,K,ht);P=ct.width,F=ct.height,z=xt.width,V=xt.height}let ft=z-P,at=V-F;(Math.abs(ft)>De||Math.abs(at)>De)&&($.style.boxSizing="border-box",$.style.width=`${W(P)}px`,$.style.height=`${W(F)}px`,m++)}}v($,T,B)}};v(e,h)}finally{l.remove()}return m}var zf=/::-(?:webkit-(?:scrollbar|meter|progress|slider)|moz-(?:meter|progress))/i;function go(t,e=new Set){let n="";if(!t)return n;for(let r=0;r<t.length;r++){let i=t[r];try{if(i.type===CSSRule.IMPORT_RULE&&i.styleSheet){n+=go(i.styleSheet.cssRules,e);continue}if(i.type===CSSRule.MEDIA_RULE&&i.cssRules){let o=go(i.cssRules,e);o&&(n+=`@media ${i.conditionText}{${o}}`);continue}if(i.type===CSSRule.STYLE_RULE){let o=i.selectorText||"";if(zf.test(o)){let s=i.cssText;s&&!e.has(s)&&(e.add(s),n+=s)}}}catch{}}return n}var Ns=new WeakMap;function Hf(t){let e="";for(let n of t.styleSheets){let r=-1;try{r=n.cssRules?n.cssRules.length:-1}catch{}e+=(n.href||"inline")+":"+r+"|"}return e}function jf(t){if(!t||!t.styleSheets)return"";let e=Hf(t),n=Ns.get(t);if(n&&n.fp===e)return n.css;let r=new Set,i="";for(let o of Array.from(t.styleSheets))try{let s=o.cssRules;s&&(i+=go(s,r))}catch{}return Ns.set(t,{fp:e,css:i}),i}function zs(t,e){let n=Nr(t.clone).sort(),r=n.join(","),i=nn(t.element),o=L.baseStyle.get(r),s;o&&o.universe===i?s=o.css:(s=Lr(n,i),L.baseStyle.set(r,{universe:i,css:s}));let a=jf(t.element?.ownerDocument||document);return t.fontsCSS=e,t.baseCSS=s,t.scrollbarCSS=a,{baseCSS:s,scrollbarCSS:a,fontsCSS:e}}yt();var Hn=new Set;async function Hs(t,e={}){Tt(),Cn(t.ownerDocument||document);let n=e.__session||{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map},r={styleMap:n.styleMap,styleCache:n.styleCache,nodeMap:n.nodeMap,options:e,slicer:e.__slicer||null},i=null,o=null;if(e.clip&&(o=Un(t,e.clip),o&&(r.clip={rect:o,root:t})),e.captureSelection)try{r.selection=Ki(t)}catch(d){H(r,"prepareSelectionContext failed",d)}let s,a="",c="";if(Hn.size){let d=(g,y)=>{for(let b=y;b;b=b.assignedSlot||b.parentElement||b.getRootNode()?.host)if(b===g)return!0;return!1};for(;;){let g=[...Hn].filter(({root:y})=>d(y,t)||d(t,y)).map(({promise:y})=>y.catch(()=>{}));if(!g.length)break;await Promise.all(g)}}if(!r.clip&&t.isConnected&&t.ownerDocument?.visibilityState!=="hidden")try{let d=t.getBoundingClientRect(),g=t.ownerDocument?.defaultView||window,y=d.right<=0||d.bottom<=0||d.left>=g.innerWidth||d.top>=g.innerHeight,b=[];if(y&&(()=>{let k=[];t.shadowRoot&&k.push(t.shadowRoot);for(let v of t.querySelectorAll("*"))v.shadowRoot&&k.push(v.shadowRoot);for(;k.length;){let v=k.pop(),w=v.host?.localName==="calcite-icon";for(let M of v.querySelectorAll("*")){if(M.shadowRoot&&k.push(M.shadowRoot),!w||M.localName!=="svg")continue;let A=M.querySelectorAll("path");if(!A.length||[...A].some(x=>x.getAttribute("d")?.trim()))continue;let C=M.getBoundingClientRect();C.width&&C.height&&b.push(M)}}})(),b.length){let k=(async()=>{let w=t.style,M=t.hasAttribute("style"),A=new Map,C=(x,_)=>{A.has(x)||A.set(x,{value:w.getPropertyValue(x),priority:w.getPropertyPriority(x)}),w.setProperty(x,_,"important");let R=A.get(x);R.forcedValue=w.getPropertyValue(x),R.forcedPriority=w.getPropertyPriority(x)};try{C("left","0"),C("top","0"),C("right","auto"),C("bottom","auto"),C("margin-top","0"),C("margin-right","0"),C("margin-bottom","0"),C("margin-left","0"),C("transform","none"),C("translate","none"),C("opacity","0"),C("pointer-events","none");let x=t.getBoundingClientRect();if(x.right<=0||x.bottom<=0||x.left>=g.innerWidth||x.top>=g.innerHeight){let $=t.parentElement?.getBoundingClientRect(),T=$&&$.right>0&&$.left<g.innerWidth?Math.max(0,$.left):0,I=$&&$.bottom>0&&$.top<g.innerHeight?Math.max(0,$.top):0;C("position","fixed"),C("left",`${T}px`),C("top",`${I}px`)}await gt(100);let _=Date.now()+1500,R=()=>b.some($=>{if([...$.querySelectorAll("path")].some(I=>I.getAttribute("d")?.trim()))return!1;let T=$.getBoundingClientRect();return T.width&&T.height&&T.right>0&&T.bottom>0&&T.left<g.innerWidth&&T.top<g.innerHeight});for(;Date.now()<_&&R();)await new Promise($=>setTimeout($,25));await gt(100)}finally{for(let[x,_]of A)w.getPropertyValue(x)!==_.forcedValue||w.getPropertyPriority(x)!==_.forcedPriority||(_.value?w.setProperty(x,_.value,_.priority):w.removeProperty(x));!M&&!w.length&&t.removeAttribute("style"),await gt(100)}})(),v={root:t,promise:k};Hn.add(v);try{await k}finally{Hn.delete(v)}}}catch{}let f=Ms(t),l=Bn(t,o);if(o){let d=t.getBoundingClientRect(),g=t.offsetWidth||d.width,y=t.offsetHeight||d.height,b=d.width&&Math.abs(g-d.width)>=1?g/d.width:1,S=d.height&&Math.abs(y-d.height)>=1?y/d.height:1;i={x:(o.left-d.left)*b,y:(o.top-d.top)*S,width:o.width*b,height:o.height*S}}try{s=await Qt(t,r,e)}catch(d){throw console.warn("deepClone failed:",d),d}finally{l(),f()}r.slicer?.due()&&await r.slicer.pause();try{As(s,void 0,t)}catch(d){console.warn("inlineExternal defs or symbol failed:",d)}try{await We(t,s,r,e)}catch(d){console.warn("inlinePseudoElements failed:",d)}await _n(s,r);for(let[d,g]of r.nodeMap.entries())if(g?.tagName==="STYLE"&&d?.tagName==="STYLE"&&!d.hasAttribute("data-sd"))try{let y=g.sheet&&g.sheet.cssRules;y&&/@media/i.test(d.textContent||"")&&(d.textContent=ae(y))}catch{}try{let d=s.querySelectorAll("style[data-sd]");for(let g of d)c+=g.textContent||"",g.remove()}catch(d){H(r,"Shadow CSS extraction failed",d)}r.slicer?.due()&&await r.slicer.pause();let u=Ye(r.styleMap);a=Array.from(u.entries()).map(([d,g])=>`.${g}{${d}}`).join("");let h=c+"[data-snapdom-has-after]::after,[data-snapdom-has-before]::before{content:none!important;display:none!important}"+(r.__pseudoCSS||"");a=h+a;for(let[d,g]of r.styleMap.entries())wo(d,g,u);try{Vf(t,s,r.nodeMap)}catch(d){H(r,"top-layer lift failed",d)}if((r.clip||t.scrollTop||t.scrollLeft)&&s?.nodeType===1)try{let d=r.clip&&i?{x:i.x,y:i.y}:{x:0,y:0};Is(t,s,r.nodeMap,r.styleCache,d)}catch(d){H(r,"freezeViewportPositioned failed",d)}for(let[d,g]of r.nodeMap.entries())r.clip&&g===t||So(d,g);let m=t.ownerDocument;if((t===m.body||t===m.documentElement)&&m.documentElement.localName==="html"){let d=r.styleCache.get(m.documentElement)||O(m.documentElement);t===m.documentElement&&(s.style.overflow="visible");let g=t===m.body?s:s.querySelector("body");if(g&&d.overflowX==="visible"&&d.overflowY==="visible"&&d.contain==="none"&&!d.containerType?.includes("size")&&d.contentVisibility!=="auto"&&d.contentVisibility!=="hidden"){let y=r.styleCache.get(m.body)||O(m.body);y.contain==="none"&&!y.containerType?.includes("size")&&y.contentVisibility!=="auto"&&y.contentVisibility!=="hidden"&&y.display!=="none"&&(g.style.overflow="visible")}}if(t===r.nodeMap.get(s)){let d=r.styleCache.get(t)||O(t);r.styleCache.set(t,d);let g=vr(d.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=g||"",s.style.translate="none"}for(let[d,g]of r.nodeMap.entries())g.tagName==="PRE"&&(d.style.marginTop="0",d.style.marginBlockStart="0");return{clone:s,classCSS:a,classPrefixCSS:h,styleCache:r.styleCache,nodeMap:r.nodeMap,reconcileRisk:r.reconcileRisk||0,clipWindow:i}}function Vf(t,e,n){let r=[];for(let s of[":modal",":popover-open"])try{r.push(...t.querySelectorAll(s))}catch{}if(!r.length)return;let i=new Map;for(let[s,a]of n.entries())i.set(a,s);let o=214748e4;for(let s of r){let a=i.get(s);if(!(!a||a===e||a.parentNode==null)){try{let c=getComputedStyle(s,"::backdrop"),f=c.backgroundColor,l=c.backgroundImage;if(f&&f!=="rgba(0, 0, 0, 0)"&&f!=="transparent"||l&&l!=="none"){let p=document.createElement("div");p.setAttribute("data-sd-backdrop",""),p.style.cssText=`position:fixed;inset:0;z-index:${o};background-color:${f};`+(l&&l!=="none"&&l.includes("data:")?`background-image:${l};`:""),e.appendChild(p)}}catch{}o+=1,a.style.zIndex=String(o),e.appendChild(a),o+=1}}}function wo(t,e,n){if(t.tagName==="STYLE")return;if(t.getRootNode&&Wt(t.getRootNode())){t.setAttribute("style",e.replace(/;/g,"; "));return}let r=n.get(e);r&&t.classList.add(r);let i=t.style?.backgroundImage,o=t.dataset?.snapdomHasIcon;i&&i!=="none"&&(t.style.backgroundImage=i),o&&(t.style.verticalAlign="middle",t.style.display="inline")}function So(t,e){let n=e.scrollLeft,r=e.scrollTop;if(!(n||r)||t?.nodeType!==1||t.namespaceURI!=="http://www.w3.org/1999/xhtml")return;t.style.overflow="hidden",t.style.scrollbarWidth="none",t.style.msOverflowStyle="none";try{let s=t.querySelectorAll("*");for(let a of s){if(a.nodeType!==1||a.namespaceURI!=="http://www.w3.org/1999/xhtml")continue;let c=a.style.position;if(c==="fixed"||c==="absolute"){let f=parseFloat(a.style.top)||0,l=parseFloat(a.style.left)||0;a.style.top=`${f+r}px`,a.style.left=`${l+n}px`,c==="fixed"&&(a.style.position="absolute")}}}catch{}let o=document.createElement("div");for(o.style.all="unset",o.style.transform=`translate(${-n}px, ${-r}px)`,o.style.willChange="transform",o.style.display="inline-block",o.style.width="100%";t.firstChild;)o.appendChild(t.firstChild);t.appendChild(o)}Se();ne();mt();var js="http://www.w3.org/1999/xlink";function qf(t){return t.getAttribute("href")||t.getAttribute("xlink:href")||(typeof t.getAttributeNS=="function"?t.getAttributeNS(js,"href"):null)}function Gf(t){let e=parseFloat(t.dataset?.snapdomWidth||"")||0,n=parseFloat(t.dataset?.snapdomHeight||"")||0,r=parseInt(t.getAttribute("width")||"",10)||0,i=parseInt(t.getAttribute("height")||"",10)||0,o=parseFloat(t.style?.width||"")||0,s=parseFloat(t.style?.height||"")||0,a=e||o||r||t.width||t.naturalWidth||100,c=n||s||i||t.height||t.naturalHeight||100;return{width:a,height:c}}async function jn(t,e={}){let n=Array.from(t.querySelectorAll("img"));t.tagName==="IMG"&&n.unshift(t);let r=async a=>{if(!a.getAttribute("src")){let m=a.currentSrc||a.src||Pe(a.getAttribute("srcset"),a)||"";m&&a.setAttribute("src",m)}if(a.removeAttribute("srcset"),a.removeAttribute("sizes"),(a.getAttribute("src")||"").startsWith("data:")){a.width||(a.width=a.naturalWidth||100),a.height||(a.height=a.naturalHeight||100);return}let c=a.src||"";if(!c)return;let f=L.image?.get(c);if(f){a.src=f,a.width||(a.width=a.naturalWidth||100),a.height||(a.height=a.naturalHeight||100);return}let l=await dt(c,{as:"dataURL",useProxy:e.useProxy});if(l.ok&&typeof l.data=="string"&&l.data.startsWith("data:")){L.image?.set(c,l.data),a.src=l.data,l.blob&&(a.__snapdomBlob=l.blob),a.width||(a.width=a.naturalWidth||100),a.height||(a.height=a.naturalHeight||100);return}let{width:u,height:p}=Gf(a),{fallbackURL:h}=e||{};if(h)try{let m=typeof h=="function"?await h({width:u,height:p,src:c,element:a}):h;if(m){let d=await dt(m,{as:"dataURL",useProxy:e.useProxy});if(d?.ok&&typeof d.data=="string"){a.src=d.data,a.width||(a.width=u),a.height||(a.height=p);return}}}catch{}if(e.placeholders!==!1){At(e.__session,"image-fallback",`image failed to inline, using placeholder: ${c}`);let m=document.createElement("div");m.style.cssText=[`width:${u}px`,`height:${p}px`,"background:#ccc","display:inline-block","text-align:center",`line-height:${p}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:${u}px;height:${p}px;visibility:hidden;`,a.replaceWith(m)}},i=6;for(let a=0;a<n.length;a+=i){let c=n.slice(a,a+i).map(r);await Promise.allSettled(c)}let o=Array.from(t.querySelectorAll("image"));t.localName==="image"&&o.unshift(t);let s=async a=>{let c=qf(a);if(!c||c.startsWith("data:")||c.startsWith("blob:"))return;let f=await dt(c,{as:"dataURL",useProxy:e.useProxy});f.ok&&typeof f.data=="string"&&f.data.startsWith("data:")&&(a.setAttribute("href",f.data),a.removeAttribute("xlink:href"),typeof a.removeAttributeNS=="function"&&a.removeAttributeNS(js,"href"))};for(let a=0;a<o.length;a+=i){let c=o.slice(a,a+i).map(s);await Promise.allSettled(c)}}yt();bt();var Xf=["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"],Yf=["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"],Kf=["background-position","background-position-x","background-position-y","background-size","background-repeat","background-origin","background-clip","background-attachment","background-blend-mode"],Qf=["border-image-slice","border-image-width","border-image-outset","border-image-repeat"];async function Jf(t,e,n,r){let i=n.get(t)||O(t);n.has(t)||n.set(t,i);let o=Ai(t),s=o?m=>m in o?o[m]:"":m=>i.getPropertyValue(m),a=s("border-image"),c=s("border-image-source"),f=a&&a!=="none"||c&&c!=="none",l=i.getPropertyValue("background-image"),u=s("background-color"),p=l&&l!=="none"||u&&u!=="rgba(0, 0, 0, 0)"&&u!=="transparent"||/url\\s*\\(|gradient\\s*\\(/i.test(i.getPropertyValue("background")||""),h=$t()&&(s("background-clip")||s("-webkit-background-clip")||"").includes("text");if(p&&!h)for(let m of Kf){let d=s(m);d&&e.style.setProperty(m,d)}for(let m of Xf){if(h&&m==="background-image")continue;let d=i.getPropertyValue(m);if(m==="background-image"&&(!d||d==="none")){let b=i.getPropertyValue("background");b&&/url\\s*\\(/.test(b)&&(d=Gt(b).filter(S=>/url\\s*\\(/.test(S)).join(", ")||d)}if(!d||d==="none")continue;let g=Gt(d),y=await Promise.all(g.map(b=>xe(b,r)));y.some(b=>b&&b!=="none"&&!/^url\\(undefined/.test(b))&&e.style.setProperty(m,y.join(", "))}for(let m of Yf){let d=s(m);!d||d==="initial"||e.style.setProperty(m,d)}if(f)for(let m of Qf){let d=s(m);!d||d==="initial"||e.style.setProperty(m,d)}if(p&&/fixed/.test(s("background-attachment")||""))try{await tu(t,e,i)}catch{}}function Zf(t,e,n,r,i){let o=(t||"auto").trim();if(o==="cover"||o==="contain"){if(!e||!n)return{w:r,h:i};let p=o==="cover"?Math.max(r/e,i/n):Math.min(r/e,i/n);return{w:e*p,h:n*p}}let s=o.split(/\\s+/),a=(p,h)=>{if(p==="auto"||p===void 0)return null;if(p.endsWith("px"))return parseFloat(p);if(p.endsWith("%"))return h*parseFloat(p)/100},c=a(s[0],r),f=a(s[1],i);if(c===void 0||f===void 0)return null;let l=c,u=f;return l==null&&u==null?(l=e||r,u=n||i):l==null?l=e&&n?u*(e/n):r:u==null&&(u=e&&n?l*(n/e):i),!l||!u?null:{w:l,h:u}}async function tu(t,e,n){let r=(n.getPropertyValue("background-attachment")||"").split(",").map(m=>m.trim()),i=Ke();if(!i)for(let m=t.parentElement;m&&!i;m=m.parentElement){let d=O(m);(d.transform&&d.transform!=="none"||d.filter&&d.filter!=="none")&&(i=!0)}if(i){e.style.setProperty("background-attachment",r.map(()=>"scroll").join(", "));return}let o=t.getBoundingClientRect(),s=t.ownerDocument?.defaultView||window,a=s.innerWidth,c=s.innerHeight,f=Gt(e.style.backgroundImage||n.getPropertyValue("background-image")||""),l=(e.style.backgroundSize||n.getPropertyValue("background-size")||"auto").split(",").map(m=>m.trim()),u=(e.style.backgroundPosition||n.getPropertyValue("background-position")||"0% 0%").split(",").map(m=>m.trim()),p=[],h=[];for(let m=0;m<f.length;m++){let d=r[m%r.length]||"scroll",g=l[m%l.length],y=u[m%u.length];if(d!=="fixed"){p.push(g),h.push(y);continue}let b=0,S=0,k=f[m]&&f[m].match(/url\\(["\']?([^"\')]+)["\']?\\)/);if(k)try{let x=new Image;x.src=k[1],await x.decode(),b=x.naturalWidth,S=x.naturalHeight}catch{p.push(g),h.push(y);continue}let v=Zf(g,b,S,a,c);if(!v){p.push(g),h.push(y);continue}let w=y.split(/\\s+/),M=(x,_,R)=>{if(!x)return 0;if(x.endsWith("px"))return parseFloat(x);if(x.endsWith("%"))return(_-R)*parseFloat(x)/100},A=M(w[0]||"0%",a,v.w),C=M(w[1]||w[0]||"0%",c,v.h);if(A===void 0||C===void 0){p.push(g),h.push(y);continue}p.push(`${Vn(v.w)}px ${Vn(v.h)}px`),h.push(`${Vn(A-o.left)}px ${Vn(C-o.top)}px`)}e.style.setProperty("background-size",p.join(", ")),e.style.setProperty("background-position",h.join(", ")),e.style.setProperty("background-attachment",r.map(()=>"scroll").join(", "))}var Vn=t=>Math.round(t*100)/100;async function qn(t,e,n,r={},i=new Map){if(!e)return;let o=[];t&&qr(t)&&o.push([t,e]);let s=[e];for(;s.length;){let c=s.pop();if(c.children)for(let f of c.children){if(f.tagName==="STYLE")continue;let l=i.get(f);l&&qr(l)&&o.push([l,f]),s.push(f)}}let a=6;for(let c=0;c<o.length;c+=a)await Promise.allSettled(o.slice(c,c+a).map(([f,l])=>Jf(f,l,n,r)))}bt();function qs(t,e,n=new Map){let r=[],i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(let a=i.currentNode;a;a=i.nextNode()){let c=n.get(a);if(c?.nodeType!==1)continue;let f=O(c),l=f.getPropertyValue("backdrop-filter")||f.getPropertyValue("-webkit-backdrop-filter");l&&l!=="none"&&a!==e&&r.push({cloneEl:a,orig:c,bf:l,path:ou(e,a)})}if(!r.length)return;let o=t.getBoundingClientRect(),s=r.map((a,c)=>{let f=e.cloneNode(!0);ru(f,e,a.orig.getBoundingClientRect(),n),iu(Vs(f,a.path));for(let l=0;l<c;l++){let u=Vs(f,r[l].path);u&&(u.style.setProperty("backdrop-filter","none","important"),u.style.setProperty("-webkit-backdrop-filter","none","important"))}return{...a,copy:f}});for(let{cloneEl:a,orig:c,bf:f,copy:l}of s)eu.has(a.tagName)||nu(a,c,f,l,o)}var eu=new Set(["IMG","INPUT","TEXTAREA","SELECT","CANVAS","VIDEO","AUDIO","IFRAME","EMBED","OBJECT","PROGRESS","METER","HR","BR"]);function nu(t,e,n,r,i){let o=e.getBoundingClientRect();if(!o.width||!o.height)return;let s=O(e),a=e.offsetWidth?o.width/e.offsetWidth:1,c=Math.abs(a-1)>.001?1/a:1;r.style.position="absolute",r.style.left=`${(i.left-o.left)*c}px`,r.style.top=`${(i.top-o.top)*c}px`,r.style.width=`${i.width}px`,r.style.height=`${i.height}px`,r.style.margin="0",r.style.filter=n,c!==1&&(r.style.transform=`scale(${c})`,r.style.transformOrigin="top left");let f=document.createElement("div");f.style.cssText="position:absolute;inset:0;overflow:hidden;border-radius:inherit;z-index:-2",f.appendChild(r);let l=document.createElement("div");l.style.cssText="position:absolute;inset:0;border-radius:inherit;z-index:-1",l.style.backgroundColor=s.backgroundColor,l.style.backgroundImage=t.style.backgroundImage||s.backgroundImage;for(let u of["background-size","background-position","background-repeat","background-origin","background-clip"])l.style.setProperty(u,s.getPropertyValue(u));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"),s.position==="static"&&(t.style.position="relative"),t.style.isolation="isolate",t.prepend(l),t.prepend(f)}var Gn=128;function ru(t,e,n,r){let i=[[t,e]];for(;i.length;){let[o,s]=i.pop(),a=r.get(s);if(a?.nodeType===1){let l=a.getBoundingClientRect();(l.left>n.right+Gn||l.right<n.left-Gn||l.top>n.bottom+Gn||l.bottom<n.top-Gn)&&(o.tagName==="IMG"&&o.setAttribute("src","data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA="),o.style&&(o.style.backgroundImage="none"))}let c=o.children,f=s.children;for(let l=0;l<c.length;l++)i.push([c[l],f[l]])}}function ou(t,e){let n=[];for(let r=e;r!==t;r=r.parentElement){if(!r?.parentElement)return null;n.push([...r.parentElement.children].indexOf(r))}return n.reverse()}function Vs(t,e){if(!e)return null;let n=t;for(let r of e)if(n=n.children[r],!n)return null;return n}function iu(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}}bt();yt();mt();mt();function xo(t){return Qo(t),{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map,warnings:[]}}ne();function Yn(t,e){if(!t)return()=>{};let n=[],r=200;function i(o){if(e){let f=o.getBoundingClientRect();if(f.width>0||f.height>0){let l=Math.max(f.right,f.left+(o.scrollWidth||0)),u=Math.max(f.bottom,f.top+(o.scrollHeight||0));if(l<e.left-r||f.left>e.right+r||u<e.top-r||f.top>e.bottom+r)return}}let s=getComputedStyle(o),a=su(o,s);a&&n.push(a);let c=au(o,s);c&&n.push(c);for(let f of o.children||[])i(f)}return i(t),()=>n.forEach(o=>o())}function su(t,e){if(!t)return()=>{};e=e||getComputedStyle(t);let n=cu(e);if(n<=0)return()=>{};if(!Ys(t))return()=>{};let r=Xs(t),i=r.text,o=fu(e);r.write("X");let s=t.scrollHeight-o;r.restore();let a=s>0?s:lu(e),c=Math.round(a*n+o);if(t.scrollHeight<=c+.5)return()=>{};let f=0,l=i.length,u=-1;for(;f<=l;){let h=f+l>>1;r.write(i.slice(0,Xn(i,h))+"\\u2026"),t.scrollHeight<=c+.5?(u=h,f=h+1):l=h-1}let p=(u>=0?i.slice(0,Xn(i,u)):"")+"\\u2026";return r.write(p),Gs(t,p,r)}function au(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(!Ys(t))return()=>{};if(t.scrollWidth<=t.clientWidth+.5)return()=>{};let n=Xs(t),r=n.text,i=0,o=r.length,s=-1;for(;i<=o;){let c=i+o>>1;n.write(r.slice(0,Xn(r,c))+"\\u2026"),t.scrollWidth<=t.clientWidth+.5?(s=c,i=c+1):o=c-1}let a=(s>=0?r.slice(0,Xn(r,s)):"")+"\\u2026";return n.write(a),Gs(t,a,n)}function Gs(t,e,n){return()=>{t.textContent===e&&n.restore()}}function Xs(t){let e=[];for(let r=t.firstChild;r;r=r.nextSibling)r.nodeType===Node.TEXT_NODE&&e.push(r);let n=e.map(r=>r.data);return{text:n.join(""),write(r){e[0].data=r;for(let i=1;i<e.length;i++)e[i].data=""},restore(){for(let r=0;r<e.length;r++)e[r].data=n[r]}}}function Xn(t,e){if(e<=0||e>=t.length)return e;let n=t.charCodeAt(e-1);return n>=55296&&n<=56319?e-1:e}function cu(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 lu(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 fu(t){return(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0)}function Ys(t){return t.childElementCount>0?!1:Array.from(t.childNodes).some(e=>e.nodeType===Node.TEXT_NODE)}var Ks=["clone","render"],Kn={clone:0,render:1},_t="render";function Qs(t){let e=Array.isArray(t&&t.plugins)?t.plugins:[];if(!e.length)return{stage:_t,loweredBy:[]};let n=-1,r=[];for(let o of e){if(!o||typeof o!="object")continue;let s=o.needs===void 0?_t:o.needs;if(!Object.prototype.hasOwnProperty.call(Kn,s))throw new Error(`[snapdom] plugin \'${o.name||"(unnamed)"}\' declares needs: ${JSON.stringify(s)}, expected one of ${Ks.join(", ")}`);r.push({name:o.name||"(unnamed)",needs:s}),n=Math.max(n,Kn[s])}if(n<0)return{stage:_t,loweredBy:[]};let i=Ks[n];return{loweredBy:i===_t?[]:r.filter(o=>o.needs===i).map(o=>o.name),stage:i}}function Be(t,e){return Kn[t]>=Kn[e]}function Js(t,e,n){let r=e.length?e.map(i=>`\'${i}\'`).join(", "):"the attached plugins";return new Error(`[snapdom] no ${n}: this capture stopped at \'${t}\' because ${r} declared needs: \'${t}\' (result.needs says so too). It is not re-captured on demand \\u2014 that would be a different instant. Ask the plugin for needs: \'render\', or capture without it.`)}var ln=[];function fn(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 Zs(...t){let e=t.flat();for(let n of e){let r=fn(n);if(r){if(r.needs!==void 0&&r.needs!==_t)throw new Error(`[snapdom] global plugin \'${r.name||"(unnamed)"}\' declares needs: ${JSON.stringify(r.needs)}. A global plugin must run to \'${_t}\': lowering it here would stop EVERY capture in the app short of pixels. Pass it per capture instead: snapdom(el, { plugins: [<plugin>] }).`);ln.some(i=>i&&i.name&&r.name&&i.name===r.name)||ln.push(r)}}}function ta(t){return t&&Array.isArray(t.plugins)?t.plugins:ln}async function Bt(t,e,n){let r=n,i=ta(e);for(let o of i){let s=o&&typeof o[t]=="function"?o[t]:null;if(!s)continue;let a=await s(e,r);typeof a<"u"&&(r=a)}return r}async function Qn(t,e,n){let r=[],i=ta(e);for(let o of i){let s=o&&typeof o[t]=="function"?o[t]:null;if(!s)continue;let a=await s(e,n);typeof a<"u"&&r.push(a)}return r}var uu=0;function du(t){let e=[];if(Array.isArray(t))for(let n of t){let r=fn(n);if(!r)continue;r.name||(r.name=`anonymous-${++uu}`);let i=e.findIndex(o=>o&&o.name===r.name);i>=0&&e.splice(i,1),e.push(r)}for(let n of ln)n&&n.name&&!e.some(r=>r.name===n.name)&&e.push(n);return Object.freeze(e)}function ea(t,e,n=!1){return!t||t.plugins&&!n||(t.plugins=du(e)),t}function na(){return ln.slice()}var pu=["resolveNode","beforeSnap","beforeClone","afterClone","beforeRender","afterRender"];function Jn(t){let e=Array.isArray(t&&t.plugins)?t.plugins:[];for(let n of e){let r=fn(n);if(!(!r||r.pure===!0)){for(let i of pu)if(typeof r[i]=="function")return!0}}return!1}mt();Ae();var fe="data-snapdom-asset",sa="http://www.w3.org/1999/xlink",hu=0;function tr(t,e,n,r,i,o){let s=o.__compressedAssets||(o.__compressedAssets=new WeakMap),a=s.get(t);a||(a={token:String(++hu),properties:[]},s.set(t,a),t.setAttribute(fe,a.token));let c=a.properties.find(f=>f.kind===e&&f.name===n);c?(c.compressed!==r&&(c.original=r),c.compressed=i):a.properties.push({kind:e,name:n,original:r,compressed:i})}var aa=(t,e)=>e.kind==="style"?t.style?.getPropertyValue(e.name):t.getAttribute(e.name);function er(t,e){let n=new Map;if(!t||!e)return n;let r=[t,...t.querySelectorAll(`[${fe}]`)];for(let i of r){let o=e.get(i);if(!o||i.getAttribute(fe)!==o.token)continue;let s=o.properties.filter(a=>aa(i,a)===a.compressed).map(a=>Object.freeze({...a}));s.length&&n.set(o.token,Object.freeze(s))}return n}function nr(t,e){if(!t||!e)return;let n=0;for(let r of[t,...t.querySelectorAll(`[${fe}]`)]){let i=e.get(r);i&&(i.token=String(++n),r.setAttribute(fe,i.token))}}function ca(t,e){if(!e?.size||typeof t!="string"||!t.startsWith("data:image/svg+xml"))return t;let n=t.indexOf(","),r=new DOMParser().parseFromString(decodeURIComponent(t.slice(n+1)),"image/svg+xml");if(r.querySelector("parsererror"))return t;let i=!1;for(let o of r.querySelectorAll(`[${fe}]`))for(let s of e.get(o.getAttribute(fe))||[])aa(o,s)===s.compressed&&(s.kind==="style"?o.style.setProperty(s.name,s.original,o.style.getPropertyPriority(s.name)):s.name==="xlink:href"?o.setAttributeNS(sa,s.name,s.original):o.setAttribute(s.name,s.original),i=!0);return i?`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(r))}`:t}function ra(t){if(t.is2D===!1)return 1/0;let e=t.a*t.a+t.b*t.b+t.c*t.c+t.d*t.d,n=t.a*t.d-t.b*t.c;return Math.sqrt((e+Math.sqrt(Math.max(0,e*e-4*n*n)))/2)}function vo(t,e){let n=e.element||t,r=n.isConnected?O(n):n.style,i=e.__compressionClip,o=(h,m)=>{try{return h[m]?.baseVal?.value||0}catch{return 0}},s=i?.width||n.offsetWidth||parseFloat(r?.width)||o(n,"width"),a=i?.height||n.offsetHeight||parseFloat(r?.height)||o(n,"height"),c=Number.isFinite(e.width),f=Number.isFinite(e.height);if(!i&&(c||f)&&s&&a)try{let h=e.outerTransforms===!1&&e.__compressionRootTransform?e.__compressionRootTransform:Jt({baseTransform:r?.transform,rotate:r?.rotate,scale:r?.scale,width:s,height:a});if(h.is2D===!1)s=0,a=0;else{let m=Math.abs(h.a)*s+Math.abs(h.c)*a,d=Math.abs(h.b)*s+Math.abs(h.d)*a;s=Math.min(s,m),a=Math.min(a,d)}}catch{s=0,a=0}let l=(c||f?Math.max(c?s?e.width/s:1/0:0,f?a?e.height/a:1/0:0):e.scale||1)*(e.dpr||1);e.__compressionDensity=l;let u=new WeakMap,p=h=>{if(!h||h.nodeType!==1)return 1;if(u.has(h))return u.get(h);let m=h.isConnected?O(h):h.style,d=1;try{m?.perspective&&m.perspective!=="none"&&(d=1/0);let g=m?.transform;if(g&&g!=="none")d*=ra(new DOMMatrix(g));else if(h.transform?.baseVal?.numberOfItems){let y=new DOMMatrix;for(let b=0;b<h.transform.baseVal.numberOfItems;b++){let S=h.transform.baseVal.getItem(b).matrix;y=y.multiply(new DOMMatrix([S.a,S.b,S.c,S.d,S.e,S.f]))}d*=ra(y)}if(m?.scale&&m.scale!=="none"){let y=m.scale.trim().split(/\\s+/).map(b=>parseFloat(b)/(b.endsWith("%")?100:1));d*=Math.max(...y.map(Math.abs))}if(h!==n&&m?.zoom&&m.zoom!=="normal"&&(d*=parseFloat(m.zoom)||1),h.localName==="svg"&&h.viewBox?.baseVal?.width>0&&h.viewBox.baseVal.height>0){let y=h.viewBox.baseVal,b=v=>/^\\d+(?:\\.\\d+)?px$/.test(m?.[v]||"")?parseFloat(m[v]):o(h,v),S=b("width"),k=b("height");d*=S>0&&k>0?Math.max(S/y.width,k/y.height):1/0}}catch{d=1/0}return Number.isFinite(d)||(d=1/0),h!==n&&(d*=p(h.parentElement||h.getRootNode?.().host)),u.set(h,d),d};return{density:l,stretch:p}}var la=.92,fa=1;async function mu(t){let e=new Image;return e.decoding="sync",e.src=t,typeof e.decode=="function"?(await e.decode(),e):(await new Promise((n,r)=>{e.onload=()=>n(),e.onerror=r}),e)}function gu(t){let e=/^data:([^;,]+)/.exec(t);return e?e[1]:""}var yu=64*1024,oa=32*1024*1024,Zn=new Map;function bu(t,e,n,r){if(n.length+(r?.length||0)>oa)return;t.set(e,{source:n,result:r});let i=0;for(let o of t.values())i+=o.source.length+(o.result?.length||0);for(;i>oa;){let o=t.keys().next().value,s=t.get(o);i-=s.source.length+(s.result?.length||0),t.delete(o)}}function wu(t,e){let n=t.indexOf(",");if(n<0||!/;base64/i.test(t.slice(0,n)))return null;let r=Math.ceil(e/3)*4,i=t.length-n-1,o=Math.min(i,r);try{let s=atob(t.slice(n+1,n+1+o-o%4)),a=new Uint8Array(s.length);for(let c=0;c<s.length;c++)a[c]=s.charCodeAt(c);return a}catch{return null}}function Su(t){let e=wu(t,4096);if(!e||e.length<16)return null;let n=r=>e[r]<<8|e[r+1];if(e[0]===137&&e[1]===80&&e.length>=24)return{w:(e[16]<<24|e[17]<<16|e[18]<<8|e[19])>>>0,h:(e[20]<<24|e[21]<<16|e[22]<<8|e[23])>>>0};if(e[0]===71&&e[1]===73&&e[2]===70)return{w:e[6]|e[7]<<8,h:e[8]|e[9]<<8};if(e[0]===82&&e[1]===73&&e[8]===87&&e.length>=30){let r=e[15];if(r===32&&e[23]===157)return{w:(e[26]|e[27]<<8)&16383,h:(e[28]|e[29]<<8)&16383};if(r===76)return{w:(e[21]|(e[22]&63)<<8)+1,h:((e[22]>>6|e[23]<<2|(e[24]&15)<<10)&16383)+1};if(r===88)return{w:(e[24]|e[25]<<8|e[26]<<16)+1,h:(e[27]|e[28]<<8|e[29]<<16)+1}}if(e[0]===255&&e[1]===216){let r=2;for(;r+9<e.length;){if(e[r]!==255){r++;continue}let i=e[r+1];if(i===216||i===1||i>=208&&i<=215){r+=2;continue}if(i>=192&&i<=207&&i!==196&&i!==200&&i!==204)return{h:n(r+5),w:n(r+7)};let o=n(r+2);if(o<2)break;r+=2+o}}return null}function ia(t,e,n,r){let i=Math.min(1,Math.max(n/t,r/e));return!(i>0)||i>=.95?0:i}var xu=`self.onmessage = async (e) => {\n const { id, dataURL, blob: given, srcLength, targetW, targetH, resFactor, quality, mime } = e.data\n try {\n const blob = given || await (await fetch(dataURL)).blob()\n const bmp = await createImageBitmap(blob)\n const nw = bmp.width, nh = bmp.height\n if (!nw || !nh) { bmp.close(); self.postMessage({ id, url: null }); return }\n const raw = Math.min(1, Math.max(targetW / nw, targetH / nh))\n if (!(raw > 0) || raw >= 0.95) { bmp.close(); self.postMessage({ id, url: null }); return }\n const factor = raw * resFactor\n const ow = Math.max(1, Math.round(nw * factor))\n const oh = Math.max(1, Math.round(nh * factor))\n const canvas = new OffscreenCanvas(ow, oh)\n const ctx = canvas.getContext(\'2d\')\n ctx.imageSmoothingEnabled = true\n ctx.imageSmoothingQuality = \'high\'\n ctx.drawImage(bmp, 0, 0, ow, oh)\n bmp.close()\n const out = await canvas.convertToBlob({ type: mime, quality })\n const url = new FileReaderSync().readAsDataURL(out)\n self.postMessage({ id, url: (url && url.length < srcLength) ? url : null })\n } catch (err) {\n self.postMessage({ id, error: String(err) })\n }\n}`,vu=Math.max(1,Math.min(4,(typeof navigator<"u"&&navigator.hardwareConcurrency||2)-1)),Lt=null,ku=0,Cu=0,le=new Map;function ua(){for(let t of le.values())t(void 0);if(le.clear(),Array.isArray(Lt))for(let t of Lt)try{t?.terminate()}catch{}Lt=!1}function Au(){let t,e=null;try{t=URL.createObjectURL(new Blob([xu],{type:"text/javascript"})),e=new Worker(t),e.onmessage=n=>{let r=le.get(n.data.id);r&&(le.delete(n.data.id),r(n.data.error?void 0:n.data.url??null))},e.onerror=ua}catch{e=null}return t&&URL.revokeObjectURL(t),e}function Mu(){if(Lt===!1)return!1;if(Lt===null){if(typeof Worker>"u"||typeof OffscreenCanvas>"u")return Lt=!1;Lt=[]}let t=ku++%vu;if(!Lt[t]){let e=Au();if(!e)return ua(),!1;Lt[t]=e}return Lt[t]}var _u=5e3;function Eu(t,e,n,r,i){let o=Mu();return o?new Promise(s=>{let a=++Cu,c=setTimeout(()=>{le.delete(a),s(void 0)},_u);le.set(a,f=>{clearTimeout(c),s(f)});try{o.postMessage({id:a,dataURL:i?"":t,blob:i,srcLength:t.length,targetW:e,targetH:n,resFactor:fa,quality:la,mime:r})}catch{clearTimeout(c),le.delete(a),s(void 0)}}):Promise.resolve(void 0)}async function ko(t,e,n,r){if(typeof t!="string"||!t.startsWith("data:image")||t.startsWith("data:image/svg"))return null;e=Math.ceil(e),n=Math.ceil(n);let i=t.length+":"+t.slice(0,64)+t.slice(-64)+":"+e+"x"+n,o=L.compress,s=o.get(i);if(s?.source===t)return s.result;let a=Zn.get(i);if(a?.source===t&&a.cache===o)return a.promise;let c=(async()=>{let l=gu(t),u=l==="image/jpeg"?"image/jpeg":l==="image/webp"?"image/webp":"image/png",p=Su(t);if(p&&p.w>0&&p.h>0&&!ia(p.w,p.h,e,n))return null;if(t.length>=yu){let w=await Eu(t,e,n,u,r);if(w!==void 0)return w}let h;try{h=await mu(t)}catch{return null}let m=h.naturalWidth||h.width,d=h.naturalHeight||h.height;if(!m||!d)return null;let g=ia(m,d,e,n);if(!g)return null;let y=g*fa,b=Math.max(1,Math.round(m*y)),S=Math.max(1,Math.round(d*y)),k=document.createElement("canvas");k.width=b,k.height=S;let v=k.getContext("2d");if(!v)return null;v.imageSmoothingEnabled=!0,v.imageSmoothingQuality="high",v.drawImage(h,0,0,b,S);try{let w=k.toDataURL(u,la);if(typeof w=="string"&&w.startsWith("data:image")&&w.length<t.length)return w}catch{}return null})(),f={source:t,promise:c,cache:o};Zn.set(i,f);try{let l=await c;return bu(o,i,t,l),l}finally{Zn.get(i)===f&&Zn.delete(i)}}async function Ru(t,e,n=new Map,r={}){if(!e.compress)return{count:0,before:0,after:0};let i=Array.from(t.querySelectorAll("img"));t.tagName==="IMG"&&i.unshift(t);let o=0,s=0,a=0,c=async l=>{let u=l.getAttribute("src")||"";if(!u.startsWith("data:image")||u.startsWith("data:image/svg"))return;let p=parseFloat(l.dataset.snapdomWidth)||parseFloat(l.style.width)||l.width||0,h=parseFloat(l.dataset.snapdomHeight)||parseFloat(l.style.height)||l.height||0;if(!p||!h)return;let m=r.value||(r.value=vo(t,e)),d=m.density*m.stretch(n.get(l)||l),g=await ko(u,p*d,h*d,l.__snapdomBlob);g&&(o++,s+=u.length,a+=g.length,l.setAttribute("src",g),tr(l,"attribute","src",u,g,e))},f=6;for(let l=0;l<i.length;l+=f)await Promise.allSettled(i.slice(l,l+f).map(c));return{count:o,before:s,after:a}}var Fu=/^(cover|contain|(\\d+(\\.\\d+)?%(\\s+\\d+(\\.\\d+)?%)?))$/;function Tu(t){let e=t.offsetWidth||t.getBoundingClientRect().width||0,n=t.offsetHeight||t.getBoundingClientRect().height||0;return{w:e,h:n}}async function $u(t,e,n=new Map,r={}){if(!e.compress)return{count:0};let i=[],o=[t,...t.querySelectorAll("*")];for(let f of o){let l=f.style&&f.style.backgroundImage;l&&l.includes("data:image")&&i.push(f)}let s=0,a=async f=>{let l=n.get(f);if(!l||!l.isConnected)return;let u;try{u=getComputedStyle(l)}catch{return}if((u.backgroundRepeat||"repeat").toLowerCase().split(",").some(A=>A.trim()!=="no-repeat"))return;let h=(f.style.backgroundSize||u.backgroundSize||"auto").toLowerCase();if(h.split(",").some(A=>!Fu.test(A.trim())))return;let{w:m,h:d}=Tu(l);if(!m||!d)return;let g=Math.max(1,...(h.match(/\\d+(?:\\.\\d+)?%/g)||[]).map(A=>parseFloat(A)/100)),y=r.value||(r.value=vo(t,e)),b=y.density*y.stretch(l)*g,S=m*b,k=d*b,v=f.style.backgroundImage,w=[...v.matchAll(/url\\(([\'"]?)(data:image\\/[^)\'"]+)\\1\\)/gi)],M=v;for(let A of w){let C=A[2];if(C.startsWith("data:image/svg"))continue;let x=await ko(C,S,k);x&&(M=M.split(C).join(x),s++)}M!==v&&(f.style.setProperty("background-image",M,f.style.getPropertyPriority("background-image")),tr(f,"style","background-image",v,f.style.backgroundImage,e))},c=6;for(let f=0;f<i.length;f+=c)await Promise.allSettled(i.slice(f,f+c).map(a));return{count:s}}async function Pu(t,e,n=new Map,r={}){if(!e.compress)return{count:0};let i=Array.from(t.querySelectorAll("image"));t.localName==="image"&&i.unshift(t);let o=0,s=async c=>{let f=c.getAttribute("href")||(typeof c.getAttributeNS=="function"?c.getAttributeNS("http://www.w3.org/1999/xlink","href"):null);if(!f||!f.startsWith("data:image")||f.startsWith("data:image/svg"))return;let l=c.getAttribute("width")||"",u=c.getAttribute("height")||"";if(l.includes("%")||u.includes("%"))return;let p=n.get(c),h=p?O(p):c.style,m=(k,v)=>{if(/^\\d+(?:\\.\\d+)?px$/.test(h?.[k]||""))return parseFloat(h[k]);if(/^\\d+(?:\\.\\d+)?(?:px)?$/.test(v.trim()))return parseFloat(v);try{return p?.[k]?.baseVal?.value||0}catch{return 0}},d=m("width",l),g=m("height",u);if(!d||!g)return;let y=r.value||(r.value=vo(t,e)),b=y.density*y.stretch(p||c),S=await ko(f,d*b,g*b);S&&(c.setAttribute("href",S),tr(c,"attribute","href",f,S,e),c.hasAttribute("xlink:href")&&(c.setAttributeNS(sa,"xlink:href",S),tr(c,"attribute","xlink:href",f,S,e)),o++)},a=6;for(let c=0;c<i.length;c+=a)await Promise.allSettled(i.slice(c,c+a).map(s));return{count:o}}async function rr(t,e,n){if(!e.compress)return;let r={};await Ru(t,e,n,r),await $u(t,e,n,r),await Pu(t,e,n,r)}bt();mt();Ct();function Nu(t,e){if(X())return t;let n=t.indexOf("</style>");if(n===-1)return t;let r=/<style\\b[^>]*>[\\s\\S]*?<\\/style>/g,i=[],o=n,s;for(r.lastIndex=n;s=r.exec(t);)i.push({text:t.slice(o,s.index),intern:!0}),i.push({text:s[0],intern:!1}),o=r.lastIndex;i.push({text:t.slice(o),intern:!0});let a=new Map,c=/ style="([^"]*)"/g,f;for(let y of i)if(y.intern)for(c.lastIndex=0;f=c.exec(y.text);)a.set(f[1],(a.get(f[1])||0)+1);let l=0;for(let[y,b]of a)b>1&&(l+=(b-1)*y.length);if(l<2048||t.includes(" data-sdi="))return t;let u=Lu(e,i.some(y=>!y.intern),t.includes("data-snapdom-asset"));if(u===null)return t;let p=new Map,h=0,m=[],d=(y,b)=>{if((a.get(b)||0)<2||u.has(b))return y;let S=p.get(b);return S===void 0&&(S="i"+(h++).toString(36),p.set(b,S),m.push(`[data-sdi="${S}"]{${b}}`)),` data-sdi="${S}"`},g="";for(let y of i)g+=y.intern?y.text.replace(c,d):y.text;return t.slice(0,n)+m.join("")+g}function Lu(t,e,n){let r=new Set;if(!e&&!n)return r;if(!t||t.querySelector("[data-sdi]"))return null;let i=c=>{let f=c.getAttribute("style");f&&r.add(f)};if(n&&t.querySelectorAll("[data-snapdom-asset][style]").forEach(i),e)try{let c=f=>{for(let l of f){if(l.type===CSSRule.IMPORT_RULE||l.type===CSSRule.NAMESPACE_RULE)throw new Error("External or namespaced CSS");if(l.selectorText){if(/\\[\\s*style\\b|data-sdi|\\[[^\\]]*\\\\|&/i.test(l.selectorText))throw new Error("Attribute-dependent or nested CSS");t.querySelectorAll(l.selectorText).forEach(i)}l.cssRules&&c(l.cssRules)}};for(let f of[...t.querySelectorAll("style")].slice(1)){let l=f.textContent||"";if(/@import\\b/i.test(l))return null;let u=new CSSStyleSheet;u.replaceSync(l),c(u.cssRules)}}catch{return null}let o=new Set,s=document.createElement("div"),a=new XMLSerializer;for(let c of r){s.setAttribute("style",c);let f=a.serializeToString(s).match(/ style="([^"]*)"/);f&&o.add(f[1])}return o}async function or(t,e){let{clipWindow:n,outerTransforms:r,outerShadows:i,rootTransform2D:o,fontsCSS:s}=e,a=t.options;if(t!==a){let{options:Q,...et}=t;t=Object.assign(a,et),Object.defineProperty(t,"options",{value:t,configurable:!0})}let c,f;zs(t,s),await Bt("beforeRender",t);let l=O(t.element),u=t.element.getBoundingClientRect(),p=Math.max(1,W(t.element.offsetWidth||parseFloat(l.width)||u.width||1)),h=Math.max(1,W(t.element.offsetHeight||parseFloat(l.height)||u.height||1)),m=t.element.ownerDocument||document;if(!n&&(t.element===m.body||t.element===m.documentElement)&&!t.__pinned){let Q=Math.max(t.element.scrollHeight||0,m.documentElement?.scrollHeight||0,m.body?.scrollHeight||0),et=Math.max(t.element.scrollWidth||0,m.documentElement?.scrollWidth||0,m.body?.scrollWidth||0);Q>0&&(h=Math.max(h,W(Q))),et>0&&(p=Math.max(p,W(et)));try{let Z=(t.scrollbarCSS||"").length+(t.baseCSS||"").length+(t.fontsCSS||"").length+(t.classCSS||"").length,ot=L.measureHints.get(t.element);if(ot&&ot.cssLen===Z&&ot.w0===p&&ot.docH===Q&&ot.docW===et)ot.csh>0&&(h=Math.max(h,W(ot.csh))),ot.csw>0&&(p=Math.max(p,W(ot.csw)));else{let it=m.createElement("div");tt(it),it.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;width:"+p+"px!important;overflow:visible!important;visibility:hidden!important;";let Zt=it.attachShadow({mode:"open"}),te=m.createElement("style");te.textContent=(t.scrollbarCSS||"")+t.baseCSS+"svg{overflow:visible;} foreignObject{overflow:visible;}"+t.classCSS,Zt.appendChild(te),Zt.appendChild(t.clone.cloneNode(!0)),m.body.appendChild(it);let Ve=it.scrollHeight,jt=it.scrollWidth;m.body.removeChild(it),L.measureHints.set(t.element,{cssLen:Z,w0:p,docH:Q,docW:et,csh:Ve,csw:jt}),Ve>0&&(h=Math.max(h,W(Ve))),jt>0&&(p=Math.max(p,W(jt)))}}catch{}}if(t.options?.excludeMode==="remove"||typeof t.options?.filter=="function"&&t.options.filterMode==="remove"){let Q=bo(t.element,t.options),et=1,Z=bo(t.element,{}),ot=Math.max(2,h*.15);Number.isFinite(Z)&&Z>=h-ot&&Number.isFinite(Q)&&Q>0&&(h=Math.max(1,Math.min(h,W(Q+et))))}if(t.options?.reconcile)try{let Q=(t.scrollbarCSS||"")+t.baseCSS+"svg{overflow:visible;} foreignObject{overflow:visible;}"+t.classCSS;Us(t.element,t.clone,Q,t.nodeMap,p,h)}catch(Q){console.warn("[snapdom] reconcile pass failed:",Q)}let g=(Q,et=NaN)=>{let Z=typeof Q=="string"?parseFloat(Q):Q;return Number.isFinite(Z)?Z:et},y=g(t.options.width),b=g(t.options.height),S=n?W(n.width):p,k=n?W(n.height):h,v=S,w=k,M=Number.isFinite(y),A=Number.isFinite(b),C=k>0?S/k:1;M&&A?(v=Math.max(1,W(y)),w=Math.max(1,W(b))):M?(v=Math.max(1,W(y)),w=Math.max(1,W(v/(C||1)))):A&&(w=Math.max(1,W(b)),v=Math.max(1,W(w*(C||1))));let x=0,_=0,R=p,$=h;if(n){let Q=0,et=0;if(Co(t.element)){let Z=null;if(!r&&o&&Number.isFinite(o.a))Z={a:o.a,b:o.b||0,c:o.c||0,d:o.d||1,e:0,f:0};else{let ot=ce(t.element),it=yo(l.transform&&l.transform!=="none"?l.transform:"",ot);it&&it.is2D&&(Z={a:it.a,b:it.b,c:it.c,d:it.d,e:0,f:0})}if(Z&&!(Z.a===1&&Z.b===0&&Z.c===0&&Z.d===1)){let{ox:ot,oy:it}=cn(l,p,h),Zt=Oe(p,h,Z,ot,it);Q=Zt.minX,et=Zt.minY}}x=W(n.x+Q),_=W(n.y+et),R=W(x+n.width),$=W(_+n.height)}else if(!r&&o&&Number.isFinite(o.a)){let Q={a:o.a,b:o.b||0,c:o.c||0,d:o.d||1,e:0,f:0},et=Oe(p,h,Q,0,0);x=W(et.minX),_=W(et.minY),R=W(et.maxX),$=W(et.maxY)}else if(r&&Co(t.element)){let et=l.transform&&l.transform!=="none"?l.transform:"",Z=ce(t.element),ot=Jt({baseTransform:et,rotate:Z.rotate||"0deg",scale:Z.scale,translate:Z.translate,width:p,height:h}),{ox:it,oy:Zt}=cn(l,p,h),te=ot.is2D?ot:new DOMMatrix(ot.toString()),Ve={a:te.a,b:te.b,c:te.c,d:te.d,e:0,f:0},jt=Oe(p,h,Ve,it,Zt);x=W(jt.minX),_=W(jt.minY),R=W(jt.maxX),$=W(jt.maxY)}let T=lo(l),I=fo(l),B=uo(l),E=po(l),N=ho(l),P=u.width>0?(R-x)/u.width:1,F=u.height>0?($-_)/u.height:1,z=i==="subtree"&&!n?Rs(t.element,t.nodeMap,t.styleCache,P,F):{top:0,right:0,bottom:0,left:0},V=n?{top:0,right:0,bottom:0,left:0}:i?{top:W(Math.max(T.top,I.top,z.top)+B.top+E.top+N.bleed.top),right:W(Math.max(T.right,I.right,z.right)+B.right+E.right+N.bleed.right),bottom:W(Math.max(T.bottom,I.bottom,z.bottom)+B.bottom+E.bottom+N.bleed.bottom),left:W(Math.max(T.left,I.left,z.left)+B.left+E.left+N.bleed.left)}:{top:B.top,right:B.right,bottom:B.bottom,left:B.left};x=W(x-V.left),_=W(_-V.top),R=W(R+V.right),$=W($+V.bottom);let j=Math.max(1,W(R-x)),D=Math.max(1,W($-_)),K="http://www.w3.org/2000/svg",ht=Co(t.element)?2:0,ft=W(ht+(r?0:1)),at=Math.ceil(j+ft*2),ct=Math.ceil(D+ft*2),xt=W(-(W(x)-ft)),U=W(-(W(_)-ft)),G=Math.max(0,xt),q=Math.max(0,U),nt=W(at-Math.min(0,xt)),rt=W(ct-Math.min(0,U)),me=m.defaultView||window,J=!X()&&CSS.supports("zoom","2")&&me.devicePixelRatio||1,vt=document.createElementNS(K,"foreignObject");vt.setAttribute("x",String(Math.min(0,xt)*J)),vt.setAttribute("y",String(Math.min(0,U)*J)),vt.setAttribute("width",String(nt*J)),vt.setAttribute("height",String(rt*J)),vt.style.overflow="visible";let br=document.createElement("style"),ge="svg{overflow:visible;} foreignObject{overflow:visible;} foreignObject>div{-webkit-text-size-adjust:100%!important;text-size-adjust:100%!important;}";br.textContent=(t.scrollbarCSS||"")+t.baseCSS+t.fontsCSS+ge+t.classCSS,vt.appendChild(br);let ye=document.createElement("div");ye.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),ye.style.cssText=`all:initial;box-sizing:border-box;display:block;overflow:visible;width:${nt}px;height:${rt}px`+(G!==0||q!==0?`;padding:${q}px 0 0 ${G}px !important`:"")+(J!==1?`;zoom:${J} !important`:""),ye.appendChild(t.clone),vt.appendChild(ye);let wr=new XMLSerializer().serializeToString(vt),mn=M||A,gn=Object.freeze({w0:S,h0:k,vbW:at,vbH:ct,targetW:v,targetH:w,contentX:W(xt+(n?x:0)),contentY:W(U+(n?_:0)),clip:n?Object.freeze({x:W(x),y:W(_),width:S,height:k}):null});Object.defineProperty(a,"meta",{value:gn,enumerable:!0,writable:!1,configurable:!0});let Ht=!mn||X()?at:M?v:W(at*(w/ct)),tc=!mn||X()?ct:A?w:W(ct*(v/at)),ec=parseFloat(O(m.documentElement)?.fontSize)||16,Yo=J!==1,nc=`<svg xmlns="${K}" width="${Ht}" height="${tc}" viewBox="0 0 ${at} ${ct}" font-size="${ec}px">${Yo?`<g transform="scale(${1/J})">`:""}`,rc=Yo?"</g></svg>":"</svg>";f=nc+Nu(wr,vt)+rc,c=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(f)}`,t.svgString=f,t.dataURL=c,a.__artifacts={classCSS:t.classCSS||"",fontsCSS:t.fontsCSS||"",baseCSS:t.baseCSS||"",scrollbarCSS:t.scrollbarCSS||""},await Bt("afterRender",t),t.clone=t.nodeMap=t.styleCache=t.svgString=null;let Sr=[...document.querySelectorAll("#snapdom-sandbox")].find(qt);return Sr&&Sr.style.position==="absolute"&&Sr.remove(),t.dataURL}function Co(t){return Ts(t)}function Iu(t){let e=Array.isArray(t.plugins)?t.plugins:na(),n=[];for(let r of e){let i=fn(r);i&&typeof i.resolveNode=="function"&&n.push(i.resolveNode.bind(i))}return n.length?n:null}async function da(t,e){if(!t)throw new Error("Element cannot be null or undefined");e.__session=xo(e.cache),delete e.__compressedAssets,delete e.__compressedSnapshot,delete e.__compressionDensity,e.__resolveNodeHooks=Iu(e);let n=e;n.element=t,Object.defineProperty(n,"options",{value:n,configurable:!0});let r,i,o,s,a,c,f,l="",u=null,p=e.needs||_t,h=n.format,m=n.type;await Bt("beforeSnap",n);let d=n.format!==h&&/^(?:png|jpe?g|webp|svg)$/i.test(n.format),g=n.type!==m&&/^(?:png|jpe?g|webp|svg)$/i.test(n.type);if(d||g){let R=String(d?n.format:n.type).toLowerCase();n.format=R==="jpg"?"jpeg":R,n.type=n.format,n.__explicitFormat=n.format,/^(?:jpeg|webp)$/.test(n.format)&&(n.backgroundColor==null||n.backgroundColor==="transparent")&&(n.backgroundColor="#ffffff")}await Bt("beforeClone",n);let y=n.outerTransforms!==!1,b=n.outerShadows==="subtree"?"subtree":!!n.outerShadows,S=n.clip?Un(n.element,n.clip):null;if(e.__styleShare===void 0)try{e.__styleShare=Mi(n.element)&&(typeof n.element.getAnimations!="function"||n.element.getAnimations({subtree:!0}).length===0)}catch{e.__styleShare=!1}let k=mi(e.fast);for(;;){e.__slicer=k;let R=Yn(n.element,S);try{({clone:r,classCSS:i,classPrefixCSS:o,styleCache:s,nodeMap:a,reconcileRisk:c,clipWindow:f}=await Hs(n.element,n.options)),c>0&&!e.reconcile&&(At(e.__session,"reconcile-risk","text in inline/table-cell elements kept natural width and may re-wrap; pass { reconcile: true } for pixel-exact layout"),L.warnedReconcile||(L.warnedReconcile=!0,console.warn("[snapdom] Inline/table text may re-wrap with fallback fonts. Use { reconcile: true } to check layout (~2x capture time)."))),!y&&r&&(u=Fs(n.element,r)),!b&&r&&Ws(n.element,r,n.options),r&&(Ds(n.element,r,a),Os(n.element,r))}finally{R()}if(!k?.yielded||!e.__tornSinceStart?.())break;k=null,e.__session=xo(e.cache)}if(e.__slicer=null,n.clone=r,n.classCSS=i,n.styleCache=s,n.nodeMap=a,await Bt("afterClone",n),!Be(p,"render"))return null;if(k?.due()&&await k.pause(),zn(n.clone),n.options?.excludeMode==="remove"||typeof n.options?.filter=="function"&&n.options.filterMode==="remove")try{Bs(n.element,n.clone,n.styleCache,n.nodeMap)}catch(R){At(e.__session,"shrink-failed","shrink pass failed",R),console.warn("[snapdom] shrink pass failed:",R)}try{await $n(n.clone,n.element,n.nodeMap)}catch{}let v=R=>Promise.resolve().then(R),w=(async()=>{await Promise.all([v(()=>jn(n.clone,n.options)),v(()=>qn(n.element,n.clone,n.styleCache,n.options,n.nodeMap))]);try{qs(n.element,n.clone,n.nodeMap)}catch(R){At(e.__session,"backdrop-filter-failed","backdrop-filter emulation failed",R),console.warn("[snapdom] backdrop-filter emulation failed:",R)}if(e.compress&&(e.__compressionClip=f,e.__compressionRootTransform=u,await v(()=>rr(n.clone,n.options,n.nodeMap))),e.captureSelection)try{Zi(n.nodeMap)}catch(R){At(e.__session,"selection-compose-failed","field selection compose failed",R)}})(),M=Promise.resolve();(e.embedFonts==="auto"?((n.element.ownerDocument||document).fonts?.size||0)>0:e.embedFonts)&&(M=v(async()=>{let R=n.element.ownerDocument||document,$=S?B=>{try{let E=B.getBoundingClientRect();return E.right>=S.left-200&&E.left<=S.right+200&&E.bottom>=S.top-200&&E.top<=S.bottom+200}catch{return!0}}:null,{required:T,usedCodepoints:I}=!S&&e.__fontUsage||In(n.element,$);if(e.embedFonts==="auto"){let B=new Set;try{for(let N of R.fonts)B.add(String(N.family).replace(/["\']/g,"").toLowerCase())}catch{}if(!(B.size>0&&Array.from(T).some(N=>B.has(String(N).split("__")[0].toLowerCase()))))return}if(X()){let B=new Set(Array.from(T).map(E=>String(E).split("__")[0]).filter(Boolean));await Wn(B,1,R)}l=await ps({required:T,usedCodepoints:I,exclude:n.options.excludeFonts,localFonts:n.options.localFonts,useProxy:n.options.useProxy,fontStylesheetDomains:n.options.fontStylesheetDomains,iconMatchers:n.options.__iconMatchers,doc:R})})),await Promise.all([w,M]);let C=(n.options.plugins||[]).some(R=>R&&(typeof R.beforeRender=="function"||typeof R.afterRender=="function"));n.options.engine,k?.due()&&await k.pause();let x=n.clone;nr(x,e.__compressedAssets);let _=await or(n,{clipWindow:f,outerTransforms:y,outerShadows:b,rootTransform2D:u,fontsCSS:l});if(e.__compressedSnapshot=er(x,e.__compressedAssets),typeof e.__retain=="function")try{e.__retain({clone:r,nodeMap:a,styleCache:s,styleMap:e.__session.styleMap,classPrefixCSS:o,fontsCSS:l,clipWindow:f,outerTransforms:y,outerShadows:b,rootTransform2D:u,__compressedAssets:e.__compressedAssets,__compressionDensity:e.__compressionDensity})}catch{}return _}mt();kt();var Wu=new Set(["png","jpeg","jpg","webp","svg"]);function pa(t={}){let e=typeof t.type=="string"&&Wu.has(t.type.toLowerCase())?t.type.toLowerCase():null,n=t.format??e??"png";n==="jpg"&&(n="jpeg");let r=t.format!=null?n:e==="jpg"?"jpeg":e,i=Ko(t.cache),o=t.exclude==null?[]:Array.isArray(t.exclude)?t.exclude:[t.exclude],s=[],a=[];for(let u of o)typeof u=="string"?s.push(u):typeof u=="function"?a.push(u):u!=null&&console.warn("[snapdom] Invalid exclude entry; expected selector or predicate:",u);let c=t.excludeMode??"hide",f=u=>{if(!u||u.nodeType!==1)return!1;if(u.getAttribute("data-capture")==="exclude")return!0;for(let p of Array.isArray(l.exclude)?l.exclude:[])try{if(u.matches(p))return!0}catch{}for(let p of Array.isArray(l.excludePredicates)?l.excludePredicates:[])try{if(p(u))return!0}catch{}if(typeof l.filter=="function")try{if(!l.filter(u))return!0}catch{}return!1},l={debug:t.debug??!1,scale:t.scale??1,exclude:s,excludePredicates:a.length?a:null,excludeMode:c,filter:t.filter??null,filterMode:t.filterMode??"hide",shouldExclude:f,placeholders:t.placeholders!==!1,captureSelection:t.captureSelection??!1,canvas:st(t.canvas,"canvas")?t.canvas:null,embedFonts:t.embedFonts??"auto",iconFonts:Array.isArray(t.iconFonts)?t.iconFonts:t.iconFonts?[t.iconFonts]:[],__iconMatchers:rs(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:i,__styleShare:t.__styleShare,useProxy:typeof t.useProxy=="string"?t.useProxy:"",width:t.width??null,height:t.height??null,format:n,__explicitFormat:r,type:n,quality:t.quality??.92,dpr:t.dpr??(window.devicePixelRatio||1),backgroundColor:t.backgroundColor??(["jpeg","webp"].includes(n)?"#ffffff":null),filename:t.filename??"snapDOM",outerTransforms:t.outerTransforms??!0,outerShadows:t.outerShadows??!1,reconcile:t.reconcile??!1,burst:t.burst,fast:t.fast===!1||t.fast==="auto"?t.fast:!0,engine:t.engine,invalidate:t.invalidate??!1,__pinned:t.__pinned===!0,clip:t.clip??null,compress:t.compress!==!1,excludeStyleProps:t.excludeStyleProps??null,resolvePicturePlaceholders:t.resolvePicturePlaceholders!==!1};return l}yt();ne();bt();var ha="svg,iframe,canvas,video,audio,object,embed,slot,template,picture,style,pre";function Ou(t){try{return t.matches?.("dialog,[popover]")||!!t.querySelector?.("dialog,[popover]")}catch{return!0}}var Du=/(?:^|;)\\s*(?:-webkit-)?backdrop-filter:\\s*(?!none(?:\\s*!important)?(?:;|$))[^;]+/i;function Bu(t){if(t.__usesBackdropFilter!==void 0)return t.__usesBackdropFilter;let e=!1;for(let n of t.styleMap.values())if(Du.test(n)){e=!0;break}return t.__usesBackdropFilter=e,e}function Uu(t,e){let n=e.has("backdrop-filter")||e.has("-webkit-backdrop-filter");if(!n&&(n=(o=>/(?:^|;)\\s*(?:-webkit-)?backdrop-filter\\s*:/i.test(o.getAttribute?.("style")||""))(t),!n))try{n=!!t.querySelector?.(\'[style*="backdrop-filter" i]\')}catch{n=!0}if(!n)return!1;let r=[t];t.querySelectorAll&&r.push(...t.querySelectorAll("*"));for(let i of r){let o=getComputedStyle(i),s=o.getPropertyValue("backdrop-filter")||o.getPropertyValue("-webkit-backdrop-filter");if(s&&s!=="none")return!0}return!1}var ma=new WeakMap;function zu(t){let e=Dt(),n=ma.get(t);if(n&&n.epoch===e)return n.leaky;let r=!1,i={budget:2e4},o=s=>{for(let a=0;a<s.length&&!r;a++){if(--i.budget<0){r=!0;return}let c=s[a],f=c.selectorText;if(f&&/[+~]|:has\\(/.test(f)){r=!0;return}let l=c.style;if(l&&(l.counterReset||l.counterIncrement||l.counterSet||l.content&&l.content.includes("counter"))){r=!0;return}c.cssRules&&c.cssRules.length&&o(c.cssRules)}};try{for(let s of t.styleSheets){let a=null;try{a=s.cssRules}catch{r=!0}if(r)break;a&&o(a)}if(!r){let s=t.adoptedStyleSheets;if(Array.isArray(s))for(let a of s){if(r)break;try{o(a.cssRules)}catch{r=!0}}}}catch{r=!0}return ma.set(t,{epoch:e,leaky:r}),r}var Hu=1/16;function ju(t,e){if(t===e)return!0;if(!t.endsWith("px")||!e.endsWith("px"))return!1;let n=parseFloat(t),r=parseFloat(e);return Number.isFinite(n)&&Number.isFinite(r)&&Math.abs(n-r)<=Hu}var ir=new Map,Vu=["width","height","min-width","min-height"];function qu(t){let e=ir.get(t);if(e===void 0){e=null;for(let n of Vu){let r=t.match(new RegExp("(?:^|;)"+n+":([^;]+)"));r&&r[1].endsWith("px")&&((e||(e={}))[n]=r[1])}ir.size>5e3&&ir.clear(),ir.set(t,e)}return e}function Gu(t){if(!(!t.classList||!t.classList.length))for(let e of Array.from(t.classList))/^c\\d+$/.test(e)&&t.classList.remove(e)}function Xu(t,e){let n=[t];for(;n.length;){let r=n.pop();if(r.nodeType===1){let i=e.nodeMap.get(r);i!==void 0&&(e.nodeMap.delete(r),e.srcToClone.get(i)===r&&e.srcToClone.delete(i)),e.styleMap.delete(r)}for(let i=r.firstChild;i;i=i.nextSibling)n.push(i)}}var Ao={attempts:0,served:0,reconciled:0};async function ga(t,e,n){Ao.attempts++;try{let r=await Yu(t,e,n);return r&&Ao.served++,r}catch{return null}}async function Yu(t,e,n){let r=e.retained;if(!r||!r.clone||!r.styleMap||!r.srcToClone||n.reconcile||n.clip||n.captureSelection||r.clipWindow||t.scrollTop||t.scrollLeft||Ou(t)||Bu(r)||r.fontsCSS||Jn(n))return null;for(let u of n.plugins||[])if(u&&(typeof u.beforeSnap=="function"||typeof u.beforeClone=="function"||typeof u.resolveNode=="function"||typeof u.afterClone=="function"))return null;if(r.classPrefixCSS&&(r.classPrefixCSS.includes("::marker")||r.classPrefixCSS.includes("::first-line"))||n.excludeMode==="remove")return null;let i=t.ownerDocument||document,o=nn(t);if(!o||zu(i))return null;let s=[];t:for(let u of e.dirtyRoots){if(!u.isConnected||u===t||!t.contains(u))return null;for(let p of e.dirtyRoots)if(p!==u&&p!==t&&p.contains(u))continue t;s.push(u)}if(!s.length)return null;n.__compressedAssets=r.__compressedAssets,n.__compressionDensity=r.__compressionDensity,n.__compressionRootTransform=r.rootTransform2D;for(let u of s){if(u.parentElement===t||u.matches?.(ha)||u.querySelector?.(ha)||Uu(u,o))return null;let p=r.srcToClone.get(u);if(!p||!p.parentNode)return null;let h=new Map,m={styleMap:r.styleMap,styleCache:r.styleCache,nodeMap:h,options:n},d=Yn(u,null),g=Bn(u),y;try{y=await Qt(u,m,n)}finally{g(),d()}if(!y||y.nodeType!==1||y.querySelector?.("style[data-sd]")||(await We(u,y,m,n),m.__pseudoCSS))return null;await _n(y,m),zn(y);try{await $n(y,u,h)}catch{}if(await Promise.all([jn(y,n),qn(u,y,r.styleCache,n,h)]),n.compress)try{await rr(y,n,h)}catch{}for(let[b,S]of h.entries())So(b,S);p.replaceWith(y),Xu(p,r);for(let[b,S]of h.entries())r.nodeMap.set(b,S),r.srcToClone.set(S,b)}let a={styleMap:r.styleMap,styleCache:r.styleCache,nodeMap:r.nodeMap,options:n};for(let[u,p]of r.nodeMap.entries()){if(!p||p.nodeType!==1||!p.isConnected)continue;let h=r.styleMap.get(u);if(!h)continue;let m=qu(h);if(!m)continue;let d=null,g=!1;for(let y in m)if(d||(d=getComputedStyle(p)),!ju(d.getPropertyValue(y),m[y])){g=!0;break}if(g){if(n.__compressedAssets?.has(u))return null;Ao.reconciled++,await pt(p,u,a,n)}}let c=Ye(r.styleMap);for(let[u,p]of r.styleMap.entries())Gu(u),wo(u,p,c);let f=(r.classPrefixCSS||"")+Array.from(c.entries()).map(([u,p])=>`.${p}{${u}}`).join("");nr(r.clone,n.__compressedAssets);let l=await or({element:t,options:n,plugins:n.plugins,clone:r.clone,classCSS:f,styleCache:r.styleCache,nodeMap:r.nodeMap},{clipWindow:null,outerTransforms:r.outerTransforms,outerShadows:r.outerShadows,rootTransform2D:r.rootTransform2D,fontsCSS:r.fontsCSS||""});return n.__compressedSnapshot=er(r.clone,n.__compressedAssets),r.__compressedAssets=n.__compressedAssets,r.__compressionDensity=n.__compressionDensity,l}kt();var _o=new WeakMap,ar=new WeakMap,_a=new WeakSet,Mo=new WeakMap,Ku=64,un=new Map,Ea=["scroll","input","change","focusin","focusout","pointerdown","pointerup","pointercancel","keydown","keyup","beforetoggle","toggle"],Qu=["(prefers-color-scheme: dark)","(prefers-reduced-motion: reduce)","(prefers-contrast: more)","(forced-colors: active)","(inverted-colors: inverted)","(prefers-reduced-transparency: reduce)","(hover: hover)","(any-hover: hover)","(pointer: coarse)","(any-pointer: coarse)","(color-gamut: p3)","(dynamic-range: high)"];function Ju(t){let e=t?.defaultView;return typeof e?.matchMedia!="function"?"":Qu.map(n=>{try{return e.matchMedia(n).matches?"1":"0"}catch{return"?"}}).join("")}function ya(t){let e=[];for(let n=t;n;){try{let r=n.getBoundingClientRect();e.push(r.x,r.y,r.width,r.height)}catch{e.push("?")}n.parentElement?n=n.parentElement:n=n.getRootNode?.()?.host||null}return e.join("|")}function ba(t,e){if(e.disposed||(un.delete(t),un.set(t,e),un.size<=Ku))return;let[n,r]=un.entries().next().value;Ra(n,r)}function Ra(t,e){e.disposed=!0,un.delete(t),_o.delete(t);for(let n of e.observers)try{n.disconnect()}catch{}for(let n of Ea)t.removeEventListener(n,e.onMediaDirty,!0);for(let n of e.trackedShadowRoots.keys())for(let r of Ro)n.removeEventListener(r,e.onMediaDirty,!0);for(let[n,r]of e.trackedImages)n.removeEventListener("load",r),n.removeEventListener("error",r);e.trackedImages.clear(),e.trackedShadowRoots.clear(),e.images.length=0,e.controls.length=0,e.scrollNodes.length=0,e.observers.length=0,e.last=null,e.retained=null,e.retainedFrameDriven=!1}function Fa(t){if(_a.has(t))return!1;ar.delete(t);let e=[t],n=[],r=[];for(let i=0;i<e.length;i++){let o=e[i],s=[];o?.nodeType===1&&s.push(o);try{s.push(...o.querySelectorAll("*"))}catch{return!1}for(let a of s){a.shadowRoot&&e.push(a.shadowRoot);let c=String(a.localName||a.tagName||"").toLowerCase();if(/^(?:iframe|canvas|video|audio|object|embed|marquee|blink)$/.test(c)||c==="progress"&&!a.hasAttribute("value")||/^(?:animate|animatetransform|animatemotion|set)$/.test(c))return!1;let f="";if(c==="img"){r.push(a);try{f=a.currentSrc||a.src||""}catch{}}/^(?:input|textarea|select|option)$/.test(c)&&n.push(a);let l=a.getAttribute?.("style")||"",u=Mo.get(a);if(f||l){if((!u||u.src!==f||u.style!==l)&&(u={src:f,style:l,animated:He(f)||He(l)},Mo.set(a,u)),u.animated)return!1}else u&&Mo.delete(a)}}return ar.set(t,{roots:e.slice(1),controls:n,images:r}),!0}function Eo(t,e){if(!t.querySelectorAll)return!1;let n=ar.get(t);ar.delete(t);let r=new Set(n?.roots||[]);if(n&&(e.controls=n.controls,e.scannedImages=n.images),!n){let i=[t];for(let o=0;o<i.length;o++){let s=i[o];s.shadowRoot&&!r.has(s.shadowRoot)&&(r.add(s.shadowRoot),i.push(s.shadowRoot));for(let a of s.querySelectorAll("*"))a.shadowRoot&&!r.has(a.shadowRoot)&&(r.add(a.shadowRoot),i.push(a.shadowRoot))}}for(let[i,o]of e.trackedShadowRoots)if(!r.has(i)){try{o.disconnect()}catch{}for(let a of Ro)i.removeEventListener(a,e.onMediaDirty,!0);e.trackedShadowRoots.delete(i);let s=e.observers.indexOf(o);s>=0&&e.observers.splice(s,1)}for(let i of r)if(!e.trackedShadowRoots.has(i))try{let o=new MutationObserver(e.markDirty);o.observe(i,{subtree:!0,childList:!0,attributes:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),o.__flush=e.markDirty,e.observers.push(o),e.trackedShadowRoots.set(i,o);for(let s of Ro)i.addEventListener(s,e.onMediaDirty,{capture:!0,passive:!0});e.retained&&e.dirtyAll()}catch{}return!!n}var Ro=["scroll","change","beforetoggle","toggle"];function cr(t,e){return[t,...e.trackedShadowRoots.keys()]}function Fo(t,e){let n=e.scannedImages;if(e.scannedImages=null,!n){n=[],t.tagName==="IMG"&&n.push(t);for(let r of cr(t,e))r.querySelectorAll&&n.push(...r.querySelectorAll("img"))}if(e.images=n,e.trackedImages.size){let r=new Set(n);for(let[i,o]of e.trackedImages)r.has(i)||(i.removeEventListener("load",o),i.removeEventListener("error",o),e.trackedImages.delete(i))}for(let r of n){if(r.complete||e.trackedImages.has(r))continue;let i=()=>{e.capturing&&(e.torn=!0),e.dirty=!0,e.dirtyRoots=null,r.removeEventListener("load",i),r.removeEventListener("error",i),e.trackedImages.delete(r)};e.trackedImages.set(r,i),r.addEventListener("load",i),r.addEventListener("error",i)}}function wa(t){let e=new Map,n=new Map,r=new Map;for(let i of t)if(ie(i))if(i.type==="attributes"){let o=e.get(i.target);o||e.set(i.target,o=new Map),o.has(i.attributeName)||o.set(i.attributeName,i.oldValue)}else if(i.type==="characterData")n.has(i.target)||n.set(i.target,i.oldValue);else if(i.type==="childList"){let o=r.get(i.target);o||r.set(i.target,o=new Map);for(let s of i.addedNodes){if(s.nodeType!==3)return!0;o.set(s.data,(o.get(s.data)||0)+1)}for(let s of i.removedNodes){if(s.nodeType!==3)return!0;o.set(s.data,(o.get(s.data)||0)-1)}}else return!0;for(let[i,o]of e)for(let[s,a]of o)if(i.getAttribute(s)!==a)return!0;for(let[i,o]of n)if(i.data!==o)return!0;for(let i of r.values())for(let o of i.values())if(o!==0)return!0;return!1}var Zu=/(?:^data:image\\/(?:gif|apng)|\\.(?:gif|apng)(?=[?#)\'"\\s;]|$))/i,ze=t=>t&&(typeof t=="object"||typeof t=="function")?sr(t):"-";function td(t,e=131072){if(t=String(t||"").trim(),!/^data:/i.test(t))return"";let n=t.indexOf(",");if(n<0)return"";let r=t.slice(0,n),i=t.slice(n+1);try{if(/;base64/i.test(r)){let o=Math.ceil(e/3)*4;return atob(i.slice(0,o-o%4))}return i.slice(0,e*3).replace(/%([0-9a-f]{2})/gi,(o,s)=>String.fromCharCode(parseInt(s,16))).slice(0,e)}catch{return""}}function ed(t){let e=(t.match(/^data:([^;,]+)/i)?.[1]||"").toLowerCase();if(e==="image/gif"||e==="image/apng")return!0;if(!/image\\/(?:png|webp|avif|svg\\+xml)/.test(e))return!1;let n=td(t);return e==="image/png"?n.includes("acTL"):e==="image/webp"?n.includes("ANIM")||n.includes("ANMF")||n.includes("VP8X")&&!!(n.charCodeAt(n.indexOf("VP8X")+8)&2):e==="image/avif"?n.includes("avis"):/<(?:animate|animateTransform|animateMotion|set)\\b|@keyframes\\b|animation(?:-name)?\\s*:/i.test(n)}function Sa(t){let e=String(t||"").trim();return e?Zu.test(e)?!0:/^data:/i.test(e)?ed(e):!1:!1}function He(t){let e=String(t||"");if(Sa(e))return!0;for(let n of e.matchAll(/url\\(\\s*(?:"((?:\\\\.|[^"\\\\])*)"|\'((?:\\\\.|[^\'\\\\])*)\'|([^)]*))\\s*\\)/gi))if(Sa(n[1]??n[2]??n[3]))return!0;return!1}function xa(t,e=null){let n=t&&t.clone;if(!n)return!1;let r=e?e.map(i=>t.srcToClone?.get(i)).filter(Boolean):[n];for(let i of r)for(let o of Ta(i))if(He(o.getAttribute?.("src"))||He(o.getAttribute?.("href"))||He(o.getAttribute?.("style"))||He(t.styleMap?.get(o)))return!0;return!1}function Ta(t){let e=[];t&&t.nodeType===1&&e.push(t);try{e.push(...t.querySelectorAll("*"))}catch{}return e}function To(t,e){let n=[],r=new Set,i=o=>{o&&!r.has(o)&&(r.add(o),n.push(o))};t.matches?.("input,textarea,select,option")&&i(t);for(let o of cr(t,e))try{for(let s of o.querySelectorAll("input,textarea,select,option"))i(s)}catch{}e.controls=n}function $o(t,e){let n=[],r=new Set,i=(o,s=!1)=>{if(!(!o||r.has(o))){r.add(o);try{(s||o.scrollLeft||o.scrollTop||o.scrollWidth>o.clientWidth||o.scrollHeight>o.clientHeight)&&n.push(o)}catch{}}};for(let o=t;o;o=o.parentElement)i(o,!0);for(let o of cr(t,e))for(let s of Ta(o))i(s);e.scrollNodes=n}function va(t,e){let n=t.ownerDocument||document,r=n.defaultView,i=[r?.location?.hash||"",Ju(n),r?.innerWidth||0,r?.innerHeight||0,r?.devicePixelRatio||1,r?.screen?.orientation?.type||""];try{i.push(...[...n.adoptedStyleSheets||[]].map(ze))}catch{}for(let l of e.trackedShadowRoots.keys())try{i.push("#shadow",...[...l.adoptedStyleSheets||[]].map(ze))}catch{}let o=n.activeElement,s=n.fullscreenElement;(o?.contains(t)||t.contains(o))&&i.push(ze(o)),(s?.contains(t)||t.contains(s))&&i.push(ze(s));let a=[r?.scrollX||0,r?.scrollY||0];for(let l of e.scrollNodes)a.push(l.scrollLeft||0,l.scrollTop||0);let c=[];for(let l of e.controls){let u=String(l.localName||"").toLowerCase();u==="input"?c.push(l.type,Ge(l)?l.value.length:l.value,l.checked?1:0,l.indeterminate?1:0):u==="textarea"?c.push(l.value):u==="select"?c.push(l.selectedIndex,l.value):c.push(l.selected?1:0)}let f=[];for(let l of e.images){let u="";try{u=l.currentSrc||l.src||""}catch{}f.push(u,l.complete?1:0,l.naturalWidth||0,l.naturalHeight||0)}return{style:i.join("|"),scroll:a.join("|"),controls:c,images:f,frameDriven:e.retainedFrameDriven}}function Ue(t,e,n){if(!t)return!1;let r=t[n],i=e[n];if(r===i)return!0;if(!Array.isArray(r)||r.length!==i.length)return!1;for(let o=0;o<r.length;o++)if(r[o]!==i[o])return!1;return!0}function ka(t,e){let n=new Set;for(let r of cr(t,e))try{let i=r.getAnimations?.(r.nodeType===1?{subtree:!0}:void 0)||[];for(let o of i)n.add(o)}catch{}return[...n]}function Ca(t){return t.map(e=>[ze(e),e.playState,Math.round((Number(e.currentTime)||0)*10),e.playbackRate].join(":")).join("|")}function nd(t,e,n){if(!n||n.nodeType!==1)return null;if(n===t||t.contains(n))return t;for(let r of e.trackedShadowRoots.keys())if(r.contains(n))return r;return null}function rd(t){let e={dirty:!0,pending:[],torn:!1,dirtyRoots:new Set,retained:null,retainedFrameDriven:!1,disposed:!1,capturing:!1,last:null,inflight:Promise.resolve(),observers:[],trackedShadowRoots:new Map,trackedImages:new Map,images:[],scannedImages:null,scrollNodes:[],controls:[],envEpoch:Ee(),styleEpoch:Dt(),styleStamp:en(t),outsideMutations:tn(t),geometry:null,renderState:null},n=()=>{e.dirty=!0,e.dirtyRoots=null},r=a=>{if(!e.dirtyRoots)return;let c=a&&(a.nodeType===1?a:a.parentElement);if(!c||c===t||!t.contains(c)||e.dirtyRoots.size>=12){e.dirtyRoots=null;return}e.dirtyRoots.add(c)},i=a=>{if(e.capturing){for(let c of a)e.pending.push(c);return}for(let c of a)ie(c)&&(e.dirty=!0,r(c.target))},o=()=>{if(e.capturing){e.torn=!0;return}n()};e.dirtyAll=n;try{let a=new MutationObserver(i);a.observe(t,{subtree:!0,childList:!0,attributes:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),a.__flush=i,e.observers.push(a)}catch{}e.markDirty=i,e.onMediaDirty=o;try{for(let a of Ea)t.addEventListener(a,o,{capture:!0,passive:!0})}catch{}return Eo(t,e)||To(t,e),$o(t,e),Fo(t,e),e}var od=0,Aa=new WeakMap;function sr(t){let e=Aa.get(t);return e||(e="@"+ ++od,Aa.set(t,e)),e}function Po(t,e){let n=typeof t;if(n==="undefined")return null;if(t===null||n==="boolean"||n==="number"||n==="string")return JSON.stringify(t);if(n==="function"||n==="symbol")return n==="symbol"?null:JSON.stringify(sr(t));if(n!=="object")return null;if(typeof t.nodeType=="number")return JSON.stringify(sr(t));if(e.has(t))return null;e.add(t);try{if(Array.isArray(t)){let o=[];for(let s of t){let a=Po(s,e);if(a===null)return null;o.push(a)}return"["+o.join(",")+"]"}let r=Object.getPrototypeOf(t);if(r!==Object.prototype&&r!==null)return JSON.stringify(sr(t));let i=[];for(let o of Object.keys(t).sort()){let s=t[o];if(s===void 0)continue;let a=Po(s,e);if(a===null)return null;i.push(JSON.stringify(o)+":"+a)}return"{"+i.join(",")+"}"}finally{e.delete(t)}}function Ma(t,e){let{burst:n,invalidate:r,...i}=t||{};try{let o=Po(i,new Set);return o===null?null:`${(e||[]).map(ze).join(",")}:${o}`}catch{return null}}function $a(t,e,n,r,i=null){let o=_o.get(t);o||(o=rd(t),o.baselineSignature=Ma(e,n.plugins),_o.set(t,o));let s=Ma(e,n.plugins),a=async()=>{if(o.disposed)return r();let f=s===null||s!==o.baselineSignature;f&&s!==null?o.pendingSig===s?(o.baselineSignature=s,o.last=null,o.dirty=!0,o.dirtyRoots=null,o.pendingSig=null,f=!1):o.pendingSig=s:o.pendingSig=null,Eo(t,o),Fo(t,o);for(let M of o.observers)M.__flush(M.takeRecords());Tt();let l=tn(t);o.dirty&&o.outsideMutations!==l&&o.dirtyAll(),o.outsideMutations=l;let u=t.getRootNode?.(),p=[...o.trackedShadowRoots.keys()];u?.nodeType===11&&!p.includes(u)&&p.push(u),Cn(t.ownerDocument||document,p);let h=en(t);o.styleStamp!==h&&(o.styleStamp=h,o.dirty||o.dirtyAll());let m=va(t,o),d=ka(t,o);m.animation=Ca(d),o.renderState&&(!Ue(o.renderState,m,"style")&&(Re(),o.dirtyAll()),Ue(o.renderState,m,"scroll")||o.dirtyAll(),Ue(o.renderState,m,"controls")||(se(t),o.dirtyAll()),!Ue(o.renderState,m,"images")&&!o.dirty&&o.dirtyAll());let g=Ee();o.envEpoch!==g&&(o.dirtyAll(),o.envEpoch=g);let y=Dt();if(o.styleEpoch!==y&&(o.styleEpoch=y,!o.dirty)){let M=ya(t);o.geometry!==null&&M!==o.geometry&&(se(t),o.dirtyAll()),o.geometry=M}n.invalidate&&o.dirtyAll();let b=!1,S=!!o.renderState&&!Ue(o.renderState,m,"animation");try{let M=new Set;S&&d.length===0&&(M=null);for(let A of d){let C=A.playState==="running";if(!C&&!S)continue;C&&(b=!0),S=!0;let x=A.effect?.target;if(nd(t,o,x)===t)M.add(x);else{M=null;break}}if(S&&M&&M.size&&o.retained){o.dirty=!0;for(let A of M)o.dirtyRoots&&o.dirtyRoots.add(A),se(A)}else S&&!M&&o.dirtyAll()}catch{}let k=m.frameDriven,v=b||k;if(v&&(o.last=null),k&&o.dirtyAll(),!f&&!v&&!o.dirty&&o.last)return ba(t,o),o.last;o.capturing=!0;let w=null;try{let M=null,A=!1,C=null;if(!f&&o.dirty&&o.retained&&o.dirtyRoots&&o.dirtyRoots.size&&i){C=[...o.dirtyRoots];let x=await ga(t,o,n);x&&(M=await i(x),A=!0)}if(M||(f||(n.__retain=x=>{let _=new Map;for(let[R,$]of x.nodeMap.entries())_.set($,R);w={...x,srcToClone:_}}),n.__tornSinceStart=()=>{for(let x of o.observers)for(let _ of x.takeRecords())o.pending.push(_);return Tt(),o.torn||wa(o.pending)||tn(t)!==l},M=await r()),!f&&!o.disposed){o.dirty=!1,o.dirtyRoots=new Set,w?(o.retained=w,o.retainedFrameDriven=xa(w),To(t,o),$o(t,o)):A&&(o.retainedFrameDriven||(o.retainedFrameDriven=xa(o.retained,C)),To(t,o),$o(t,o));let x=va(t,o);x.animation=Ca(ka(t,o));let _=["style","scroll","controls","images"];b||_.push("animation");let R=_.every($=>Ue(m,x,$));o.renderState=x,o.styleEpoch=Dt(),o.styleStamp=en(t),o.geometry=ya(t),o.renderState.frameDriven?(_a.add(t),Ra(t,o)):R?!v&&!o.renderState.frameDriven&&(o.last=M,ba(t,o)):(o.dirtyAll(),o.last=null)}return M}finally{n.__retain=void 0,n.__tornSinceStart=void 0;for(let A of o.observers)for(let C of A.takeRecords())o.pending.push(C);Tt();let M=tn(t);(o.torn||wa(o.pending)||M!==l)&&(o.dirtyAll(),o.last=null),o.outsideMutations=M,o.styleEpoch=Dt(),o.styleStamp=en(t),o.pending.length=0,o.torn=!1,o.capturing=!1,o.disposed||(Eo(t,o),Fo(t,o))}},c=o.inflight.then(a,a);return o.inflight=c.catch(()=>{}),c}var lr=null;function La(t){lr=t}var id=\'button, a[href], [role="button"], input, select, summary, label, [tabindex]\',No=!1,dn=null,Lo=new WeakMap,Pa=!1;function Ia(t,e){!No||!dn||e&&e.burst===!1||Lo.set(dn.control,{element:t,options:e&&typeof e=="object"?{...e}:e})}function Wa(t){let e={control:t};dn=e,setTimeout(()=>{dn===e&&(dn=null)},0)}function Wo(t){let e=t.target,n=e&&(e.nodeType===1?e:e.parentElement);return n&&n.closest?n.closest(id):null}function Na(t){if(t.type==="keydown"&&t.key!=="Enter"&&t.key!==" ")return;let e=Wo(t);e&&(Wa(e),Io(t,!1))}function sd(t){let e=Wo(t);e&&Wa(e)}function Io(t,e=!0){if(!lr||document.visibilityState==="hidden")return;let n=Wo(t);if(!n||t.type==="pointerenter"&&t.target!==n)return;let r=Lo.get(n);if(r){if(!r.element.isConnected){Lo.delete(n);return}lr(r.element,r.options).catch(()=>{});return}e&&!Pa&&(Pa=!0,lr(document.body,{clip:"viewport",burst:!1}).catch(()=>{}))}function Oa(){if(No||typeof document>"u"||typeof document.addEventListener!="function")return;No=!0;let t={capture:!0,passive:!0};document.addEventListener("pointerdown",Na,t),document.addEventListener("keydown",Na,t),document.addEventListener("click",sd,t),document.addEventListener("pointerenter",Io,t),document.addEventListener("focusin",Io,t)}Ct();function Ad(...t){return Zs(...t),Y}async function Md(t,e){if(typeof t!="string"||!t.trim())throw new Error("[snapdom.fromString] html string required");let n=document.createElement("div");tt(n),n.style.cssText="position:fixed;left:-99999px;top:0;pointer-events:none;",n.innerHTML=t,document.body.appendChild(n);try{await gt();let r=Array.from(n.childNodes).some(o=>o.nodeType===3&&o.textContent.trim()),i=n.children.length===1&&!r?n.firstElementChild:n;return await Xo(i,{...e||{},burst:!1})}finally{n.remove()}}var _d="3.2.0",Y=Object.assign(Xo,{plugins:Ad,fromString:Md,version:_d,preCapture:Oa});La(Xo);var Go=Symbol("snapdom.internal"),Ed=Symbol("snapdom.internal.silent"),Ja=new Set(["png","jpeg","jpg","webp","svg"]);async function Xo(t,e){if(!t)throw new Error("Element cannot be null or undefined");let n=pa(e);n.element=t,n.invalidate&&Re(),ea(n,e&&e.plugins);let{stage:r,loweredBy:i}=Qs(n);n.needs=r,n.__needsLoweredBy=i;let o=Be(r,"render"),s=n.burst===!0||!Jn(n),a=typeof n.filter=="function"||!!n.excludePredicates||typeof n.excludeStyleProps=="function"||typeof n.fallbackURL=="function",f=o&&!n.captureSelection&&n.burst!==!1&&s&&!a&&Fa(t);return f&&Ia(t,e),n.snap||(n.snap={toPng:(l,u)=>Y.toPng(l,u),toSvg:(l,u)=>Y.toSvg(l,u)}),f?$a(t,e,n,()=>Y.capture(t,n,Go),l=>Za(l,n)):Y.capture(t,n,Go)}Y.capture=async(t,e,n)=>{if(n!==Go)throw new Error("[snapdom.capture] is internal. Use snapdom(...) instead.");if(Be(e.needs||_t,"render")&&X()){if(e.embedFonts)try{let o=t.ownerDocument||document,s=new Set;if(e.embedFonts==="auto"){try{for(let l of o.fonts)s.add(String(l.family).replace(/["\']/g,"").toLowerCase())}catch{}if(s.size===0)throw null}let a=In(t);e.clip||(e.__fontUsage=a);let c=a.required,f=new Set([...c].map(l=>String(l).split("__")[0]).filter(Boolean));if(e.embedFonts==="auto"&&(f=new Set([...f].filter(l=>s.has(l.toLowerCase()))),f.size===0))throw null;await Wn(f,1,o)}catch{}let i=Array.from(t.querySelectorAll("canvas"));t.tagName==="CANVAS"&&i.unshift(t);for(let o of i)try{if(sn(o))continue;let s=o.getContext("2d",{willReadFrequently:!0});s&&s.getImageData(0,0,1,1)}catch(s){H(e,"safari canvas poke failed",s)}}let r=await da(t,e);return Za(r,e)};async function Za(t,e){let n=e.needs||_t,r=Be(n,"render"),i=E=>Js(n,e.__needsLoweredBy||[],E),o=typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?t:null,s=o?null:t,a=()=>s??(s=o.toDataURL()),c=o||t;o&&(t="");let f=e.__compressedSnapshot,l=e.__compressionDensity;delete e.__compressedSnapshot,delete e.__compressedAssets;let u,p=e.meta||{},m=(Number.isFinite(e.width)||Number.isFinite(e.height))&&!X(),d=m?Number.isFinite(e.width)?p.targetW/p.vbW:p.targetH/p.vbH:1,g=m?Number.isFinite(e.height)?p.targetH/p.vbH:p.targetW/p.vbW:1,y=E=>{if(o||!f?.size)return c;let N=p.vbW,P=p.vbH,F=E.crop;F&&(N=Math.max(1,Math.min(N,F.x+F.width)-Math.max(0,F.x)),P=Math.max(1,Math.min(P,F.y+F.height)-Math.max(0,F.y)));let z=Number.isFinite(E.width),V=Number.isFinite(E.height);return(z&&V?Math.max(E.width/N,E.height/P):z?E.width/N*(F?Math.max(1,g/d):1):V?E.height/P*(F?Math.max(1,d/g):1):(E.scale||1)*Math.max(d,g))*(E.dpr||1)<=l?c:u??(u=ca(a(),f))},b=async(E,N)=>{let{rasterize:P}=await Promise.resolve().then(()=>(je(),hn));return P(c,{...E,...N||{},format:"png"})},S=()=>{if(!r)throw i("svgString");if(o)throw new Error("[snapdom] svgString: engine:\'html-in-canvas\' produces a raster capture; there is no serialized SVG");let E=t.indexOf(",");return E>=0?decodeURIComponent(t.slice(E+1)):""},k=E=>Object.defineProperty({...E||{},svgString:S},"url",r?{get:a,enumerable:!0}:{get(){throw i("export.url")},enumerable:!1,configurable:!0}),v={img:async(E,N)=>{if(o)return b(E,N);let{toImg:P}=await Promise.resolve().then(()=>(Ho(),zo)),F={...E,...N||{}};return P(y(F),F)},svg:async(E,N)=>{if(o)return b(E,N);let{toSvg:P}=await Promise.resolve().then(()=>(Ho(),zo)),F={...E,...N||{}};return P(y(F),F)},canvas:async(E,N)=>{let{toCanvas:P}=await Promise.resolve().then(()=>(he(),ja)),F={...E,...N||{}};return P(y(F),F)},blob:async(E,N)=>{let{toBlob:P}=await Promise.resolve().then(()=>(qo(),Xa)),F={...E,...N||{}};return P(y(F),F)},png:async(E,N)=>{let{rasterize:P}=await Promise.resolve().then(()=>(je(),hn)),F={...E,...N||{},format:"png"};return P(y(F),F)},jpeg:async(E,N)=>{let{rasterize:P}=await Promise.resolve().then(()=>(je(),hn)),F={...E,...N||{},format:"jpeg"};return P(y(F),F)},webp:async(E,N)=>{let{rasterize:P}=await Promise.resolve().then(()=>(je(),hn)),F={...E,...N||{},format:"webp"};return P(y(F),F)},download:async(E,N)=>{let{download:P}=await Promise.resolve().then(()=>(Qa(),Ka)),F={...E,...N||{}};return P(y(F),F)}};if(!r)for(let E of Object.keys(v)){let N=E==="download"?"download()":`to${E.charAt(0).toUpperCase()}${E.slice(1)}()`;v[E]=async()=>{throw i(N)}}let w={};for(let E of["img","svg","canvas","blob","png","jpeg","webp"])w[E]=async N=>v[E](e,{...R(E,N||{}),[Ed]:!0});w.jpg=w.jpeg;let M=E=>Object.defineProperty({...e,...E},"options",{value:e,configurable:!0}),A=M({artifacts:e.__artifacts||null,export:k(),exports:w}),C=await Qn("defineExports",A),x=Object.assign({},...C.filter(E=>E&&typeof E=="object").reverse()),_={...v,...x};_.jpeg&&!_.jpg&&(_.jpg=(E,N)=>_.jpeg(E,N));function R(E,N){let P=N||{},F={...e,...P},z=typeof P.type=="string"?P.type.toLowerCase():"",V=typeof P.format=="string"?P.format.toLowerCase():Ja.has(z)?z:"";V&&(F.format=V==="jpg"?"jpeg":V),F.__explicitFormat=V?F.format:e.__explicitFormat??null,E==="blob"&&!F.__explicitFormat&&(F.format=o?"png":"svg"),F.type=F.format;let j=K=>K==="jpeg"||K==="jpg"||K==="webp";return[E,F.format,z].map(K=>typeof K=="string"?K.toLowerCase():"").find(j)&&(F.backgroundColor==null||F.backgroundColor==="transparent")&&(F.backgroundColor="#ffffff"),F.scale!==1&&(Number.isFinite(F.width)||Number.isFinite(F.height))&&H(F,"scale ignored: width/height sets output size"),F}let $=!1,T=Promise.resolve();async function I(E,N){let P=Object.freeze(N&&typeof N=="object"?{...N}:{}),F=async()=>{let V=_[E];if(!V)throw new Error(`[snapdom] Unknown export type: ${E}`);let j=R(E,P),D=M({artifacts:e.__artifacts||null,export:k({type:E,options:j,requestedOptions:P})}),K=j.format,ht=j.type;await Qn("beforeExport",D,{format:E,options:j});let St=j.format!==K?j.format:j.type!==ht?j.type:"",ft=typeof St=="string"?St.toLowerCase():"";Ja.has(ft)&&(j.format=ft==="jpg"?"jpeg":ft,j.type=j.format,j.__explicitFormat=j.format,/^(?:jpeg|webp)$/.test(j.format)&&(j.backgroundColor==null||j.backgroundColor==="transparent")&&(j.backgroundColor="#ffffff"));let at=await V(D,j);return await Qn("afterExport",D,{format:E,options:j,result:at}),$||($=!0,await Bt("afterSnap",e)),at},z=T.then(F);return T=z.catch(()=>{}),z}let B={url:t,needs:n,warnings:e.__session&&e.__session.warnings||[],toRaw:()=>{if(!r)throw i("toRaw()");return a()},to:(E,N)=>I(E,N),toImg:E=>I("img",E),toSvg:E=>I("svg",E),toCanvas:E=>I("canvas",E),toBlob:E=>I("blob",E),toPng:E=>I("png",E),toJpg:E=>I("jpg",E),toWebp:E=>I("webp",E),download:E=>I("download",E)};r?o&&Object.defineProperty(B,"url",{get:a,enumerable:!0,configurable:!0}):Object.defineProperty(B,"url",{get(){throw i("url")},enumerable:!1,configurable:!0}),Object.defineProperty(B,"meta",r?{value:e.meta,enumerable:!0}:{get(){throw i("meta")},enumerable:!1,configurable:!0});for(let E of Object.keys(_)){let N="to"+E.charAt(0).toUpperCase()+E.slice(1);B[N]||(B[N]=P=>I(E,P))}return B}Y.toRaw=(t,e)=>Y(t,e).then(n=>n.toRaw());Y.toImg=(t,e)=>Y(t,e).then(n=>n.toImg());Y.toSvg=(t,e)=>Y(t,e).then(n=>n.toSvg());Y.toCanvas=(t,e)=>Y(t,e).then(n=>n.toCanvas());Y.toBlob=(t,e)=>Y(t,e).then(n=>n.toBlob());Y.toPng=(t,e)=>Y(t,{...e,format:"png"}).then(n=>n.toPng());Y.toJpg=(t,e)=>Y(t,{...e,format:"jpeg"}).then(n=>n.toJpg());Y.toWebp=(t,e)=>Y(t,{...e,format:"webp"}).then(n=>n.toWebp());Y.download=(t,e)=>Y(t,e).then(n=>n.download());typeof window<"u"&&(window.snapdom=Y);})();\n'}function HC(){let e=process.env.CHROME_PATH?.trim();return e&&ch(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=>ch(n))??null}async function VC(e,t,n,r){let o=fc(n,r),s=o.profile,i,l,a,c=()=>a??=(async()=>{try{i&&await JC(i,l)}finally{process.off("SIGINT",u),process.off("SIGTERM",p),process.off("SIGHUP",d),process.off("exit",f),(!i||i.exitCode!==null||i.signalCode!==null||!i.pid)&&o.release()}})(),u=()=>{c().finally(()=>process.exit(130))},p=()=>{c().finally(()=>process.exit(143))},d=()=>{c().finally(()=>process.exit(129))},f=()=>{i&&i.exitCode===null&&i.signalCode===null&&i.kill("SIGKILL")};process.once("SIGINT",u),process.once("SIGTERM",p),process.once("SIGHUP",d),process.once("exit",f);try{i=LC(e,[...t?[]:["--headless=new","--disable-gpu"],"--remote-debugging-port=0",`--user-data-dir=${s}`,"--no-first-run","--no-default-browser-check","--disable-extensions","--disable-background-networking","--hide-scrollbars","--window-size=1440,900","about:blank"],{stdio:["ignore","ignore","pipe"]}),o.setChromePid(i.pid);let m=await XC(i,wh);i.stderr?.on("data",()=>{}),l=await ZC(m);let g=l,S=await qC(g,t),b=(await g.send("Target.attachToTarget",{targetId:S,flatten:!0})).sessionId,k=(x,v)=>g.send(x,v,b);await k("Page.enable"),await k("Runtime.enable");let y=async(x,v=60)=>{try{let $=x?"png":"jpeg",R=await k("Page.captureScreenshot",{format:$,...x?{}:{quality:v},fromSurface:!0,captureBeyondViewport:!1,...x?{clip:x}:{}});return typeof R.data=="string"&&R.data?`data:image/${$};base64,${R.data}`:void 0}catch{return}};return{async open(x){try{await k("Page.navigate",{url:x}),await g.waitLoad(b,bh),await YC(800);let $=(await k("Page.getFrameTree")).frameTree?.frame?.url??x;return KC(x,$)?$:null}catch{return null}},async evaluate(x,v){let $=await k("Runtime.evaluate",{expression:x,awaitPromise:v,returnByValue:!0});if(!$.exceptionDetails)return $.result?.value},async screenshot(x,v){try{let R=(await k("Page.getLayoutMetrics")).cssVisualViewport;return y(Wm(x,{x:R?.pageX??0,y:R?.pageY??0},v))}catch{return}},async screenshotViewport(x=60){return y(void 0,x)},async location(){try{return(await k("Page.getFrameTree")).frameTree?.frame?.url??null}catch{return null}},close:c}}catch(m){throw await c(),m}}async function qC(e,t){if(t){let o=(await e.send("Target.getTargets")).targetInfos?.find(s=>s.type==="page");if(o)return o.targetId}return(await e.send("Target.createTarget",{url:"about:blank"})).targetId}async function JC(e,t,n=3e3){let r=()=>e.exitCode!==null||e.signalCode!==null||!e.pid,o=()=>new Promise(s=>{if(r()){s();return}let i=()=>{clearTimeout(l),e.off("exit",i),s()},l=setTimeout(i,n);e.once("exit",i)});try{if(r()||(t&&(t.send("Browser.close").catch(()=>{}),await o()),r()||(e.kill("SIGTERM"),await o()),r()||(e.kill("SIGKILL"),await o())),!r())throw new Error("Chrome did not close. Close Grum's capture window before trying again.")}finally{await t?.close()}}function KC(e,t){try{return new URL(e).host===new URL(t).host}catch{return!1}}function XC(e,t){return new Promise((n,r)=>{let o="",s=()=>{clearTimeout(i),e.stderr?.off("data",l),e.off("exit",c),e.off("error",a)},i=setTimeout(()=>{s(),r(new Error("Chrome did not open a debug port."))},t),l=u=>{o+=u.toString("utf8");let p=o.match(/DevTools listening on (ws:\/\/\S+)/);p?.[1]&&(s(),n(p[1]))};e.stderr?.on("data",l);let a=u=>{s(),r(u)},c=()=>{s(),r(new Error("Chrome couldn't start here. If an editor's agent ran this, run it from a normal terminal instead."))};e.once("exit",c),e.once("error",a)})}async function ZC(e){let t=new WebSocket(e);await new Promise((i,l)=>{let a=setTimeout(()=>{t.close(),l(new Error("Timed out connecting to Chrome."))},wh);t.addEventListener("open",()=>{clearTimeout(a),i()},{once:!0}),t.addEventListener("error",()=>{clearTimeout(a),t.close(),l(new Error("Could not talk to Chrome."))},{once:!0})});let n=1,r=new Map,o=new Set,s=()=>{for(let i of r.values())i.reject(new Error("Chrome closed."));r.clear()};return t.addEventListener("close",s),t.addEventListener("error",s),t.addEventListener("message",i=>{let l=typeof i.data=="string"?i.data:"";if(!l)return;let a;try{a=JSON.parse(l)}catch{return}if(a.method==="Page.loadEventFired")for(let u of[...o])u(a.sessionId??a.params?.sessionId);if(typeof a.id!="number")return;let c=r.get(a.id);if(c){if(r.delete(a.id),a.error){c.reject(new Error(a.error.message||"Chrome command failed."));return}c.resolve(a.result)}}),{send(i,l,a){let c=n++,u={id:c,method:i};return l&&(u.params=l),a&&(u.sessionId=a),new Promise((p,d)=>{let f=setTimeout(()=>{r.delete(c),d(new Error(`Chrome timed out: ${i}.`))},bh);r.set(c,{resolve:m=>{clearTimeout(f),p(m)},reject:m=>{clearTimeout(f),d(m)}});try{if(t.readyState!==WebSocket.OPEN)throw new Error("Chrome closed.");t.send(JSON.stringify(u))}catch(m){clearTimeout(f),r.delete(c),d(m)}})},waitLoad(i,l){return new Promise(a=>{let c=()=>{clearTimeout(u),o.delete(p),a()},u=setTimeout(c,l),p=d=>{d&&d!==i||c()};o.add(p)})},async close(){s(),o.clear(),t.close()}}}function YC(e){return new Promise(t=>setTimeout(t,e))}import{createInterface as kh}from"node:readline/promises";async function ge(e,t,n=`Please answer one of the options.
|
|
471
|
+
; return 0; })()`,!1)}catch{}let s;try{s=await e.evaluate(FC(t),!0)}catch{return null}let i=GC(s);if(!i)return BC(s)?{miss:"ambiguous"}:null;let l=await e.screenshot(i.box,i.dpr),a;if(l){let u=`(${Jm()})`;try{i.mark&&await e.evaluate(`${u}(${JSON.stringify(i.mark)})`,!1),a=await zC(e)}finally{i.mark&&await e.evaluate(`${u}(null)`,!1)}}let c=dn({...r?{url:r}:{},screenshot:l||(o?await e.screenshotViewport():void 0),viewport:a,snapdom:mf(i.snapdom),observed:i.observed,viewportSize:i.viewport,capturedAt:new Date().toISOString()});return c&&Ft(c)?c:null}function mh(e,t){if(!(!t||t.includes("..")||sr.isAbsolute(t)))try{let n=sr.resolve(e,t),r=sr.resolve(e);if(n!==r&&!n.startsWith(r+sr.sep))return;let o=yh(n,"utf8");return o.length>2e5?void 0:o}catch{return}}async function zC(e){for(let t of[55,35]){let n=await e.screenshotViewport(t);if(n&&n.length<=zn)return n}}function hh(e){let t=e,n=Number(t?.x),r=Number(t?.y),o=Number(t?.width),s=Number(t?.height);return![n,r,o,s].every(i=>Number.isFinite(i))||o<1||s<1?null:{x:n,y:r,width:o,height:s}}function GC(e){if(!e||typeof e!="object")return null;let t=e;if(t.found!==!0)return null;let n=hh(t.box);return n?{box:n,mark:hh(t.mark),snapdom:typeof t.snapdom=="string"?t.snapdom:"",dpr:Number(t.dpr)||1,observed:t.observed,viewport:t.viewport}:null}function BC(e){return e&&typeof e=="object"&&e.miss==="ambiguous"?"ambiguous":null}function WC(){return'/*\n* SnapDOM\n* v3.2.0\n* License: MIT\n*/\n"use strict";(()=>{var oc=Object.defineProperty;var lt=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(r){throw n=[r],r}};var we=(t,e)=>{for(var n in e)oc(t,n,{get:e[n],enumerable:!0})};function Ko(t){return t===!1||typeof t=="string"&&t.toLowerCase().trim()==="disabled"?"disabled":"soft"}function Qo(t="soft"){t==="disabled"&&(L.computedStyle=new WeakMap,L.measureHints=new WeakMap,L.baseStyle=new ut(50),L.defaultStyle=new ut(64),L.image=new ut(100),L.background=new ut(100),L.resource=new ut(150),L.compress=new ut(50))}var ut,L,mt=lt(()=>{"use strict";ut=class extends Map{constructor(e=100,...n){super(...n),this._maxSize=e}set(e,n){if(this.size>=this._maxSize&&!this.has(e)){let r=this.keys().next().value;r!==void 0&&this.delete(r)}return super.set(e,n)}},L={image:new ut(100),background:new ut(100),resource:new ut(150),defaultStyle:new ut(64),baseStyle:new ut(50),compress:new ut(50),computedStyle:new WeakMap,measureHints:new WeakMap,warnedReconcile:!1}});function ee(t){let e=t.match(/url\\(([\'"]?)(.*?)(\\1)\\)/);if(!e)return null;let n=e[2].trim();return n.startsWith("#")?null:n}function sc(t){let e=[],n=0,r=0,i="";for(let o=0;o<t.length;o++){let s=t[o];if(s==="\\\\"){o++;continue}i?s===i&&(i=""):s===\'"\'||s==="\'"?i=s:s==="("?r++:s===")"?r--:s===","&&r===0&&(e.push(t.slice(n,o)),n=o+1)}return e.push(t.slice(n)),e}function qe(t,e=1){let n=t.match(/^\\s*-?(?:webkit-)?image-set\\(([\\s\\S]*)\\)\\s*$/i);if(!n)return null;let r=[];for(let o of sc(n[1])){let s=o.match(/url\\(([\'"]?)(.*?)(\\1)\\)/);if(!s)continue;let a=o.match(/type\\(\\s*["\']([^"\']+)["\']\\s*\\)/i);if(a&&!ic.test(a[1].trim()))continue;let c=o.replace(/url\\(([\'"]?)[\\s\\S]*?\\1\\)/," ").match(/(\\d+(?:\\.\\d+)?)\\s*(x|dpi|dppx)\\b/i),f=1;if(c){let l=parseFloat(c[1]);f=/dpi/i.test(c[2])?l/96:l}r.push({url:s[2].trim(),dppx:f})}return r.length?(r.sort((o,s)=>o.dppx-s.dppx),(r.find(o=>o.dppx>=e)||r[r.length-1]).url):null}function vr(t){if(!t||t==="none")return"";let e=t.replace(/translate[XY]?\\([^)]*\\)/g,"");return e=e.replace(/matrix\\(([^)]+)\\)/g,(n,r)=>{let i=r.split(",").map(o=>o.trim());return i.length!==6?`matrix(${r})`:(i[4]="0",i[5]="0",`matrix(${i.join(", ")})`)}),e=e.replace(/matrix3d\\(([^)]+)\\)/g,(n,r)=>{let i=r.split(",").map(o=>o.trim());return i.length!==16?`matrix3d(${r})`:(i[12]="0",i[13]="0",`matrix3d(${i.join(", ")})`)}),e.trim().replace(/\\s{2,}/g," ")}function Vt(t){if(/%[0-9A-Fa-f]{2}/.test(t))return t;try{return encodeURI(t)}catch{return t}}function kr(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}}function Ge(t){return!!t&&t.tagName==="INPUT"&&(t.getAttribute("type")||"").toLowerCase()==="password"}function Cr(t){return"\\u2022".repeat(String(t??"").length)}function st(t,e){return t?.nodeType===1&&t.localName===e}function Rt(t){return t?.nodeType===1&&t.namespaceURI===ac}function It(t){return t?.nodeType===1&&t.namespaceURI===cc}function Wt(t){return t?.nodeType===11&&!!t.host}function Ar(t){return t?.nodeType===9}var xr,ic,ac,cc,kt=lt(()=>{"use strict";xr=/^image\\/(jpeg|jpg|png|gif|webp|avif|apng|svg\\+xml|bmp|x-icon|vnd\\.microsoft\\.icon)\\s*(;|$)/i,ic=xr;ac="http://www.w3.org/1999/xhtml",cc="http://www.w3.org/2000/svg"});function lc(t="[snapDOM]",{ttlMs:e=5*6e4,maxEntries:n=12}={}){let r=new Map,i=0;function o(s,a,c){if(i>=n)return;let f=Date.now();(r.get(a)||0)>f||(r.set(a,f+e),i++,s==="warn"&&console&&console.warn?console.warn(`${t} ${c}`):console&&console.error&&console.error(`${t} ${c}`))}return{warnOnce(s,a){o("warn",s,a)},errorOnce(s,a){o("error",s,a)},reset(){r.clear(),i=0}}}function ti(t,e,n){if(Ot.size>=Zo){let r=Date.now();for(let[i,o]of Ot)o.until<=r&&Ot.delete(i);for(;Ot.size>=Zo;)Ot.delete(Ot.keys().next().value)}Ot.set(t,{until:Date.now()+n,result:e})}function fc(t){return/^data:|^blob:|^about:blank$/i.test(t)}function uc(t,e){try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",r=e.split(/\\{url(?:Raw)?\\}/)[0],i=new URL(r||".",n);if(new URL(t,n).origin===i.origin)return!0}catch{}return!1}function dc(t,e){if(!e||fc(t)||uc(t,e))return!1;try{let n=typeof location<"u"&&location.href?location.href:"http://localhost/",r=new URL(t,n);return typeof location<"u"?r.origin!==location.origin:!0}catch{return!!e}}function pc(t,e){if(!e)return t;if(/\\{url(?:Raw)?\\}/.test(e))return e.replace("{urlRaw}",()=>Vt(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}${Vt(t)}`;let n=e.includes("?")?"&":"?";return`${e}${n}url=${encodeURIComponent(t)}`}function ei(t){return new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result||"")),r.onerror=()=>n(new Error("read_failed")),r.readAsDataURL(t)})}function hc(t,e){return new Headers(e.headers||{}).keys().next().done?JSON.stringify([e.as||"blob",e.timeout??3e3,e.useProxy||"",e.errorTTL??8e3,e.credentials||"",t]):null}function ni(t){try{return new URL(t,globalThis.location?.href||"http://localhost/").origin}catch{return"invalid-url"}}function _r(t,e){try{t.onError?.(e)}catch{}}async function dt(t,e={}){let n=e.as??"blob",r=e.timeout??3e3,i=e.useProxy||"",o=e.errorTTL??8e3,s=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[,g="",y=""]=String(t).match(/^data:([^,]*),(.*)$/)||[],S=/;base64/i.test(g)?atob(y):decodeURIComponent(y),k=new Uint8Array([...S].map(w=>w.charCodeAt(0))),v=new Blob([k],{type:(g||"").split(";")[0]||""});return{ok:!0,data:v,status:200,url:t,fromCache:!1,mime:v.type||""}}catch{return{ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"special_url_error"}}if(/^blob:/i.test(t))try{let g=await fetch(t);if(!g.ok)return{ok:!1,data:null,status:g.status,url:t,fromCache:!1,reason:"http_error"};let y=await g.blob(),b=y.type||g.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await ei(y),blob:y,status:g.status,url:t,fromCache:!1,mime:b}:n==="text"?{ok:!0,data:await y.text(),status:g.status,url:t,fromCache:!1,mime:b}:{ok:!0,data:y,status:g.status,url:t,fromCache:!1,mime:b}}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;try{c=hc(t,{as:n,timeout:r,useProxy:i,errorTTL:o,credentials:e.credentials,headers:s})}catch{let g={ok:!1,data:null,status:0,url:t,fromCache:!1,reason:"network"};return _r(e,g),g}let f=Ot.get(c);if(f&&f.until>Date.now())return{...f.result,fromCache:!0};f&&Ot.delete(c);let l=Mr.get(c);if(l)return l;let u=dc(t,i)?pc(t,i):t,p=e.credentials;if(!p)try{let g=typeof location<"u"&&location.href?location.href:"http://localhost/",y=new URL(t,g);p=typeof location<"u"&&y.origin===location.origin?"include":"omit"}catch{p="omit"}let h=new AbortController,m=setTimeout(()=>h.abort("timeout"),r),d=(async()=>{try{let g=await fetch(u,{signal:h.signal,credentials:p,headers:s});if(!g.ok){let S={ok:!1,data:null,status:g.status,url:u,fromCache:!1,reason:"http_error"};if(c!==null&&o>0&&ti(c,S,o),!a){let k=`${g.status} ${g.statusText||""}`.trim();Jo.warnOnce(`http:${g.status}:${n}:${ni(t)}`,`HTTP ${k} fetching ${n}: ${t}`)}return _r(e,S),S}if(n==="text")return{ok:!0,data:await g.text(),status:g.status,url:u,fromCache:!1};let y=await g.blob(),b=y.type||g.headers.get("content-type")||"";return n==="dataURL"?{ok:!0,data:await ei(y),blob:y,status:g.status,url:u,fromCache:!1,mime:b}:{ok:!0,data:y,status:g.status,url:u,fromCache:!1,mime:b}}catch(g){let y=h.signal.aborted?h.signal.reason==="timeout"?"timeout":"abort":g&&typeof g=="object"&&g.name==="AbortError"?"abort":"network",b={ok:!1,data:null,status:0,url:u,fromCache:!1,reason:y};if(c!==null&&!/^blob:/i.test(t)&&o>0&&ti(c,b,o),!a){let S=`${y}:${n}:${ni(t)}`,k=y==="timeout"?`Timeout (${r}ms): ${t}. Increase timeout or use a proxy`:y==="abort"?`Aborted fetching ${n}: ${t}`:`Network/CORS fetching ${n}: ${t}. Try useProxy`;Jo.errorOnce(S,k)}return _r(e,b),b}finally{clearTimeout(m),Mr.delete(c)}})();return c!==null&&Mr.set(c,d),d}var Jo,Mr,Zo,Ot,Se=lt(()=>{"use strict";kt();Jo=lc("[snapDOM]",{ttlMs:3*6e4,maxEntries:10}),Mr=new Map,Zo=50,Ot=new Map});async function xe(t,e={}){if(/^\\s*url\\(\\s*[\'"]?data:/i.test(t)||/^((repeating-)?(linear|radial|conic)-gradient)\\(/i.test(t)||t.trim()==="none")return t;let r=qe(t,typeof devicePixelRatio<"u"&&devicePixelRatio||1)??ee(t);if(!r)return t;let i=kr(r),o=Vt(i),s=(e.useProxy||"")+"|"+o;if(L.background.has(s)){let a=L.background.get(s);return a?`url("${a}")`:"none"}try{let a=await dt(o,{as:"dataURL",useProxy:e.useProxy});return a.ok?(L.background.set(s,a.data),`url("${a.data}")`):(L.background.set(s,null),"none")}catch{return L.background.set(s,null),"none"}}var ri=lt(()=>{"use strict";mt();kt();Se()});function Sc(t){let e=t.replace(wc,"").trim();return e?e.replace(/(^|,)(\\s*)(?=,|$)/g,"$1$2*"):"*"}function si(t,e,n,r){for(let i=0;i<t.length;i++){if(--r.budget<0)return!1;let o=t[i],s=o.style;if(s){let c=!!o.selectorText&&yc.test(o.selectorText);for(let f=0;f<s.length;f++){let l=s[f];if(e.add(l),c&&r.pseudoProps.add(l),s.getPropertyPriority(l)&&r.importantProps.add(l),l.length>5&&(l[0]==="m"||l[0]==="p")){let u=l.startsWith("margin")?"marginUnstable":l.startsWith("padding")?"paddingUnstable":null;u&&!r[u]&&bc.test(s.getPropertyValue(l))&&(r[u]=!0)}}}let a=o.selectorText;if(a&&a.includes(":has(")&&(r.usesHas=!0),a&&a.includes("&"))for(let c=o.parentRule;c&&a.includes("&");c=c.parentRule)c.selectorText&&(a=a.replace(/&/g,`:is(${c.selectorText})`));if(a&&(r.inContainer||ii.test(a)||a.includes("+")||a.includes("~")))for(let c of Fr(a,",")){let f=c.trim();f&&(r.inContainer||ii.test(f)||f.includes("+")||f.includes("~"))&&r.shareUnsafeSels.add(f)}if(a&&a.includes(":"))for(let c in oi)oi[c].test(a)&&n[c].push(Sc(a));if(o.styleSheet){if(!yn(o.styleSheet,e,n,r))return!1}else if(o.cssRules&&o.cssRules.length){let c=o.constructor?.name==="CSSContainerRule";c&&r.inContainer++;let f=si(o.cssRules,e,n,r);if(c&&r.inContainer--,!f)return!1}}return!0}function yn(t,e,n,r){let i;try{i=t.cssRules}catch{return!1}return i?si(i,e,n,r):!1}function Rr(t,e){for(let n of t){let r=n.effect?.getKeyframes?.()||[];for(let i of r)for(let o of Object.keys(i))o==="offset"||o==="easing"||o==="composite"||o==="computedOffset"||e.add(o.replace(/[A-Z]/g,s=>"-"+s.toLowerCase()))}}function ai(t){let e=new Set;return yn(t,e,{before:[],after:[],firstLetter:[],marker:[],firstLine:[]},{budget:2e4,usesHas:!1,shareUnsafeSels:new Set,inContainer:0,marginUnstable:!1,paddingUnstable:!1,importantProps:new Set,pseudoProps:new Set})?e:null}function Fr(t,e){if(!t.includes(e))return[t];let n=[],r=0,i=null,o=0;for(let s=0;s<t.length;s++){let a=t[s];if(a==="\\\\"){s++;continue}if(i){a===i&&(i=null);continue}a===\'"\'||a==="\'"?i=a:a==="("||a==="["?r++:a===")"||a==="]"?r--:r===0&&a===e&&(n.push(t.slice(o,s)),o=s+1)}return n.push(t.slice(o)),n}function xc(t){let e=0,n=null,r=0;for(let l=0;l<t.length;l++){let u=t[l];if(n){u===n&&t[l-1]!=="\\\\"&&(n=null);continue}u===\'"\'||u==="\'"?n=u:u==="("||u==="["?e++:u===")"||u==="]"?e--:e===0&&(u===" "||u===">"||u==="+"||u==="~")&&(r=l+1)}let i="",o=0;for(let l of t.slice(r))l==="("||l==="["?o++:l===")"||l==="]"?o--:o===0&&(i+=l);let s=l=>!l||/\\\\[0-9a-fA-F]/.test(l)?null:l.replace(/\\\\(.)/g,"$1"),a=s((i.match(/\\.((?:\\\\.|[\\w-])+)/)||[])[1]);if(a)return"c"+a;let c=s((i.match(/#((?:\\\\.|[\\w-])+)/)||[])[1]);if(c)return"i"+c;let f=(i.match(/^([a-zA-Z][\\w-]*)/)||[])[1];return f?"t"+f.toLowerCase():null}function ci(t,e){if(!e.length)return"";if(e.some(r=>r.includes("&")))return null;let n=e.join(",");try{return t.matches(n),n}catch{return null}}function vc(t,e){let n=t.createElement("div"),r={};for(let i in e){let o=e[i];(i==="before"||i==="after")&&o.push("q"),r[i]=ci(n,o)}return r}function li(t){let e={universe:null,pseudoUniverse:null,usesHas:!0,shareGate:null,marginUnstable:!0,paddingUnstable:!0,importantProps:null,pseudoGates:{before:null,after:null,firstLetter:null,marker:null,firstLine:null}};try{let n=new Set(Er),r={before:[],after:[],firstLetter:[],marker:[],firstLine:[]},i={budget:2e4,usesHas:!1,shareUnsafeSels:new Set,inContainer:0,marginUnstable:!1,paddingUnstable:!1,importantProps:new Set,pseudoProps:new Set};for(let f of t.styleSheets)if(!yn(f,n,r,i))return e;let o=t.adoptedStyleSheets;if(Array.isArray(o)){for(let f of o)if(!yn(f,n,r,i))return e}typeof t.getAnimations=="function"&&Rr(t.getAnimations(),n);let s=Array.from(i.shareUnsafeSels),a=ci(t.createElement("div"),s)===null?null:s.map(f=>({sel:f,key:xc(f)})),c=new Set(gc);for(let f of mc)n.has(f)&&c.add(f);for(let f of i.pseudoProps)c.add(f);return{universe:n,pseudoUniverse:c,pseudoGates:vc(t,r),usesHas:i.usesHas,shareGate:a,marginUnstable:i.marginUnstable,paddingUnstable:i.paddingUnstable,importantProps:i.importantProps}}catch{return e}}var Er,mc,gc,yc,bc,oi,wc,ii,bn=lt(()=>{"use strict";Er=["display","position","top","right","bottom","left","float","clear","z-index","box-sizing","width","height","min-width","min-height","max-width","max-height","margin-top","margin-right","margin-bottom","margin-left","padding-top","padding-right","padding-bottom","padding-left","overflow-x","overflow-y","visibility","opacity","content-visibility","vertical-align","border-top-width","border-right-width","border-bottom-width","border-left-width","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-left-radius","border-top-right-radius","border-bottom-right-radius","border-bottom-left-radius","flex-direction","flex-wrap","flex-grow","flex-shrink","flex-basis","order","align-items","align-self","align-content","justify-content","justify-items","justify-self","row-gap","column-gap","grid-template-columns","grid-template-rows","grid-auto-flow","grid-auto-columns","grid-auto-rows","grid-column-start","grid-column-end","grid-row-start","grid-row-end","color","font-family","font-size","font-weight","font-style","font-stretch","line-height","letter-spacing","word-spacing","white-space","text-align","text-transform","text-indent","text-overflow","text-shadow","direction","unicode-bidi","writing-mode","text-orientation","word-break","overflow-wrap","tab-size","list-style-type","list-style-position","list-style-image","counter-reset","counter-increment","counter-set","background-color","background-image","background-size","background-position","background-repeat","background-clip","background-origin","background-attachment","box-shadow","outline-width","outline-style","outline-color","outline-offset","transform","transform-origin","rotate","scale","translate","filter","mix-blend-mode","clip-path","object-fit","object-position","border-collapse","border-spacing","table-layout","caption-side","empty-cells"],mc=["color","font-family","font-size","font-weight","font-style","font-stretch","font-variant","font-kerning","font-feature-settings","font-variation-settings","line-height","letter-spacing","word-spacing","white-space","text-align","text-align-last","text-indent","text-transform","text-shadow","text-rendering","direction","unicode-bidi","word-break","overflow-wrap","writing-mode","text-orientation","hyphens","tab-size","visibility","list-style-type","list-style-position","list-style-image","border-collapse","border-spacing","caption-side","empty-cells","quotes","color-scheme","-webkit-text-fill-color","-webkit-font-smoothing","image-rendering"],gc=["display","width","height","min-width","min-height"],yc=/::?(?:before|after|first-letter|first-line|marker)/,bc=/%|\\bauto\\b|calc\\(|var\\(/i,oi={before:/::?before\\b/,after:/::?after\\b/,firstLetter:/::?first-letter\\b/,marker:/::marker\\b/,firstLine:/::?first-line\\b/},wc=/::?(?:before|after|first-letter|first-line|marker)\\b/g;ii=/:(nth-|first-child|last-child|only-|first-of-type|last-of-type|empty|hover|focus|active|target|checked|indeterminate|disabled|enabled|read-only|read-write|placeholder-shown|autofill|valid|invalid|user-valid|user-invalid|in-range|out-of-range|required|optional|default|link|any-link|scope|defined|modal|fullscreen|picture-in-picture|playing|paused|dir\\(|lang\\(|has\\()/});function tt(t){return fi.add(t),t.setAttribute("data-snapdom-internal",""),t}function qt(t){return fi.has(t)}var fi,Ct=lt(()=>{"use strict";fi=new WeakSet});function $r(t){if(t=String(t).toLowerCase(),Xe.has(t)){let o={};return L.defaultStyle.set(t,o),o}if(L.defaultStyle.has(t))return L.defaultStyle.get(t);let e=[...document.querySelectorAll("#snapdom-sandbox")].find(qt);e||(e=document.createElement("div"),tt(e),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.includes("-")?"span":t);n.style.all="initial",e.appendChild(n);let r=getComputedStyle(n),i={};for(let o of r){if(ve(o))continue;let s=r.getPropertyValue(o);i[o]=s}for(let o of Er)!(o in i)&&!ve(o)&&(i[o]=r.getPropertyValue(o));return e.removeChild(n),L.defaultStyle.set(t,i),i}function ve(t){let e=ui.get(t);if(e===void 0){let n=String(t).toLowerCase();e=Ac.has(n)||Cc.test(n)||kc.test(n),ui.set(t,e)}return e}function pi(t,e){let n=Fc.get(t);if(n===void 0||e[n]!==e[t])return!1;let r=e["writing-mode"];if(r&&r!=="horizontal-tb")return!1;let i=e.direction;return!(i&&i!=="ltr")}function wn(t,e){return!_c.has(t)&&(e==="inline"||Mc.has(t)||di.has(t))}function Pr(t,e,n){let r=(e.display||"").toLowerCase();if(r==="inline"||di.has(t))return!1;if(n)return!0;if((e.float||"none").toLowerCase()!=="none")return!1;let o=(e.position||"static").toLowerCase();return o==="absolute"||o==="fixed"?!1:!$c.has(r)}function ke(t,e,n=!0,r=!1){if(e=String(e||"").toLowerCase(),Xe.has(e))return"";let i=[],o=$r(e),s=(t.display||"").toLowerCase(),a=s==="inline",c=wn(e,s),f=t["text-wrap-mode"]||t["white-space"]||"",l=f==="nowrap"||f==="pre",p=c&&n&&!(c&&n&&!a&&l),h=!1;for(let m in t){if(ve(m)||pi(m,t))continue;let d=t[m];if(p){if(Ec.has(m))continue;if(Rc.has(m)){d&&d!==o[m]&&(i.push(`${m}:${d}`),d!=="auto"&&(h=!0));continue}}if(d&&d!==o[m]){if(!l&&(m==="width"||m==="inline-size")&&d.endsWith("px")&&d.includes(".")){let g=parseFloat(d);if(Number.isFinite(g)){i.push(`${m}:${(g+Tc).toFixed(3)}px`);continue}}i.push(`${m}:${d}`)}}if(p&&!a&&!r&&!h){let m=t.width;m&&m!=="auto"&&m!==o.width&&i.push(`min-width:${m}`)}return i.sort(),i.join(";")}function Nr(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 Lr(t,e=null){let n=new Map;for(let s of t){let a=$r(s);if(!a)continue;let l=(e?Object.entries(a).filter(([p])=>e.has(p)):Object.entries(a)).filter(([p])=>!pi(p,a)).map(([p,h])=>`${p}:${h};`).sort(),u=l.join("");u&&(n.has(u)||n.set(u,{tagList:[],declarations:l}),n.get(u).tagList.push(s))}let r=[...n.values()],i=null;for(let{declarations:s}of r){let a=new Set(s);if(!i){i=a;continue}for(let c of i)a.has(c)||i.delete(c)}i??(i=new Set);let o="";if(i.size&&r.length>1){let s=r.flatMap(a=>a.tagList);o+=`${s.join(",")} { ${[...i].join("")} }\n`}for(let{tagList:s,declarations:a}of r){let c=r.length>1?a.filter(l=>!i.has(l)):a;if(!c.length)continue;let f=c.join("");o+=`${s.join(",")} { ${f} }\n`}return o}function Ye(t){let e=Array.from(new Set(t.values())).filter(Boolean).sort(),n=new Map,r=1;for(let i of e)n.set(i,`c${r++}`);return n}function Pc(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 r=0;r<window.frames.length;r++)try{if(window.frames[r]?.document===e)return window.frames[r]}catch{}}catch{}return typeof window<"u"?window:null}function O(t,e=null){let n=()=>{let o={length:0,getPropertyValue:()=>"",item:()=>""};return o[Symbol.iterator]=function*(){},o};if(t?.nodeType!==1){let o=typeof window<"u"?window:null;if(o&&typeof o.getComputedStyle=="function")try{return o.getComputedStyle(t,e)||n()}catch{return n()}return n()}let r=L.computedStyle.get(t);r||(r=new Map,L.computedStyle.set(t,r));let i=r.get(e);if(!i){let o=Pc(t),s=null;try{s=o&&typeof o.getComputedStyle=="function"?o.getComputedStyle(t,e):null}catch{}if(!s&&typeof window<"u"&&typeof window.getComputedStyle=="function")try{t.ownerDocument===document&&(s=window.getComputedStyle(t,e))}catch{}i=s||n(),r.set(e,i)}return i}function Ce(t,e=null){let n={};for(let r of e||t){let i=t.getPropertyValue(r);i&&(n[r]=i)}for(let r of Nc){let i=n[`border-${r}-style`],o=n[`border-${r}-width`];(i==="none"||i==="hidden"||o==="0px")&&(delete n[`border-${r}-style`],delete n[`border-${r}-width`],delete n[`border-${r}-color`])}return n}function Gt(t){let e=[],n=0,r=0;for(let i=0;i<t.length;i++){let o=t[i];o==="("&&n++,o===")"&&n--,o===","&&n===0&&(e.push(t.slice(r,i).trim()),r=i+1)}return e.push(t.slice(r).trim()),e}var Tr,Xe,kc,Cc,Ac,ui,Mc,di,_c,Ec,Rc,Fc,Tc,$c,Nc,Ae=lt(()=>{"use strict";mt();bn();Ct();Tr=new Set(["meta","script","noscript","title","link","template"]),Xe=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"]);kc=/(?:^|-)(animation|transition)(?:-|$)/i,Cc=/^(--.+|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,Ac=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"]),ui=new Map;Mc=new Set(["span","small","em","strong","b","i","u","s","code","cite","mark","sub","sup"]),di=new Set(["table","thead","tbody","tfoot","tr","td","th"]),_c=new Set(["img","video","canvas","svg","iframe","embed","object","input","textarea","select"]),Ec=new Set(["width","max-width","inline-size","max-inline-size"]),Rc=new Set(["min-width","min-inline-size"]),Fc=new Map(Object.entries({"block-size":"height","inline-size":"width","min-block-size":"min-height","min-inline-size":"min-width","max-block-size":"max-height","max-inline-size":"max-width","margin-block-start":"margin-top","margin-block-end":"margin-bottom","margin-inline-start":"margin-left","margin-inline-end":"margin-right","padding-block-start":"padding-top","padding-block-end":"padding-bottom","padding-inline-start":"padding-left","padding-inline-end":"padding-right","inset-block-start":"top","inset-block-end":"bottom","inset-inline-start":"left","inset-inline-end":"right","border-block-start-width":"border-top-width","border-block-start-style":"border-top-style","border-block-start-color":"border-top-color","border-block-end-width":"border-bottom-width","border-block-end-style":"border-bottom-style","border-block-end-color":"border-bottom-color","border-inline-start-width":"border-left-width","border-inline-start-style":"border-left-style","border-inline-start-color":"border-left-color","border-inline-end-width":"border-right-width","border-inline-end-style":"border-right-style","border-inline-end-color":"border-right-color","border-start-start-radius":"border-top-left-radius","border-start-end-radius":"border-top-right-radius","border-end-start-radius":"border-bottom-left-radius","border-end-end-radius":"border-bottom-right-radius","overflow-block":"overflow-y","overflow-inline":"overflow-x","overscroll-behavior-block":"overscroll-behavior-y","overscroll-behavior-inline":"overscroll-behavior-x","contain-intrinsic-block-size":"contain-intrinsic-height","contain-intrinsic-inline-size":"contain-intrinsic-width"}));Tc=.001;$c=new Set(["inline-block","inline-flex","inline-grid","inline-table","inline-flow-root","table"]);Nc=["top","right","bottom","left"]});function gt(t=1e3){return typeof requestAnimationFrame!="function"||typeof document<"u"&&document.visibilityState==="hidden"?Promise.resolve():new Promise(e=>{let n=!1,r=()=>{n||(n=!0,e())};try{requestAnimationFrame(r)}catch{r();return}setTimeout(r,t)})}function mi(t){if(t!==!1&&t!=="auto")return null;let e=performance.now()+(t==="auto"?Lc:hi),n=null,r={yielded:!1,due:()=>performance.now()>=e,pause:()=>n||(n=new Promise(i=>{let o=()=>{n=null,r.yielded=!0,e=performance.now()+hi,i()},s=new MessageChannel;s.port1.onmessage=o,s.port2.postMessage(0)}))};return r}function Ke(){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 X(){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"),r=/applewebkit/i.test(t),i=/mobile/i.test(t),o=!/safari/i.test(t),s=r&&i&&o,a=/(micromessenger|wxwork|wecom|windowswechat|macwechat)/i.test(t),c=/(baiduboxapp|baidubrowser|baidusearch|baiduboxlite)/i.test(e),f=/ipad|iphone|ipod/.test(e)&&r;return n||s||a||c||f}function $t(){return typeof navigator>"u"?!1:(navigator.userAgent||"").toLowerCase().includes("firefox")}var hi,Lc,yt=lt(()=>{"use strict";hi=16,Lc=40});function H(t,e,n){let r=t&&typeof t=="object"&&(t.options||t);r&&r.debug&&(n!==void 0?console.warn("[snapdom]",e,n):console.warn("[snapdom]",e))}function At(t,e,n,r){let i=t&&t.warnings;i&&i.length<Ic&&i.push(r===void 0?{code:e,message:n}:{code:e,message:n,detail:r})}var Ic,ne=lt(()=>{"use strict";Ic=50});var bt=lt(()=>{"use strict";ri();Ae();yt();kt();ne()});var ja={};we(ja,{MAX_RASTER_AREA:()=>ue,MAX_RASTER_SIDE:()=>Ut,cropSvgText:()=>pr,decodeSvgFromDataURL:()=>de,encodeSvgToDataURL:()=>pe,fixSafariShadows:()=>mr,peekSvgHeader:()=>hr,toCanvas:()=>zt});function ad(t,e){try{let n=t.match(/<svg\\b[^>]*>/i);if(!n)return t;let r=n[0],i=parseFloat((r.match(/\\bwidth="([\\d.]+)/i)||[])[1]),o=parseFloat((r.match(/\\bheight="([\\d.]+)/i)||[])[1]);if(!Number.isFinite(i)||!Number.isFinite(o)||i<=0||o<=0)return t;let s=Math.min(1,Ut/i,Ut/o,Math.sqrt(ue/(i*o)));if(s>=1)return t;let a=Math.max(1,Math.floor(i*s)),c=Math.max(1,Math.floor(o*s));return At(e,"raster-clamp",`capture ${Math.round(i)}x${Math.round(o)}px exceeds decode limits; downscaled to ${a}x${c}px`),console.warn(`[snapdom] Decode limit: ${Math.round(i)}\\xD7${Math.round(o)} \\u2192 ${a}\\xD7${c}. Use ${typeof CompressionStream=="function"?"PNG Blob, ":""}SVG or crop.`),t.replace(r,r.replace(/(\\bwidth=")[\\d.]+/i,`$1${a}`).replace(/(\\bheight=")[\\d.]+/i,`$1${c}`))}catch{return t}}function pr(t,e){let n=["x","y","width","height"].map(w=>Number(e?.[w]));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 r=t.match(/<svg\\b[^>]*>/i);if(!r)throw new Error("[snapdom] cannot crop a non-SVG capture");let i=r[0],o=(i.match(/\\bviewBox="([^"]+)"/i)||[])[1],s=String(o||"").trim().split(/[\\s,]+/).map(Number);if(s.length!==4||!s.every(Number.isFinite)||s[2]<=0||s[3]<=0)throw new Error("[snapdom] cannot crop an SVG without a finite viewBox");let[a,c,f,l]=s,u=Math.max(a,n[0]),p=Math.max(c,n[1]),h=Math.min(a+f,n[0]+n[2]),m=Math.min(c+l,n[1]+n[3]);if(!(h>u)||!(m>p))throw new RangeError("[snapdom] canvas crop does not intersect the SVG viewBox");let d=parseFloat((i.match(/\\bwidth="([\\d.]+)/i)||[])[1]),g=parseFloat((i.match(/\\bheight="([\\d.]+)/i)||[])[1]),y=Number.isFinite(d)&&d>0?d/f:1,b=Number.isFinite(g)&&g>0?g/l:1,S=Math.max(1,(h-u)*y),k=Math.max(1,(m-p)*b),v=i.replace(/(\\bwidth=")[^"]*/i,`$1${S}`).replace(/(\\bheight=")[^"]*/i,`$1${k}`).replace(/(\\bviewBox=")[^"]*/i,`$1${u} ${p} ${h-u} ${m-p}`);return t.replace(i,v)}function Oo(t){return typeof t=="string"&&/^data:image\\/svg\\+xml/i.test(t)}function de(t){let e=t.indexOf(",");return e>=0?decodeURIComponent(t.slice(e+1)):""}function hr(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 pe(t){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}function za(t){let e=[],n="",r=0;for(let i=0;i<t.length;i++){let o=t[i];o==="("&&r++,o===")"&&(r=Math.max(0,r-1)),o===";"&&r===0?(e.push(n),n=""):n+=o}return n.trim()&&e.push(n),e.map(i=>i.trim()).filter(Boolean)}function cd(t){let e=[],n="",r=0;for(let o=0;o<t.length;o++){let s=t[o];s==="("&&r++,s===")"&&(r=Math.max(0,r-1)),s===","&&r===0?(e.push(n.trim()),n=""):n+=s}n.trim()&&e.push(n.trim());let i=[];for(let o of e){if(/\\binset\\b/i.test(o))continue;let s=o.match(/-?\\d+(?:\\.\\d+)?px/gi)||[],[a="0px",c="0px",f="0px"]=s;f=`${parseFloat(f)/2}px`;let l=o.replace(/-?\\d+(?:\\.\\d+)?px/gi,"").replace(/\\binset\\b/ig,"").trim().replace(/\\s{2,}/g," "),u=!!l&&l!==",";i.push(`drop-shadow(${a} ${c} ${f}${u?` ${l}`:""})`)}return i.join(" ")}function Ha(t){let e=za(t),n=null,r=null,i=null,o=[];for(let a of e){let c=a.indexOf(":");if(c<0)continue;let f=a.slice(0,c).trim().toLowerCase(),l=a.slice(c+1).trim();f==="box-shadow"?i=l:f==="filter"?n=l:f==="-webkit-filter"?r=l:o.push([f,l])}if(i){let a=cd(i);a&&(n=n?`${n} ${a}`:a,r=r?`${r} ${a}`:a)}let s=[...o];return n&&s.push(["filter",n]),r&&s.push(["-webkit-filter",r]),s.map(([a,c])=>`${a}:${c}`).join(";")}function ld(t){return t.replace(/([^{}]+)\\{([^}]*)\\}/g,(e,n,r)=>`${n}{${Ha(r)}}`)}function fd(t){return t=t.replace(/<style[^>]*>([\\s\\S]*?)<\\/style>/gi,(e,n)=>e.replace(n,ld(n))),t=t.replace(/style=([\'"])([\\s\\S]*?)\\1/gi,(e,n,r)=>`style=${n}${Ha(r)}${n}`),t}function ud(){return fr||(fr=(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 r=n.getContext("2d",{willReadFrequently:!0});r.drawImage(e,0,0);let i=r.getImageData(2,18,1,1).data[3]>128,o=r.getImageData(2,2,1,1).data[3]>128;return{native:i||o,flippedY:o&&!i}}catch{return{native:!1,flippedY:!1}}})(),fr)}function dd(t){let e=[],n=0,r=0;for(let i=0;i<t.length;i++){let o=t[i];o==="("?n++:o===")"?n=Math.max(0,n-1):o===","&&n===0&&(e.push(t.slice(r,i)),r=i+1)}return e.push(t.slice(r)),e.map(i=>{let o=0,s=0,a="",c=0;for(;c<i.length;){let f=i[c];if(f==="("?o++:f===")"&&(o=Math.max(0,o-1)),o===0&&(c===0||i[c-1]===" ")){let l=/^-?\\d*\\.?\\d+px/.exec(i.slice(c));if(l){s++,a+=s===2?`${-parseFloat(l[0])}px`:l[0],c+=l[0].length;continue}}a+=f,c++}return a}).join(",")}function pd(t,e){let n=r=>za(r).map(i=>{let o=i.indexOf(":");if(o<0)return i;let s=i.slice(0,o).trim().toLowerCase();return s==="text-shadow"||e&&s==="box-shadow"?`${s}:${dd(i.slice(o+1))}`:i}).join(";");return t=t.replace(/<style[^>]*>([\\s\\S]*?)<\\/style>/gi,(r,i)=>r.replace(i,i.replace(/([^{}]+)\\{([^}]*)\\}/g,(o,s,a)=>`${s}{${n(a)}}`))),t=t.replace(/style=([\'"])([\\s\\S]*?)\\1/gi,(r,i,o)=>`style=${i}${n(o)}${i}`),t}async function mr(t){if(!/(?:box-shadow|text-shadow)\\s*:[^;"}]*px/i.test(t))return{svg:t,naturalOnly:!1};let{native:n,flippedY:r}=await ud();try{let i=t;return n||(i=fd(i)),r&&(i=pd(i,n)),{svg:i,naturalOnly:!0}}catch{return{svg:t,naturalOnly:!0}}}function hd(){let t=document.createElement("canvas");t.width=16,t.height=16;let e=t.getContext("2d",{willReadFrequently:!0});return e?n=>{e.clearRect(0,0,16,16),e.drawImage(n,0,0,16,16);let r=e.getImageData(0,0,16,16).data;for(let i=3;i<r.length;i+=4)if(r[i]>0)return!0;return!1}:null}async function md(t,e,n){tt(t),t.style.cssText="position:fixed;left:-99999px;top:-99999px;pointer-events:none",document.body.appendChild(t);try{if(!n)return await ur(),await ur(),!1;let r=performance.now()+(e?600:150);for(;;){let i;try{i=n(t)}catch{return!1}if(i)return!0;if(performance.now()>r)return!1;await ur()}}finally{try{t.remove()}catch{}}}function Da(t){if(typeof document>"u"||!document.body)return new Image;if(Et&&!Et.contentDocument){try{Et.remove()}catch{}Et=null}if(Et&&dr>gd&&pn===0){try{Et.remove()}catch{}Et=null}if(!Et){let n=document.createElement("iframe");tt(n),n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;left:-9999px;top:0;width:0;height:0;border:0;visibility:hidden;pointer-events:none";try{document.body.appendChild(n)}catch{}if(n.contentDocument)Et=n,dr=0;else{try{n.remove()}catch{}return new Image}}dr+=t.length,pn+=1;let e=Et.contentDocument.createElement("img");return e.__snapdomDecodeFrame=!0,e}function Bo(t,e=!1){!t||!t.__snapdomDecodeFrame||(t.__snapdomDecodeFrame=!1,pn=Math.max(0,pn-1),e&&(Do=!0),Do&&pn===0&&(Et?.remove(),Et=null,dr=0,Do=!1))}function Ba(t,e){return t.loading="eager",t.decoding="sync",t.crossOrigin="anonymous",t.src=e,t.decode()}function xd(t){if(typeof t!="string")return!1;let e=t.indexOf(",")+1,n=Math.max(48,Math.floor((t.length-e)/200)),r=0,i=0;for(let o=e;o+48<=t.length;o+=n){let s=t.slice(o,o+48);r++,Sd.some(a=>s.includes(a))||i++}return i*2>r}function Ua(t,e,n,r,i){if(!e.naturalWidth){t.drawImage(e,0,0,n,r);return}let o=n*r,s=o>yd&&!xd(i)?Math.min(wd,Math.ceil(o/bd)):1;if(s===1){t.drawImage(e,0,0,n,r);return}let a=e.naturalWidth,c=e.naturalHeight/r;for(let f=0;f<s;f++){let l=Math.round(f*r/s),u=f===s-1?r:Math.round((f+1)*r/s);t.drawImage(e,0,l*c,a,(u-l)*c,0,l,n,u-l)}}async function zt(t,e){let{width:n,height:r,scale:i=1,dpr:o=1,meta:s={},backgroundColor:a,crop:c=null}=e,f=typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?t:null,l=t,u=!1,p=!1;if(c&&!Oo(t))throw new RangeError("[snapdom] canvas crop requires an SVG capture payload");if(Oo(t)){let m=(hr(t).match(/<svg\\b[^>]*>/i)||[])[0]||"",d=parseFloat((m.match(/\\bwidth="([\\d.]+)/i)||[])[1]),g=parseFloat((m.match(/\\bheight="([\\d.]+)/i)||[])[1]),y=Number.isFinite(d)&&Number.isFinite(g)&&d>0&&g>0&&Math.min(1,Ut/d,Ut/g,Math.sqrt(ue/(d*g)))<1;if(c||y||X())try{let b=de(t);if(c&&(b=pr(b,c)),X()){let S=await mr(b);b=S.svg,u=S.naturalOnly,p=/@font-face|data:image\\//i.test(b)}(y||c)&&(b=ad(b,e.__session)),l=pe(b)}catch(b){if(c)throw b;l=t}}let h=f||Da(l);try{f||await Ba(h,l)}catch(m){if(!h.__snapdomDecodeFrame)throw m;let d=h;h=Da(l),Bo(d);try{await Ba(h,l)}catch(g){throw Bo(h,e.__releaseDecodeFrame),g}}try{!f&&!X()&&!$t()&&Oo(l)&&/(?:%40|@)font-face/i.test(l)&&await new Promise(T=>{let I=new MessageChannel;I.port1.onmessage=()=>{I.port1.close(),I.port2.close(),T()},I.port2.postMessage(0)});let m=X()&&!f?hd():null,d=!1;m&&(d=await md(h,p,m));let g=f?f.width:h.naturalWidth,y=f?f.height:h.naturalHeight,b=c?g:Number.isFinite(s.vbW)?s.vbW:Number.isFinite(s.w0)?s.w0:g,S=c?y:Number.isFinite(s.vbH)?s.vbH:Number.isFinite(s.h0)?s.h0:y,k,v,w=Number.isFinite(n),M=Number.isFinite(r);if(w&&M)k=Math.max(1,n),v=Math.max(1,r);else if(w){let T=n/Math.max(1,b);k=n,v=S*T}else if(M){let T=r/Math.max(1,S);v=r,k=b*T}else{let T=f&&Number.isFinite(s.vbW)&&Number.isFinite(s.vbH);k=T?s.vbW:g,v=T?s.vbH:y}!w&&!M&&(k=k*i,v=v*i);let A=k*o,C=v*o,x=Math.max(A/Ut,C/Ut,Math.sqrt(A*C/ue));x>1&&(At(e.__session,"canvas-clamp",`output ${Math.round(A)}x${Math.round(C)}px exceeds canvas limits; downscaled`),console.warn(`[snapdom] Canvas limit: reducing ${Math.round(A)}\\xD7${Math.round(C)}. Use ${typeof CompressionStream=="function"?"PNG Blob, ":""}SVG or crop.`),k/=x,v/=x);let _=Rt(e.canvas)&&st(e.canvas,"canvas")?e.canvas:document.createElement("canvas");_.width=Math.max(1,k*o),_.height=Math.max(1,v*o),_.style.width=`${k}px`,_.style.height=`${v}px`;let R=_.getContext("2d");if(!R)throw new Error("[snapdom] toCanvas: the target canvas has no 2d context");let $=()=>{if(o!==1&&R.scale(o,o),a&&(R.save(),R.fillStyle=a,R.fillRect(0,0,k,v),R.restore()),u&&(Math.round(k*o)!==g||Math.round(v*o)!==y)){let T=document.createElement("canvas");T.width=g,T.height=y,Ua(T.getContext("2d"),h,g,y,l),R.drawImage(T,0,0,k,v)}else R.save(),R.setTransform(1,0,0,1,0,0),Ua(R,h,k*o,v*o,l),R.restore()};if($(),m&&d&&p){let T=!0;try{T=m(h)}catch{}if(!T){let I=performance.now()+600;do{await ur();try{T=m(h)}catch{break}}while(!T&&performance.now()<I);_.width=_.width,$()}}return _}finally{Bo(h,e.__releaseDecodeFrame)}}var Ut,ue,fr,ur,gd,Et,dr,pn,Do,yd,bd,wd,Sd,he=lt(()=>{"use strict";yt();ne();kt();Ct();Ut=X()?16384:32767,ue=16384*16384;fr=null;ur=()=>new Promise(t=>{requestAnimationFrame(t),setTimeout(t,50)});gd=24*1024*1024,Et=null,dr=0,pn=0,Do=!1;yd=4e6,bd=2e6,wd=8,Sd=["%3C","%3E","%20","%7B","%7D","%3B"]});var hn={};we(hn,{rasterize:()=>Uo});async function Uo(t,e){let n=await zt(t,e),o=n.width*n.height<=2e6?n.toDataURL(`image/${e.format}`,e.quality):await new Promise(a=>{let c=()=>a(n.toDataURL(`image/${e.format}`,e.quality));try{n.toBlob(f=>{if(!f)return c();let l=new FileReader;l.onload=()=>a(String(l.result||"")),l.onerror=c,l.readAsDataURL(f)},`image/${e.format}`,e.quality)}catch{c()}}),s=new Image;return s.src=o,X()?await s.decode():await new Promise((a,c)=>{if(s.complete&&s.naturalWidth)return a();s.onload=a,s.onerror=c}),s.style.width=`${n.width/e.dpr}px`,s.style.height=`${n.height/e.dpr}px`,s}var je=lt(()=>{"use strict";he();yt()});var zo={};we(zo,{toImg:()=>vd,toSvg:()=>vd});async function vd(t,e){let{scale:n=1,width:r,height:i,meta:o={}}=e,s=Number.isFinite(r),a=Number.isFinite(i),c=Number.isFinite(n)&&n!==1||s||a;if(X()&&c)try{let{svg:p}=await mr(de(t)),h=(p.match(/<svg\\b[^>]*>/i)||[])[0]||"",m=parseFloat((h.match(/\\bwidth="([\\d.]+)/i)||[])[1]),d=parseFloat((h.match(/\\bheight="([\\d.]+)/i)||[])[1]);if(!Number.isFinite(m)||!Number.isFinite(d))throw new Error("svg without dimensions");let g=Number.isFinite(o.vbW)?o.vbW:Number.isFinite(o.w0)?o.w0:m,y=Number.isFinite(o.vbH)?o.vbH:Number.isFinite(o.h0)?o.h0:d,b,S;s&&a?(b=r,S=i):s?(b=r,S=Math.max(1,Math.round(y*(r/Math.max(1,g))))):a?(S=i,b=Math.max(1,Math.round(g*(i/Math.max(1,y))))):(b=Math.max(1,Math.round(m*n)),S=Math.max(1,Math.round(d*n)));let k=p.replace(/width="[^"]*"/,`width="${b}"`).replace(/height="[^"]*"/,`height="${S}"`),v=new Image;return v.decoding="sync",v.loading="eager",v.src=pe(k),await v.decode(),v.style.width=`${b}px`,v.style.height=`${S}px`,v}catch(p){return At(e.__session,"safari-png-fallback","Safari vector toImg failed; using PNG",p),H(e,"Safari vector toImg failed; using PNG",p),Uo(t,{...e,format:"png",quality:1,meta:o})}let f=t,l=!1;if(!s&&!a&&n!==1&&typeof t=="string"&&t.startsWith("data:image/svg+xml"))try{let p=de(t),h=(p.match(/<svg\\b[^>]*>/i)||[])[0]||"",m=Number((h.match(/\\bwidth="([\\d.]+)"/i)||[])[1]),d=Number((h.match(/\\bheight="([\\d.]+)"/i)||[])[1]);if(m>0&&d>0){let g=h.replace(/\\bwidth="[^"]*"/i,`width="${Math.max(1,Math.round(m*n))}"`).replace(/\\bheight="[^"]*"/i,`height="${Math.max(1,Math.round(d*n))}"`);f=pe(p.replace(h,g)),l=!0}}catch{}let u=new Image;u.decoding="sync",u.loading="eager",u.src=f;try{await u.decode()}catch(p){if(!l)throw p;u.src=t,l=!1,await u.decode()}if(s&&a)u.style.width=`${r}px`,u.style.height=`${i}px`;else if(s){let p=Number.isFinite(o.vbW)?o.vbW:Number.isFinite(o.w0)?o.w0:u.naturalWidth,h=Number.isFinite(o.vbH)?o.vbH:Number.isFinite(o.h0)?o.h0:u.naturalHeight,m=r/Math.max(1,p);u.style.width=`${r}px`,u.style.height=`${Math.max(1,Math.round(h*m))}px`}else if(a){let p=Number.isFinite(o.vbW)?o.vbW:Number.isFinite(o.w0)?o.w0:u.naturalWidth,h=Number.isFinite(o.vbH)?o.vbH:Number.isFinite(o.h0)?o.h0:u.naturalHeight,m=i/Math.max(1,h);u.style.height=`${i}px`,u.style.width=`${Math.max(1,Math.round(p*m))}px`}else{let p=Math.max(1,Math.round(u.naturalWidth*(l?1:n))),h=Math.max(1,Math.round(u.naturalHeight*(l?1:n)));if(u.style.width=`${p}px`,u.style.height=`${h}px`,!l&&n!==1&&typeof t=="string"&&t.startsWith("data:image/svg+xml"))try{let d=decodeURIComponent(t.split(",")[1]).replace(/width="[^"]*"/,`width="${p}"`).replace(/height="[^"]*"/,`height="${h}"`);u.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(d)}`,await u.decode()}catch(m){H(e,"toImg SVG sizing failed",m),u.src!==t&&(u.src=t,await u.decode().catch(()=>{}))}}return u}var Ho=lt(()=>{"use strict";bt();ne();je();he()});var qa={};we(qa,{encodePng:()=>kd});function gr(t,e=new Uint8Array(0)){let n=new Uint8Array(e.length+12),r=new DataView(n.buffer);r.setUint32(0,e.length);for(let o=0;o<4;o++)n[o+4]=t.charCodeAt(o);n.set(e,8);let i=4294967295;for(let o=4;o<n.length-4;o++)i=Va[(i^n[o])&255]^i>>>8;return r.setUint32(n.length-4,(i^4294967295)>>>0),n}async function kd(t,e,n){if(![t,e].every(d=>Number.isInteger(d)&&d>0&&d<=2147483647))throw new RangeError("[snapdom] PNG dimensions must be integers from 1 to 2147483647");let r=new Uint8Array(13),i=new DataView(r.buffer);i.setUint32(0,t),i.setUint32(4,e),r[8]=8,r[9]=6;let o=[new Uint8Array([137,80,78,71,13,10,26,10]),gr("IHDR",r),gr("sRGB",new Uint8Array([0]))],s=t*4,a=Math.max(1,Math.floor(65536/(s+1))),c=new Uint8Array(s),f=0,l=new CompressionStream("deflate"),u=l.writable.getWriter(),p=l.readable.getReader(),h,m=(async()=>{try{for(;;){let{done:d,value:g}=await p.read();if(d)return;o.push(gr("IDAT",g))}}catch(d){h=d,await u.abort(d).catch(()=>{})}})();try{for await(let d of n){if(!(d instanceof Uint8Array||d instanceof Uint8ClampedArray)||!d.length||d.length%s)throw new RangeError("[snapdom] PNG input must contain complete RGBA rows");let g=d.length/s;if(f+g>e)throw new RangeError("[snapdom] PNG input exceeds the declared height");for(let y=0;y<g;y+=a){let b=Math.min(g,y+a),S=new Uint8Array((b-y)*(s+1));for(let k=y;k<b;k++){let v=d.subarray(k*s,(k+1)*s),w=(k-y)*(s+1),M=0,A=0;for(let C=0;C<s;C++){let x=v[C]-(C<4?0:v[C-4])&255,_=v[C]-c[C]&255;M+=Math.min(x,256-x),A+=Math.min(_,256-_),S[w+C+1]=_}if(S[w]=A<=M?2:1,M<A)for(let C=0;C<s;C++)S[w+C+1]=v[C]-(C<4?0:v[C-4]);c=v}await u.write(S)}c=c.slice(),f+=g}if(f!==e)throw new RangeError("[snapdom] PNG input does not match the declared height");if(await u.close(),await m,h)throw h;return o.push(gr("IEND")),new Blob(o,{type:"image/png"})}catch(d){throw await Promise.allSettled([u.abort(d),p.cancel(d)]),await m,d}finally{u.releaseLock(),p.releaseLock()}}var Va,Ga=lt(()=>{"use strict";Va=new Uint32Array(256);for(let t=0;t<256;t++){let e=t;for(let n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;Va[t]=e}});function yr(t,e){if(typeof t!="string"||!t.startsWith("data:image/svg+xml"))return null;let n=hr(t).match(/<svg\\b[^>]*>/i)?.[0];if(!n)return null;let r=e.crop?pr(n,e.crop):n,i=parseFloat(r.match(/\\bwidth="([^"]+)/i)?.[1]),o=parseFloat(r.match(/\\bheight="([^"]+)/i)?.[1]),s=(r.match(/\\bviewBox="([^"]+)/i)?.[1]||"").trim().split(/[\\s,]+/).map(Number);if(!(i>0&&o>0)||s.length!==4||!s.every(Number.isFinite)||!(s[2]>0&&s[3]>0))return null;let a=Number.isFinite(e.width),c=Number.isFinite(e.height),f=e.meta||{},l=Math.max(1,Math.floor(i)),u=Math.max(1,Math.floor(o)),p=e.crop?l:Number.isFinite(f.vbW)?f.vbW:Number.isFinite(f.w0)?f.w0:l,h=e.crop?u:Number.isFinite(f.vbH)?f.vbH:Number.isFinite(f.h0)?f.h0:u,m=e.dpr??1,d=e.scale??1,g=(a&&c?Math.max(1,e.width):a?e.width:c?e.height*p/Math.max(1,h):l*d)*m,y=(a&&c?Math.max(1,e.height):c?e.height:a?e.width*h/Math.max(1,p):u*d)*m;if(Math.max(i,o,g,y)<=Ut&&i*o<=ue&&g*y<=ue||typeof CompressionStream!="function")return null;return b();async function b(){let{encodePng:S}=await Promise.resolve().then(()=>(Ga(),qa)),k=Math.max(1,Math.floor(g)),v=Math.max(1,Math.floor(y)),w=de(t),M=w.slice(w.indexOf(n)+n.length,w.lastIndexOf("</svg>")),A=r.match(/\\bpreserveAspectRatio="([^"]*)"/i)?.[1]||"xMidYMid meet",C=i/s[2],x=o/s[3],_=0,R=0;/\\bnone\\b/.test(A)||(C=x=/\\bslice\\b/.test(A)?Math.max(C,x):Math.min(C,x),_=(i-s[2]*C)*(/xMin/.test(A)?0:/xMax/.test(A)?1:.5),R=(o-s[3]*x)*(/YMin/.test(A)?0:/YMax/.test(A)?1:.5)),_-=s[0]*C,R-=s[1]*x;let $=r.replace(/\\s(?:width|height|preserveAspectRatio)="[^"]*"/gi,"").slice(0,-1),T=X()&&/(?:box-shadow|text-shadow)\\s*:[^;"}]*px/i.test(w),I=i/g,B=o/y,E=Math.max(1,Math.min(8192,Math.floor(4*1024*1024/k),T?Math.floor(2046/B):8192)),N=Math.max(1,Math.min(8192,k,T?Math.floor(2046/I):8192));async function*P(){for(let F=0;F<v;F+=E){let z=Math.min(E,v-F),V=new Uint8Array(k*z*4);for(let j=0;j<k;j+=N){let D=Math.min(N,k-j),K=T?Math.max(0,Math.floor(j*I)-1):j*I,ht=T?Math.max(0,Math.floor(F*B)-1):F*B,St=T?Math.min(l,Math.ceil((j+D)*I)+1)-K:D,ft=T?Math.min(u,Math.ceil((F+z)*B)+1)-ht:z,at=St/s[2],ct=ft/s[3],xt=T?1:1/I,U=T?1:1/B,G=`matrix(${C*xt/at},0,0,${x*U/ct},${(_-K)*xt/at+s[0]},${(R-ht)*U/ct+s[1]})`,q=`${$} width="${St}" height="${ft}" preserveAspectRatio="none"><g style="all:unset!important;transform:${G}!important;transform-origin:0 0!important">${M}</g></svg>`,nt=await zt(pe(q),{width:St,height:ft,dpr:1,backgroundColor:T?null:e.backgroundColor,__session:e.__session,__releaseDecodeFrame:!0}),rt=nt;try{if(T){rt=document.createElement("canvas"),rt.width=D,rt.height=z;let J=rt.getContext("2d");e.backgroundColor&&(J.fillStyle=e.backgroundColor,J.fillRect(0,0,D,z)),J.drawImage(nt,j*I-K,F*B-ht,D*I,z*B,0,0,D,z)}let me=rt.getContext("2d").getImageData(0,0,D,z).data;for(let J=0;J<z;J++)V.set(me.subarray(J*D*4,(J+1)*D*4),(J*k+j)*4)}finally{nt.width=nt.height=0,rt!==nt&&(rt.width=rt.height=0)}}yield V}}return S(k,v,P())}}var jo=lt(()=>{"use strict";he();yt()});var Xa={};we(Xa,{toBlob:()=>Vo});async function Vo(t,e){let n=e.format||e.type||"svg";if(n==="svg"){if(typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement)throw new Error("[snapdom] toBlob: engine:\'html-in-canvas\' produces a raster capture; ask for png/jpeg/webp");let o=decodeURIComponent(t.split(",")[1]);return new Blob([o],{type:"image/svg+xml"})}let r=n==="png"&&yr(t,e);if(r)return r;let i=await zt(t,e);return new Promise(o=>i.toBlob(s=>o(s),`image/${n==="jpg"?"jpeg":n}`,e.quality))}var qo=lt(()=>{"use strict";he();jo()});var Ka={};we(Ka,{download:()=>Cd});async function Ya(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(r){if(r.name!=="AbortError")return!1}return!0}async function Cd(t,e){let n=new Set(["png","jpeg","jpg","webp","svg"]),r=(e?.type||"").toLowerCase(),i=n.has(r)?r:"",o=(e?.format||i||"").toLowerCase(),s=o==="jpg"?"jpeg":o||"png",a=e?.filename||"snapdom",c=/\\.(png|jpe?g|webp|svg)$/i.test(a)?a:`${a}.${s}`,f={...e||{},format:s,type:s};f.dpr=1;let l=Ke(),u=s==="png"&&yr(t,f);if(s==="svg"||u){let m=u?await u:await Vo(t,{...f,type:"svg"});if(l&&await Ya(m,c))return;let d=URL.createObjectURL(m),g=document.createElement("a");g.href=d,g.download=c,document.body.appendChild(g),g.click(),setTimeout(()=>URL.revokeObjectURL(d),1e3),g.remove();return}let p=await zt(t,f);if(l){let m=`image/${s}`,d=await new Promise(g=>p.toBlob(g,m,e?.quality));if(d&&await Ya(d,c))return}let h=document.createElement("a");h.href=p.toDataURL(`image/${s}`,e?.quality),h.download=c,document.body.appendChild(h),h.click(),h.remove()}var Qa=lt(()=>{"use strict";qo();he();jo();yt()});bt();bt();yt();mt();bn();Ct();var re=new WeakMap,gi=["margin-top","margin-right","margin-bottom","margin-left","margin-block-start","margin-block-end","margin-inline-start","margin-inline-end"],Ir=new Map,Wc=2e3,_e=0;function Pt(){_e++}function Sn(t){let e=t&&(t.nodeType===1?t:t.parentElement);for(;e;){if(qt(e))return!0;if(e.parentElement)e=e.parentElement;else{let n=e.getRootNode?.();e=n&&n.host?n.host:null}}return!1}function vn(t){for(let e of t)if(ie(e))return!0;return!1}function ie(t){if(Sn(t.target))return!1;if(t.type==="childList"){let e=!0;for(let n of t.addedNodes)if(!Sn(n)){e=!1;break}if(e){for(let n of t.removedNodes)if(!Sn(n)){e=!1;break}}if(e)return!1}return!0}var Me=new WeakMap;function vi(t){for(let e of t){if(!ie(e))continue;let n=e.target.ownerDocument||document;Me.set(n,(Me.get(n)||0)+1);let r=e.target.nodeType===1?e.target:e.target.parentElement||e.target.host;for(;r;r=r.parentElement||r.getRootNode?.()?.host)Me.set(r,(Me.get(r)||0)+1)}}function tn(t){let e=t.ownerDocument||document;return Fe(e),(Me.get(e)||0)-(Me.get(t)||0)}var Ft=0;function Ee(t=document){return Fe(t),Ft}function Dt(){return Fe(),_e}function en(t){return t?(Fe(t.ownerDocument||document),kn(t,Hr(t))):0}function Re(){Pt(),Ft++}var oe=new WeakMap,Xt=0,Yt=0;function Oc(t){oe.set(t,++Xt)}function Ur(t){if(!t||t.nodeType!==1)return;Xt++,oe.set(t,Xt);let e=t.querySelectorAll("*");for(let n=0;n<e.length;n++)oe.set(e[n],Xt)}function zr(t){Ur(t.parentElement||t);for(let e=t.parentElement;e;e=e.parentElement)Oc(e)}function kn(t,e=null){let n=oe.get(t)||0;if(e)for(let r of e)n=Math.max(n,oe.get(r)||0);return Yt*1e9+n}function Hr(t){let e=t.getRootNode?.();if(!e?.host)return null;let n=[];for(;e?.host;)e.mode==="open"&&Vr(e),n.push(e.host),e=e.host.getRootNode?.();return n}var Wr=new WeakMap;function jr(t){t=t||document;let e=Wr.get(t);if(!e||e.env!==Ft){let n=!0;try{n=Kt(t).usesHas}catch{}e={env:Ft,usesHas:n},Wr.set(t,e)}return!e.usesHas}function Dc(t){let e=n=>n?.nodeType===1&&(n.matches?.("style,link")||n.querySelector?.("style,link"));for(let n of t){let r=n.target,i=r&&(r.nodeType===1?r:r.parentElement);if(i&&(i.tagName==="STYLE"||i.tagName==="LINK"))return i.ownerDocument||document;for(let o of n.addedNodes)if(e(o))return o.ownerDocument||document;for(let o of n.removedNodes)if(e(o))return o.ownerDocument||r&&r.ownerDocument||document}return null}var Or=new WeakSet,Qe=[];function ki(t){if(!vn(t))return;vi(t),Pt();let e=new Set;for(let n of t){if(!ie(n))continue;let r=n.target.getRootNode&&n.target.getRootNode();if(!r||r.nodeType!==11||e.has(r))continue;e.add(r),r.host?Ur(r.host):Xt++;let i=r.querySelectorAll("*");for(let o=0;o<i.length;o++)oe.set(i[o],Xt)}}function Vr(t){if(!(!t||Or.has(t))){Or.add(t);try{let e=new MutationObserver(ki);e.observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0}),Qe.push({o:e,root:t})}catch{}}}function Ci(t){if(!vn(t))return;vi(t),Pt();let e=Dc(t);if(e){Wr.delete(e),Ft++,Yt++;return}let n=new Set;for(let r of t){if(!ie(r))continue;let i=r.target.nodeType===1?r.target:r.target.parentElement;if(!i)continue;let o=i.ownerDocument||document;if(!jr(o)){Yt++;return}if(i===o.documentElement||i===o.body){Yt++;return}let s=i.parentElement||i;n.has(s)||(n.add(s),zr(i))}}var Dr=new WeakSet,Je=null,Ze=[];function Fe(t=document){if(t===Je||!t||t.nodeType!==9)return;if(Dr.has(t)){Je=t;return}Dr.add(t),Je=t;let e=t.defaultView,n=i=>{vn(i)&&(Pt(),Ft++)},r=()=>{Pt(),Ft++};try{let i=new MutationObserver(Ci);i.observe(t.documentElement,{subtree:!0,childList:!0,characterData:!0,attributes:!0}),Ze.push({o:i,env:!1,doc:t})}catch{}try{let i=new MutationObserver(n);i.observe(t.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0}),Ze.push({o:i,env:!0,doc:t})}catch{}try{e?.addEventListener("resize",r,{passive:!0})}catch{}try{let i=o=>{Pt();let s=o.composedPath?.()[0]||o.target;s&&s.nodeType===1&&!Sn(s)&&jr(s.ownerDocument||t)?zr(s):Yt++};t.addEventListener("focusin",i,{capture:!0,passive:!0}),t.addEventListener("focusout",i,{capture:!0,passive:!0}),t.addEventListener("change",i,{capture:!0,passive:!0}),t.addEventListener("pointerdown",i,{capture:!0,passive:!0}),t.addEventListener("pointerup",i,{capture:!0,passive:!0}),t.addEventListener("pointercancel",i,{capture:!0,passive:!0}),t.addEventListener("keydown",i,{capture:!0,passive:!0}),t.addEventListener("keyup",i,{capture:!0,passive:!0}),t.addEventListener("beforetoggle",i,{capture:!0,passive:!0}),t.addEventListener("toggle",i,{capture:!0,passive:!0}),e?.addEventListener("hashchange",()=>{Pt(),Yt++},{passive:!0})}catch{}try{let i=t.fonts;i&&(i.addEventListener?.("loadingdone",r),i.status==="loading"&&i.ready?.then(r).catch(()=>{}))}catch{}}var yi=new WeakMap;function bi(t,e){if(!t?.querySelectorAll)return;let n;try{n=Array.from(t.querySelectorAll(":hover"))}catch{return}let r=yi.get(t)||[];if(r.length===n.length&&r.every((o,s)=>o===n[s]))return;if(yi.set(t,n),Pt(),t.nodeType===11){t.host?Ur(t.host):Xt++;for(let o of t.querySelectorAll("*"))oe.set(o,Xt);return}let i=r.filter(o=>!n.includes(o)).concat(n.filter(o=>!r.includes(o)));for(let o of i)if(o.isConnected)if(jr(e))zr(o);else{Yt++;return}}function Cn(t,e=null){if(!t)return;bi(t,t);let n=e||Qe.filter(({root:r})=>r.host?.isConnected).map(({root:r})=>r);for(let r of n)bi(r,t)}function Tt(){Fe();try{for(let t=Ze.length-1;t>=0;t--){let{o:e,env:n,doc:r}=Ze[t];if(r!==document&&!r.defaultView){try{e.disconnect()}catch{}Dr.delete(r),Je===r&&(Je=null),Ze.splice(t,1);continue}let i=e.takeRecords();i.length&&(n?vn(i)&&(Pt(),Ft++):Ci(i))}for(let t=Qe.length-1;t>=0;t--){let{o:e,root:n}=Qe[t];if(!n.host||!n.host.isConnected){try{e.disconnect()}catch{}Or.delete(n),Qe.splice(t,1);continue}let r=e.takeRecords();r.length&&ki(r)}}catch{}}function se(t){if(!(!t||t.nodeType!==1)){re.delete(t);try{let e=(t.ownerDocument||document).createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;e.nextNode();)re.delete(e.currentNode)}catch{}}}var Bc=["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 qr(t){let e=re.get(t);if(e&&Gr(e,t)){let n=e.snapshot&&e.snapshot.__needsBgInline;if(n!==void 0)return n}return!0}function Ai(t){let e=re.get(t);if(!e||!Gr(e,t))return null;let n=e.snapshot;return!n||n.__bgClipTextFix?null:n}var wi=new WeakMap;function Kt(t){let e=wi.get(t);if(!e||e.epoch!==_e){let n=e&&e.universe;e={epoch:_e,...li(t)};let r=e.universe;if(n&&r&&n.size===r.size){let i=!0;for(let o of r)if(!n.has(o)){i=!1;break}i&&(e.universe=n)}wi.set(t,e)}return e}function Mi(t){try{let e=Kt(t.ownerDocument||document).shareGate;if(e===null)return!1;if(!e.length)return!0;let n=new Set,r=s=>{n.add("t"+s.localName),s.id&&n.add("i"+s.id);let a=s.classList;for(let c=0;c<a.length;c++)n.add("c"+a[c])};r(t);for(let s of t.querySelectorAll("*"))r(s);let i=[];for(let{sel:s,key:a}of e)(a===null||n.has(a))&&i.push(s);if(!i.length)return!0;let o=i.join(",");return!t.matches(o)&&t.querySelector(o)===null}catch{return!1}}function Uc(t){let e=t.ownerDocument||document;return t.getRootNode&&t.getRootNode()!==e?null:Kt(e).importantProps}function nn(t,e){let n=t.ownerDocument||document,r=t.getRootNode?t.getRootNode():n;return r===n?Kt(n).universe:e&&Wt(r)?zc(t,r,n,e):null}var Si=new WeakMap;function zc(t,e,n,r){let i=r.__shadowUniverse;if(i===null)return null;if(!i){let a=Kt(n).universe;if(!a)return r.__shadowUniverse=null;i=r.__shadowUniverse={universe:new Set(a),roots:new Set}}let o=a=>{for(;Wt(a)&&!i.roots.has(a);a=a.host.getRootNode()){i.roots.add(a);for(let c of[...a.styleSheets,...a.adoptedStyleSheets||[]]){let f=Si.get(c);if((!f||f.epoch!==_e)&&Si.set(c,f={epoch:_e,props:ai(c)}),!f.props)return!1;for(let l of f.props)i.universe.add(l)}Rr(a.getAnimations(),i.universe)}return!0},s=o(e)&&(!t.shadowRoot||o(t.shadowRoot));for(let a=t.assignedSlot;s&&a;a=a.assignedSlot)s=o(a.getRootNode());return s?i.universe:r.__shadowUniverse=null}function xn(t){let e=t.ownerDocument||document;return t.getRootNode&&t.getRootNode()!==e?null:Kt(e).pseudoUniverse}var Hc={before:null,after:null,firstLetter:null,marker:null,firstLine:null};function Te(t){let e=t.ownerDocument||document;return t.getRootNode&&t.getRootNode()!==e?Hc:Kt(e).pseudoGates}function jc(t,e={},n=null,r=null){let i={},o=e.excludeStyleProps,s=h=>{if(i[h]!==void 0||ve(h)||o&&(o instanceof RegExp&&o.test(h)||typeof o=="function"&&o(h)))return;let m=t.getPropertyValue(h);m&&((h==="background-image"||h==="content")&&m.includes("url(")&&!m.includes("data:")&&(m="none"),i[h]=m)};if(r){for(let m of r)s(m);let h=n&&n.style;if(h&&h.length)for(let m=0;m<h.length;m++)s(h[m])}else for(let h=0;h<t.length;h++)s(t[h]);let a=["text-decoration-line","text-decoration-color","text-decoration-style","text-decoration-thickness","text-underline-offset","text-decoration-skip-ink"];for(let h of a)if(!i[h])try{let m=t.getPropertyValue(h);m&&(i[h]=m)}catch{}let c=["-webkit-text-stroke","-webkit-text-stroke-width","-webkit-text-stroke-color","paint-order"];for(let h of c)if(!i[h])try{let m=t.getPropertyValue(h);m&&(i[h]=m)}catch{}if(e.embedFonts){let h=["font-feature-settings","font-variation-settings","font-kerning","font-variant","font-variant-ligatures","font-optical-sizing"];for(let m of h)if(!i[m])try{let d=t.getPropertyValue(m);d&&(i[m]=d)}catch{}}try{(i["content-visibility"]||t.getPropertyValue("content-visibility"))==="hidden"&&(i["content-visibility"]="hidden")}catch{}Object.defineProperty(i,"__needsBgInline",{value:_i(t),enumerable:!1});let f=parseFloat(t.getPropertyValue("border-top-width")||0)||0,l=parseFloat(t.getPropertyValue("border-right-width")||0)||0,u=parseFloat(t.getPropertyValue("border-bottom-width")||0)||0,p=parseFloat(t.getPropertyValue("border-left-width")||0)||0;if(f===0&&l===0&&u===0&&p===0){let h=(t.getPropertyValue("border-image-source")||"").trim(),m=h&&h!=="none",d=["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","border-block-start","border-block-start-width","border-block-start-style","border-block-start-color","border-block-end","border-block-end-width","border-block-end-style","border-block-end-color","border-inline-start","border-inline-start-width","border-inline-start-style","border-inline-start-color","border-inline-end","border-inline-end-width","border-inline-end-style","border-inline-end-color"];for(let g of d)delete i[g];m||(i.border="none")}return Vc(i),i}function Vc(t){if(!$t())return;let e=t["background-clip"]||t["-webkit-background-clip"];if(!e||!e.includes("text"))return;let n=o=>o==="transparent"||o==="rgba(0, 0, 0, 0)",r=t["-webkit-text-fill-color"];if(!n(r!==void 0?r:t.color))return;let i=qc(t["background-image"],t["background-color"]);i&&(n(t.color)&&(t.color=i),r!==void 0&&(t["-webkit-text-fill-color"]=i),t["background-image"]="none",t["background-color"]="transparent",delete t["background-clip"],delete t["-webkit-background-clip"],Object.defineProperty(t,"__bgClipTextFix",{value:i,enumerable:!1}))}function qc(t,e){let n=o=>{let s=[],a=/rgba?\\(\\s*(\\d+)[,\\s]+(\\d+)[,\\s]+(\\d+)(?:[,\\s/]+([\\d.]+%?))?\\s*\\)/g,c;for(;c=a.exec(o||"");){let f=c[4];(f===void 0?1:parseFloat(f)/(f.endsWith("%")?100:1))>.05&&s.push([+c[1],+c[2],+c[3]])}return s},r=n(t);if(r.length||(r=n(e)),!r.length)return null;let i=[0,0,0];for(let[o,s,a]of r)i[0]+=o,i[1]+=s,i[2]+=a;return`rgb(${i.map(o=>Math.round(o/r.length)).join(", ")})`}function _i(t){let e=t.getPropertyValue("background-image");if(e&&e!=="none")return!0;let n=t.getPropertyValue("background-color");if(n&&n!=="rgba(0, 0, 0, 0)"&&n!=="transparent")return!0;for(let i of Bc){let o=t.getPropertyValue(i);if(o&&o!=="none")return!0}let r=t.getPropertyValue("background");return!!(r&&/url\\s*\\(/i.test(r))}function Gc(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=O(e).position;if(n!=="absolute"&&n!=="fixed")return!0}}return!1}function Xc(t,e,n){try{if(typeof t.computedStyleMap=="function"){let i=t.computedStyleMap().get("width");if(i!=null)return!xi(String(i).trim().toLowerCase())}}catch{}let r=t.style&&(t.style.width||t.style.inlineSize);return r&&!xi(String(r).trim().toLowerCase())?!0:Kc(t,e)?n||Qc(t,e):!1}var Yc=new Set(["auto","min-content","max-content","stretch","fill-available","-webkit-fill-available"]);function xi(t){return Yc.has(t)||t.startsWith("fit-content")}function Kc(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 r=1/0,i=-1/0,o=null;for(let s=t.firstChild;s;s=s.nextSibling){let a;if(s.nodeType===3){if(!/\\S/.test(s.nodeValue||"")||(o=o||document.createRange(),o.selectNode(s),a=o.getBoundingClientRect(),!a.width&&!a.height))continue}else if(s.nodeType===1){let c=O(s);if(c.display==="none"||c.position==="absolute"||c.position==="fixed")continue;a=s.getBoundingClientRect()}else continue;a.left<r&&(r=a.left),a.right>i&&(i=a.right)}return i===-1/0?!1:i-r<n-.5}function Qc(t,e){let n=t.parentElement;if(!n)return!1;let r=O(n),i=n.getBoundingClientRect().width-(parseFloat(r.paddingLeft)||0)-(parseFloat(r.paddingRight)||0)-(parseFloat(r.borderLeftWidth)||0)-(parseFloat(r.borderRightWidth)||0)-(parseFloat(e.marginLeft)||0)-(parseFloat(e.marginRight)||0);return i>0?Math.abs(t.getBoundingClientRect().width-i)>.5:!1}var Br=new WeakMap;function Jc(t,e){let n=Br.get(t);if(n)return n;let r=[e];for(let i in t)r.push(i,t[i]);return n=r.join(""),Br.set(t,n),n}function Gr(t,e){return t.env===Ft&&t.stamp===kn(e,t.hosts)}var Zc=/^(width|height|inline-size|block-size|top|right|bottom|left|transform-origin|perspective-origin)$|^inset-/,tl=/(margin|padding)[a-z-]*\\s*:[^;]*(%|\\bauto\\b|calc\\(|var\\()/i,el=new Set(["INPUT","TEXTAREA","SELECT","OPTION","OPTGROUP","PROGRESS","METER","BUTTON","DATALIST"]);function nl(t){let e=t.__styleShare;return e||(e=t.__styleShare={ids:new WeakMap,intern:new Map,snaps:new Map,rootSeen:!1}),e}function rl(t,e){let n=e.ids.get(t);if(n!==void 0)return n;let r=t.parentElement,i;if(!r)i="R";else if(i=e.ids.get(r),i===void 0){if(e.rootSeen)return e.ids.set(t,-1),-1;i="R"}if(e.rootSeen=!0,i===-1)return e.ids.set(t,-1),-1;let o="",s=t.attributes;if(s&&s.length)if(s.length===1)o=s[0].name+"="+s[0].value;else{let c=[];for(let f=0;f<s.length;f++)c.push(s[f].name+"="+s[f].value);c.sort(),o=c.join("")}let a=i+"|"+t.tagName+"|"+o;return n=e.intern.get(a),n===void 0&&(n=e.intern.size,e.intern.set(a,n)),e.ids.set(t,n),n}function Ei(t,e){let n=t.snap,r=t.snap={...n};Object.defineProperty(r,"__needsBgInline",{value:n.__needsBgInline,enumerable:!1}),n.__bgClipTextFix!==void 0&&Object.defineProperty(r,"__bgClipTextFix",{value:n.__bgClipTextFix,enumerable:!1});let i=Kt(e.ownerDocument||document),o=e.getAttribute&&e.getAttribute("style")||"",s=o&&tl.test(o),a=!!i.marginUnstable||s&&/margin/i.test(o),c=!!i.paddingUnstable||s&&/padding/i.test(o),f=r.display!==void 0&&r.display.includes("grid"),l=r.transform!==void 0&&r.transform!=="none",u=[];for(let m in r)(Zc.test(m)||f&&(m==="grid-template-columns"||m==="grid-template-rows")||l&&m==="transform"||a&&m.charCodeAt(0)===109&&m.startsWith("margin-")||c&&m.charCodeAt(0)===112&&m.startsWith("padding-"))&&u.push(m);t.h&&!("height"in r)&&u.push("height"),t.b&&!("block-size"in r)&&u.push("block-size");let p=new Set(u),h=[e.tagName.toLowerCase()];for(let m in r)p.has(m)||h.push(m,r[m]);return t.rr=u,t.sig=h.join("")+""+u.join(""),u}function Ri(t,e,n,r,i){let o=i&&i.__styleShare?r&&r.__styleShare:null,s=o?o.ids.get(t):void 0;if(s===void 0||s===-1||t.shadowRoot||t.assignedSlot)return Ce(n,xn(t));let a=s+e,c=o.pseudo||(o.pseudo=new Map),f=c.get(a);if(f){let u={...f.snap},p=f.rr||Ei(f,t);for(let h=0;h<p.length;h++){let m=n.getPropertyValue(p[h]);m?u[p[h]]=m:delete u[p[h]]}return u}let l=Ce(n,xn(t));return c.set(a,{snap:l,rr:null,sig:null,h:"height"in l,b:"block-size"in l}),l}function ol(t,e=null,n={},r=null,i=null){let o=re.get(t),s=!!(n&&n.embedFonts),a=n&&n.excludeStyleProps||null;if(typeof a!="function"&&o&&Gr(o,t)&&o.embedFonts===s&&o.excludeStyleProps===a)return o.snapshot;let c=e||getComputedStyle(t),f,l=null,u=r&&r.st.snaps.get(r.id);if(u){f={...u.snap};let d=u.rr||Ei(u,t);l=[];for(let g=0;g<d.length;g++){let y=d[g],b=c.getPropertyValue(y);b?f[y]=b:delete f[y],l.push(b)}Object.defineProperty(f,"__needsBgInline",{value:u.snap.__needsBgInline,enumerable:!1}),u.snap.__bgClipTextFix!==void 0&&Object.defineProperty(f,"__bgClipTextFix",{value:u.snap.__bgClipTextFix,enumerable:!1})}else f=jc(c,n,t,nn(t,i)),r&&r.st.snaps.set(r.id,{snap:f,rr:null,sig:null,h:"height"in f,b:"block-size"in f});let p=!1;if(typeof t.computedStyleMap=="function"){let d;for(let g of gi)if(f[g]==="0px")try{d||(d=t.computedStyleMap()),d.get(g)?.toString()==="auto"&&(f[g]="auto",p=!0)}catch{}}bl(t,c,f);let h=ul(t,c,f);l!==null&&(p&&l.push("",...gi.map(d=>f[d])),h&&l.push(""+h),Br.set(f,u.sig+""+l.join("")+("height"in f?"":"")+("block-size"in f?"":"")));let m=Hr(t);return re.set(t,{env:Ft,stamp:kn(t,m),hosts:m,snapshot:f,embedFonts:s,excludeStyleProps:a}),f}function il(t,e){if(t&&t.session&&t.persist)return t;if(t&&(t.styleMap||t.styleCache||t.nodeMap)){let n=t.__ctx;return(!n||t.__ctxOpts!==e)&&(n={session:t,persist:{snapshotKeyCache:Ir,defaultStyle:L.defaultStyle,baseStyle:L.baseStyle,image:L.image,resource:L.resource,background:L.background},options:e||{}},t.__ctx=n,t.__ctxOpts=e),n}return{session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map},persist:{snapshotKeyCache:Ir,defaultStyle:L.defaultStyle,baseStyle:L.baseStyle,image:L.image,resource:L.resource,background:L.background},options:t||e||{}}}var sl=/%|[\\d.](?:em|rem|ex|ch|cap|ic|lh|rlh|v[whib]|vmin|vmax|cq[whbi]|cqmin|cqmax)\\b|\\b(?:calc|var|min|max|clamp|env|attr)\\(|\\b(?:auto|inherit|initial|unset|revert|currentcolor|-webkit-fill-available|fit-content|min-content|max-content)\\b/i,al=t=>t.tagName==="INPUT"||t.tagName==="TEXTAREA";function cl(t,e,n){if(!t.style||t.style.length===0)return;let r=Uc(t),i=r!=null&&!sl.test(t.getAttribute("style")||"");for(let o=0;o<t.style.length;o++){let s=t.style[o];if(i&&!r.has(s)&&!(s.startsWith("background")&&al(t)))continue;let a=n.getPropertyValue(s);a&&e.style.setProperty(s,a,t.style.getPropertyPriority(s))}}function pt(t,e,n,r){if(t.tagName==="STYLE")return;let i=il(n,r),o=i.options&&i.options.cache||"soft";o!=="disabled"&&Fe(t.ownerDocument),o==="disabled"&&!i.session.__bumpedForDisabled&&(Pt(),Ir.clear(),i.session.__bumpedForDisabled=!0);let{session:s,persist:a}=i;if(!s.styleCache.has(t)){let y=null;try{y=getComputedStyle(t)}catch{}s.styleCache.set(t,y||getComputedStyle((t.ownerDocument||document).documentElement))}let c=s.styleCache.get(t);t.getAttribute?.("style")&&cl(t,e,c);let f=c.getPropertyValue("animation-name");e&&e.style&&f&&f!=="none"&&e.style.setProperty("animation","none","important");let l=t.tagName?.toLowerCase()||"div";if(Xe.has(l)){let y={};Object.defineProperty(y,"__needsBgInline",{value:_i(c),enumerable:!1});let b=Hr(t);re.set(t,{env:Ft,stamp:kn(t,b),hosts:b,snapshot:y,embedFonts:!!(i.options&&i.options.embedFonts),excludeStyleProps:i.options&&i.options.excludeStyleProps||null}),s.styleMap.set(e,"");return}let u=null;if(i.options&&i.options.__styleShare&&s.styleMap){let y=nl(s),b=rl(t,y),S=t.ownerDocument||document,k=S.activeElement;b!==-1&&!el.has(t.tagName)&&!(k&&k!==S.body&&k!==S.documentElement&&k===t)&&(!t.getRootNode||t.getRootNode()===S)&&!t.shadowRoot&&!t.assignedSlot&&(u={st:y,id:b})}let p=ol(t,c,i.options,u,s);if(t.getAttribute?.("style"))for(let y of["top","right","bottom","left"]){let b=`margin-${y}`;p[b]==="auto"&&e.style.setProperty(b,"auto","important")}p.__bgClipTextFix&&e&&e.style&&(e.style.setProperty("background-image","none","important"),e.style.setProperty("background-color","transparent","important"),e.style.setProperty("color",p.__bgClipTextFix,"important"),e.style.setProperty("-webkit-text-fill-color",p.__bgClipTextFix,"important")),ll(t,c,p),e.style?.length&&p["box-sizing"]==="border-box"&&c.getPropertyValue("box-sizing")!=="border-box"&&hl(t,e,p);let h=Ti(t);if(h){let y=c.getPropertyValue("min-width");(!y||y==="auto"||y==="0px")&&(p["min-width"]="0px")}let m=Jc(p,l),d=!0;if(wn(l,(p.display||"").toLowerCase())){d=Gc(t),d&&Pr(l,p,h)&&Xc(t,c,h)&&(d=!1),m=`${m}${d?"|c":""}${h?"|f":""}`;let y=p["text-wrap-mode"]||p["white-space"]||"";d&&y!=="nowrap"&&y!=="pre"&&(s.reconcileRisk=(s.reconcileRisk||0)+1)}let g=a.snapshotKeyCache.get(m);g===void 0&&(g=ke(p,l,d,h),a.snapshotKeyCache.size>=Wc&&a.snapshotKeyCache.delete(a.snapshotKeyCache.keys().next().value),a.snapshotKeyCache.set(m,g)),s.styleMap.set(e,g)}function ll(t,e,n){let r=e.getPropertyValue("overflow-x"),i=e.getPropertyValue("overflow-y");if((r==="visible"||!r)&&(i==="visible"||!i)||e.getPropertyValue("box-sizing")==="border-box"||typeof t.clientWidth!="number"||!t.offsetWidth)return;let o=f=>parseFloat(f)||0,s=t.offsetWidth-t.clientWidth-o(e.getPropertyValue("border-left-width"))-o(e.getPropertyValue("border-right-width")),a=t.offsetHeight-t.clientHeight-o(e.getPropertyValue("border-top-width"))-o(e.getPropertyValue("border-bottom-width")),c=(f,l)=>{let u=n[f];if(!u||!u.endsWith("px"))return;let p=parseFloat(u);Number.isFinite(p)&&(n[f]=`${Math.round((p+l)*1e3)/1e3}px`)};s>=2&&(c("width",s),c("inline-size",s)),a>=2&&(c("height",a),c("block-size",a))}var fl=["border-top-width","border-right-width","border-bottom-width","border-left-width"],Fi=["width","inline-size","height","block-size"];function ul(t,e,n){if(!fl.some(c=>n[c]?.includes("."))||e.getPropertyValue("box-sizing")==="border-box"||n.display==="inline")return"";for(let c of["width","height"]){let f=n[`min-${c}`],l=n[`max-${c}`];if(f&&f!=="0px"&&f!=="auto"||l&&l!=="none")return""}let r=c=>parseFloat(n[c])||0,i=r("padding-left")+r("padding-right")+r("border-left-width")+r("border-right-width"),o=r("padding-top")+r("padding-bottom")+r("border-top-width")+r("border-bottom-width"),s=(n["writing-mode"]||"horizontal-tb")!=="horizontal-tb";for(let c of Fi){let f=n[c];if(!f||!f.endsWith("px"))continue;let u=c==="width"||c==="inline-size"&&!s||c==="block-size"&&s?i:o;n[c]=`${Math.round((parseFloat(f)+u)*1e3)/1e3}px`}n["box-sizing"]="border-box";let a="";if(e.getPropertyValue("overflow-x")==="auto"){let c=t.scrollWidth<=t.clientWidth;n["overflow-x"]=c?"hidden":"auto",c&&(a+="x")}if(e.getPropertyValue("overflow-y")==="auto"){let c=t.scrollHeight<=t.clientHeight;n["overflow-y"]=c?"hidden":"auto",c&&(a+="y")}return a}var dl=["box-sizing",...Fi,"overflow-x","overflow-y"],pl=/(?:box-sizing|width|height|inline-size|block-size|overflow(?:-[xy])?)\\s*:/i;function hl(t,e,n){if(pl.test(t.getAttribute("style")))for(let r of dl)e.style.getPropertyValue(r)&&n[r]&&e.style.setProperty(r,n[r],e.style.getPropertyPriority(r))}function ml(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 Ti(t){let e=t.parentElement;if(!e)return!1;let n=O(e).display||"";return n.includes("flex")||n.includes("grid")}function gl(t){for(let r=t.firstChild;r;r=r.nextSibling)if(r.nodeType===3&&/\\S/.test(r.nodeValue))return!0;let e=t.firstElementChild,n=t.lastElementChild;if(e&&e.tagName==="BR"||n&&n.tagName==="BR")return!0;for(let r=t.firstElementChild;r;r=r.nextElementSibling){let i=O(r);if(i.display==="none")continue;let o=i.position;if(o!=="absolute"&&o!=="fixed")return!0}return!1}function yl(t){let e=t.getBoundingClientRect().top,n=-1/0,r=null;for(let i=t.firstChild;i;i=i.nextSibling){if(i.nodeType===3){if(!/\\S/.test(i.nodeValue||""))continue;r=r||document.createRange(),r.selectNode(i);let a=r.getBoundingClientRect();(a.width||a.height)&&(n=Math.max(n,a.bottom));continue}if(i.nodeType!==1)continue;let o=O(i);if(o.display==="none")continue;let s=o.position;s==="absolute"||s==="fixed"||o.float&&o.float!=="none"||(n=Math.max(n,i.getBoundingClientRect().bottom))}return n===-1/0?NaN:n-e}function bl(t,e,n){if(Rt(t)&&t.style&&t.style.height)return;let r=t.tagName&&t.tagName.toLowerCase();if(!r||!["div","section","article","main","aside","header","footer","nav"].includes(r)||e.aspectRatio&&e.aspectRatio!=="none"&&e.aspectRatio!=="auto")return;let o=e.display||"";if(o.includes("flex")||o.includes("grid"))return;let s=e.position;if(s==="absolute"||s==="fixed"||s==="sticky"||e.transform!=="none"||ml(e)||Ti(t))return;let a=e.overflowX||e.overflow||"visible",c=e.overflowY||e.overflow||"visible";if(a!=="visible"||c!=="visible")return;let f=e.clip;if(f&&f!=="auto"&&f!=="rect(auto, auto, auto, auto)"||e.visibility==="hidden"||e.opacity==="0"||!gl(t))return;let l=parseFloat(e.height),u=yl(t);Number.isFinite(l)&&Number.isFinite(u)&&Math.abs(l-u)>2||(delete n.height,delete n["block-size"])}Ae();var wl=new Set(["symbol","defs","pattern","marker","linearGradient","radialGradient","filter"]),Xr=new WeakMap,$i=-1;function An(t){let e=Dt();return e!==$i&&(Xr=new WeakMap,$i=e),Pi(t)}function Pi(t){let e=Xr.get(t);if(e!==void 0)return e;let n;if(t.namespaceURI==="http://www.w3.org/2000/svg"&&(t.localName==="mask"||t.localName==="clipPath"?n=!1:wl.has(t.localName)&&(n=!0)),n===void 0){let r=t.parentNode;n=!!(r&&r.nodeType===1)&&Pi(r)}return Xr.set(t,n),n}function Ni(t,e){if(t?.nodeType!==1||e?.nodeType!==1||An(t))return;let n=t.getAttribute?.("style"),r=!!(n&&n.includes("var("));if(!r&&t.attributes?.length){let o=t.attributes;for(let s=0;s<o.length;s++){let a=o[s];if(a&&typeof a.value=="string"&&!a.value.startsWith("data:")&&a.value.includes("var(")){r=!0;break}}}let i=null;if(r)try{i=getComputedStyle(t)}catch{}if(r){let o=t.style;if(o&&o.length){let s=new Set;for(let a=0;a<o.length;a++){let c=o[a];if(s.has(c))continue;s.add(c);let f=o.getPropertyValue(c);if(!f||!f.includes("var("))continue;let l=i&&i.getPropertyValue(c);if(l)try{e.style.setProperty(c,l.trim(),o.getPropertyPriority(c))}catch{}}}}if(r&&t.attributes?.length){let o=t.attributes;for(let s=0;s<o.length;s++){let a=o[s];if(!a||typeof a.value!="string"||a.value.startsWith("data:")||!a.value.includes("var("))continue;let c=a.name,f=i&&i.getPropertyValue(c);if(f)try{e.style.setProperty(c,f.trim())}catch{}}}}bt();bt();mt();Se();bn();kt();function $e(t){return!!(!t||t.startsWith("data:")||t.startsWith("blob:"))}function Pe(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 r=[];for(let o of t.split(",")){let s=o.trim().split(/\\s+/);if(!s[0])continue;let a=s[1]||"",c=1;/^\\d*\\.?\\d+x$/i.test(a)?c=parseFloat(a):/^\\d+w$/i.test(a)&&(c=parseInt(a,10)/n),r.push({url:s[0],d:c})}if(!r.length)return null;r.sort((o,s)=>o.d-s.d);let i=window.devicePixelRatio||1;return(r.find(o=>o.d>=i)||r[r.length-1]).url}function Li(t,e){let n=t.currentSrc||"";if(n&&!$e(n))return n;let r=e.querySelectorAll("source[srcset]"),i=null;for(let o of r){let s=o.getAttribute("srcset");if(!s||$e(s))continue;let a=o.getAttribute("type");if(a&&!xr.test(a.trim()))continue;let c=o.getAttribute("media");if(c)try{if(window.matchMedia(c).matches)return Pe(s,t)}catch{}i||(i=Pe(s,t))}return i}function Ii(t){let e=[t.getAttribute("data-src"),t.getAttribute("data-lazy-src"),t.getAttribute("data-original"),t.getAttribute("data-hi-res-src")];for(let r of e)if(r&&!$e(r))return r;let n=t.getAttribute("data-srcset")||t.getAttribute("data-lazy-srcset");if(n){let r=n.split(",")[0].trim().split(/\\s+/)[0];if(r&&!$e(r))return r}return null}Ct();function Sl(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})`}var xl=/::[a-zA-Z-]+(?:\\([^)]*\\))?$|:(?:before|after|first-letter|first-line)$/,vl=/^::?(?:before|after|first-letter)$/;function kl(t,e,n=!0,r){return Fr(t,",").map(i=>i.trim()).filter(Boolean).map(i=>{if(i.startsWith(":where(")&&i.includes("data-sd")||i.startsWith("@"))return i;let o=i.match(xl);if(o&&vl.test(o[0]))return":not(*)";let s=o?i.slice(0,o.index).trim():i,a=n?Sl(s,r):s;return`:where(${e} ${a})${o?o[0]:""}`}).join(", ")}function Oi(t,e,n){return t?(t=t.replace(/:host-context\\(([^)]+)\\)/g,(r,i)=>`:where(:where(${i.trim()}) ${e})`),t=t.replace(/:host\\(([^)]+)\\)/g,(r,i)=>`:where(${e}:is(${i.trim()}))`),t=t.replace(/:host\\b/g,`:where(${e})`),t=t.replace(/::slotted\\(([^)]+)\\)/g,(r,i)=>`:where(${e} ${i.trim()})`),t=t.replace(/(^|})(\\s*)([^@}{]+){/g,(r,i,o,s)=>{let a=kl(s,e,!0,n);return`${i}${o}${a}{`}),t):""}function Di(t){return t.shadowScopeSeq=(t.shadowScopeSeq||0)+1,`s${t.shadowScopeSeq}`}function ae(t){let e="";for(let n of t)if(n.media&&n.cssRules){let r=!1;try{r=window.matchMedia(n.conditionText||n.media.mediaText).matches}catch{}r&&(e+=ae(n.cssRules))}else if(n.constructor?.name==="CSSSupportsRule")e+=`@supports ${n.conditionText}{${ae(n.cssRules)}}`;else if(n.cssRules&&n.cssRules.length&&/@media/i.test(n.cssText)){let r=n.cssText.slice(0,n.cssText.indexOf("{")+1);e+=r+(n.style?n.style.cssText:"")+ae(n.cssRules)+"}"}else e+=n.cssText+`\n`;return e}function Bi(t){let e="";try{t.querySelectorAll("style").forEach(r=>{let i=null;try{i=r.sheet&&r.sheet.cssRules}catch{}e+=(i?ae(i):r.textContent||"")+`\n`});let n=t.adoptedStyleSheets||[];for(let r of n)try{r&&r.cssRules&&(e+=ae(r.cssRules))}catch{}}catch{}return e}function Ui(t,e,n){if(!e)return;let r=document.createElement("style");r.setAttribute("data-sd",n),r.textContent=e,t.insertBefore(r,t.firstChild||null)}function zi(t,e,n={}){try{let r=null,i=O(t).content;if(i&&i.includes("url(")){let f=i.match(/url\\(["\']?([^"\')]+)["\']?\\)/);f&&(r=f[1])}let o=t.closest?.("picture"),s=t.getAttribute("src")||"",a=t.getAttribute("srcset")||"",c=r||(o?Li(t,o):!a.trim()&&s.startsWith("data:")?s:t.currentSrc)||Pe(a,t)||t.src||"";if((!c||$e(c))&&n.resolvePicturePlaceholders!==!1){let f=Ii(t);f&&(c=f)}if(!c)return;e.getAttribute("src")!==c&&e.setAttribute("src",c),e.removeAttribute("srcset"),e.removeAttribute("sizes"),e.loading="eager",e.decoding="sync"}catch{}}function Hi(t){let e=new Set;if(!t)return e;let n=/var\\(\\s*(--[A-Za-z0-9_-]+)\\b/g,r;for(;r=n.exec(t);)e.add(r[1]);return e}function Cl(t,e){try{let r=getComputedStyle(t).getPropertyValue(e).trim();if(r)return r}catch{}try{let r=getComputedStyle(document.documentElement).getPropertyValue(e).trim();if(r)return r}catch{}return""}function ji(t,e,n){let r=[];for(let i of e){let o=Cl(t,i);o&&r.push(`${i}: ${o};`)}return r.length?`${n}{${r.join("")}}\n`:""}function Vi(t,e){if(!t)return;let n=r=>{let i=r.getAttribute("data-sd-slotted")||"";e?` ${i} `.includes(` ${e} `)||r.setAttribute("data-sd-slotted",i?`${i} ${e}`:e):r.setAttribute("data-sd-slotted",i)};t.nodeType===Node.ELEMENT_NODE&&n(t),t.querySelectorAll?.("*").forEach(n)}async function Al(t,e=3){let n=()=>{try{return t.contentDocument||t.contentWindow?.document||null}catch{return null}},r=n(),i=0;for(;i<e&&(!r||!r.body&&!r.documentElement);)await new Promise(o=>setTimeout(o,0)),r=n(),i++;return r&&(r.body||r.documentElement)?r:null}function Ml(t){let e=t.getBoundingClientRect(),n=0,r=0,i=0,o=0;try{let c=getComputedStyle(t);n=parseFloat(c.borderLeftWidth)||0,r=parseFloat(c.borderRightWidth)||0,i=parseFloat(c.borderTopWidth)||0,o=parseFloat(c.borderBottomWidth)||0}catch{}let s=Math.max(0,Math.round(e.width-(n+r))),a=Math.max(0,Math.round(e.height-(i+o)));return{contentWidth:s,contentHeight:a,rect:e}}function wt(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 r=getComputedStyle(t);if(e===0){let i=parseFloat(r.width);!isNaN(i)&&i>0&&(e=i)}if(n===0){let i=parseFloat(r.height);!isNaN(i)&&i>0&&(n=i)}}catch{}if(e===0||n===0)try{if(e===0){let r=parseFloat(t.getAttribute("width"));!isNaN(r)&&r>0&&(e=r)}if(n===0){let r=parseFloat(t.getAttribute("height"));!isNaN(r)&&r>0&&(n=r)}}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 _l(t,e,n){let r=t.defaultView,i=r?r.scrollX:0,o=r?r.scrollY:0,s=t.body?t.body.scrollLeft:0,a=t.body?t.body.scrollTop:0,c=t.documentElement?t.documentElement.scrollLeft:0,f=t.documentElement?t.documentElement.scrollTop:0,l=0,u=0,p=0,h=0;try{let d=r&&t.body?r.getComputedStyle(t.body):null;d&&(l=(parseFloat(d.marginTop)||0)+(parseFloat(d.paddingTop)||0),u=(parseFloat(d.marginRight)||0)+(parseFloat(d.paddingRight)||0),p=(parseFloat(d.marginBottom)||0)+(parseFloat(d.paddingBottom)||0),h=(parseFloat(d.marginLeft)||0)+(parseFloat(d.paddingLeft)||0))}catch{}let m=t.createElement("style");if(m.setAttribute("data-sd-iframe-pin",""),tt(m),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 ${u}px ${p}px ${h}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),se(t.documentElement),i||o)try{t.body&&(t.body.scrollLeft=i,t.body.scrollTop=o),t.documentElement&&(t.documentElement.scrollLeft||(t.documentElement.scrollLeft=i),t.documentElement.scrollTop||(t.documentElement.scrollTop=o))}catch{}return()=>{try{m.remove()}catch{}try{r&&typeof r.scrollTo=="function"&&r.scrollTo(i,o),t.body&&(t.body.scrollLeft=s,t.body.scrollTop=a),t.documentElement&&(t.documentElement.scrollLeft=c,t.documentElement.scrollTop=f)}catch{}se(t.documentElement)}}async function Yr(t,e,n){let r=await Al(t,3);if(!r)throw new Error("iframe document not accessible/ready");let{contentWidth:i,contentHeight:o,rect:s}=Ml(t),a=n?.snap;if(!a||typeof a.toPng!="function")throw new Error("[snapdom] iframe capture requires the snapdom entrypoints on options.snap \\u2014 capture through snapdom(el) (set automatically) or pass options.snap.");let c={...n,scale:1,clip:null,__pinned:!0},f=_l(r,i,o),l;try{l=await a.toPng(r.documentElement,c)}finally{f()}l.style.display="block",l.style.width=`${i}px`,l.style.height=`${o}px`;let u=document.createElement("div");return e.nodeMap.set(u,t),pt(t,u,e,n),u.style.overflow="hidden",u.style.display="block",u.style.width||(u.style.width=`${Math.round(s.width)}px`),u.style.height||(u.style.height=`${Math.round(s.height)}px`),u.appendChild(l),u}function qi(t){try{let e=t&&t.accentColor;if(e&&e!=="auto"&&e!=="none")return e;let n=t&&t.color;if(n)return n}catch{}return"#0a6ed1"}function Gi(t){let{width:e,height:n}=wt(t),r=t.getBoundingClientRect(),i;try{i=window.getComputedStyle(t)}catch{}let o=i?parseFloat(i.width):NaN,s=i?parseFloat(i.height):NaN,a=Number.isFinite(o)&&o>0?o:e||r.width||128,c=Number.isFinite(s)&&s>0?s:n||r.height||16,f=Number.parseFloat(t.min)||0,l=Number.isFinite(Number.parseFloat(t.max))?Number.parseFloat(t.max):100,u=Number.parseFloat(t.value),p=l-f,h=p>0&&Number.isFinite(u)?Math.min(1,Math.max(0,(u-f)/p)):.5,m="middle";try{i&&i.verticalAlign&&(m=i.verticalAlign)}catch{}let d=document.createElement("div");d.setAttribute("data-snapdom-input-replacement","range"),d.style.cssText=`display:inline-block;width:${a}px;height:${c}px;vertical-align:${m};flex-shrink:0;line-height:0;`;let g=document.createElementNS("http://www.w3.org/2000/svg","svg");g.setAttribute("width",String(a)),g.setAttribute("height",String(c)),g.setAttribute("viewBox",`0 0 ${a} ${c}`),g.style.overflow="visible",d.appendChild(g);function y(){let b=qi(i),S=!!t.disabled,k=Math.max(2,Math.min(4,c)),v=(c-k)/2,w=Math.max(10,Math.min(14,Math.max(c,10))),M=w/2,A=M+h*Math.max(0,a-w);g.innerHTML="";let C=(_,R,$,T)=>{let I=document.createElementNS("http://www.w3.org/2000/svg","rect");I.setAttribute("x",String(_)),I.setAttribute("y",String(v)),I.setAttribute("width",String(Math.max(0,R))),I.setAttribute("height",String(k)),I.setAttribute("rx",String(k/2)),I.setAttribute("fill",$),T&&I.setAttribute("fill-opacity",T),g.appendChild(I)};C(0,a,"#808080","0.4"),C(0,A,b);let x=document.createElementNS("http://www.w3.org/2000/svg","circle");x.setAttribute("cx",String(A)),x.setAttribute("cy",String(c/2)),x.setAttribute("r",String(M)),x.setAttribute("fill",b),g.appendChild(x),S&&g.setAttribute("opacity","0.5"),d.style.setProperty("width",`${a}px`,"important"),d.style.setProperty("height",`${c}px`,"important"),d.style.setProperty("min-width",`${a}px`,"important"),d.style.setProperty("min-height",`${c}px`,"important")}return y(),{el:d,applyVisual:y}}function Xi(t){let{width:e,height:n}=wt(t),r=t.getBoundingClientRect(),i;try{i=window.getComputedStyle(t)}catch{}let o=i?parseFloat(i.width):NaN,s=i?parseFloat(i.height):NaN,a=Math.round(e||r.width||0),c=Math.round(n||r.height||0),f=Number.isFinite(o)&&o>0?Math.round(o):Math.max(12,a||16),l=Number.isFinite(s)&&s>0?Math.round(s):Math.max(12,c||16),u=(t.type||"text").toLowerCase()==="checkbox",p=!!t.checked,h=!!t.indeterminate,d=Math.max(Math.min(f,l),12),g="middle";try{i&&i.verticalAlign&&(g=i.verticalAlign)}catch{}let y=document.createElement("div");y.setAttribute("data-snapdom-input-replacement",t.type||"checkbox"),y.style.cssText=`display:inline-block;width:${d}px;height:${d}px;vertical-align:${g};flex-shrink:0;line-height:0;`;let b=document.createElementNS("http://www.w3.org/2000/svg","svg");b.setAttribute("width",String(d)),b.setAttribute("height",String(d)),b.setAttribute("viewBox",`0 0 ${d} ${d}`),y.appendChild(b);function S(){let k=qi(i),v=2,w=v/2,M=d-v;if(b.innerHTML="",u){let A=document.createElementNS("http://www.w3.org/2000/svg","rect");if(A.setAttribute("x",String(w)),A.setAttribute("y",String(w)),A.setAttribute("width",String(M)),A.setAttribute("height",String(M)),A.setAttribute("rx","2"),A.setAttribute("ry","2"),A.setAttribute("fill",p?k:"none"),A.setAttribute("stroke",k),A.setAttribute("stroke-width",String(v)),b.appendChild(A),p){let C=document.createElementNS("http://www.w3.org/2000/svg","path");C.setAttribute("d",`M ${w+2} ${d/2} L ${d/2-1} ${d-w-2} L ${d-w-2} ${w+2}`),C.setAttribute("stroke","white"),C.setAttribute("stroke-width",String(Math.max(1.5,v))),C.setAttribute("fill","none"),C.setAttribute("stroke-linecap","round"),C.setAttribute("stroke-linejoin","round"),b.appendChild(C)}else if(h){let C=document.createElementNS("http://www.w3.org/2000/svg","rect"),x=Math.max(6,M-4);C.setAttribute("x",String((d-x)/2)),C.setAttribute("y",String((d-v)/2)),C.setAttribute("width",String(x)),C.setAttribute("height",String(v)),C.setAttribute("fill",k),C.setAttribute("rx","1"),b.appendChild(C)}}else{let A=document.createElementNS("http://www.w3.org/2000/svg","circle");if(A.setAttribute("cx",String(d/2)),A.setAttribute("cy",String(d/2)),A.setAttribute("r",String((d-v)/2)),A.setAttribute("fill",p?k:"none"),A.setAttribute("stroke",k),A.setAttribute("stroke-width",String(v)),b.appendChild(A),p){let C=document.createElementNS("http://www.w3.org/2000/svg","circle"),x=Math.max(2,(d-v*2)*.35);C.setAttribute("cx",String(d/2)),C.setAttribute("cy",String(d/2)),C.setAttribute("r",String(x)),C.setAttribute("fill","white"),b.appendChild(C)}}y.style.setProperty("width",`${d}px`,"important"),y.style.setProperty("height",`${d}px`,"important"),y.style.setProperty("min-width",`${d}px`,"important"),y.style.setProperty("min-height",`${d}px`,"important")}return S(),{el:y,applyVisual:S}}var rn=new ut(80);async function El(t){if(L.resource?.has(t))return L.resource.get(t);if(rn.has(t))return rn.get(t);let e=(async()=>{let n=await dt(t,{as:"dataURL",silent:!0});if(!n.ok||typeof n.data!="string")throw new Error(`[snapDOM] Failed to read blob URL: ${t}`);return L.resource?.set(t,n.data),n.data})();rn.set(t,e);try{let n=await e;return rn.set(t,n),n}catch(n){throw rn.delete(t),n}}var Wi=/\\bblob:[^)"\'\\s]+/g;function Mn(t){return typeof t=="string"&&t.startsWith("blob:")}function Rl(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 Fl(t){return t.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(", ")}function on(t,e){let n=t.querySelectorAll?Array.from(t.querySelectorAll(e)):[];return t.matches?.(e)&&n.unshift(t),n}async function _n(t,e=null){if(!t)return;let n=e,r=new Set,i=[],o=new Map,s=(d,g,y,b)=>{r.add(y),i.push(()=>{o.has(y)&&(d.setAttribute(g,o.get(y)),b?.())})},a=(d,g)=>{if(!d||!d.includes("blob:"))return;let y=d.match(Wi)||[];if(y.length){for(let b of y)r.add(b);i.push(()=>{let b=d.replace(Wi,S=>o.get(S)||S);b!==d&&g(b)})}},c=on(t,"img");for(let d of c)try{let y=d.getAttribute("src")||d.currentSrc||"";Mn(y)&&s(d,"src",y);let b=d.getAttribute("srcset");if(b&&b.includes("blob:")){let S=Rl(b);for(let k of S)Mn(k.url)&&r.add(k.url);i.push(()=>{let k=!1;for(let v of S)o.has(v.url)&&(v.url=o.get(v.url),k=!0);k&&d.setAttribute("srcset",Fl(S))})}}catch(g){H(n,"resolveBlobUrls for img failed",g)}let f=on(t,"image");for(let d of f)try{let g="http://www.w3.org/1999/xlink",y=d.getAttribute("href")||d.getAttributeNS?.(g,"href");Mn(y)&&s(d,"href",y,()=>d.removeAttributeNS?.(g,"href"))}catch(g){H(n,"resolveBlobUrls for SVG image href failed",g)}let l=on(t,"[style*=\'blob:\']");for(let d of l)try{let g=d.getAttribute("style");a(g,y=>d.setAttribute("style",y))}catch(g){H(n,"replaceBlobUrls in inline style failed",g)}let u=on(t,"style");for(let d of u)try{let g=d.textContent||"";a(g,y=>{d.textContent=y})}catch(g){H(n,"replaceBlobUrls in style tag failed",g)}let p=["poster"];for(let d of p){let g=on(t,`[${d}^=\'blob:\']`);for(let y of g)try{let b=y.getAttribute(d);Mn(b)&&s(y,d,b)}catch(b){H(n,`resolveBlobUrls for ${d} failed`,b)}}if(!r.size)return;let h=[...r],m=0;await Promise.all(Array.from({length:Math.min(4,h.length)},async()=>{for(;m<h.length;){let d=h[m++];try{o.set(d,await El(d))}catch(g){H(n,"blobUrlToDataUrl failed; keeping original URL",g)}}}));for(let d of i)try{d()}catch(g){H(n,"resolved blob URL write failed",g)}}yt();var Yi=new Set(["rgba(0, 0, 0, 0)","transparent"]),Kr="Highlight";function Ki(t){let n=(t.ownerDocument||document).getSelection?.();if(!n||n.isCollapsed||n.rangeCount===0)return null;let r=[];for(let i=0;i<n.rangeCount;i+=1){let o=n.getRangeAt(i);if(!o.collapsed)try{o.intersectsNode(t)&&r.push(o)}catch{}}return r.length?{ranges:r,styles:new Map}:null}function Tl(t,e){if(e.styles.has(t))return e.styles.get(t);let n;try{let r=getComputedStyle(t);if(r.userSelect==="none"||r.webkitUserSelect==="none"||r.getPropertyValue("-webkit-user-select")==="none")return e.styles.set(t,null),null;let i=getComputedStyle(t,"::selection"),o=[],s=i.backgroundColor,a=s&&!Yi.has(s)&&s!==r.backgroundColor;o.push(`background-color:${a?s:Kr}`),i.color&&i.color!==r.color&&o.push(`color:${i.color}`,`-webkit-text-fill-color:${i.color}`),i.textShadow&&i.textShadow!==r.textShadow&&o.push(`text-shadow:${i.textShadow}`),i.textDecorationLine&&i.textDecorationLine!=="none"&&i.textDecorationLine!==r.textDecorationLine&&o.push(`text-decoration:${i.textDecorationLine} ${i.textDecorationStyle||"solid"} ${i.textDecorationColor||"currentcolor"}`),n=o.join(";")}catch{n=`background-color:${Kr}`}return e.styles.set(t,n),n}function Qi(t,e){let n=t.data;if(!n)return null;let r=t.parentElement;if(!r)return null;let i=[];for(let f of e.ranges){let l=!1;try{l=f.intersectsNode(t)}catch{}if(!l)continue;let u=f.startContainer===t?f.startOffset:0,p=f.endContainer===t?f.endOffset:n.length;p>u&&i.push([u,p])}if(i.length===0)return null;let o=Tl(r,e);if(!o)return null;i.sort((f,l)=>f[0]-l[0]);let s=t.ownerDocument||document,a=s.createDocumentFragment(),c=0;for(let[f,l]of i){f>c&&a.append(s.createTextNode(n.slice(c,f)));let u=s.createElement("span");u.setAttribute("data-snapdom-selection",""),u.setAttribute("style",`all:unset;${o}`),u.textContent=n.slice(f,l),a.append(u),c=l}return c<n.length&&a.append(s.createTextNode(n.slice(c))),a}var En=t=>Number.parseFloat(t)||0,$l=["font-family","font-size","font-weight","font-style","font-variant","font-stretch","letter-spacing","word-spacing","text-transform","text-indent","text-align","line-height","tab-size","direction"];function Pl(t,e){try{let r=getComputedStyle(t,"::selection").backgroundColor;if(r&&!Yi.has(r)&&r!==e.backgroundColor)return r}catch{}return Kr}function Ji(t,e){let n=t.ownerDocument||document;if(n.activeElement!==t)return;let r=null,i=null;try{r=t.selectionStart,i=t.selectionEnd}catch{return}if(r==null||i==null||r===i)return;let o=t.value||"";if(t.localName==="input"&&t.type==="password"&&(o="\\u2022".repeat(o.length)),!o)return;let s=getComputedStyle(t),a=t.localName==="textarea",c=En(s.paddingLeft),f=En(s.paddingTop),l=t.clientWidth-c-En(s.paddingRight),u=t.clientHeight-f-En(s.paddingBottom),p=n.createElement("div");p.style.cssText="position:absolute;top:0;left:-99999px;visibility:hidden;margin:0;border:0;padding:0;box-sizing:content-box;";for(let g of $l)p.style.setProperty(g,s.getPropertyValue(g));a?(p.style.whiteSpace="pre-wrap",p.style.overflowWrap="break-word",p.style.width=`${Math.max(0,l)}px`):p.style.whiteSpace="pre";let h=n.createElement("span");h.textContent=o.slice(r,i),p.append(n.createTextNode(o.slice(0,r)),h,n.createTextNode(o.slice(i))),n.body.appendChild(p);let m=[];try{let g=p.getBoundingClientRect(),y=-t.scrollLeft,b=-t.scrollTop;if(!a){b+=Math.max(0,(u-g.height)/2);let S=s.direction==="rtl",k=s.textAlign;k==="start"?k=S?"right":"left":k==="end"&&(k=S?"left":"right");let v=l-g.width;v>0&&(k==="right"?y+=v:k==="center"&&(y+=v/2))}for(let S of h.getClientRects())S.width<=0||S.height<=0||m.push({x:c+(S.left-g.left)+y,y:f+(S.top-g.top)+b,width:S.width,height:S.height})}finally{p.remove()}if(m.length===0)return;let d=Pl(t,s);e.__snapdomFieldSelection={images:m.map(()=>`linear-gradient(${d},${d})`),positions:m.map(g=>`${g.x}px ${g.y}px`),sizes:m.map(g=>`${g.width}px ${g.height}px`),repeats:m.map(()=>"no-repeat"),origins:m.map(()=>"padding-box"),clips:m.map(()=>"padding-box"),base:{image:s.backgroundImage,position:s.backgroundPosition,size:s.backgroundSize,repeat:s.backgroundRepeat,origin:s.backgroundOrigin,clip:s.backgroundClip}}}function Zi(t){for(let e of t.keys()){let n=e.__snapdomFieldSelection;if(!n)continue;delete e.__snapdomFieldSelection;let{images:r,positions:i,sizes:o,repeats:s,origins:a,clips:c,base:f}=n,l=e.style.backgroundImage||f.image;l&&l!=="none"?(r.push(l),i.push(e.style.backgroundPosition||f.position),o.push(e.style.backgroundSize||f.size),s.push(e.style.backgroundRepeat||f.repeat),a.push(e.style.backgroundOrigin||f.origin),c.push(e.style.backgroundClip||f.clip)):(r.push("linear-gradient(transparent,transparent)"),i.push("0% 0%"),o.push("auto"),s.push("repeat"),a.push(f.origin||"padding-box"),c.push(f.clip||"border-box")),e.style.backgroundImage=r.join(","),e.style.backgroundPosition=i.join(","),e.style.backgroundSize=o.join(","),e.style.backgroundRepeat=s.join(","),e.style.backgroundOrigin=a.join(","),e.style.backgroundClip=c.join(",")}}Ct();var Qr=new Map,ts=new Set(["IFRAME"]);function Ne(t,e){Qr.set(String(t).toUpperCase(),e)}function Rn(t){let e=O(t),n=e.display;if(n==="none")return null;let r=/^(block|inline-block|flow-root|flex|inline-flex|grid|inline-grid|list-item)$/.test(n),i=h=>parseFloat(h)||0,o=(h,m,d,g,y)=>{if(!r||!h?.endsWith("px"))return null;let b=parseFloat(h);if(!Number.isFinite(b)||b<0)return null;if(e.boxSizing==="border-box")return b;let S=g-y-d;return b+m+d+(S>0&&b+m<y+S/2?S:0)},[s,a,c,f]=/scroll|auto/.test(e.overflow)?[t.offsetWidth,t.clientWidth,t.offsetHeight,t.clientHeight]:[0,0,0,0],l=o(e.width,i(e.paddingLeft)+i(e.paddingRight),i(e.borderLeftWidth)+i(e.borderRightWidth),s,a),u=o(e.height,i(e.paddingTop)+i(e.paddingBottom),i(e.borderTopWidth)+i(e.borderBottomWidth),c,f);if(l===null||u===null){let{width:h,height:m}=wt(t),d=h,g=m;if(l===null&&!d||u===null&&!g){let y=t.getBoundingClientRect();d||(d=y.width||0),g||(g=y.height||0)}l??(l=d),u??(u=g)}let p=document.createElement("div");return p.style.cssText=`display:${n==="inline"?"inline-block":n};box-sizing:border-box;width:${l}px;height:${u}px;visibility:hidden;`,p}var Nl=new Set(["style","option","optgroup"]),Fn=200,Ll=new Set(["img","canvas","video","iframe","object","embed"]);function es(t,e){return t.right>=e.left-Fn&&t.left<=e.right+Fn&&t.bottom>=e.top-Fn&&t.top<=e.bottom+Fn}function Il(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 r=O(t);if(r.display==="inline"&&!Ll.has((t.localName||"").toLowerCase()))return!1;let i=e.rect,o=t.scrollWidth||0,s=t.scrollHeight||0,a={left:r.direction==="rtl"?Math.min(n.left,n.right-o):n.left,top:n.top,right:Math.max(n.right,n.left+o),bottom:Math.max(n.bottom,n.top+s)},c=r.writingMode||"";if((c.startsWith("vertical")||c.startsWith("sideways"))&&(a.top=Math.min(n.top,n.bottom-s),a.left=Math.min(a.left,n.right-o)),es(a,i))return!1;let f=(t.ownerDocument||document).createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(;f.nextNode();){let l=f.currentNode.getBoundingClientRect();if((l.width>0||l.height>0)&&es(l,i))return!1}return!0}function Wl(t,e,n){let r=t.cloneNode(!1);t.tagName==="IMG"&&(r.removeAttribute("src"),r.removeAttribute("srcset"),r.removeAttribute("sizes")),pt(t,r,e,n);let{width:i,height:o}=wt(t);i>0&&(r.style.width=`${i}px`,r.style.minWidth=`${i}px`,r.style.maxWidth=`${i}px`),o>0&&(r.style.height=`${o}px`,r.style.minHeight=`${o}px`,r.style.maxHeight=`${o}px`),r.style.visibility="hidden";let s=t.parentElement?O(t.parentElement).display:"",a=O(t).position;if(!/flex|grid|table/.test(s)&&(a==="static"||a==="relative")){let c=p=>{let h=O(p);return h.display!=="none"&&h.position!=="absolute"&&h.position!=="fixed"},f=t.getBoundingClientRect(),l=t.previousElementSibling;for(;l&&!c(l);)l=l.previousElementSibling;if(l){let p=f.top-l.getBoundingClientRect().bottom;p>=0&&(r.style.marginTop=`${p}px`)}let u=t.nextElementSibling;for(;u&&!c(u);)u=u.nextElementSibling;if(u){let p=u.getBoundingClientRect().top-f.bottom;p>=0&&(r.style.marginBottom=`${p}px`)}}return r.style.boxSizing="border-box",r}async function Qt(t,e,n){if(!t)throw new Error("Invalid node");e.slicer?.due()&&await e.slicer.pause();let r=new Set,i=null,o=null;if(t.nodeType===Node.ELEMENT_NODE){let l=(t.localName||t.tagName||"").toLowerCase(),u=qt(t);if(u&&(t.id==="snapdom-sandbox"||t.hasAttribute("data-snapdom-sandbox"))||t!==n.element&&u||Tr.has(l))return null;if(l==="foreignobject"&&t.parentElement?.closest?.("foreignObject"))return H(e,"Nested <foreignObject> unsupported; skipped"),null;if(l==="source"&&t.parentElement?.localName==="picture")return null}if(t.nodeType===Node.TEXT_NODE){if(e.selection){let l=Qi(t,e.selection);if(l)return l}return t.cloneNode(!0)}if(t.nodeType!==Node.ELEMENT_NODE)return t.cloneNode(!0);if(t.getAttribute("data-capture")==="exclude"){if(n.excludeMode==="hide")return Rn(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 Rn(t);if(n.excludeMode==="remove")return null}}catch(u){console.warn(`Invalid exclude selector: ${l}`,u)}if(n.excludePredicates)for(let l of n.excludePredicates)try{if(l(t))return n.excludeMode==="remove"?null:Rn(t)}catch(u){console.warn("Error in exclude predicate:",u)}if(typeof n.filter=="function")try{if(!n.filter(t)){if(n.filterMode==="hide")return Rn(t);if(n.filterMode==="remove")return null}}catch(l){console.warn("Error in filter function:",l)}if(t!==n.element&&!Nl.has(t.localName)&&!It(t)&&O(t).display==="none"){let l=t.cloneNode(!1);t.tagName==="IMG"&&(l.removeAttribute("src"),l.removeAttribute("srcset")),l.style.setProperty("display","none","important");for(let u of t.querySelectorAll("style")){let p=await Qt(u,e,n);p&&l.appendChild(p)}return l}if(e.clip&&Il(t,e.clip))return Wl(t,e,n);if(n.__resolveNodeHooks)for(let l of n.__resolveNodeHooks){let u;try{u=await l(t,n)}catch(p){H(e,"resolveNode plugin hook failed",p)}if(u===null)return null;if(u?.nodeType)return u.nodeType===Node.ELEMENT_NODE&&(e.nodeMap.set(u,t),pt(t,u,e,n)),u}{let l=ts.has(t.tagName)&&Qr.get(t.tagName);if(l){let u=await l(t,e,n);if(u!==void 0)return u}}if(t.getAttribute("data-capture")==="placeholder"){let l=t.cloneNode(!1);e.nodeMap.set(l,t),pt(t,l,e,n);let u=document.createElement("div");return u.textContent=t.getAttribute("data-placeholder-text")||"",u.style.cssText="color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;",l.appendChild(u),l}{let l=!ts.has(t.tagName)&&Qr.get(t.tagName);if(l){let u=await l(t,e,n);if(u!==void 0)return u}}let s;try{if(s=t.cloneNode(!1),Ni(t,s),e.nodeMap.set(s,t),t.tagName==="IMG"){zi(t,s,n);try{let l=window.getComputedStyle(t),u=parseFloat(l.width),p=parseFloat(l.height);if(!(u>0)||!(p>0)){let d=wt(t),g=b=>parseFloat(l.getPropertyValue(b))||0,y=l.getPropertyValue("box-sizing")==="border-box";u>0||(u=d.width-(y?0:g("padding-left")+g("padding-right")+g("border-left-width")+g("border-right-width"))),p>0||(p=d.height-(y?0:g("padding-top")+g("padding-bottom")+g("border-top-width")+g("border-bottom-width")))}let h=Math.round((u||0)*1e3)/1e3,m=Math.round((p||0)*1e3)/1e3;h&&(s.dataset.snapdomWidth=String(h)),m&&(s.dataset.snapdomHeight=String(m))}catch(l){H(e,"IMG measurement failed",l)}try{let l=t.getAttribute("style")||"",u=window.getComputedStyle(t),p=S=>{let k=l.match(new RegExp(`${S}\\\\s*:\\\\s*([^;]+)`,"i")),v=k?k[1].trim():u.getPropertyValue(S);return/%|auto/i.test(String(v||""))},h=parseFloat(s.dataset.snapdomWidth||"0")||0,m=parseFloat(s.dataset.snapdomHeight||"0")||0,d=p("width")||!(h>0),g=p("height")||!(m>0);d&&h>0&&(s.style.width=`${h}px`),g&&m>0&&(s.style.height=`${m}px`);let y=u.getPropertyValue("object-fit"),b=u.getPropertyValue("object-position");y&&y!=="fill"?(s.style.objectFit=y,b&&(s.style.objectPosition=b)):(h>0&&(s.style.minWidth=`${h}px`),m>0&&(s.style.minHeight=`${m}px`))}catch(l){H(e,"IMG dimension freeze failed",l)}}}catch(l){throw console.error("[Snapdom] Failed to clone node:",t,l),l}let a=null;if(st(t,"textarea")){let{width:l,height:u}=wt(t),p=l||t.getBoundingClientRect().width||0,h=u||t.getBoundingClientRect().height||0;p&&(s.style.width=`${p}px`),h&&(s.style.height=`${h}px`)}if(st(t,"input")){let l=(t.type||"text").toLowerCase();if((l==="checkbox"||l==="radio")&&($t()||t.indeterminate)){let{el:p,applyVisual:h}=Xi(t);e.nodeMap.set(p,t),a=h,s=p}else if(l==="range"&&($t()||X())){let{el:p,applyVisual:h}=Gi(t);e.nodeMap.set(p,t),a=h,s=p}else if(l==="color"&&X()){let p=s,h=t.value||"#000000";a=()=>{p.style.setProperty("background-color",h,"important"),p.style.setProperty("color","transparent","important"),p.style.setProperty("-webkit-text-fill-color","transparent","important"),p.style.setProperty("appearance","none","important"),p.style.setProperty("-webkit-appearance","none","important")},p.removeAttribute("value")}else if((l==="date"||l==="time"||l==="datetime-local")&&($t()||X())){s.setAttribute("type","text");let p=t.value;l==="date"&&t.valueAsDate&&(p=t.valueAsDate.toLocaleDateString(void 0,{timeZone:"UTC"})),s.value=p,s.setAttribute("value",p)}else{let p=Ge(t)?Cr(t.value):t.value;s.value=p,s.setAttribute("value",p),t.checked!==void 0&&(s.checked=t.checked,t.checked?s.setAttribute("checked",""):s.removeAttribute("checked"),t.indeterminate&&(s.indeterminate=t.indeterminate))}}if((st(t,"input")||st(t,"textarea"))&&!t.value&&t.placeholder)try{let l=window.getComputedStyle(t,"::placeholder"),u=l&&l.color;if(u&&u!=="rgba(0, 0, 0, 0)"){let p="snapdom-ph-"+(Math.random()*1e6|0);s.classList.add(p);let h=document.createElement("style");h.textContent=`.${p}::placeholder{color:${u}!important;opacity:${l.opacity||"1"}!important;-webkit-text-fill-color:${u}!important;}`,s.prepend(h)}}catch{}if(st(t,"select")&&(i=new Set(Array.from(t.options).filter(l=>l.selected))),st(t,"textarea")&&(o=t.value),st(t,"input")||st(t,"textarea")||st(t,"select")){t.disabled&&s.setAttribute("disabled",""),t.required&&s.setAttribute("required",""),t.readOnly&&s.setAttribute("readonly","");let l=t;l.min!==void 0&&l.min!==""&&s.setAttribute("min",l.min),l.max!==void 0&&l.max!==""&&s.setAttribute("max",l.max),l.pattern!==void 0&&l.pattern!==""&&s.setAttribute("pattern",l.pattern);let u=t.getAttribute("aria-invalid");u!==null&&s.setAttribute("aria-invalid",u)}if(An(t)||pt(t,s,e,n),a&&a(),n.captureSelection&&(st(t,"input")||st(t,"textarea")))try{Ji(t,s)}catch(l){H(e,"inlineTextFieldSelection failed",l)}if(It(t)&&!An(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","color"];try{let u=window.getComputedStyle(t);for(let p of l){let h=u.getPropertyValue(p);h&&s.style.setProperty(p,h)}}catch{}}if(t.shadowRoot){Vr(t.shadowRoot);try{let b=t.shadowRoot.querySelectorAll("slot");for(let S of b){let k=S.assignedNodes?.()||[];for(let v of k)r.add(v)}}catch{}let l=Di(e),u=`[data-sd="${l}"]`;e.shadowScopes||(e.shadowScopes=new WeakMap),e.shadowScopes.set(t.shadowRoot,l);try{s.setAttribute("data-sd",l)}catch{}let p=Bi(t.shadowRoot);!e.__shadowPseudo&&/::?(?:before|after|first-l|marker)|counter/.test(p)&&(e.__shadowPseudo=!0);let h=Oi(p,u,l),m=Hi(p),d=ji(t,m,u);Ui(s,d+h,l);let g=document.createDocumentFragment(),y=await Promise.all(Array.from(t.shadowRoot.childNodes).map(b=>b.nodeType===Node.ELEMENT_NODE&&b.tagName==="STYLE"?null:Qt(b,e,n).catch(()=>null)));g.append(...y.filter(b=>!!b)),s.appendChild(g)}if(t.tagName==="SLOT"){let l=e.shadowScopes?.get(t.getRootNode()),u=t.assignedNodes?.()||[],p=u.length?t.assignedNodes?.({flatten:!0})||u:[],h=p.length?p:Array.from(t.childNodes),m=document.createDocumentFragment(),d=await Promise.all(h.map(g=>Qt(g,e,n).then(y=>(y&&u.length&&Vi(y,l),y||null)).catch(()=>null)));return m.append(...d.filter(g=>!!g)),m}let c=l=>r.has(l)||t.shadowRoot&&!l.assignedSlot,f=await Promise.all(Array.from(t.childNodes).map(l=>c(l)?null:Qt(l,e,n).catch(()=>null)));if(s.append(...f.filter(l=>!!l)),i&&st(s,"select")){let l=!1;for(let u of s.options){let p=i.has(e.nodeMap.get(u));u.selected=p,p?u.setAttribute("selected",""):u.removeAttribute("selected"),l||(l=p)}if(!l&&!s.multiple){let u=s.ownerDocument.createElement("option");u.hidden=!0,u.style.setProperty("display","none","important"),u.setAttribute("selected",""),u.value="",s.appendChild(u)}}return o!==null&&st(s,"textarea")&&(s.textContent=o),s}async function Ol(t,e,n){let r=!1;try{r=!!(t.contentDocument||t.contentWindow?.document)}catch(i){H(e,"iframe same-origin probe failed",i)}if(r)try{return await Yr(t,e,n)}catch(i){console.warn("[SnapDOM] iframe rasterization failed, fallback:",i)}if(r||console.warn("[snapdom] Unreadable cross-origin <iframe>; keeping its box. Use { placeholders: false } to hide it.",t),n.placeholders){let{width:i,height:o}=wt(t),s=document.createElement("div");return s.style.cssText=`width:${i}px;height:${o}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;`,pt(t,s,e,n),s}else{let{width:i,height:o}=wt(t),s=document.createElement("div");return s.style.cssText=`display:inline-block;width:${i}px;height:${o}px;visibility:hidden;`,pt(t,s,e,n),s}}function sn(t){try{let e=Math.max(1,Math.min(32,t.width)),n=Math.max(1,Math.min(32,t.height)),r=document.createElement("canvas");r.width=e,r.height=n;let i=r.getContext("2d",{willReadFrequently:!0});if(!i)return!1;i.drawImage(t,0,0,e,n);let o=i.getImageData(0,0,e,n).data;for(let s=3;s<o.length;s+=4)if(o[s]!==0)return!1;return!0}catch{return!1}}var Dl=.95;function Bl(t,e,n){try{let r=t.getImageData(0,0,e,n).data;for(let i=3;i<r.length;i+=4)if(r[i]!==255)return!1;return!0}catch{return!1}}async function Ul(t,e,n){let r="";try{let a=sn(t);a&&(await gt(),a=sn(t));let c=null;if(!a){c=t.getContext("2d",{willReadFrequently:!0});try{c&&c.getImageData(0,0,1,1)}catch{}X()&&await gt()}if(r=t.toDataURL("image/png"),!r||r==="data:,"){try{c&&c.getImageData(0,0,1,1)}catch{}if(await gt(),r=t.toDataURL("image/png"),!r||r==="data:,"){let f=document.createElement("canvas");f.width=t.width,f.height=t.height;let l=f.getContext("2d");l&&(l.drawImage(t,0,0),r=f.toDataURL("image/png"))}}}catch(a){H(e,"Canvas toDataURL failed; using fallback",a)}n&&n.debug&&r&&sn(t)&&H(e,"Empty canvas; capture after its first frame",t);let i=document.createElement("img");try{i.decoding="sync",i.loading="eager"}catch(a){H(e,"img decoding/loading hints failed",a)}r&&(i.src=r),i.width=t.width,i.height=t.height;let{width:o,height:s}=wt(t);return o>0&&(i.style.width=`${o}px`),s>0&&(i.style.height=`${s}px`),e.nodeMap.set(i,t),pt(t,i,e,n),i}async function zl(t,e,n){let r="",i=t.poster&&t.paused&&!t.currentTime&&!t.played.length,o=document.createElement("img");try{o.decoding="sync",o.loading="eager"}catch{}if(!i)try{let c=document.createElement("canvas");c.width=t.videoWidth||t.offsetWidth||320,c.height=t.videoHeight||t.offsetHeight||240;let f=c.getContext("2d");f&&(f.drawImage(t,0,0,c.width,c.height),r=c.toDataURL(Bl(f,c.width,c.height)?"image/jpeg":"image/png",Dl),(!r||r==="data:,")&&(r=""))}catch(c){H(e,"Video capture failed; using poster",c)}r?o.src=r:t.poster&&(o.src=t.poster),o.width=t.videoWidth||t.offsetWidth||0,o.height=t.videoHeight||t.offsetHeight||0;let{width:s,height:a}=wt(t);return s>0&&(o.style.width=`${s}px`),a>0&&(o.style.height=`${a}px`),o.style.objectFit="contain",e.nodeMap.set(o,t),pt(t,o,e,n),o}async function Hl(t,e,n){if(!t.controls)return;let{width:r,height:i}=wt(t),o=Math.round(r||t.offsetWidth||300),s=Math.round(i||t.offsetHeight||54),a=s/2,c=Math.max(4,s*.16),f=s*.34,l=o-s*.34,u=f+c+s*.55,p=Math.max(0,l-s*.7-u),h=Math.max(9,Math.round(s*.24)),m=`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${s}" viewBox="0 0 ${o} ${s}"><rect width="${o}" height="${s}" rx="${Math.min(s/2,10)}" fill="#f1f3f4"/><path d="M ${f} ${a-c} L ${f+c} ${a} L ${f} ${a+c} Z" fill="#5f6368"/><rect x="${u}" y="${a-1.5}" width="${p}" height="3" rx="1.5" fill="#bdc1c6"/><circle cx="${u}" cy="${a}" r="${Math.max(3,s*.09)}" fill="#5f6368"/><text x="${l}" y="${a}" fill="#5f6368" font-family="sans-serif" font-size="${h}" text-anchor="end" dominant-baseline="central">0:00</text></svg>`,d=document.createElement("img");try{d.decoding="sync",d.loading="eager"}catch{}return d.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(m)}`,d.width=o,d.height=s,d.style.width=`${o}px`,d.style.height=`${s}px`,e.nodeMap.set(d,t),pt(t,d,e,n),d}async function ns(t,e,n){let r=t.getAttribute("data")||t.getAttribute("src")||"",i=(t.getAttribute("type")||"").toLowerCase(),o=/^image\\//.test(i)||/\\.(png|jpe?g|gif|webp|avif|bmp|ico|svg)(\\?|#|$)/i.test(r);if(r&&o){let a=document.createElement("img");try{a.decoding="sync",a.loading="eager"}catch{}a.src=r;let{width:c,height:f}=wt(t);return c>0&&(a.style.width=`${c}px`),f>0&&(a.style.height=`${f}px`),e.nodeMap.set(a,t),pt(t,a,e,n),a}let s=null;try{s=t.contentDocument}catch{}if(s)try{let a=await Yr(t,e,n);if(a)return a}catch{}r&&console.warn(`[snapdom] <${t.localName}> capture failed (${i||"unknown type"}); using fallback children`)}Ne("IFRAME",Ol);Ne("CANVAS",Ul);Ne("VIDEO",zl);Ne("AUDIO",Hl);Ne("OBJECT",ns);Ne("EMBED",ns);bt();kt();Ae();mt();Ct();var jl=[/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],Le=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__||{});function Vl(t){return t.replace(/[.*+?^${}()|[\\]\\\\]/g,"\\\\$&")}function rs(t){let e=Array.isArray(t)?t:t?[t]:[],n=[];for(let r of e)r instanceof RegExp?n.push(r):typeof r=="string"?n.push(new RegExp(Vl(r),"i")):console.warn("[snapdom] Ignored invalid iconFont value:",r);return n}function Nt(t,e){let n=typeof t=="string"?t:"";for(let r of jl)if(r.test(n))return!0;if(e){for(let r of e)if(r instanceof RegExp&&r.test(n))return!0}return!!(/icon/i.test(n)||/glyph/i.test(n)||/symbols/i.test(n)||/feather/i.test(n)||/fontawesome/i.test(n))}function Jr(t,e){if(typeof t!="string"||!t)return!1;let n;try{n=new URL(t,typeof location<"u"?location.href:void 0)}catch{return Nt(t,e)}let r=n.searchParams.getAll("family").flatMap(i=>i.split("|")).map(i=>i.split(":")[0].trim()).filter(Boolean);return r.length?r.every(i=>Nt(i,e)):Nt(t,e)}function ql(t=""){let e=String(t).toLowerCase();return/\\bmaterial\\s*icons\\b/.test(e)||/\\bmaterial\\s*symbols\\b/.test(e)}var Tn=new Map;function Gl(t=""){let e=Object.create(null),n=String(t||""),r=/[\'"]?\\s*([A-Za-z]{3,4})\\s*[\'"]?\\s*([+-]?\\d+(?:\\.\\d+)?)\\s*/g,i;for(;i=r.exec(n);)e[i[1].toUpperCase()]=Number(i[2]);return e}async function Xl(t,e,n){let r=String(t||""),i=r.toLowerCase(),o=String(e||"").toLowerCase();if(/\\bmaterial\\s*icons\\b/.test(i)&&!/\\bsymbols\\b/.test(i))return{familyForMeasure:r,familyForCanvas:r};if(!/\\bmaterial\\s*symbols\\b/.test(i))return{familyForMeasure:r,familyForCanvas:r};let a=n&&(n.FILL??n.fill),c="outlined";/\\brounded\\b/.test(o)||/\\bround\\b/.test(o)?c="rounded":/\\bsharp\\b/.test(o)?c="sharp":/\\boutlined\\b/.test(o)&&(c="outlined");let f=a===1,l=null;if(f&&(c==="outlined"&&Le.materialIconsFilled?l={url:Le.materialIconsFilled,alias:"snapdom-mi-filled"}:c==="rounded"&&Le.materialIconsRound?l={url:Le.materialIconsRound,alias:"snapdom-mi-round"}:c==="sharp"&&Le.materialIconsSharp&&(l={url:Le.materialIconsSharp,alias:"snapdom-mi-sharp"})),!l)return{familyForMeasure:r,familyForCanvas:r};if(!Tn.has(l.alias))try{let p=new FontFace(l.alias,`url(${l.url})`,{style:"normal",weight:"400"});await p.load(),document.fonts.add(p),Tn.set(l.alias,!0)}catch{return Tn.set(l.alias,!1),{familyForMeasure:r,familyForCanvas:r}}if(Tn.get(l.alias)===!1)return{familyForMeasure:r,familyForCanvas:r};let u=`"${l.alias}"`;return{familyForMeasure:u,familyForCanvas:u}}async function Yl(t="Material Icons",e=24){try{await Promise.all([document.fonts.load(`400 ${e}px "${String(t).replace(/["\']/g,"")}"`),document.fonts.ready])}catch{}}function Kl(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 r=t.color?.trim();return r&&r!=="inherit"?r:"#000"}async function Ql(t,{family:e="Material Icons",weight:n="normal",fontSize:r=32,color:i="#000",variation:o="",className:s=""}={}){let a=String(e||"").replace(/^[\'"]+|[\'"]+$/g,""),c=window.devicePixelRatio||1,f=Gl(o),{familyForMeasure:l,familyForCanvas:u}=await Xl(a,s,f);await Yl(u.replace(/^["\']+|["\']+$/g,""),r);let p=document.createElement("span");tt(p),p.textContent=t,p.style.position="absolute",p.style.visibility="hidden",p.style.left="-99999px",p.style.whiteSpace="nowrap",p.style.fontFamily=l,p.style.fontWeight=String(n||"normal"),p.style.fontSize=`${r}px`,p.style.lineHeight="1",p.style.margin="0",p.style.padding="0",p.style.fontFeatureSettings="\'liga\' 1",p.style.fontVariantLigatures="normal",p.style.color=i,document.body.appendChild(p);let h=p.getBoundingClientRect(),m=Math.max(1,Math.ceil(h.width)),d=Math.max(1,Math.ceil(h.height));document.body.removeChild(p);let g=document.createElement("canvas");g.width=m*c,g.height=d*c;let y=g.getContext("2d");y.scale(c,c),y.font=`${n?`${n} `:""}${r}px ${u}`,y.textAlign="left",y.textBaseline="top",y.fillStyle=i;try{y.fontKerning="normal"}catch{}return y.fillText(t,0,0),{dataUrl:g.toDataURL(),width:m,height:d}}async function $n(t,e,n=new Map){if(t?.nodeType!==1)return 0;let r=\'.material-icons, [class*="material-symbols"]\',i=Array.from(t.querySelectorAll(r)).filter(a=>a&&a.textContent&&a.textContent.trim());if(t.matches?.(r)&&t.textContent&&t.textContent.trim()&&i.unshift(t),i.length===0)return 0;let o=e?.nodeType===1?Array.from(e.querySelectorAll(r)).filter(a=>a&&a.textContent&&a.textContent.trim()):[];e?.nodeType===1&&e.matches?.(r)&&e.textContent&&e.textContent.trim()&&o.unshift(e);let s=0;for(let a=0;a<i.length;a++){let c=i[a],f=n&&n.get(c)||o[a]||null;try{let l=getComputedStyle(f||c),u=l.fontFamily||"Material Icons";if(!ql(u))continue;let p=(f||c).textContent.trim();if(!p)continue;let h=parseInt(l.fontSize,10)||24,m=l.fontWeight&&l.fontWeight!=="normal"?l.fontWeight:"normal",d=Kl(l),g=l.fontVariationSettings&&l.fontVariationSettings!=="normal"?l.fontVariationSettings:"",y=(f||c).className||"",{dataUrl:b,width:S,height:k}=await Ql(p,{family:u,weight:m,fontSize:h,color:d,variation:g,className:y});c.textContent="";let v=c.ownerDocument.createElement("img");v.src=b,v.alt=p,v.style.height=`${h}px`,v.style.width=`${Math.max(1,Math.round(S/k*h))}px`,v.style.objectFit="contain",v.style.verticalAlign=getComputedStyle(c).verticalAlign||"baseline",c.appendChild(v),s++}catch{}}return s}Se();yt();Ct();async function as(t,e,n,r=32,i="#000",o="normal"){e=e.replace(/^[\'"]+|[\'"]+$/g,"");let s=window.devicePixelRatio||1;try{await document.fonts.ready}catch{}let a=document.createElement("span");tt(a),a.textContent=t,a.style.position="absolute",a.style.visibility="hidden",a.style.fontFamily=`"${e}"`,a.style.fontWeight=n||"normal",a.style.fontStyle=o||"normal",a.style.fontSize=`${r}px`,a.style.lineHeight="1",a.style.whiteSpace="nowrap",a.style.padding="0",a.style.margin="0",document.body.appendChild(a);let c=a.getBoundingClientRect(),f=Math.ceil(c.width),l=Math.ceil(c.height);document.body.removeChild(a);let u=document.createElement("canvas");u.width=Math.max(1,f*s),u.height=Math.max(1,l*s);let p=u.getContext("2d");return p.scale(s,s),p.font=`${o||"normal"} ${n||"normal"} ${r}px "${e}"`,p.textAlign="left",p.textBaseline="top",p.fillStyle=i,p.fillText(t,0,0),{dataUrl:u.toDataURL(),width:f,height:l}}var cs=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","emoji","math","fangsong","ui-serif","ui-sans-serif","ui-monospace","ui-rounded"]),Jl=["katex","mathjax","mathml"];function eo(t){if(!t)return"";for(let e of t.split(",")){let n=e.trim().replace(/^[\'"]+|[\'"]+$/g,"");if(n&&!cs.has(n.toLowerCase()))return n}return""}function Zl(t){if(!t)return[];let e=[];for(let n of t.split(",")){let r=n.trim().replace(/^[\'"]+|[\'"]+$/g,"");r&&(cs.has(r.toLowerCase())||e.push(r))}return e}function Pn(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 Nn(t){let e=String(t??"normal").trim().toLowerCase();return e.startsWith("italic")?"italic":e.startsWith("oblique")?"oblique":"normal"}function tf(t){let e=String(t??"100%").match(/(\\d+(?:\\.\\d+)?)\\s*%/);return e?Math.max(50,Math.min(200,parseFloat(e[1]))):100}function ef(t){let e=String(t||"400").trim(),n=e.match(/^(\\d{2,3})\\s+(\\d{2,3})$/);if(n){let i=Pn(n[1]),o=Pn(n[2]);return{min:Math.min(i,o),max:Math.max(i,o)}}let r=Pn(e);return{min:r,max:r}}function nf(t){let e=String(t||"normal").trim().toLowerCase();return e==="italic"?{kind:"italic"}:e.startsWith("oblique")?{kind:"oblique"}:{kind:"normal"}}function rf(t){let e=String(t||"100%").trim(),n=e.match(/(\\d+(?:\\.\\d+)?)\\s*%\\s+(\\d+(?:\\.\\d+)?)\\s*%/);if(n){let o=parseFloat(n[1]),s=parseFloat(n[2]);return{min:Math.min(o,s),max:Math.max(o,s)}}let r=e.match(/(\\d+(?:\\.\\d+)?)\\s*%/),i=r?parseFloat(r[1]):100;return{min:i,max:i}}function of(t){return!t||typeof t!="string"?"":t.replace(/\\s+(variable|vf|v[0-9]+)$/i,"").trim().toLowerCase().replace(/\\s+/g,"-")}function sf(t,e,n=[]){if(!t)return!1;try{let r=new URL(t,location.href);if(r.origin===location.origin)return!0;let o=r.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=>o.endsWith(c))||n.some(c=>o===c.toLowerCase()||o.endsWith("."+c.toLowerCase())))return!0;let a=(r.pathname+r.search).toLowerCase();if(/\\bfont(s)?\\b/.test(a)||/\\.woff2?(\\b|$)/.test(a)||Jl.some(c=>a.includes(c)))return!0;for(let c of e){let f=c.toLowerCase().replace(/\\s+/g,"+"),l=c.toLowerCase().replace(/\\s+/g,"-"),u=of(c);if(a.includes(f)||a.includes(l)||u&&a.includes(u))return!0}return!1}catch{return!1}}function af(t){let e=new Set;for(let n of t||[]){let r=String(n).split("__")[0]?.trim();r&&e.add(r)}return e}function os(t,e){return t&&t.replace(/url\\(\\s*([\'"]?)([^)\'"]+)\\1\\s*\\)/g,(n,r,i)=>{let o=(i||"").trim();if(!o||/^data:|^blob:|^https?:|^file:|^about:/i.test(o))return n;let s=o;try{s=new URL(o,e||location.href).href}catch{}return`url("${s}")`})}var ls=/@import\\s+(?:url\\(\\s*([\'"]?)([^)"\']+)\\1\\s*\\)|([\'"])([^"\']+)\\3)([^;]*);/g,Ln=4;async function cf(t,e,n){if(!t)return t;let r=new Set;function i(a,c){try{return new URL(a,c||location.href).href}catch{return a}}async function o(a,c,f=0){if(f>Ln)return console.warn(`[snapDOM] @import depth exceeded (${Ln}) at ${c}`),a;let l="",u=0,p,h=new RegExp(ls.source,"g");for(;p=h.exec(a);){l+=a.slice(u,p.index),u=h.lastIndex;let m=(p[2]||p[4]||"").trim(),d=i(m,c);if(r.has(d)){console.warn(`[snapDOM] Skipping circular @import: ${d}`);continue}r.add(d);let g="";try{let y=await dt(d,{as:"text",useProxy:n,silent:!0});y.ok&&typeof y.data=="string"&&(g=y.data)}catch{}g?(g=os(g,d),g=await o(g,d,f+1),l+=`\n/* inlined: ${d} */\n${g}\n`):l+=p[0]}return l+=a.slice(u),l}let s=os(t,e||location.href);return s=await o(s,e||location.href,0),s}var fs=/url\\((["\']?)([^"\')]+)\\1\\)/g,lf=/@font-face[^{}]*\\{[^}]*\\}/g;function Mt(t,e,n=""){return(t.match(new RegExp(`${e}\\\\s*:\\\\s*([^;}]+)[;}]`,"i"))?.[1]||n).trim()}function us(t){if(!t)return[];let e=[],n=t.split(",").map(r=>r.trim()).filter(Boolean);for(let r of n){let i=r.match(/^U\\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!i)continue;let o=i[1],s=i[2],a=c=>{if(!c.includes("?"))return parseInt(c,16);let f=parseInt(c.replace(/\\?/g,"0"),16),l=parseInt(c.replace(/\\?/g,"F"),16);return[f,l]};if(s){let c=a(o),f=a(s),l=Array.isArray(c)?c[0]:c,u=Array.isArray(f)?f[1]:f;e.push([Math.min(l,u),Math.max(l,u)])}else{let c=a(o);Array.isArray(c)?e.push([c[0],c[1]]):e.push([c,c])}}return e}function ds(t,e){if(!e.length||!t||t.size===0)return!0;for(let n of t)for(let[r,i]of e)if(n>=r&&n<=i)return!0;return!1}function no(t,e){let n=[];if(!t)return n;for(let r of t.matchAll(fs)){let i=(r[2]||"").trim();if(!(!i||i.startsWith("data:"))){if(!/^https?:/i.test(i))try{i=new URL(i,e||location.href).href}catch{}n.push(i)}}return n}async function Zr(t,e,n=""){let r=t;for(let i of t.matchAll(fs)){let o=ee(i[0]);if(!o)continue;let s=o;if(!s.startsWith("http")&&!s.startsWith("data:"))try{s=new URL(s,e||location.href).href}catch{}if(L.resource?.has(s)){r=r.replace(i[0],`url(${L.resource.get(s)})`);continue}try{let a=await dt(s,{as:"dataURL",useProxy:n,silent:!0});if(a.ok&&typeof a.data=="string"){let c=a.data;L.resource?.set(s,c),r=r.replace(i[0],`url(${c})`)}}catch{console.warn("[snapDOM] Failed to fetch font resource:",s)}}return r}function ff(t){if(!t.length)return null;let e=(a,c)=>t.some(([f,l])=>!(l<a||f>c)),n=e(0,255)||e(305,305),r=e(256,591)||e(7680,7935),i=e(880,1023),o=e(1024,1279);return e(7840,7929)||e(258,259)||e(416,417)||e(431,432)?"vietnamese":o?"cyrillic":i?"greek":r?"latin-ext":n?"latin":null}function is(t={}){let e=new Set((t.families||[]).map(i=>String(i).toLowerCase())),n=new Set((t.domains||[]).map(i=>String(i).toLowerCase())),r=new Set((t.subsets||[]).map(i=>String(i).toLowerCase()));return(i,o)=>{if(e.size&&e.has(i.family.toLowerCase()))return!0;if(n.size)for(let s of i.srcUrls)try{if(n.has(new URL(s).host.toLowerCase()))return!0}catch{}if(r.size){let s=ff(o);if(s&&r.has(s))return!0}return!1}}function uf(t){if(!t)return t;let e=/@font-face[^{}]*\\{[^}]*\\}/gi,n=new Set,r=[];for(let o of t.match(e)||[]){let s=Mt(o,"font-family"),a=eo(s),c=Mt(o,"font-weight","400"),f=Mt(o,"font-style","normal"),l=Mt(o,"font-stretch","100%"),u=Mt(o,"unicode-range"),p=Mt(o,"src"),h=no(p,location.href),m=h.length?h.map(g=>String(g).toLowerCase()).sort().join("|"):p.toLowerCase(),d=[String(a||"").toLowerCase(),c,f,l,u.toLowerCase(),m].join("|");n.has(d)||(n.add(d),r.push(o))}if(r.length===0)return t;let i=0;return t.replace(e,()=>r[i++]||"")}var ss=new WeakMap,df=0;function pf(t){let e=ss.get(t);return e===void 0&&(e=df++,ss.set(t,e)),e}function hf(t,e,n,r,i,o,s,a,c){let f=Array.from(t||[]).sort().join("|"),l=0,u=0;for(let b of s||[]){let S=Math.imul(b,2654435761);S^=S>>>15,S=Math.imul(S,2246822507),S^=S>>>13,l=l+S|0,u++}let p=e?JSON.stringify({families:(e.families||[]).map(b=>String(b).toLowerCase()).sort(),domains:(e.domains||[]).map(b=>String(b).toLowerCase()).sort(),subsets:(e.subsets||[]).map(b=>String(b).toLowerCase()).sort()}):"",h=(n||[]).map(b=>`${(b.family||"").toLowerCase()}::${b.weight||"normal"}::${b.style||"normal"}::${b.stretchPct??100}::${b.src||""}`).sort().join("|"),m=r||"",d=(i||[]).map(b=>String(b).toLowerCase()).sort().join("|"),g=pf(o||document),y=(a||[]).map(b=>String(b)).sort().join("|");return`fonts-embed-css::req=${f}::ex=${p}::lf=${h}::px=${m}::fd=${d}::doc=${g}::cp=${l}::n=${u}::ic=${y}::env=${c}`}async function to(t,e,n,r){let i=r.doc?.defaultView||window;if(t.disabled||t.media?.mediaText&&!i.matchMedia(t.media.mediaText).matches)return;let o;try{o=t.cssRules||[]}catch{return}let s=(a,c)=>{try{return new URL(a,c||location.href).href}catch{return a}};for(let a of o){if(a.type===CSSRule.IMPORT_RULE&&a.styleSheet){let c=a.href?s(a.href,e):e;if(r.depth>=Ln){console.warn(`[snapDOM] CSSOM import depth exceeded (${Ln}) at ${c}`);continue}if(c&&r.visitedSheets.has(c)){console.warn(`[snapDOM] Skipping circular CSSOM import: ${c}`);continue}c&&r.visitedSheets.add(c);let f={...r,depth:(r.depth||0)+1};await to(a.styleSheet,c,n,f);continue}if(a.cssRules?.length){if(a.type===CSSRule.MEDIA_RULE&&!i.matchMedia(a.conditionText).matches||a.type===CSSRule.SUPPORTS_RULE&&!i.CSS.supports(a.conditionText))continue;await to(a,e,n,r);continue}if(a.type===CSSRule.FONT_FACE_RULE){let c=(a.style.getPropertyValue("font-family")||"").trim(),f=eo(c);if(!f||Nt(f,r.iconMatchers))continue;let l=(a.style.getPropertyValue("font-weight")||"").trim(),u=(a.style.getPropertyValue("font-style")||"").trim(),p=(a.style.getPropertyValue("font-stretch")||"").trim(),h=(a.style.getPropertyValue("font-variation-settings")||"").trim(),m=(a.style.getPropertyValue("src")||"").trim(),d=(a.style.getPropertyValue("unicode-range")||"").trim(),g=l||"400",y=u||"normal",b=p||"100%",S=(u?`font-style:${u};`:"")+(l?`font-weight:${l};`:"")+(p?`font-stretch:${p};`:"")+(h?`font-variation-settings:${h};`:"")+(d?`unicode-range:${d};`:""),k=r.faceMatchesRequired(f,y,g,b);if(!k&&!r.requiredIndex.has(f.toLowerCase()))continue;let v=us(d);if(!ds(r.usedCodepoints,v))continue;let w={family:f,weightSpec:g,styleSpec:y,stretchSpec:b,unicodeRange:d,srcRaw:m,srcUrls:no(m,e||location.href),href:e||location.href};if(r.simpleExcluder&&r.simpleExcluder(w,v))continue;if(!k){r.provisionalFaces.push({family:f.toLowerCase(),block:`@font-face{font-family:${f};src:${m};${S}}`,srcRaw:m,baseHref:e||location.href});continue}r.coveredFamilies.add(f.toLowerCase());let M=`"${String(f).replace(/^\\s*["\']|["\']\\s*$/g,"").replace(/(["\\\\])/g,"\\\\$1")}"`;if(/url\\(/i.test(m)){let A=await Zr(m,e||location.href,r.useProxy);await n(`@font-face{font-family:${M};src:${A};${S}}`)}else await n(`@font-face{font-family:${M};src:${m};${S}}`)}}}async function ps({required:t,usedCodepoints:e,exclude:n=void 0,localFonts:r=[],useProxy:i="",fontStylesheetDomains:o=[],iconMatchers:s=[],doc:a=document}={}){t instanceof Set||(t=new Set),e instanceof Set||(e=new Set);let c=new Map;for(let w of t){let[M,A,C,x]=String(w).split("__");if(!M)continue;let _=M.toLowerCase(),R=c.get(_)||[];R.push({w:parseInt(A,10),s:C,st:parseInt(x,10)}),c.set(_,R)}function f(w,M,A,C){let x=String(w).toLowerCase();if(!c.has(x))return!1;let _=c.get(x),R=ef(A),$=nf(M),T=rf(C),I=R.min!==R.max,B=R.min,E=P=>$.kind==="normal"&&P==="normal"||$.kind!=="normal"&&(P==="italic"||P==="oblique"),N=!1;for(let P of _){let F=I?P.w>=R.min&&P.w<=R.max:P.w===B,z=E(Nn(P.s)),V=P.st>=T.min&&P.st<=T.max;if(F&&z&&V){N=!0;break}}if(N)return!0;if(!I)for(let P of _){let F=E(Nn(P.s)),z=P.st>=T.min&&P.st<=T.max;if(Math.abs(B-P.w)<=300&&F&&z)return!0}if(!I&&$.kind==="normal"&&_.some(F=>Nn(F.s)!=="normal"))for(let F of _){let z=Math.abs(B-F.w)<=300,V=F.st>=T.min&&F.st<=T.max;if(z&&V)return!0}return!1}let l=is(n);Ee(a),Tt();let u=hf(t,n,r,i,o,a,e,s,Ee(a));if(L.resource?.has(u))return L.resource.get(u);let p=af(t),h=[],m=ls;for(let w of a.querySelectorAll("style")){let M=w.textContent||"";for(let A of M.matchAll(m)){let C=(A[2]||A[4]||"").trim();if(!C||Jr(C,s))continue;a.querySelector(`link[rel="stylesheet"][href="${C}"]`)||h.push(C)}}let d=[];h.length&&await Promise.all(h.map(w=>new Promise(M=>{if(a.querySelector(`link[rel="stylesheet"][href="${w}"]`))return M(null);let A=a.createElement("link");A.rel="stylesheet",A.href=w,tt(A),A.setAttribute("data-snapdom","injected-import");let C=setTimeout(()=>M(null),3e3),x=_=>{clearTimeout(C),M(_)};A.onload=()=>x(A),A.onerror=()=>x(null),a.head.appendChild(A),d.push(A)})));let g="",y=new Set,b=[],S=Array.from(a.querySelectorAll(\'link[rel="stylesheet"]\')).filter(w=>!!w.href);for(let w of d)try{w.remove()}catch{}for(let w of S)try{if(Jr(w.href,s))continue;let M="",A=!1;try{A=new URL(w.href,location.href).origin===location.origin}catch{}if(!A){let x=Array.isArray(o)?o:[];if(!sf(w.href,p,x))continue}if(A){let x=Array.from(a.styleSheets).find(_=>_.href===w.href);if(x)try{let _=x.cssRules||[];M=Array.from(_).map(R=>R.cssText).join("")}catch{}}if(!M){let x=await dt(w.href,{as:"text",useProxy:i});x?.ok&&typeof x.data=="string"&&(M=x.data)}M=await cf(M,w.href,i);let C="";for(let x of M.match(lf)||[]){let _=Mt(x,"font-family"),R=eo(_);if(!R||Nt(R,s))continue;let $=Mt(x,"font-weight","400"),T=Mt(x,"font-style","normal"),I=Mt(x,"font-stretch","100%"),B=Mt(x,"unicode-range"),E=Mt(x,"src"),N=no(E,w.href),P=f(R,T,$,I);if(!P&&!c.has(R.toLowerCase()))continue;let F=us(B);if(!ds(e,F))continue;let z={family:R,weightSpec:$,styleSpec:T,stretchSpec:I,unicodeRange:B,srcRaw:E,srcUrls:N,href:w.href};if(n&&l(z,F))continue;if(!P){b.push({family:R.toLowerCase(),block:x,srcRaw:E,baseHref:w.href});continue}y.add(R.toLowerCase());let V=/url\\(/i.test(E)?await Zr(x,w.href,i):x;C+=V}C.trim()&&(g+=C)}catch{console.warn("[snapDOM] Failed to process stylesheet:",w.href)}let k={doc:a,requiredIndex:c,usedCodepoints:e,faceMatchesRequired:f,coveredFamilies:y,provisionalFaces:b,simpleExcluder:n?is(n):null,useProxy:i,iconMatchers:s,visitedSheets:new Set,depth:0},v=new Set([...a.styleSheets,...a.adoptedStyleSheets||[]]);for(let w of v)if(!(w.href&&S.some(M=>M.href===w.href)))try{let M=w.href||a.baseURI||location.origin+"/";M&&k.visitedSheets.add(M),await to(w,M,async A=>{g+=A},k)}catch{}for(let w of b)y.has(w.family)||(g+=/url\\(/i.test(w.srcRaw)?await Zr(w.block,w.baseHref,i):w.block);try{for(let w of a.fonts||[]){if(!w||!w.family||w.status!=="loaded"||!w._snapdomSrc)continue;let M=String(w.family).replace(/^[\'"]+|[\'"]+$/g,"");if(Nt(M,s)||!c.has(M.toLowerCase())||n?.families&&n.families.some(C=>String(C).toLowerCase()===M.toLowerCase()))continue;let A=w._snapdomSrc;if(!String(A).startsWith("data:"))if(L.resource?.has(w._snapdomSrc))A=L.resource.get(w._snapdomSrc);else try{let C=await dt(w._snapdomSrc,{as:"dataURL",useProxy:i,silent:!0});if(C.ok&&typeof C.data=="string")A=C.data,L.resource?.set(w._snapdomSrc,A);else continue}catch{console.warn("[snapDOM] Failed to fetch dynamic font src:",w._snapdomSrc);continue}g+=`@font-face{font-family:\'${M}\';src:url(${A});font-style:${w.style||"normal"};font-weight:${w.weight||"normal"};}`}}catch{}for(let w of r){if(!w||typeof w!="object")continue;let M=String(w.family||"").replace(/^[\'"]+|[\'"]+$/g,"");if(!M||Nt(M,s)||!c.has(M.toLowerCase())||n?.families&&n.families.some($=>String($).toLowerCase()===M.toLowerCase()))continue;let A=w.weight!=null?String(w.weight):"normal",C=w.style!=null?String(w.style):"normal",x=w.stretchPct!=null?`${w.stretchPct}%`:"100%",_=String(w.src||""),R=_;if(!R.startsWith("data:"))if(L.resource?.has(_))R=L.resource.get(_);else try{let $=await dt(_,{as:"dataURL",useProxy:i,silent:!0});if($.ok&&typeof $.data=="string")R=$.data,L.resource?.set(_,R);else continue}catch{console.warn("[snapDOM] Failed to fetch localFonts src:",_);continue}g+=`@font-face{font-family:\'${M}\';src:url(${R});font-style:${C};font-weight:${A};font-stretch:${x};}`}return g&&(g=uf(g),L.resource?.set(u,g)),g}function In(t,e){let n=new Set,r=new Set;if(!t)return{required:n,usedCodepoints:r};let i=l=>{if(l)for(let u of l)r.add(u.codePointAt(0))},o=l=>{let u=Zl(l.fontFamily);if(u.length)for(let p of u)n.add(`${p}__${Pn(l.fontWeight)}__${Nn(l.fontStyle)}__${tf(l.fontStretch)}`)},s=Te(t),a=t.getRootNode(),c=l=>{o(O(l));let u=l.getRootNode()===a?s:Te(l);for(let p of["::before","::after"]){let h=p==="::before"?u.before:u.after;if(h!==null){if(h==="")continue;try{if(!l.matches(h))continue}catch{}}let m=O(l,p),d=m&&m.content;if(!(!d||d==="none"||d==="normal"))if(o(m),/^["\']/.test(d))i(d.slice(1,-1));else{let g=d.match(/\\\\[0-9A-Fa-f]{1,6}/g);if(g)for(let y of g)try{r.add(parseInt(y.slice(1),16))}catch{}}}},f=[t];for(let l=0;l<f.length;l++){let u=f[l];u.nodeType===Node.ELEMENT_NODE&&c(u),u.shadowRoot&&f.push(u.shadowRoot);let p=(t.ownerDocument||document).createTreeWalker(u,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;p.nextNode();){let h=p.currentNode;if(h.nodeType===Node.TEXT_NODE){if(e&&h.parentElement&&!e(h.parentElement))continue;i(h.nodeValue||"")}else{if(e&&!e(h))continue;c(h),h.shadowRoot&&f.push(h.shadowRoot)}}}return{required:n,usedCodepoints:r}}async function Wn(t,e=2,n=document){try{await n.fonts.ready}catch{}let r=Array.from(t||[]).filter(Boolean);if(r.length===0)return;let i=()=>{let o=n.createElement("div");tt(o),o.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;opacity:0!important;pointer-events:none!important;contain:layout size style;";for(let s of r){let a=n.createElement("span");a.textContent="AaBbGg1234\\xC1\\xC9\\xCD\\xD3\\xDA\\xE7\\xF1\\u2014\\u221E",a.style.fontFamily=`"${s}"`,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",o.appendChild(a)}n.body.appendChild(o),o.offsetWidth,n.body.removeChild(o)};for(let o=0;o<Math.max(1,e);o++)i(),await gt(),await gt()}kt();function ys(t){return/\\bcounter\\s*\\(|\\bcounters\\s*\\(/.test(t||"")}function hs(t,e=!1){let n="",r=Math.max(1,t);for(;r>0;)r--,n=String.fromCharCode(97+r%26)+n,r=Math.floor(r/26);return e?n.toUpperCase():n}function ms(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"]],r=Math.max(1,Math.min(3999,t)),i="";for(let[o,s]of n)for(;r>=o;)i+=s,r-=o;return e?i:i.toLowerCase()}function gs(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":case"lower-latin":return hs(t,!1);case"upper-alpha":case"upper-latin":return hs(t,!0);case"lower-roman":return ms(t,!1);case"upper-roman":return ms(t,!0);default:return String(t)}}function an(t,e){let n=(t||"").trim().split(/[\\s,]+/).filter(Boolean),r=[];for(let i=0;i<n.length;i++){let o=n[i];if(o==="none")continue;let s=n[i+1],a=s!==void 0&&Number.isFinite(Number(s));r.push([o,a?Number(s):e]),a&&i++}return r}function bs(t){let e=new WeakMap,n=Ar(t)?t.documentElement:t,r=f=>f&&f.tagName==="LI",i=new WeakMap,o=f=>{let l=new Map;for(let[u,p]of f)l.set(u,p.slice());return l},s=(f,l,u)=>{let p=o(f),h;try{h=getComputedStyle(u)}catch{h=u.style}let m;try{m=h?.counterReset}catch{}if(m&&m!=="none")for(let[y,b]of an(m,0)){let S=l.get(y);if(S&&S.length){let k=S.slice();k.push(b),p.set(y,k)}else p.set(y,[b])}let d;try{d=h?.counterSet}catch{}if(d&&d!=="none")for(let[y,b]of an(d,0)){let S=p.get(y)||[];S.length===0&&S.push(0),S[S.length-1]=b,p.set(y,S)}let g;try{g=h?.counterIncrement}catch{}if(g&&g!=="none")for(let[y,b]of an(g,1)){let S=p.get(y)||[];S.length===0&&S.push(0),S[S.length-1]+=b,p.set(y,S)}try{if(h?.display==="list-item"&&r(u)){let y=u.parentElement,b=y&&i.get(y),S=y?.tagName==="OL"?parseInt(y.getAttribute("start"),10):NaN,k=b===void 0?Number.isFinite(S)?S:1:b+1,v=y?.tagName==="OL"?parseInt(u.getAttribute("value"),10):NaN;Number.isFinite(v)&&(k=v),y&&i.set(y,k);let w=p.get("list-item")||[];w.length===0&&w.push(0),w[w.length-1]=k,p.set("list-item",w)}}catch{}return p},a=(f,l,u)=>{let p=s(u,l,f);e.set(f,p);let h=p;for(let d of f.children)h=a(d,p,h);let m=new Map;for(let[d,g]of u){let y=g.length,b=h.get(d);m.set(d,b&&b.length?b.slice(0,y):g.slice())}for(let[d,g]of h)!m.has(d)&&g.length&&!l.has(d)&&m.set(d,g.slice(0,1));return m},c=new Map;return a(n,c,c),{get(f,l){let u=e.get(f)?.get(l);return u&&u.length?u[u.length-1]:0},getStack(f,l){let u=e.get(f)?.get(l);return u?u.slice():[]}}}function ws(t,e,n){if(!t||t==="none")return t;try{let r=/\\b(counter|counters)\\s*\\(([^)]+)\\)/g;return t.replace(r,(i,o,s)=>{let a=String(s).split(",").map(c=>c.trim());if(o==="counter"){let c=a[0]?.replace(/^["\']|["\']$/g,""),f=(a[1]||"decimal").toLowerCase(),l=n.get(e,c);return gs(l,f)}else{let c=a[0]?.replace(/^["\']|["\']$/g,""),f=a[1]?.replace(/^["\']|["\']$/g,"")??"",l=(a[2]||"decimal").toLowerCase(),u=n.getStack(e,c);return u.length?u.map(h=>gs(h,l)).join(f):""}})}catch{return"- "}}Se();var Ie=new WeakMap,Ss=1e3;function mf(t,e){let n=Cs(t);return e?(e.__pseudoPreflightFp!==n&&(Tt(),e.__pseudoPreflight=xs(t,n),e.__pseudoPreflightFp=n),!!e.__pseudoPreflight):(Tt(),xs(t,n))}function On(t){try{return t&&t.cssRules?t.cssRules:null}catch{return null}}function Cs(t){let e=t.querySelectorAll(\'style,link[rel~="stylesheet"]\'),n=`n:${e.length}|`,r=0;for(let s=0;s<e.length;s++){let a=e[s];if(a.tagName==="STYLE"){let c=a.textContent?a.textContent.length:0;n+=`S${c}|`;let f=a.sheet,l=f?On(f):null;l&&(r+=l.length)}else{let c=a.getAttribute("href")||"",f=a.getAttribute("media")||"all";n+=`L${c}|m:${f}|`;let l=a.sheet,u=l?On(l):null;u&&(r+=u.length)}}let i=t.adoptedStyleSheets,o=0;if(Array.isArray(i))for(let s of i){let a=On(s);a&&(o+=a.length)}return n+=`ass:${Array.isArray(i)?i.length:0}/${o}|tr:${r}`,n}function ro(t,e,n){let r=On(t);if(!r)return!1;for(let i=0;i<r.length;i++){if(n.budget<=0)return!1;let o=r[i],s=o&&o.cssText?o.cssText:"";n.budget--;for(let a of e)if(s.includes(a))return!0;if(o&&o.styleSheet&&ro(o.styleSheet,e,n))return!0;if(o&&o.cssRules&&o.cssRules.length)for(let a=0;a<o.cssRules.length&&n.budget>0;a++){let c=o.cssRules[a],f=c&&c.cssText?c.cssText:"";n.budget--;for(let l of e)if(f.includes(l))return!0}if(n.budget<=0)return!1}return!1}function xs(t=document,e=Cs(t)){let n=Ie.get(t);if(n&&n.fingerprint===e)return n.result;let r=a=>(a.match(/\\|ass:[^|]*/)||[""])[0];n&&r(e)!==r(n.fingerprint)&&Re();let i=["::before","::after","::first-letter","::marker","::first-line",":before",":after",":first-letter",":first-line","counter(","counters(","counter-increment","counter-reset"],o=t.querySelectorAll("style");for(let a=0;a<o.length;a++){let c=o[a].textContent||"";for(let f of i)if(c.includes(f))return Ie.set(t,{fingerprint:e,result:!0}),!0}let s=t.adoptedStyleSheets;if(Array.isArray(s)&&s.length){let a={budget:Ss};try{for(let c of s)if(ro(c,i,a))return Ie.set(t,{fingerprint:e,result:!0}),!0}catch{}}{let a=t.querySelectorAll(\'style,link[rel~="stylesheet"]\'),c={budget:Ss};for(let f=0;f<a.length&&c.budget>0;f++){let l=a[f],u=null;if(l.tagName,u=l.sheet||null,u&&ro(u,i,c))return Ie.set(t,{fingerprint:e,result:!0}),!0}}return t.querySelector(\'[style*="counter("], [style*="counters("]\')?(Ie.set(t,{fingerprint:e,result:!0}),!0):(Ie.set(t,{fingerprint:e,result:!1}),!1)}function vs(t){for(let e of["Top","Right","Bottom","Left"]){let n=parseFloat(t[`border${e}Width`])||0,r=t[`border${e}Style`];if(n>0&&r&&r!=="none"&&r!=="hidden")return!0}return!1}function gf(t,e){let n=null,r=()=>{if(!n)try{n=bs(t)}catch(i){H(e,"buildCounterContext failed",i),n={get:()=>0,getStack:()=>[]}}return n};return{get(i,o){return r().get(i,o)},getStack(i,o){return r().getStack(i,o)}}}function yf(t){let e=!1;for(let n=0;n<t.length;n++){let r=t[n];if(r===\'"\')e=!e;else if(r==="/"&&!e)return t.slice(0,n).trim()}return t}function bf(t){return t.replace(/\\\\(?:([0-9a-fA-F]{1,6})[ \\t\\n]?|([\\s\\S]))/g,(e,n,r)=>{if(n){let i=parseInt(n,16);return i===0||i>1114111?"\\uFFFD":String.fromCodePoint(i)}return r===`\n`?"":r})}function wf(t){if(!t)return"";let e=[],n=/"((?:\\\\[\\s\\S]|[^"\\\\])*)"|\'((?:\\\\[\\s\\S]|[^\'\\\\])*)\'/g,r=0,i;for(;i=n.exec(t);){let s=t.slice(r,i.index).trim();s&&e.push(s),e.push(bf(i[1]!==void 0?i[1]:i[2])),r=n.lastIndex}let o=t.slice(r).trim();return o&&e.push(o),e.join("")}function oo(t,e,n){let r=t.parentElement,i=r&&n?n.get(r):null;return i?{get(o,s){let a=e.get(o,s),c=i.get(s);return typeof c=="number"?Math.max(a,c):a},getStack(o,s){let a=e.getStack(o,s);if(!a.length)return a;let c=i.get(s);if(typeof c=="number"){let f=a.slice();return f[f.length-1]=Math.max(f[f.length-1],c),f}return a}}:e}function io(t,e,n){let r=new Map,i=(f,l)=>an(f,l).map(([u,p])=>({name:u,num:p})),o=i(e?.counterReset,0),s=i(e?.counterSet,0),a=i(e?.counterIncrement,1);function c(f){if(r.has(f))return r.get(f).slice();let l=n.getStack(t,f);l=l.length?l.slice():[];let u=o.find(m=>m.name===f);if(u){let m=Number.isFinite(u.num)?u.num:0;l=l.length?[...l,m]:[m]}let p=s.find(m=>m.name===f);if(p){let m=Number.isFinite(p.num)?p.num:0;l.length===0&&(l=[0]),l[l.length-1]=m}let h=a.find(m=>m.name===f);if(h){let m=Number.isFinite(h.num)?h.num:1;l.length===0&&(l=[0]),l[l.length-1]+=m}return r.set(f,l.slice()),l}return{get(f,l){let u=c(l);return u.length?u[u.length-1]:0},getStack(f,l){return c(l)},__incs:a}}var Sf=["color","-webkit-text-fill-color","font-family","font-size","font-weight","font-style","letter-spacing","line-height"],xf=["color","-webkit-text-fill-color","font-family","font-size","font-weight","font-style","font-variant","letter-spacing","word-spacing","text-transform","text-decoration-line","text-decoration-color","text-decoration-style","line-height","background-color","vertical-align"];function ks(t,e,n,r,i,o){try{if(r===null){if(t.getRootNode()!==(t.ownerDocument||document))return;let u=O(t).display||"";if(i==="::marker"?!u.includes("list-item"):!(u==="block"||u==="flow-root"||u==="list-item"||u==="inline-block"||u==="table-cell"||u==="table-caption"))return}else if(!t.matches(r))return;if(i==="::marker"&&!(O(t).display||"").includes("list-item"))return;let s=O(t,i),a=O(t);if(!s)return;let c="";for(let u of o){let p=s.getPropertyValue(u);p&&p!==a.getPropertyValue(u)&&!(u==="background-color"&&p==="rgba(0, 0, 0, 0)")&&!(u==="vertical-align"&&p==="baseline")&&(c+=`${u}:${p};`)}if(i==="::marker"){let u=s.getPropertyValue("content");u&&u!=="normal"&&u!=="none"&&(c+=`content:${u};`)}if(!c)return;let l=`data-sd-p${n.__pseudoRuleSeq=(n.__pseudoRuleSeq||0)+1}`;e.setAttribute(l,""),n.__pseudoCSS=(n.__pseudoCSS||"")+`[${l}]${i}{${c}}`}catch{}}function vf(t,e){if(!/\\b(?:no-)?(?:open|close)-quote\\b/.test(t))return t;let n="\\u201C",r="\\u201D";try{let i=O(e).quotes;if(i==="none")n="",r="";else if(i&&i!=="auto"){let o=i.match(/"[^"]*"|\'[^\']*\'/g);o&&o.length>=2&&(n=o[0].slice(1,-1),r=o[1].slice(1,-1))}}catch{}return n=n.replace(/"/g,""),r=r.replace(/"/g,""),t.replace(/"[^"]*"|\\b(no-open-quote|no-close-quote|open-quote|close-quote)\\b/g,(i,o)=>o?o==="open-quote"?`"${n}"`:o==="close-quote"?`"${r}"`:\'""\':i)}function kf(t,e,n,r){let i;try{i=O(t,e)}catch{}let o=i?.content;if(!o||o==="none"||o==="normal")return{text:"",incs:[]};o=yf(o),o=vf(o,t);let s=oo(t,n,r),a=io(t,i,s),c=ys(o)?ws(o,t,a):o;return{text:wf(c),incs:a.__incs||[]}}function Cf(t,e){if(e.__shadowPseudo)return!1;let n=Te(t),r=[];for(let o of["before","after","firstLetter","marker","firstLine"]){let s=n[o];if(s===null)return!1;s&&r.push(s)}if(!r.length)return!0;let i=r.join(",");try{return!t.matches(i)&&t.querySelector(i)===null}catch{return!1}}async function We(t,e,n,r,i=!1){if(t?.nodeType!==1||e?.nodeType!==1||(n.slicer?.due()&&await n.slicer.pause(),t.tagName==="TEXTAREA"))return;let o=t.ownerDocument||document;if(!i&&!mf(o,n)&&!n.__shadowPseudo||!i&&Cf(t,n))return;n.__siblingCounters||(n.__siblingCounters=new WeakMap),n.__counterCtx||(n.__counterCtx=gf(t.ownerDocument||document,n));let s=n.__counterCtx,a=Te(t);a.marker!==""&&ks(t,e,n,a.marker,"::marker",Sf),a.firstLine!==""&&ks(t,e,n,a.firstLine,"::first-line",xf);for(let f of["::before","::after","::first-letter"]){let l=a[f==="::before"?"before":f==="::after"?"after":"firstLetter"];if(l!==null){if(l==="")continue;try{if(!t.matches(l))continue}catch{}}try{let u=O(t,f);if(!u||u.content==="none"&&u.backgroundImage==="none"&&(u.backgroundColor==="transparent"||u.backgroundColor==="rgba(0, 0, 0, 0)")&&!vs(u)&&(!u.transform||u.transform==="none")&&u.display==="inline")continue;if(u.display==="none"||f!=="::first-letter"&&(u.content==="none"||u.content==="normal")){f==="::before"&&(e.dataset.snapdomHasBefore="1"),f==="::after"&&(e.dataset.snapdomHasAfter="1");continue}if(f==="::first-letter"){let U=O(t),G=(U?.display||"").toLowerCase();if(G.includes("flex")||G.includes("grid"))continue;let q=Ht=>u[Ht]!==U[Ht]&&(parseFloat(u[Ht])||0)!==0;if(!(u.color!==U.color||u.fontSize!==U.fontSize||u.fontWeight!==U.fontWeight||u.fontFamily!==U.fontFamily||u.fontStyle!==U.fontStyle||u.textTransform!==U.textTransform||u.float!==U.float&&u.float!=="none"||q("paddingTop")||q("paddingRight")||q("paddingBottom")||q("paddingLeft")||q("marginTop")||q("marginRight")||q("marginBottom")||q("marginLeft")))continue;let rt=Array.from(e.childNodes).find(Ht=>Ht.nodeType===Node.TEXT_NODE&&Ht.textContent?.trim().length>0);if(!rt)continue;let me=rt.textContent,J=/^\\s*/.exec(me)[0],vt=me.slice(J.length),ge=vt.match(/^([^\\p{L}\\p{N}\\s]*[\\p{L}\\p{N}](?:[\'\u2019])?)/u)?.[0],ye=vt.slice(ge?.length||0);if(!ge||/[\\uD800-\\uDFFF]/.test(ge))continue;let be=document.createElement("span");be.textContent=ge,be.dataset.snapdomPseudo="::first-letter";let wr=Ce(u,xn(t)),mn=ke(wr,"span");n.styleMap.set(be,mn);let gn=document.createTextNode(ye);e.replaceChild(gn,rt),e.insertBefore(be,gn),J&&e.insertBefore(document.createTextNode(J),be);continue}let m=u.content??"",d=m===""||m==="none"||m==="normal",{text:g,incs:y}=kf(t,f,s,n.__siblingCounters),b=u.backgroundImage,S=u.backgroundColor,k=u.fontFamily,v=parseInt(u.fontSize)||32,w=parseInt(u.fontWeight)||!1,M=u.fontStyle||"normal",A=u.color||"#000",C=u.transform,x=Nt(k,r?.__iconMatchers),_=!d&&g!=="",R=b&&b!=="none",$=S&&S!=="transparent"&&S!=="rgba(0, 0, 0, 0)",T=vs(u),I=C&&C!=="none",B=m!=="none"&&m!=="normal",E=/^inline-/.test(u.display||""),N=B&&((parseFloat(u.width)||0)>0||(parseFloat(u.height)||0)>0||E),P=B&&u.boxShadow&&u.boxShadow!=="none",F=B&&u.outlineStyle&&u.outlineStyle!=="none"&&(parseFloat(u.outlineWidth)||0)>0;if(!(_||R||$||T||I||N||P||F)){if(y&&y.length&&t.parentElement){let U=n.__siblingCounters.get(t.parentElement)||new Map;for(let{name:G}of y){if(!G)continue;let q=oo(t,s,n.__siblingCounters),rt=io(t,O(t,f),q).get(t,G);U.set(G,rt)}n.__siblingCounters.set(t.parentElement,U)}continue}let V=g.startsWith("url(")||/^-?(?:webkit-)?image-set\\(/i.test(g),j=!1;if(_&&!x&&g.length>1&&!V){let U=O(t),G=parseFloat(U.fontSize)||16,q=parseFloat(U.lineHeight);Number.isFinite(q)||(q=G*1.5),t.getBoundingClientRect().height<q*1.6&&(e.style.whiteSpace="nowrap",j=!0)}let D=document.createElement("span");D.dataset.snapdomPseudo=f,D.style.pointerEvents="none",j&&(D.style.whiteSpace="nowrap");let K=Ri(t,f,u,n,r),ht=(O(t).display||"").toLowerCase(),St=ht.includes("flex")||ht.includes("grid");if(St){let U=K["min-width"];(!U||U==="auto"||U==="0px")&&(K["min-width"]="0px")}let ft=ke(K,"span",_,St);if(n.styleMap.set(D,ft),x&&g&&g.length===1){let{dataUrl:U,width:G,height:q}=await as(g,k,w,v,A,M),nt=document.createElement("img");nt.src=U,nt.style=`height:${v}px;width:${G/q*v}px;object-fit:contain;`,D.appendChild(nt),e.dataset.snapdomHasIcon="true"}else if(g&&V){let U=qe(g,typeof devicePixelRatio<"u"&&devicePixelRatio||1)??ee(g);if(U?.trim())try{let G=await dt(Vt(U),{as:"dataURL",useProxy:r.useProxy});if(G?.ok&&typeof G.data=="string"){let q=document.createElement("img");q.src=G.data,q.style=`width:${v}px;height:auto;object-fit:contain;`,D.appendChild(q)}}catch(G){console.error(`[snapdom] Error in pseudo ${f} for`,t,G)}}else!x&&_&&(D.textContent=g);D.style.backgroundImage="none","maskImage"in D.style&&(D.style.maskImage="none"),"webkitMaskImage"in D.style&&(D.style.webkitMaskImage="none");try{D.style.backgroundRepeat=u.backgroundRepeat,D.style.backgroundSize=u.backgroundSize,u.backgroundPositionX&&u.backgroundPositionY?(D.style.backgroundPositionX=u.backgroundPositionX,D.style.backgroundPositionY=u.backgroundPositionY):D.style.backgroundPosition=u.backgroundPosition,D.style.backgroundOrigin=u.backgroundOrigin,D.style.backgroundClip=u.backgroundClip,D.style.backgroundAttachment=u.backgroundAttachment,D.style.backgroundBlendMode=u.backgroundBlendMode}catch{}if(R)try{let U=Gt(b),G=await Promise.all(U.map(q=>xe(q,r)));D.style.backgroundImage=G.join(", ")}catch(U){console.warn(`[snapdom] ${f} background-image inline failed`,U)}$&&(D.style.backgroundColor=S);let at=u.maskImage||u.webkitMaskImage;if(at&&at!=="none")try{let G=(await Promise.all(Gt(at).map(q=>xe(q,r)))).join(", ");D.style.maskImage=G,D.style.webkitMaskImage=G;for(let q of["maskSize","maskRepeat","maskPosition","maskMode","maskComposite","maskOrigin","maskClip"])u[q]&&(D.style[q]=u[q])}catch(U){console.warn(`[snapdom] ${f} mask-image inline failed`,U)}let xt=D.childNodes.length>0||D.textContent?.trim()!==""||R||$||T||I||N||P||F;if(y&&y.length&&t.parentElement){let U=n.__siblingCounters.get(t.parentElement)||new Map,G=oo(t,s,n.__siblingCounters),q=io(t,O(t,f),G);for(let{name:nt}of y){if(!nt)continue;let rt=q.get(t,nt);U.set(nt,rt)}n.__siblingCounters.set(t.parentElement,U)}if(!xt)continue;f==="::before"?(e.dataset.snapdomHasBefore="1",e.insertBefore(D,e.firstChild)):(e.dataset.snapdomHasAfter="1",e.appendChild(D))}catch(u){console.warn(`[snapdom] Failed to capture ${f} for`,t,u)}}let c=Array.from(e.children).filter(f=>!f.dataset.snapdomPseudo);if(n.nodeMap)for(let f of c){let l=n.nodeMap.get(f);l?.nodeType===1&&await We(l,f,n,r,!0)}else{let f=Array.from(t.children);for(let l=0;l<Math.min(f.length,c.length);l++)await We(f[l],c[l],n,r,!0)}}kt();function As(t,e,n){if(!t||t?.nodeType!==1)return;let r=t.ownerDocument||document,i=e||r,o=It(t)&&t.localName==="svg"?[t]:Array.from(t.querySelectorAll("svg")),s=/url\\(\\s*["\']?\\s*#([^)"\']+)/g,a=["fill","stroke","filter","clip-path","mask","marker","marker-start","marker-mid","marker-end"],c=w=>window.CSS&&CSS.escape?CSS.escape(w):w.replace(/[^a-zA-Z0-9_-]/g,"\\\\$&"),f="http://www.w3.org/1999/xlink",l=w=>{if(!w||!w.getAttribute)return null;let M=w.getAttribute("href")||w.getAttribute("xlink:href")||(typeof w.getAttributeNS=="function"?w.getAttributeNS(f,"href"):null);if(M)return M;let A=w.attributes;if(!A)return null;for(let C=0;C<A.length;C++){let x=A[C];if(!x||!x.name)continue;if(x.name==="href")return x.value;let _=x.name.indexOf(":");if(_!==-1&&x.name.slice(_+1)==="href")return x.value}return null},u=new Set(Array.from(t.querySelectorAll("[id]")).map(w=>w.id)),p=new Set,h=!1,m=(w,M=null)=>{if(!w)return;s.lastIndex=0;let A;for(;A=s.exec(w);){h=!0;let C=(A[1]||"").trim();C&&(u.has(C)||(p.add(C),M&&!M.has(C)&&M.add(C)))}},d=w=>{let M=w.querySelectorAll("use");for(let x of M){let _=l(x);if(!_||!_.startsWith("#"))continue;h=!0;let R=_.slice(1).trim();R&&!u.has(R)&&p.add(R)}let A=\'*[style*="url("],*[fill^="url("], *[stroke^="url("],*[filter^="url("],*[clip-path^="url("],*[mask^="url("],*[marker^="url("],*[marker-start^="url("],*[marker-mid^="url("],*[marker-end^="url("]\';m(w.getAttribute("style")||"");for(let x of a)m(w.getAttribute(x));let C=w.querySelectorAll(A);for(let x of C){m(x.getAttribute("style")||"");for(let _ of a)m(x.getAttribute(_))}},g=w=>{if(!w||w.nodeType!==1||!w.querySelectorAll)return;let M="filter[id],clipPath[id],mask[id],linearGradient[id],radialGradient[id],pattern[id]",A=!1;try{A=!!(i.querySelector&&i.querySelector(M))}catch{return}if(!A)return;let C=["filter","clipPath","mask","maskImage","webkitMaskImage"],x=_=>{if(It(_))return;let R;try{R=getComputedStyle(_)}catch{return}for(let $ of C){let T=R[$];T&&T.includes("url(")&&m(T)}};x(w);for(let _ of w.querySelectorAll("*"))x(_)};for(let w of o)d(w);if(g(n),!h)return;let y=t.querySelector("svg.inline-defs-container");y||(y=r.createElementNS("http://www.w3.org/2000/svg","svg"),y.classList.add("inline-defs-container"),y.setAttribute("aria-hidden","true"),y.setAttribute("style","position:absolute;width:0;height:0;overflow:hidden"),t.insertBefore(y,t.firstChild||null));let b=y.querySelector("defs")||null,S=w=>{if(!w||u.has(w))return null;let M=c(w),A=C=>{let x=i.querySelector(C);return x&&!t.contains(x)?x:null};return A(`svg defs > *#${M}`)||A(`svg > symbol#${M}`)||A(`*#${M}`)};if(!p.size)return;let k=new Set(p),v=new Set;for(;k.size;){let w=k.values().next().value;if(k.delete(w),!w||u.has(w)||v.has(w))continue;let M=S(w);if(!M){v.add(w);continue}b||(b=r.createElementNS("http://www.w3.org/2000/svg","defs"),y.appendChild(b));let A=M.cloneNode(!0);A.id||A.setAttribute("id",w),b.appendChild(A),v.add(w),u.add(w);let C=[A,...A.querySelectorAll("*")];for(let x of C){let _=l(x);if(_&&_.startsWith("#")){let $=_.slice(1).trim();$&&!u.has($)&&!v.has($)&&k.add($)}let R=x.getAttribute?.("style")||"";R&&m(R,k);for(let $ of a){let T=x.getAttribute?.($);T&&m(T,k)}}}}kt();var so=new WeakMap,ao=new WeakMap;function Dn(t,e,n){let r=n.get(t),i=t.style;if(!r){let s=i.cssText,a=t.hasAttribute("style");r={users:0,saved:e.map(([f,l])=>{let u={property:f,value:i.getPropertyValue(f),priority:i.getPropertyPriority(f)};return i.setProperty(f,l,"important"),u.forcedValue=i.getPropertyValue(f),u}),originalCSS:s,forcedCSS:i.cssText,hadStyle:a},n.set(t,r)}r.users++;let o=!1;return()=>{if(!o&&(o=!0,!--r.users)){if(n.delete(t),i.cssText===r.forcedCSS)i.cssText=r.originalCSS;else for(let s of r.saved)i.getPropertyValue(s.property)!==s.forcedValue||i.getPropertyPriority(s.property)!=="important"||(s.value?i.setProperty(s.property,s.value,s.priority):i.removeProperty(s.property));!r.hadStyle&&!i.length&&(t.getAttribute("style"),t.removeAttribute("style"))}}}function Ms(t){if(so.has(t))return Dn(t,[],so);let e=getComputedStyle(t),n=e.outlineStyle,r=e.outlineWidth,i=n!=="none"&&parseFloat(r)>0,o=parseFloat(e.borderTopWidth)===0&&parseFloat(e.borderRightWidth)===0&&parseFloat(e.borderBottomWidth)===0&&parseFloat(e.borderLeftWidth)===0;if(i&&o){let s=[];for(let a of["top","right","bottom","left"])s.push([`border-${a}-width`,r],[`border-${a}-style`,"solid"],[`border-${a}-color`,"transparent"]);return Dn(t,s,so)}return()=>{}}function Bn(t,e=null){let n=[],r=i=>{if(!Rt(i))return;if(ao.has(i)){n.push(Dn(i,[],ao));return}let o=getComputedStyle(i);(o.contentVisibility||o.getPropertyValue("content-visibility")||"")==="auto"&&n.push(Dn(i,[["content-visibility","visible"]],ao))};try{if(e){let o=s=>{let a;try{a=s.getBoundingClientRect()}catch{return}if(!((a.width>0||a.height>0)&&(a.right<e.left-200||a.left>e.right+200||a.bottom<e.top-200||a.top>e.bottom+200))){r(s);for(let c=s.firstElementChild;c;c=c.nextElementSibling)o(c)}};o(t)}else{for(let i of t.querySelectorAll("*"))r(i);r(t)}}catch{}return()=>{for(let i of n)try{i()}catch{}}}bt();mt();Ct();Ae();Ct();function lo(t){return Es(t.boxShadow)}function fo(t){return Es(t.textShadow)}function Es(t){if(!t||t==="none")return{top:0,right:0,bottom:0,left:0};let e=[],n="",r=0;for(let c=0;c<t.length;c++){let f=t[c];f==="("?r++:f===")"&&(r=Math.max(0,r-1)),f===","&&r===0?(e.push(n),n=""):n+=f}n.trim()&&e.push(n);let i=0,o=0,s=0,a=0;for(let c of e){if(/\\binset\\b/i.test(c))continue;let f=c.match(/-?\\d+(\\.\\d+)?px/g)?.map(g=>parseFloat(g))||[];if(f.length<2)continue;let[l,u,p=0,h=0]=f,m=Math.abs(l)+p+h,d=Math.abs(u)+p+h;o=Math.max(o,m+Math.max(l,0)),a=Math.max(a,m+Math.max(-l,0)),s=Math.max(s,d+Math.max(u,0)),i=Math.max(i,d+Math.max(-u,0))}return{top:Math.ceil(i),right:Math.ceil(o),bottom:Math.ceil(s),left:Math.ceil(a)}}function uo(t){let e=t.filter&&t.filter!=="none"?t.filter:t.webkitFilter||"",n=/blur\\(\\s*([0-9.]+)px\\s*\\)/gi,r=0,i;for(;i=n.exec(e);)r+=parseFloat(i[1])||0;let o=Math.ceil(r*2);return{top:o,right:o,bottom:o,left:o}}function po(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,r=e+Math.max(0,Math.ceil(n));return{top:r,right:r,bottom:r,left:r}}function ho(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)||[],r=0,i=0,o=0,s=0,a=!1;for(let c of n){a=!0;let f=c.match(/-?\\d+(?:\\.\\d+)?px/gi)?.map(d=>parseFloat(d))||[],[l=0,u=0,p=0]=f,h=Math.abs(l)+p,m=Math.abs(u)+p;i=Math.max(i,h+Math.max(l,0)),s=Math.max(s,h+Math.max(-l,0)),o=Math.max(o,m+Math.max(u,0)),r=Math.max(r,m+Math.max(-u,0))}return{bleed:{top:W(r),right:W(i),bottom:W(o),left:W(s)},has:a}}function Af(t){let e=lo(t),n=fo(t),r=uo(t),i=po(t),o=ho(t);return{top:Math.max(e.top,n.top)+r.top+i.top+o.bleed.top,right:Math.max(e.right,n.right)+r.right+i.right+o.bleed.right,bottom:Math.max(e.bottom,n.bottom)+r.bottom+i.bottom+o.bleed.bottom,left:Math.max(e.left,n.left)+r.left+i.left+o.bleed.left}}function Mf(t){return t.boxShadow&&t.boxShadow!=="none"||t.textShadow&&t.textShadow!=="none"||(t.outlineStyle||"none")!=="none"||t.filter&&t.filter!=="none"?!0:!!t.webkitFilter&&t.webkitFilter!=="none"}function _s(t){let e=t.overflowX||t.overflow||"visible",n=t.overflowY||t.overflow||"visible",r=!!t.contain&&/\\b(paint|content|strict)\\b/.test(t.contain)||!!t.clipPath&&t.clipPath!=="none";return{x:r||e!=="visible",y:r||n!=="visible"}}function Rs(t,e,n,r=1,i=1){let o=0,s=0,a=0,c=0,f=_s(n.get(t)||O(t));if(f.x&&f.y)return{top:0,right:0,bottom:0,left:0};let l=t.getBoundingClientRect();for(let u of e.values()){if(u===t||u.nodeType!==1||u.ownerDocument!==t.ownerDocument)continue;let p=n.get(u);if(!p||!Mf(p))continue;let h=Af(p);if(!(h.top||h.right||h.bottom||h.left))continue;let m=u.getBoundingClientRect(),d={left:m.left-h.left/r,top:m.top-h.top/i,right:m.right+h.right/r,bottom:m.bottom+h.bottom/i};for(let g=u.parentElement;g;g=g.parentElement){let y=_s(n.get(g)||O(g));if(y.x||y.y){let b=g.getBoundingClientRect();y.x&&(d.left=Math.max(d.left,b.left),d.right=Math.min(d.right,b.right)),y.y&&(d.top=Math.max(d.top,b.top),d.bottom=Math.min(d.bottom,b.bottom))}if(g===t)break}f.x||(c=Math.max(c,(l.left-d.left)*r),s=Math.max(s,(d.right-l.right)*r)),f.y||(o=Math.max(o,(l.top-d.top)*i),a=Math.max(a,(d.bottom-l.bottom)*i))}return{top:Math.max(0,Math.ceil(o)),right:Math.max(0,Math.ceil(s)),bottom:Math.max(0,Math.ceil(a)),left:Math.max(0,Math.ceil(c))}}function Fs(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 r=n.transform||"none";if(!r||r==="none"){let c=null;try{c=ce(t).scale}catch{}try{e.style.transform="none"}catch{}if(!c)return{a:1,b:0,c:0,d:1};let f=Jt({scale:c});return{a:f.a,b:f.b,c:f.c,d:f.d}}function i(c,f,l,u){let p=Math.sqrt(c*c+f*f)||0,h=0,m=0;if(p>0){let d=c/p,g=f/p;h=d*l+g*u;let y=l-d*h,b=u-g*h;m=Math.sqrt(y*y+b*b)||0,m>0?h=h/m:h=0}return{a:p,b:0,c:h*m,d:m}}let o=c=>{let f=ce(t).scale;if(!f)return c;let l=Jt({scale:f,baseTransform:`matrix(${c.a},${c.b},${c.c},${c.d},0,0)`});return{a:l.a,b:l.b,c:l.c,d:l.d}},s=r.match(/^matrix\\(\\s*([^)]+)\\)$/i);if(s){let c=s[1].split(",").map(f=>parseFloat(f.trim()));if(c.length===6&&c.every(Number.isFinite)){let[f,l,u,p]=c,h=i(f,l,u,p);try{e.style.transform=`matrix(${h.a}, ${h.b}, ${h.c}, ${h.d}, 0, 0)`}catch{}return o(h)}}let a=r.match(/^matrix3d\\(\\s*([^)]+)\\)$/i);if(a){let c=a[1].split(",").map(f=>parseFloat(f.trim()));if(c.length===16&&c.every(Number.isFinite)){let f=c[0],l=c[1],u=c[4],p=c[5],h=i(f,l,u,p);try{e.style.transform=`matrix(${h.a}, ${h.b}, ${h.c}, ${h.d}, 0, 0)`}catch{}return o(h)}}try{let c=new DOMMatrix(r),f=i(c.a,c.b,c.c,c.d);try{e.style.transform=`matrix(${f.a}, ${f.b}, ${f.c}, ${f.d}, 0, 0)`}catch{}return o(f)}catch{return null}}function Oe(t,e,n,r,i){let o=n.a,s=n.b,a=n.c,c=n.d,f=n.e||0,l=n.f||0;function u(y,b){let S=y-r,k=b-i,v=o*S+a*k,w=s*S+c*k;return v+=r+f,w+=i+l,[v,w]}let p=[u(0,0),u(t,0),u(0,e),u(t,e)],h=1/0,m=1/0,d=-1/0,g=-1/0;for(let[y,b]of p)y<h&&(h=y),b<m&&(m=b),y>d&&(d=y),b>g&&(g=b);return{minX:h,minY:m,maxX:d,maxY:g,width:d-h,height:g-m}}function cn(t,e,n){let r=(t.transformOrigin||"0 0").trim().split(/\\s+/),[i,o]=[r[0]||"0",r[1]||"0"],s=(a,c)=>{let f=a.toLowerCase();return f==="left"||f==="top"?0:f==="center"?c/2:f==="right"||f==="bottom"?c:f.endsWith("px")?parseFloat(f)||0:f.endsWith("%")?(parseFloat(f)||0)*c/100:/^-?\\d+(\\.\\d+)?$/.test(f)&&parseFloat(f)||0};return{ox:s(i,e),oy:s(o,n)}}function ce(t){let e={rotate:"0deg",scale:null,translate:null},n=null;try{n=typeof t.computedStyleMap=="function"?t.computedStyleMap():null}catch{}if(n){let i=c=>{try{return typeof n.has=="function"&&!n.has(c)||typeof n.get!="function"?null:n.get(c)}catch{return null}},o=i("rotate");if(o)if(o.angle){let c=o.angle;e.rotate=c.unit==="rad"?c.value*180/Math.PI+"deg":c.value+c.unit,o.is2D===!1&&o.x&&o.y&&o.z&&(e.rotate=`${o.x.value} ${o.y.value} ${o.z.value} ${e.rotate}`)}else o.unit?e.rotate=o.unit==="rad"?o.value*180/Math.PI+"deg":o.value+o.unit:e.rotate=String(o);else{let c=getComputedStyle(t);e.rotate=c.rotate&&c.rotate!=="none"?c.rotate:"0deg"}let s=i("scale");if(s){let c=f=>f&&f.value!=null?`${f.value}${f.unit==="percent"?"%":""}`:null;"x"in s&&s.x?.value!=null?e.scale=[c(s.x),c(s.y)??c(s.x),...s.is2D===!1?[c(s.z)??"1"]:[]].join(" "):Array.isArray(s)?e.scale=s.map(c).join(" "):e.scale=String(s)}else{let c=getComputedStyle(t);e.scale=c.scale&&c.scale!=="none"?c.scale:null}let a=i("translate");if(a){let c=f=>f&&f.value!=null?`${f.value}${f.unit==="percent"?"%":f.unit||"px"}`:null;"x"in a&&a.x?.value!=null?e.translate=[c(a.x),c(a.y)??"0px",...a.is2D===!1?[c(a.z)??"0px"]:[]].join(" "):Array.isArray(a)?e.translate=a.map(c).join(" "):e.translate=String(a)}else{let c=getComputedStyle(t);e.translate=c.translate&&c.translate!=="none"?c.translate:null}return(!e.rotate||e.rotate==="none")&&(e.rotate="0deg"),(!e.scale||e.scale==="none")&&(e.scale=null),(!e.translate||e.translate==="none")&&(e.translate=null),e}let r=getComputedStyle(t);return e.rotate=r.rotate&&r.rotate!=="none"?r.rotate:"0deg",e.scale=r.scale&&r.scale!=="none"?r.scale:null,e.translate=r.translate&&r.translate!=="none"?r.translate:null,e}var co=null;function _f(){if(co?.isConnected)return co;let t=document.createElement("div");return t.id="snapdom-measure-slot",t.setAttribute("aria-hidden","true"),tt(t),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),co=t,t}function Jt(t){let e=o=>{let s=[],a=0,c=0,f=String(o).trim();for(let l=0;l<f.length;l++)f[l]==="("?a++:f[l]===")"?a--:/\\s/.test(f[l])&&!a&&(l>c&&s.push(f.slice(c,l)),c=l+1);return c<f.length&&s.push(f.slice(c)),s},n=o=>o&&o!=="none",r=[];if(n(t.translate)){let o=e(t.translate);for(let s=0;s<2&&s<o.length;s++){let a=s===0?t.width:t.height;/^[+-]?(?:\\d*\\.)?\\d+%$/.test(o[s])&&Number.isFinite(a)&&(o[s]=`${parseFloat(o[s])*a/100}px`)}r.push(o.length>2?`translate3d(${o.join(",")})`:`translate(${o.join(",")})`)}if(n(t.rotate)&&t.rotate!=="0deg"){let o=e(t.rotate);o.length===4?r.push(`rotate3d(${o.join(",")})`):o.length===2&&/^[xyz]$/i.test(o[0])?r.push(`rotate${o[0].toUpperCase()}(${o[1]})`):r.push(`rotate(${o.join(" ")})`)}if(n(t.scale)){let o=e(t.scale).map(s=>/%$/.test(s)?String(parseFloat(s)/100):s);r.push(o.length>2?`scale3d(${o.join(",")})`:`scale(${o.join(",")})`)}if(n(t.baseTransform)&&r.push(t.baseTransform),!r.length)return new DOMMatrix;let i=r.join(" ");try{if(i.includes("%"))throw new Error("Transform needs a reference box");return new DOMMatrix(i)}catch{let o=_f(),s=document.createElement("div");if(s.style.cssText="all:initial!important;display:block!important;transform-origin:0 0!important",s.style.setProperty("width",`${Number.isFinite(t.width)?t.width:0}px`,"important"),s.style.setProperty("height",`${Number.isFinite(t.height)?t.height:0}px`,"important"),s.style.setProperty("transform",i,"important"),!s.style.transform)throw new Error("Invalid transform composition");o.appendChild(s);try{return Ef(s)}finally{s.remove()}}}function Ts(t){let e=O(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 i=e.rotate&&e.rotate!=="none"&&e.rotate!=="0deg",o=e.scale&&e.scale!=="none"&&e.scale!=="1",s=e.translate&&e.translate!=="none"&&e.translate!=="0px 0px";return!!(i||o||s)}function Ef(t){let e=getComputedStyle(t).transform;if(!e||e==="none")return new DOMMatrix;try{return new DOMMatrix(e)}catch{return new WebKitCSSMatrix(e)}}var Ls=new WeakSet;function Un(t,e){if(!e)return null;let n=t.ownerDocument||document,r=n.defaultView||window,i,o,s,a;if(e==="viewport")i=0,o=0,s=n.documentElement?.clientWidth||r.innerWidth,a=n.documentElement?.clientHeight||r.innerHeight;else if(typeof e=="object")i=(Number(e.x)||0)-(r.scrollX||0),o=(Number(e.y)||0)-(r.scrollY||0),s=Number(e.width),a=Number(e.height);else return null;return s>0&&a>0?{left:i,top:o,width:s,height:a,right:i+s,bottom:o+a}:null}function mo(t){if(t.parentElement)return t.parentElement;let e=t.getRootNode&&t.getRootNode();return Wt(e)?e.host:null}function Rf(t,e){for(let n=e;n;n=mo(n))if(n===t)return!0;return!1}function Ff(t,e){for(let n=mo(t);n&&n!==e&&n?.nodeType===1;n=mo(n)){let r=O(n);if(r.position!=="static"||r.transform&&r.transform!=="none"||r.filter&&r.filter!=="none"||r.backdropFilter&&r.backdropFilter!=="none"||r.perspective&&r.perspective!=="none"||/transform|perspective|filter/.test(r.willChange||"")||/layout|paint|strict|content/.test(r.contain||""))return n}return null}function yo(t,e){try{return Jt({baseTransform:t,rotate:e?.rotate,scale:e?.scale})}catch{return null}}function Is(t,e,n,r,i){let o=t.getBoundingClientRect();Rt(e)&&O(t).position==="static"&&(e.style.position="relative");let s=[];for(let[a,c]of n){if(!Rt(a)||c?.nodeType!==1||c===t||!Rf(t,c))continue;let f=r.get(c)||O(c),l=f.position;if(l!=="fixed"&&l!=="sticky"&&l!=="-webkit-sticky"||a.style.position==="absolute")continue;let u=c.getBoundingClientRect();if(!(u.width>0&&u.height>0))continue;Ls.add(a);let p=f.transform&&f.transform!=="none"?f.transform:"",h=ce(c),m=!!(p||h.rotate!=="0deg"||h.scale||h.translate),d=m?yo(p,h):null,g=!d||!d.is2D||d.a===1&&d.b===0&&d.c===0&&d.d===1,y=u.width,b=u.height;g||(y=c.offsetWidth||u.width,b=c.offsetHeight||u.height);let S=c.getRootNode&&Wt(c.getRootNode()),k=o,v=t.clientLeft||0,w=t.clientTop||0;if(S){let _=Ff(c,t);_&&(k=_.getBoundingClientRect(),v=_.clientLeft||0,w=_.clientTop||0)}let M=u.left-k.left-v,A=u.top-k.top-w;if(m)if(a.style.translate="none",a.style.rotate="none",a.style.scale="none",g)a.style.transform="none";else{a.style.transform=`matrix(${d.a},${d.b},${d.c},${d.d},0,0)`;let{ox:_,oy:R}=cn(f,y,b),$=Oe(y,b,{a:d.a,b:d.b,c:d.c,d:d.d,e:0,f:0},_,R);M-=$.minX,A-=$.minY}if(l!=="fixed"){let _=a.cloneNode(!1);_.setAttribute("data-snap-ph","1"),_.style.position="static",_.style.visibility="hidden",_.style.width=`${y}px`,_.style.height=`${b}px`,_.style.boxSizing="border-box",a.parentElement?.insertBefore(_,a)}let C=y+2,x=b;i&&(Math.abs(A-i.y)<.5&&(A-=1,x+=1),Math.abs(M-i.x)<.5&&(M-=1,C+=1)),a.style.position="absolute",a.style.left=`${M}px`,a.style.top=`${A}px`,a.style.right="auto",a.style.bottom="auto",a.style.margin="0",a.style.width=`${C}px`,a.style.height=`${x}px`,a.style.boxSizing="border-box",S||s.push(a)}for(let a of s)e.appendChild(a)}function Ws(t,e,n={}){if(!t||!e||!e.style)return;let r=getComputedStyle(t);try{e.style.boxShadow="none"}catch(s){H(n,"stripRootShadows boxShadow",s)}try{e.style.textShadow="none"}catch(s){H(n,"stripRootShadows textShadow",s)}try{e.style.outline="none"}catch(s){H(n,"stripRootShadows outline",s)}let o=(r.filter||"").replace(/\\bdrop-shadow\\((?:[^()]|\\([^()]*\\))*\\)\\s*/gi,"").trim().replace(/\\s+/g," ");try{e.style.filter=o.length?o:"none"}catch(s){H(n,"stripRootShadows filter",s)}}function Os(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 $s(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",r=t.overflowY||t.overflow||"visible";return!!(n!=="visible"||r!=="visible"||t.contain&&/\\b(layout|content|paint|strict)\\b/.test(t.contain))}function Tf(t,e){let n=Array.from(t.childNodes),r=e==="top"?n:n.reverse();for(let i of r){if(i.nodeType===Node.TEXT_NODE){if(/\\S/.test(i.textContent||""))return null;continue}if(i.nodeType!==Node.ELEMENT_NODE)continue;let o=getComputedStyle(i),s=String(o.display||"");if(!(s==="none"||s==="contents")&&!(o.position==="absolute"||o.position==="fixed"))return o.float&&o.float!=="none"||s.startsWith("inline")?null:i}return null}function Ds(t,e,n){if(!t||!e||!e.style)return;let r=getComputedStyle(t);if(!$s(r))for(let i of["top","bottom"]){let o=i==="top"?"Top":"Bottom";if((parseFloat(r[`border${o}Width`])||0)>0||(parseFloat(r[`padding${o}`])||0)>0)continue;let s=t,a=e;for(;s&&a;){let c=Tf(s,i);if(!c)break;let f=n?Array.from(a.children).find(p=>n.get(p)===c)||null:a.children[Array.from(s.children).indexOf(c)]||null,l=getComputedStyle(c),u=parseFloat(l[`margin${o}`])||0;if(f&&f.style&&u>0&&(f.style[`margin${o}`]="0px"),$s(l)||(parseFloat(l[`border${o}Width`])||0)>0||(parseFloat(l[`padding${o}`])||0)>0)break;s=c,a=f}}}var $f=new Set(["xml","xlink"]);function Pf(t,e){if(t.startsWith("*")||t.includes("@"))return!0;if(t.includes(":")){let n=t.split(":",1)[0];if(!$f.has(n))return!0}return e?t.startsWith("x-")||t.startsWith("v-")||t.startsWith(":")||t.startsWith("on:")||t.startsWith("bind:")||t.startsWith("let:")||t.startsWith("class:"):!1}var Nf=/[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\uD800-\\uDFFF\\uFFFE\\uFFFF]/g,Ps=t=>t.replace(Nf,e=>e.length===2?e:""),Lf=/^data:[^,]{0,120};base64,/;function zn(t,e={}){if(!t)return;let{stripFrameworkDirectives:n=!0}=e,r=a=>{for(let c of Array.from(a.attributes)){if(Pf(c.name,n)){a.removeAttribute(c.name);continue}if(Lf.test(c.value))continue;let f=Ps(c.value);if(f!==c.value)try{a.setAttribute(c.name,f)}catch{}}};t.nodeType===Node.ELEMENT_NODE&&r(t);let i=[],o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT|NodeFilter.SHOW_COMMENT),s;for(;s=o.nextNode();)if(s.nodeType===Node.ELEMENT_NODE)r(s);else if(s.nodeType===Node.COMMENT_NODE)i.push(s);else{let a=Ps(s.data);a!==s.data&&(s.data=a)}for(let a of i)a.remove()}function If(t){try{let e=t.getAttribute?.("style")||"";return/\\b(height|width|block-size|inline-size)\\s*:/.test(e)}catch{return!1}}var Wf=new Set(["img","canvas","video","iframe","object","embed"]);function Of(t){return It(t)||Wf.has(t?.localName)}function Df(t,e){if(t?.nodeType!==1||If(t)||Of(t))return!1;let n=e.position;if(n==="absolute"||n==="fixed"||n==="sticky")return!1;let r=e.display||"";return!(r.includes("flex")||r.includes("grid")||r.startsWith("table")||e.transform&&e.transform!=="none")}function Bs(t,e,n=new Map,r=null){function i(o,s){if(o?.nodeType!==1||s?.nodeType!==1)return;let a=o.childElementCount>s.childElementCount,c=n.get(o)||getComputedStyle(o);if(n.has(o)||n.set(o,c),a&&Df(o,c)){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=c.overflowY||c.overflowBlock||"visible",u=c.overflowX||c.overflowInline||"visible";(l!=="visible"||u!=="visible")&&(s.style.overflow="visible")}let f=Array.from(s.children);if(r)for(let l of f){let u=r.get(l);u&&u.nodeType===1&&i(u,l)}else{let l=Array.from(o.children);for(let u=0;u<Math.min(l.length,f.length);u++)i(l[u],f[u])}}i(t,e)}function Bf(t){let e=getComputedStyle(t);return!(e.display==="none"||e.position==="absolute"||e.position==="fixed")}function Uf(t,e){if(t?.nodeType!==1)return!1;if(t.getAttribute("data-capture")==="exclude")return e?.excludeMode==="remove";if(Array.isArray(e?.exclude))for(let n of e.exclude)try{if(t.matches(n))return e.excludeMode==="remove"}catch(r){H(e,"exclude selector match failed",r)}if(Array.isArray(e?.excludePredicates))for(let n of e.excludePredicates)try{if(n(t))return e.excludeMode==="remove"}catch(r){H(e,"exclude predicate failed",r)}if(typeof e?.filter=="function"&&e.filterMode==="remove")try{if(!e.filter(t))return!0}catch(n){H(e,"filter function failed",n)}return!1}function bo(t,e){let n=getComputedStyle(t),r=t.getBoundingClientRect(),i=1/0,o=-1/0,s=!1,a=Array.from(t.children);for(let h of a){if(Uf(h,e)||!Bf(h))continue;let m=h.getBoundingClientRect(),d=m.top-r.top,g=m.bottom-r.top;g<=d||(d<i&&(i=d),g>o&&(o=g),s=!0)}let c=s?Math.max(0,o-i):0,f=parseFloat(n.borderTopWidth)||0,l=parseFloat(n.borderBottomWidth)||0,u=parseFloat(n.paddingTop)||0,p=parseFloat(n.paddingBottom)||0;return f+l+u+p+c}var W=(t,e=3)=>Number.isFinite(t)?Math.round(t*10**e)/10**e:t,De=.75;function Us(t,e,n,r,i,o){let s=t.ownerDocument||document,a=t.getBoundingClientRect(),c=i>0&&a.width>0?a.width/i:1,f=o>0&&a.height>0?a.height/o:1;if(Math.abs(c-f)>.02)return 0;let l=s.createElement("div");tt(l),l.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;width:"+i+"px!important;overflow:visible!important;visibility:hidden!important;";let u=l.attachShadow({mode:"open"}),p=s.createElement("style");p.textContent=n,u.appendChild(p);let h=e.cloneNode(!0);u.appendChild(h),s.body.appendChild(l);let m=0,d=(g,y,b)=>{let S=O(g),k=S.boxSizing==="border-box",v=(w,M,...A)=>{let C=parseFloat(w);if(!Number.isFinite(C))return M;let x=C+(k?0:A.reduce((_,R)=>_+(parseFloat(R)||0),0));return Math.abs(x-M)<=.51?x:M};return{width:v(S.width,y,S.paddingLeft,S.paddingRight,S.borderLeftWidth,S.borderRightWidth),height:v(S.height,b,S.paddingTop,S.paddingBottom,S.borderTopWidth,S.borderBottomWidth)}};try{let g=h.getBoundingClientRect(),y=h.offsetWidth||i,b=h.offsetHeight||o,S=y>0&&g.width>0?g.width/y:1,k=b>0&&g.height>0?g.height/b:1,v=(w,M,A=!1)=>{let C=w.children,x=M.children,_=Math.min(C.length,x.length);for(let R=0;R<_;R++){let $=C[R],T=x[R],I=r.get($),B=A||Ls.has($);if(I?.nodeType===1&&Rt($)&&$.style&&I.isConnected){let E=I.getBoundingClientRect();if(E.width>0&&E.height>0){let N=T.getBoundingClientRect(),P=E.width/c,F=E.height/f,z=N.width,V=N.height,j=I.offsetWidth||P,D=I.offsetHeight||F,K=T.offsetWidth||z,ht=T.offsetHeight||V,St=Math.abs(P-j)>De||Math.abs(F-D)>De||Math.abs(z-K)>De||Math.abs(V-ht)>De;if(B){let ct=d(T,K,ht);P=z>0?P*S*ct.width/z:P,F=V>0?F*k*ct.height/V:F,z=ct.width,V=ct.height}else if(St){let ct=d(I,j,D),xt=d(T,K,ht);P=ct.width,F=ct.height,z=xt.width,V=xt.height}let ft=z-P,at=V-F;(Math.abs(ft)>De||Math.abs(at)>De)&&($.style.boxSizing="border-box",$.style.width=`${W(P)}px`,$.style.height=`${W(F)}px`,m++)}}v($,T,B)}};v(e,h)}finally{l.remove()}return m}var zf=/::-(?:webkit-(?:scrollbar|meter|progress|slider)|moz-(?:meter|progress))/i;function go(t,e=new Set){let n="";if(!t)return n;for(let r=0;r<t.length;r++){let i=t[r];try{if(i.type===CSSRule.IMPORT_RULE&&i.styleSheet){n+=go(i.styleSheet.cssRules,e);continue}if(i.type===CSSRule.MEDIA_RULE&&i.cssRules){let o=go(i.cssRules,e);o&&(n+=`@media ${i.conditionText}{${o}}`);continue}if(i.type===CSSRule.STYLE_RULE){let o=i.selectorText||"";if(zf.test(o)){let s=i.cssText;s&&!e.has(s)&&(e.add(s),n+=s)}}}catch{}}return n}var Ns=new WeakMap;function Hf(t){let e="";for(let n of t.styleSheets){let r=-1;try{r=n.cssRules?n.cssRules.length:-1}catch{}e+=(n.href||"inline")+":"+r+"|"}return e}function jf(t){if(!t||!t.styleSheets)return"";let e=Hf(t),n=Ns.get(t);if(n&&n.fp===e)return n.css;let r=new Set,i="";for(let o of Array.from(t.styleSheets))try{let s=o.cssRules;s&&(i+=go(s,r))}catch{}return Ns.set(t,{fp:e,css:i}),i}function zs(t,e){let n=Nr(t.clone).sort(),r=n.join(","),i=nn(t.element),o=L.baseStyle.get(r),s;o&&o.universe===i?s=o.css:(s=Lr(n,i),L.baseStyle.set(r,{universe:i,css:s}));let a=jf(t.element?.ownerDocument||document);return t.fontsCSS=e,t.baseCSS=s,t.scrollbarCSS=a,{baseCSS:s,scrollbarCSS:a,fontsCSS:e}}yt();var Hn=new Set;async function Hs(t,e={}){Tt(),Cn(t.ownerDocument||document);let n=e.__session||{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map},r={styleMap:n.styleMap,styleCache:n.styleCache,nodeMap:n.nodeMap,options:e,slicer:e.__slicer||null},i=null,o=null;if(e.clip&&(o=Un(t,e.clip),o&&(r.clip={rect:o,root:t})),e.captureSelection)try{r.selection=Ki(t)}catch(d){H(r,"prepareSelectionContext failed",d)}let s,a="",c="";if(Hn.size){let d=(g,y)=>{for(let b=y;b;b=b.assignedSlot||b.parentElement||b.getRootNode()?.host)if(b===g)return!0;return!1};for(;;){let g=[...Hn].filter(({root:y})=>d(y,t)||d(t,y)).map(({promise:y})=>y.catch(()=>{}));if(!g.length)break;await Promise.all(g)}}if(!r.clip&&t.isConnected&&t.ownerDocument?.visibilityState!=="hidden")try{let d=t.getBoundingClientRect(),g=t.ownerDocument?.defaultView||window,y=d.right<=0||d.bottom<=0||d.left>=g.innerWidth||d.top>=g.innerHeight,b=[];if(y&&(()=>{let k=[];t.shadowRoot&&k.push(t.shadowRoot);for(let v of t.querySelectorAll("*"))v.shadowRoot&&k.push(v.shadowRoot);for(;k.length;){let v=k.pop(),w=v.host?.localName==="calcite-icon";for(let M of v.querySelectorAll("*")){if(M.shadowRoot&&k.push(M.shadowRoot),!w||M.localName!=="svg")continue;let A=M.querySelectorAll("path");if(!A.length||[...A].some(x=>x.getAttribute("d")?.trim()))continue;let C=M.getBoundingClientRect();C.width&&C.height&&b.push(M)}}})(),b.length){let k=(async()=>{let w=t.style,M=t.hasAttribute("style"),A=new Map,C=(x,_)=>{A.has(x)||A.set(x,{value:w.getPropertyValue(x),priority:w.getPropertyPriority(x)}),w.setProperty(x,_,"important");let R=A.get(x);R.forcedValue=w.getPropertyValue(x),R.forcedPriority=w.getPropertyPriority(x)};try{C("left","0"),C("top","0"),C("right","auto"),C("bottom","auto"),C("margin-top","0"),C("margin-right","0"),C("margin-bottom","0"),C("margin-left","0"),C("transform","none"),C("translate","none"),C("opacity","0"),C("pointer-events","none");let x=t.getBoundingClientRect();if(x.right<=0||x.bottom<=0||x.left>=g.innerWidth||x.top>=g.innerHeight){let $=t.parentElement?.getBoundingClientRect(),T=$&&$.right>0&&$.left<g.innerWidth?Math.max(0,$.left):0,I=$&&$.bottom>0&&$.top<g.innerHeight?Math.max(0,$.top):0;C("position","fixed"),C("left",`${T}px`),C("top",`${I}px`)}await gt(100);let _=Date.now()+1500,R=()=>b.some($=>{if([...$.querySelectorAll("path")].some(I=>I.getAttribute("d")?.trim()))return!1;let T=$.getBoundingClientRect();return T.width&&T.height&&T.right>0&&T.bottom>0&&T.left<g.innerWidth&&T.top<g.innerHeight});for(;Date.now()<_&&R();)await new Promise($=>setTimeout($,25));await gt(100)}finally{for(let[x,_]of A)w.getPropertyValue(x)!==_.forcedValue||w.getPropertyPriority(x)!==_.forcedPriority||(_.value?w.setProperty(x,_.value,_.priority):w.removeProperty(x));!M&&!w.length&&t.removeAttribute("style"),await gt(100)}})(),v={root:t,promise:k};Hn.add(v);try{await k}finally{Hn.delete(v)}}}catch{}let f=Ms(t),l=Bn(t,o);if(o){let d=t.getBoundingClientRect(),g=t.offsetWidth||d.width,y=t.offsetHeight||d.height,b=d.width&&Math.abs(g-d.width)>=1?g/d.width:1,S=d.height&&Math.abs(y-d.height)>=1?y/d.height:1;i={x:(o.left-d.left)*b,y:(o.top-d.top)*S,width:o.width*b,height:o.height*S}}try{s=await Qt(t,r,e)}catch(d){throw console.warn("deepClone failed:",d),d}finally{l(),f()}r.slicer?.due()&&await r.slicer.pause();try{As(s,void 0,t)}catch(d){console.warn("inlineExternal defs or symbol failed:",d)}try{await We(t,s,r,e)}catch(d){console.warn("inlinePseudoElements failed:",d)}await _n(s,r);for(let[d,g]of r.nodeMap.entries())if(g?.tagName==="STYLE"&&d?.tagName==="STYLE"&&!d.hasAttribute("data-sd"))try{let y=g.sheet&&g.sheet.cssRules;y&&/@media/i.test(d.textContent||"")&&(d.textContent=ae(y))}catch{}try{let d=s.querySelectorAll("style[data-sd]");for(let g of d)c+=g.textContent||"",g.remove()}catch(d){H(r,"Shadow CSS extraction failed",d)}r.slicer?.due()&&await r.slicer.pause();let u=Ye(r.styleMap);a=Array.from(u.entries()).map(([d,g])=>`.${g}{${d}}`).join("");let h=c+"[data-snapdom-has-after]::after,[data-snapdom-has-before]::before{content:none!important;display:none!important}"+(r.__pseudoCSS||"");a=h+a;for(let[d,g]of r.styleMap.entries())wo(d,g,u);try{Vf(t,s,r.nodeMap)}catch(d){H(r,"top-layer lift failed",d)}if((r.clip||t.scrollTop||t.scrollLeft)&&s?.nodeType===1)try{let d=r.clip&&i?{x:i.x,y:i.y}:{x:0,y:0};Is(t,s,r.nodeMap,r.styleCache,d)}catch(d){H(r,"freezeViewportPositioned failed",d)}for(let[d,g]of r.nodeMap.entries())r.clip&&g===t||So(d,g);let m=t.ownerDocument;if((t===m.body||t===m.documentElement)&&m.documentElement.localName==="html"){let d=r.styleCache.get(m.documentElement)||O(m.documentElement);t===m.documentElement&&(s.style.overflow="visible");let g=t===m.body?s:s.querySelector("body");if(g&&d.overflowX==="visible"&&d.overflowY==="visible"&&d.contain==="none"&&!d.containerType?.includes("size")&&d.contentVisibility!=="auto"&&d.contentVisibility!=="hidden"){let y=r.styleCache.get(m.body)||O(m.body);y.contain==="none"&&!y.containerType?.includes("size")&&y.contentVisibility!=="auto"&&y.contentVisibility!=="hidden"&&y.display!=="none"&&(g.style.overflow="visible")}}if(t===r.nodeMap.get(s)){let d=r.styleCache.get(t)||O(t);r.styleCache.set(t,d);let g=vr(d.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=g||"",s.style.translate="none"}for(let[d,g]of r.nodeMap.entries())g.tagName==="PRE"&&(d.style.marginTop="0",d.style.marginBlockStart="0");return{clone:s,classCSS:a,classPrefixCSS:h,styleCache:r.styleCache,nodeMap:r.nodeMap,reconcileRisk:r.reconcileRisk||0,clipWindow:i}}function Vf(t,e,n){let r=[];for(let s of[":modal",":popover-open"])try{r.push(...t.querySelectorAll(s))}catch{}if(!r.length)return;let i=new Map;for(let[s,a]of n.entries())i.set(a,s);let o=214748e4;for(let s of r){let a=i.get(s);if(!(!a||a===e||a.parentNode==null)){try{let c=getComputedStyle(s,"::backdrop"),f=c.backgroundColor,l=c.backgroundImage;if(f&&f!=="rgba(0, 0, 0, 0)"&&f!=="transparent"||l&&l!=="none"){let p=document.createElement("div");p.setAttribute("data-sd-backdrop",""),p.style.cssText=`position:fixed;inset:0;z-index:${o};background-color:${f};`+(l&&l!=="none"&&l.includes("data:")?`background-image:${l};`:""),e.appendChild(p)}}catch{}o+=1,a.style.zIndex=String(o),e.appendChild(a),o+=1}}}function wo(t,e,n){if(t.tagName==="STYLE")return;if(t.getRootNode&&Wt(t.getRootNode())){t.setAttribute("style",e.replace(/;/g,"; "));return}let r=n.get(e);r&&t.classList.add(r);let i=t.style?.backgroundImage,o=t.dataset?.snapdomHasIcon;i&&i!=="none"&&(t.style.backgroundImage=i),o&&(t.style.verticalAlign="middle",t.style.display="inline")}function So(t,e){let n=e.scrollLeft,r=e.scrollTop;if(!(n||r)||t?.nodeType!==1||t.namespaceURI!=="http://www.w3.org/1999/xhtml")return;t.style.overflow="hidden",t.style.scrollbarWidth="none",t.style.msOverflowStyle="none";try{let s=t.querySelectorAll("*");for(let a of s){if(a.nodeType!==1||a.namespaceURI!=="http://www.w3.org/1999/xhtml")continue;let c=a.style.position;if(c==="fixed"||c==="absolute"){let f=parseFloat(a.style.top)||0,l=parseFloat(a.style.left)||0;a.style.top=`${f+r}px`,a.style.left=`${l+n}px`,c==="fixed"&&(a.style.position="absolute")}}}catch{}let o=document.createElement("div");for(o.style.all="unset",o.style.transform=`translate(${-n}px, ${-r}px)`,o.style.willChange="transform",o.style.display="inline-block",o.style.width="100%";t.firstChild;)o.appendChild(t.firstChild);t.appendChild(o)}Se();ne();mt();var js="http://www.w3.org/1999/xlink";function qf(t){return t.getAttribute("href")||t.getAttribute("xlink:href")||(typeof t.getAttributeNS=="function"?t.getAttributeNS(js,"href"):null)}function Gf(t){let e=parseFloat(t.dataset?.snapdomWidth||"")||0,n=parseFloat(t.dataset?.snapdomHeight||"")||0,r=parseInt(t.getAttribute("width")||"",10)||0,i=parseInt(t.getAttribute("height")||"",10)||0,o=parseFloat(t.style?.width||"")||0,s=parseFloat(t.style?.height||"")||0,a=e||o||r||t.width||t.naturalWidth||100,c=n||s||i||t.height||t.naturalHeight||100;return{width:a,height:c}}async function jn(t,e={}){let n=Array.from(t.querySelectorAll("img"));t.tagName==="IMG"&&n.unshift(t);let r=async a=>{if(!a.getAttribute("src")){let m=a.currentSrc||a.src||Pe(a.getAttribute("srcset"),a)||"";m&&a.setAttribute("src",m)}if(a.removeAttribute("srcset"),a.removeAttribute("sizes"),(a.getAttribute("src")||"").startsWith("data:")){a.width||(a.width=a.naturalWidth||100),a.height||(a.height=a.naturalHeight||100);return}let c=a.src||"";if(!c)return;let f=L.image?.get(c);if(f){a.src=f,a.width||(a.width=a.naturalWidth||100),a.height||(a.height=a.naturalHeight||100);return}let l=await dt(c,{as:"dataURL",useProxy:e.useProxy});if(l.ok&&typeof l.data=="string"&&l.data.startsWith("data:")){L.image?.set(c,l.data),a.src=l.data,l.blob&&(a.__snapdomBlob=l.blob),a.width||(a.width=a.naturalWidth||100),a.height||(a.height=a.naturalHeight||100);return}let{width:u,height:p}=Gf(a),{fallbackURL:h}=e||{};if(h)try{let m=typeof h=="function"?await h({width:u,height:p,src:c,element:a}):h;if(m){let d=await dt(m,{as:"dataURL",useProxy:e.useProxy});if(d?.ok&&typeof d.data=="string"){a.src=d.data,a.width||(a.width=u),a.height||(a.height=p);return}}}catch{}if(e.placeholders!==!1){At(e.__session,"image-fallback",`image failed to inline, using placeholder: ${c}`);let m=document.createElement("div");m.style.cssText=[`width:${u}px`,`height:${p}px`,"background:#ccc","display:inline-block","text-align:center",`line-height:${p}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:${u}px;height:${p}px;visibility:hidden;`,a.replaceWith(m)}},i=6;for(let a=0;a<n.length;a+=i){let c=n.slice(a,a+i).map(r);await Promise.allSettled(c)}let o=Array.from(t.querySelectorAll("image"));t.localName==="image"&&o.unshift(t);let s=async a=>{let c=qf(a);if(!c||c.startsWith("data:")||c.startsWith("blob:"))return;let f=await dt(c,{as:"dataURL",useProxy:e.useProxy});f.ok&&typeof f.data=="string"&&f.data.startsWith("data:")&&(a.setAttribute("href",f.data),a.removeAttribute("xlink:href"),typeof a.removeAttributeNS=="function"&&a.removeAttributeNS(js,"href"))};for(let a=0;a<o.length;a+=i){let c=o.slice(a,a+i).map(s);await Promise.allSettled(c)}}yt();bt();var Xf=["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"],Yf=["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"],Kf=["background-position","background-position-x","background-position-y","background-size","background-repeat","background-origin","background-clip","background-attachment","background-blend-mode"],Qf=["border-image-slice","border-image-width","border-image-outset","border-image-repeat"];async function Jf(t,e,n,r){let i=n.get(t)||O(t);n.has(t)||n.set(t,i);let o=Ai(t),s=o?m=>m in o?o[m]:"":m=>i.getPropertyValue(m),a=s("border-image"),c=s("border-image-source"),f=a&&a!=="none"||c&&c!=="none",l=i.getPropertyValue("background-image"),u=s("background-color"),p=l&&l!=="none"||u&&u!=="rgba(0, 0, 0, 0)"&&u!=="transparent"||/url\\s*\\(|gradient\\s*\\(/i.test(i.getPropertyValue("background")||""),h=$t()&&(s("background-clip")||s("-webkit-background-clip")||"").includes("text");if(p&&!h)for(let m of Kf){let d=s(m);d&&e.style.setProperty(m,d)}for(let m of Xf){if(h&&m==="background-image")continue;let d=i.getPropertyValue(m);if(m==="background-image"&&(!d||d==="none")){let b=i.getPropertyValue("background");b&&/url\\s*\\(/.test(b)&&(d=Gt(b).filter(S=>/url\\s*\\(/.test(S)).join(", ")||d)}if(!d||d==="none")continue;let g=Gt(d),y=await Promise.all(g.map(b=>xe(b,r)));y.some(b=>b&&b!=="none"&&!/^url\\(undefined/.test(b))&&e.style.setProperty(m,y.join(", "))}for(let m of Yf){let d=s(m);!d||d==="initial"||e.style.setProperty(m,d)}if(f)for(let m of Qf){let d=s(m);!d||d==="initial"||e.style.setProperty(m,d)}if(p&&/fixed/.test(s("background-attachment")||""))try{await tu(t,e,i)}catch{}}function Zf(t,e,n,r,i){let o=(t||"auto").trim();if(o==="cover"||o==="contain"){if(!e||!n)return{w:r,h:i};let p=o==="cover"?Math.max(r/e,i/n):Math.min(r/e,i/n);return{w:e*p,h:n*p}}let s=o.split(/\\s+/),a=(p,h)=>{if(p==="auto"||p===void 0)return null;if(p.endsWith("px"))return parseFloat(p);if(p.endsWith("%"))return h*parseFloat(p)/100},c=a(s[0],r),f=a(s[1],i);if(c===void 0||f===void 0)return null;let l=c,u=f;return l==null&&u==null?(l=e||r,u=n||i):l==null?l=e&&n?u*(e/n):r:u==null&&(u=e&&n?l*(n/e):i),!l||!u?null:{w:l,h:u}}async function tu(t,e,n){let r=(n.getPropertyValue("background-attachment")||"").split(",").map(m=>m.trim()),i=Ke();if(!i)for(let m=t.parentElement;m&&!i;m=m.parentElement){let d=O(m);(d.transform&&d.transform!=="none"||d.filter&&d.filter!=="none")&&(i=!0)}if(i){e.style.setProperty("background-attachment",r.map(()=>"scroll").join(", "));return}let o=t.getBoundingClientRect(),s=t.ownerDocument?.defaultView||window,a=s.innerWidth,c=s.innerHeight,f=Gt(e.style.backgroundImage||n.getPropertyValue("background-image")||""),l=(e.style.backgroundSize||n.getPropertyValue("background-size")||"auto").split(",").map(m=>m.trim()),u=(e.style.backgroundPosition||n.getPropertyValue("background-position")||"0% 0%").split(",").map(m=>m.trim()),p=[],h=[];for(let m=0;m<f.length;m++){let d=r[m%r.length]||"scroll",g=l[m%l.length],y=u[m%u.length];if(d!=="fixed"){p.push(g),h.push(y);continue}let b=0,S=0,k=f[m]&&f[m].match(/url\\(["\']?([^"\')]+)["\']?\\)/);if(k)try{let x=new Image;x.src=k[1],await x.decode(),b=x.naturalWidth,S=x.naturalHeight}catch{p.push(g),h.push(y);continue}let v=Zf(g,b,S,a,c);if(!v){p.push(g),h.push(y);continue}let w=y.split(/\\s+/),M=(x,_,R)=>{if(!x)return 0;if(x.endsWith("px"))return parseFloat(x);if(x.endsWith("%"))return(_-R)*parseFloat(x)/100},A=M(w[0]||"0%",a,v.w),C=M(w[1]||w[0]||"0%",c,v.h);if(A===void 0||C===void 0){p.push(g),h.push(y);continue}p.push(`${Vn(v.w)}px ${Vn(v.h)}px`),h.push(`${Vn(A-o.left)}px ${Vn(C-o.top)}px`)}e.style.setProperty("background-size",p.join(", ")),e.style.setProperty("background-position",h.join(", ")),e.style.setProperty("background-attachment",r.map(()=>"scroll").join(", "))}var Vn=t=>Math.round(t*100)/100;async function qn(t,e,n,r={},i=new Map){if(!e)return;let o=[];t&&qr(t)&&o.push([t,e]);let s=[e];for(;s.length;){let c=s.pop();if(c.children)for(let f of c.children){if(f.tagName==="STYLE")continue;let l=i.get(f);l&&qr(l)&&o.push([l,f]),s.push(f)}}let a=6;for(let c=0;c<o.length;c+=a)await Promise.allSettled(o.slice(c,c+a).map(([f,l])=>Jf(f,l,n,r)))}bt();function qs(t,e,n=new Map){let r=[],i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(let a=i.currentNode;a;a=i.nextNode()){let c=n.get(a);if(c?.nodeType!==1)continue;let f=O(c),l=f.getPropertyValue("backdrop-filter")||f.getPropertyValue("-webkit-backdrop-filter");l&&l!=="none"&&a!==e&&r.push({cloneEl:a,orig:c,bf:l,path:ou(e,a)})}if(!r.length)return;let o=t.getBoundingClientRect(),s=r.map((a,c)=>{let f=e.cloneNode(!0);ru(f,e,a.orig.getBoundingClientRect(),n),iu(Vs(f,a.path));for(let l=0;l<c;l++){let u=Vs(f,r[l].path);u&&(u.style.setProperty("backdrop-filter","none","important"),u.style.setProperty("-webkit-backdrop-filter","none","important"))}return{...a,copy:f}});for(let{cloneEl:a,orig:c,bf:f,copy:l}of s)eu.has(a.tagName)||nu(a,c,f,l,o)}var eu=new Set(["IMG","INPUT","TEXTAREA","SELECT","CANVAS","VIDEO","AUDIO","IFRAME","EMBED","OBJECT","PROGRESS","METER","HR","BR"]);function nu(t,e,n,r,i){let o=e.getBoundingClientRect();if(!o.width||!o.height)return;let s=O(e),a=e.offsetWidth?o.width/e.offsetWidth:1,c=Math.abs(a-1)>.001?1/a:1;r.style.position="absolute",r.style.left=`${(i.left-o.left)*c}px`,r.style.top=`${(i.top-o.top)*c}px`,r.style.width=`${i.width}px`,r.style.height=`${i.height}px`,r.style.margin="0",r.style.filter=n,c!==1&&(r.style.transform=`scale(${c})`,r.style.transformOrigin="top left");let f=document.createElement("div");f.style.cssText="position:absolute;inset:0;overflow:hidden;border-radius:inherit;z-index:-2",f.appendChild(r);let l=document.createElement("div");l.style.cssText="position:absolute;inset:0;border-radius:inherit;z-index:-1",l.style.backgroundColor=s.backgroundColor,l.style.backgroundImage=t.style.backgroundImage||s.backgroundImage;for(let u of["background-size","background-position","background-repeat","background-origin","background-clip"])l.style.setProperty(u,s.getPropertyValue(u));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"),s.position==="static"&&(t.style.position="relative"),t.style.isolation="isolate",t.prepend(l),t.prepend(f)}var Gn=128;function ru(t,e,n,r){let i=[[t,e]];for(;i.length;){let[o,s]=i.pop(),a=r.get(s);if(a?.nodeType===1){let l=a.getBoundingClientRect();(l.left>n.right+Gn||l.right<n.left-Gn||l.top>n.bottom+Gn||l.bottom<n.top-Gn)&&(o.tagName==="IMG"&&o.setAttribute("src","data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA="),o.style&&(o.style.backgroundImage="none"))}let c=o.children,f=s.children;for(let l=0;l<c.length;l++)i.push([c[l],f[l]])}}function ou(t,e){let n=[];for(let r=e;r!==t;r=r.parentElement){if(!r?.parentElement)return null;n.push([...r.parentElement.children].indexOf(r))}return n.reverse()}function Vs(t,e){if(!e)return null;let n=t;for(let r of e)if(n=n.children[r],!n)return null;return n}function iu(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}}bt();yt();mt();mt();function xo(t){return Qo(t),{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map,warnings:[]}}ne();function Yn(t,e){if(!t)return()=>{};let n=[],r=200;function i(o){if(e){let f=o.getBoundingClientRect();if(f.width>0||f.height>0){let l=Math.max(f.right,f.left+(o.scrollWidth||0)),u=Math.max(f.bottom,f.top+(o.scrollHeight||0));if(l<e.left-r||f.left>e.right+r||u<e.top-r||f.top>e.bottom+r)return}}let s=getComputedStyle(o),a=su(o,s);a&&n.push(a);let c=au(o,s);c&&n.push(c);for(let f of o.children||[])i(f)}return i(t),()=>n.forEach(o=>o())}function su(t,e){if(!t)return()=>{};e=e||getComputedStyle(t);let n=cu(e);if(n<=0)return()=>{};if(!Ys(t))return()=>{};let r=Xs(t),i=r.text,o=fu(e);r.write("X");let s=t.scrollHeight-o;r.restore();let a=s>0?s:lu(e),c=Math.round(a*n+o);if(t.scrollHeight<=c+.5)return()=>{};let f=0,l=i.length,u=-1;for(;f<=l;){let h=f+l>>1;r.write(i.slice(0,Xn(i,h))+"\\u2026"),t.scrollHeight<=c+.5?(u=h,f=h+1):l=h-1}let p=(u>=0?i.slice(0,Xn(i,u)):"")+"\\u2026";return r.write(p),Gs(t,p,r)}function au(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(!Ys(t))return()=>{};if(t.scrollWidth<=t.clientWidth+.5)return()=>{};let n=Xs(t),r=n.text,i=0,o=r.length,s=-1;for(;i<=o;){let c=i+o>>1;n.write(r.slice(0,Xn(r,c))+"\\u2026"),t.scrollWidth<=t.clientWidth+.5?(s=c,i=c+1):o=c-1}let a=(s>=0?r.slice(0,Xn(r,s)):"")+"\\u2026";return n.write(a),Gs(t,a,n)}function Gs(t,e,n){return()=>{t.textContent===e&&n.restore()}}function Xs(t){let e=[];for(let r=t.firstChild;r;r=r.nextSibling)r.nodeType===Node.TEXT_NODE&&e.push(r);let n=e.map(r=>r.data);return{text:n.join(""),write(r){e[0].data=r;for(let i=1;i<e.length;i++)e[i].data=""},restore(){for(let r=0;r<e.length;r++)e[r].data=n[r]}}}function Xn(t,e){if(e<=0||e>=t.length)return e;let n=t.charCodeAt(e-1);return n>=55296&&n<=56319?e-1:e}function cu(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 lu(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 fu(t){return(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0)}function Ys(t){return t.childElementCount>0?!1:Array.from(t.childNodes).some(e=>e.nodeType===Node.TEXT_NODE)}var Ks=["clone","render"],Kn={clone:0,render:1},_t="render";function Qs(t){let e=Array.isArray(t&&t.plugins)?t.plugins:[];if(!e.length)return{stage:_t,loweredBy:[]};let n=-1,r=[];for(let o of e){if(!o||typeof o!="object")continue;let s=o.needs===void 0?_t:o.needs;if(!Object.prototype.hasOwnProperty.call(Kn,s))throw new Error(`[snapdom] plugin \'${o.name||"(unnamed)"}\' declares needs: ${JSON.stringify(s)}, expected one of ${Ks.join(", ")}`);r.push({name:o.name||"(unnamed)",needs:s}),n=Math.max(n,Kn[s])}if(n<0)return{stage:_t,loweredBy:[]};let i=Ks[n];return{loweredBy:i===_t?[]:r.filter(o=>o.needs===i).map(o=>o.name),stage:i}}function Be(t,e){return Kn[t]>=Kn[e]}function Js(t,e,n){let r=e.length?e.map(i=>`\'${i}\'`).join(", "):"the attached plugins";return new Error(`[snapdom] no ${n}: this capture stopped at \'${t}\' because ${r} declared needs: \'${t}\' (result.needs says so too). It is not re-captured on demand \\u2014 that would be a different instant. Ask the plugin for needs: \'render\', or capture without it.`)}var ln=[];function fn(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 Zs(...t){let e=t.flat();for(let n of e){let r=fn(n);if(r){if(r.needs!==void 0&&r.needs!==_t)throw new Error(`[snapdom] global plugin \'${r.name||"(unnamed)"}\' declares needs: ${JSON.stringify(r.needs)}. A global plugin must run to \'${_t}\': lowering it here would stop EVERY capture in the app short of pixels. Pass it per capture instead: snapdom(el, { plugins: [<plugin>] }).`);ln.some(i=>i&&i.name&&r.name&&i.name===r.name)||ln.push(r)}}}function ta(t){return t&&Array.isArray(t.plugins)?t.plugins:ln}async function Bt(t,e,n){let r=n,i=ta(e);for(let o of i){let s=o&&typeof o[t]=="function"?o[t]:null;if(!s)continue;let a=await s(e,r);typeof a<"u"&&(r=a)}return r}async function Qn(t,e,n){let r=[],i=ta(e);for(let o of i){let s=o&&typeof o[t]=="function"?o[t]:null;if(!s)continue;let a=await s(e,n);typeof a<"u"&&r.push(a)}return r}var uu=0;function du(t){let e=[];if(Array.isArray(t))for(let n of t){let r=fn(n);if(!r)continue;r.name||(r.name=`anonymous-${++uu}`);let i=e.findIndex(o=>o&&o.name===r.name);i>=0&&e.splice(i,1),e.push(r)}for(let n of ln)n&&n.name&&!e.some(r=>r.name===n.name)&&e.push(n);return Object.freeze(e)}function ea(t,e,n=!1){return!t||t.plugins&&!n||(t.plugins=du(e)),t}function na(){return ln.slice()}var pu=["resolveNode","beforeSnap","beforeClone","afterClone","beforeRender","afterRender"];function Jn(t){let e=Array.isArray(t&&t.plugins)?t.plugins:[];for(let n of e){let r=fn(n);if(!(!r||r.pure===!0)){for(let i of pu)if(typeof r[i]=="function")return!0}}return!1}mt();Ae();var fe="data-snapdom-asset",sa="http://www.w3.org/1999/xlink",hu=0;function tr(t,e,n,r,i,o){let s=o.__compressedAssets||(o.__compressedAssets=new WeakMap),a=s.get(t);a||(a={token:String(++hu),properties:[]},s.set(t,a),t.setAttribute(fe,a.token));let c=a.properties.find(f=>f.kind===e&&f.name===n);c?(c.compressed!==r&&(c.original=r),c.compressed=i):a.properties.push({kind:e,name:n,original:r,compressed:i})}var aa=(t,e)=>e.kind==="style"?t.style?.getPropertyValue(e.name):t.getAttribute(e.name);function er(t,e){let n=new Map;if(!t||!e)return n;let r=[t,...t.querySelectorAll(`[${fe}]`)];for(let i of r){let o=e.get(i);if(!o||i.getAttribute(fe)!==o.token)continue;let s=o.properties.filter(a=>aa(i,a)===a.compressed).map(a=>Object.freeze({...a}));s.length&&n.set(o.token,Object.freeze(s))}return n}function nr(t,e){if(!t||!e)return;let n=0;for(let r of[t,...t.querySelectorAll(`[${fe}]`)]){let i=e.get(r);i&&(i.token=String(++n),r.setAttribute(fe,i.token))}}function ca(t,e){if(!e?.size||typeof t!="string"||!t.startsWith("data:image/svg+xml"))return t;let n=t.indexOf(","),r=new DOMParser().parseFromString(decodeURIComponent(t.slice(n+1)),"image/svg+xml");if(r.querySelector("parsererror"))return t;let i=!1;for(let o of r.querySelectorAll(`[${fe}]`))for(let s of e.get(o.getAttribute(fe))||[])aa(o,s)===s.compressed&&(s.kind==="style"?o.style.setProperty(s.name,s.original,o.style.getPropertyPriority(s.name)):s.name==="xlink:href"?o.setAttributeNS(sa,s.name,s.original):o.setAttribute(s.name,s.original),i=!0);return i?`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(r))}`:t}function ra(t){if(t.is2D===!1)return 1/0;let e=t.a*t.a+t.b*t.b+t.c*t.c+t.d*t.d,n=t.a*t.d-t.b*t.c;return Math.sqrt((e+Math.sqrt(Math.max(0,e*e-4*n*n)))/2)}function vo(t,e){let n=e.element||t,r=n.isConnected?O(n):n.style,i=e.__compressionClip,o=(h,m)=>{try{return h[m]?.baseVal?.value||0}catch{return 0}},s=i?.width||n.offsetWidth||parseFloat(r?.width)||o(n,"width"),a=i?.height||n.offsetHeight||parseFloat(r?.height)||o(n,"height"),c=Number.isFinite(e.width),f=Number.isFinite(e.height);if(!i&&(c||f)&&s&&a)try{let h=e.outerTransforms===!1&&e.__compressionRootTransform?e.__compressionRootTransform:Jt({baseTransform:r?.transform,rotate:r?.rotate,scale:r?.scale,width:s,height:a});if(h.is2D===!1)s=0,a=0;else{let m=Math.abs(h.a)*s+Math.abs(h.c)*a,d=Math.abs(h.b)*s+Math.abs(h.d)*a;s=Math.min(s,m),a=Math.min(a,d)}}catch{s=0,a=0}let l=(c||f?Math.max(c?s?e.width/s:1/0:0,f?a?e.height/a:1/0:0):e.scale||1)*(e.dpr||1);e.__compressionDensity=l;let u=new WeakMap,p=h=>{if(!h||h.nodeType!==1)return 1;if(u.has(h))return u.get(h);let m=h.isConnected?O(h):h.style,d=1;try{m?.perspective&&m.perspective!=="none"&&(d=1/0);let g=m?.transform;if(g&&g!=="none")d*=ra(new DOMMatrix(g));else if(h.transform?.baseVal?.numberOfItems){let y=new DOMMatrix;for(let b=0;b<h.transform.baseVal.numberOfItems;b++){let S=h.transform.baseVal.getItem(b).matrix;y=y.multiply(new DOMMatrix([S.a,S.b,S.c,S.d,S.e,S.f]))}d*=ra(y)}if(m?.scale&&m.scale!=="none"){let y=m.scale.trim().split(/\\s+/).map(b=>parseFloat(b)/(b.endsWith("%")?100:1));d*=Math.max(...y.map(Math.abs))}if(h!==n&&m?.zoom&&m.zoom!=="normal"&&(d*=parseFloat(m.zoom)||1),h.localName==="svg"&&h.viewBox?.baseVal?.width>0&&h.viewBox.baseVal.height>0){let y=h.viewBox.baseVal,b=v=>/^\\d+(?:\\.\\d+)?px$/.test(m?.[v]||"")?parseFloat(m[v]):o(h,v),S=b("width"),k=b("height");d*=S>0&&k>0?Math.max(S/y.width,k/y.height):1/0}}catch{d=1/0}return Number.isFinite(d)||(d=1/0),h!==n&&(d*=p(h.parentElement||h.getRootNode?.().host)),u.set(h,d),d};return{density:l,stretch:p}}var la=.92,fa=1;async function mu(t){let e=new Image;return e.decoding="sync",e.src=t,typeof e.decode=="function"?(await e.decode(),e):(await new Promise((n,r)=>{e.onload=()=>n(),e.onerror=r}),e)}function gu(t){let e=/^data:([^;,]+)/.exec(t);return e?e[1]:""}var yu=64*1024,oa=32*1024*1024,Zn=new Map;function bu(t,e,n,r){if(n.length+(r?.length||0)>oa)return;t.set(e,{source:n,result:r});let i=0;for(let o of t.values())i+=o.source.length+(o.result?.length||0);for(;i>oa;){let o=t.keys().next().value,s=t.get(o);i-=s.source.length+(s.result?.length||0),t.delete(o)}}function wu(t,e){let n=t.indexOf(",");if(n<0||!/;base64/i.test(t.slice(0,n)))return null;let r=Math.ceil(e/3)*4,i=t.length-n-1,o=Math.min(i,r);try{let s=atob(t.slice(n+1,n+1+o-o%4)),a=new Uint8Array(s.length);for(let c=0;c<s.length;c++)a[c]=s.charCodeAt(c);return a}catch{return null}}function Su(t){let e=wu(t,4096);if(!e||e.length<16)return null;let n=r=>e[r]<<8|e[r+1];if(e[0]===137&&e[1]===80&&e.length>=24)return{w:(e[16]<<24|e[17]<<16|e[18]<<8|e[19])>>>0,h:(e[20]<<24|e[21]<<16|e[22]<<8|e[23])>>>0};if(e[0]===71&&e[1]===73&&e[2]===70)return{w:e[6]|e[7]<<8,h:e[8]|e[9]<<8};if(e[0]===82&&e[1]===73&&e[8]===87&&e.length>=30){let r=e[15];if(r===32&&e[23]===157)return{w:(e[26]|e[27]<<8)&16383,h:(e[28]|e[29]<<8)&16383};if(r===76)return{w:(e[21]|(e[22]&63)<<8)+1,h:((e[22]>>6|e[23]<<2|(e[24]&15)<<10)&16383)+1};if(r===88)return{w:(e[24]|e[25]<<8|e[26]<<16)+1,h:(e[27]|e[28]<<8|e[29]<<16)+1}}if(e[0]===255&&e[1]===216){let r=2;for(;r+9<e.length;){if(e[r]!==255){r++;continue}let i=e[r+1];if(i===216||i===1||i>=208&&i<=215){r+=2;continue}if(i>=192&&i<=207&&i!==196&&i!==200&&i!==204)return{h:n(r+5),w:n(r+7)};let o=n(r+2);if(o<2)break;r+=2+o}}return null}function ia(t,e,n,r){let i=Math.min(1,Math.max(n/t,r/e));return!(i>0)||i>=.95?0:i}var xu=`self.onmessage = async (e) => {\n const { id, dataURL, blob: given, srcLength, targetW, targetH, resFactor, quality, mime } = e.data\n try {\n const blob = given || await (await fetch(dataURL)).blob()\n const bmp = await createImageBitmap(blob)\n const nw = bmp.width, nh = bmp.height\n if (!nw || !nh) { bmp.close(); self.postMessage({ id, url: null }); return }\n const raw = Math.min(1, Math.max(targetW / nw, targetH / nh))\n if (!(raw > 0) || raw >= 0.95) { bmp.close(); self.postMessage({ id, url: null }); return }\n const factor = raw * resFactor\n const ow = Math.max(1, Math.round(nw * factor))\n const oh = Math.max(1, Math.round(nh * factor))\n const canvas = new OffscreenCanvas(ow, oh)\n const ctx = canvas.getContext(\'2d\')\n ctx.imageSmoothingEnabled = true\n ctx.imageSmoothingQuality = \'high\'\n ctx.drawImage(bmp, 0, 0, ow, oh)\n bmp.close()\n const out = await canvas.convertToBlob({ type: mime, quality })\n const url = new FileReaderSync().readAsDataURL(out)\n self.postMessage({ id, url: (url && url.length < srcLength) ? url : null })\n } catch (err) {\n self.postMessage({ id, error: String(err) })\n }\n}`,vu=Math.max(1,Math.min(4,(typeof navigator<"u"&&navigator.hardwareConcurrency||2)-1)),Lt=null,ku=0,Cu=0,le=new Map;function ua(){for(let t of le.values())t(void 0);if(le.clear(),Array.isArray(Lt))for(let t of Lt)try{t?.terminate()}catch{}Lt=!1}function Au(){let t,e=null;try{t=URL.createObjectURL(new Blob([xu],{type:"text/javascript"})),e=new Worker(t),e.onmessage=n=>{let r=le.get(n.data.id);r&&(le.delete(n.data.id),r(n.data.error?void 0:n.data.url??null))},e.onerror=ua}catch{e=null}return t&&URL.revokeObjectURL(t),e}function Mu(){if(Lt===!1)return!1;if(Lt===null){if(typeof Worker>"u"||typeof OffscreenCanvas>"u")return Lt=!1;Lt=[]}let t=ku++%vu;if(!Lt[t]){let e=Au();if(!e)return ua(),!1;Lt[t]=e}return Lt[t]}var _u=5e3;function Eu(t,e,n,r,i){let o=Mu();return o?new Promise(s=>{let a=++Cu,c=setTimeout(()=>{le.delete(a),s(void 0)},_u);le.set(a,f=>{clearTimeout(c),s(f)});try{o.postMessage({id:a,dataURL:i?"":t,blob:i,srcLength:t.length,targetW:e,targetH:n,resFactor:fa,quality:la,mime:r})}catch{clearTimeout(c),le.delete(a),s(void 0)}}):Promise.resolve(void 0)}async function ko(t,e,n,r){if(typeof t!="string"||!t.startsWith("data:image")||t.startsWith("data:image/svg"))return null;e=Math.ceil(e),n=Math.ceil(n);let i=t.length+":"+t.slice(0,64)+t.slice(-64)+":"+e+"x"+n,o=L.compress,s=o.get(i);if(s?.source===t)return s.result;let a=Zn.get(i);if(a?.source===t&&a.cache===o)return a.promise;let c=(async()=>{let l=gu(t),u=l==="image/jpeg"?"image/jpeg":l==="image/webp"?"image/webp":"image/png",p=Su(t);if(p&&p.w>0&&p.h>0&&!ia(p.w,p.h,e,n))return null;if(t.length>=yu){let w=await Eu(t,e,n,u,r);if(w!==void 0)return w}let h;try{h=await mu(t)}catch{return null}let m=h.naturalWidth||h.width,d=h.naturalHeight||h.height;if(!m||!d)return null;let g=ia(m,d,e,n);if(!g)return null;let y=g*fa,b=Math.max(1,Math.round(m*y)),S=Math.max(1,Math.round(d*y)),k=document.createElement("canvas");k.width=b,k.height=S;let v=k.getContext("2d");if(!v)return null;v.imageSmoothingEnabled=!0,v.imageSmoothingQuality="high",v.drawImage(h,0,0,b,S);try{let w=k.toDataURL(u,la);if(typeof w=="string"&&w.startsWith("data:image")&&w.length<t.length)return w}catch{}return null})(),f={source:t,promise:c,cache:o};Zn.set(i,f);try{let l=await c;return bu(o,i,t,l),l}finally{Zn.get(i)===f&&Zn.delete(i)}}async function Ru(t,e,n=new Map,r={}){if(!e.compress)return{count:0,before:0,after:0};let i=Array.from(t.querySelectorAll("img"));t.tagName==="IMG"&&i.unshift(t);let o=0,s=0,a=0,c=async l=>{let u=l.getAttribute("src")||"";if(!u.startsWith("data:image")||u.startsWith("data:image/svg"))return;let p=parseFloat(l.dataset.snapdomWidth)||parseFloat(l.style.width)||l.width||0,h=parseFloat(l.dataset.snapdomHeight)||parseFloat(l.style.height)||l.height||0;if(!p||!h)return;let m=r.value||(r.value=vo(t,e)),d=m.density*m.stretch(n.get(l)||l),g=await ko(u,p*d,h*d,l.__snapdomBlob);g&&(o++,s+=u.length,a+=g.length,l.setAttribute("src",g),tr(l,"attribute","src",u,g,e))},f=6;for(let l=0;l<i.length;l+=f)await Promise.allSettled(i.slice(l,l+f).map(c));return{count:o,before:s,after:a}}var Fu=/^(cover|contain|(\\d+(\\.\\d+)?%(\\s+\\d+(\\.\\d+)?%)?))$/;function Tu(t){let e=t.offsetWidth||t.getBoundingClientRect().width||0,n=t.offsetHeight||t.getBoundingClientRect().height||0;return{w:e,h:n}}async function $u(t,e,n=new Map,r={}){if(!e.compress)return{count:0};let i=[],o=[t,...t.querySelectorAll("*")];for(let f of o){let l=f.style&&f.style.backgroundImage;l&&l.includes("data:image")&&i.push(f)}let s=0,a=async f=>{let l=n.get(f);if(!l||!l.isConnected)return;let u;try{u=getComputedStyle(l)}catch{return}if((u.backgroundRepeat||"repeat").toLowerCase().split(",").some(A=>A.trim()!=="no-repeat"))return;let h=(f.style.backgroundSize||u.backgroundSize||"auto").toLowerCase();if(h.split(",").some(A=>!Fu.test(A.trim())))return;let{w:m,h:d}=Tu(l);if(!m||!d)return;let g=Math.max(1,...(h.match(/\\d+(?:\\.\\d+)?%/g)||[]).map(A=>parseFloat(A)/100)),y=r.value||(r.value=vo(t,e)),b=y.density*y.stretch(l)*g,S=m*b,k=d*b,v=f.style.backgroundImage,w=[...v.matchAll(/url\\(([\'"]?)(data:image\\/[^)\'"]+)\\1\\)/gi)],M=v;for(let A of w){let C=A[2];if(C.startsWith("data:image/svg"))continue;let x=await ko(C,S,k);x&&(M=M.split(C).join(x),s++)}M!==v&&(f.style.setProperty("background-image",M,f.style.getPropertyPriority("background-image")),tr(f,"style","background-image",v,f.style.backgroundImage,e))},c=6;for(let f=0;f<i.length;f+=c)await Promise.allSettled(i.slice(f,f+c).map(a));return{count:s}}async function Pu(t,e,n=new Map,r={}){if(!e.compress)return{count:0};let i=Array.from(t.querySelectorAll("image"));t.localName==="image"&&i.unshift(t);let o=0,s=async c=>{let f=c.getAttribute("href")||(typeof c.getAttributeNS=="function"?c.getAttributeNS("http://www.w3.org/1999/xlink","href"):null);if(!f||!f.startsWith("data:image")||f.startsWith("data:image/svg"))return;let l=c.getAttribute("width")||"",u=c.getAttribute("height")||"";if(l.includes("%")||u.includes("%"))return;let p=n.get(c),h=p?O(p):c.style,m=(k,v)=>{if(/^\\d+(?:\\.\\d+)?px$/.test(h?.[k]||""))return parseFloat(h[k]);if(/^\\d+(?:\\.\\d+)?(?:px)?$/.test(v.trim()))return parseFloat(v);try{return p?.[k]?.baseVal?.value||0}catch{return 0}},d=m("width",l),g=m("height",u);if(!d||!g)return;let y=r.value||(r.value=vo(t,e)),b=y.density*y.stretch(p||c),S=await ko(f,d*b,g*b);S&&(c.setAttribute("href",S),tr(c,"attribute","href",f,S,e),c.hasAttribute("xlink:href")&&(c.setAttributeNS(sa,"xlink:href",S),tr(c,"attribute","xlink:href",f,S,e)),o++)},a=6;for(let c=0;c<i.length;c+=a)await Promise.allSettled(i.slice(c,c+a).map(s));return{count:o}}async function rr(t,e,n){if(!e.compress)return;let r={};await Ru(t,e,n,r),await $u(t,e,n,r),await Pu(t,e,n,r)}bt();mt();Ct();function Nu(t,e){if(X())return t;let n=t.indexOf("</style>");if(n===-1)return t;let r=/<style\\b[^>]*>[\\s\\S]*?<\\/style>/g,i=[],o=n,s;for(r.lastIndex=n;s=r.exec(t);)i.push({text:t.slice(o,s.index),intern:!0}),i.push({text:s[0],intern:!1}),o=r.lastIndex;i.push({text:t.slice(o),intern:!0});let a=new Map,c=/ style="([^"]*)"/g,f;for(let y of i)if(y.intern)for(c.lastIndex=0;f=c.exec(y.text);)a.set(f[1],(a.get(f[1])||0)+1);let l=0;for(let[y,b]of a)b>1&&(l+=(b-1)*y.length);if(l<2048||t.includes(" data-sdi="))return t;let u=Lu(e,i.some(y=>!y.intern),t.includes("data-snapdom-asset"));if(u===null)return t;let p=new Map,h=0,m=[],d=(y,b)=>{if((a.get(b)||0)<2||u.has(b))return y;let S=p.get(b);return S===void 0&&(S="i"+(h++).toString(36),p.set(b,S),m.push(`[data-sdi="${S}"]{${b}}`)),` data-sdi="${S}"`},g="";for(let y of i)g+=y.intern?y.text.replace(c,d):y.text;return t.slice(0,n)+m.join("")+g}function Lu(t,e,n){let r=new Set;if(!e&&!n)return r;if(!t||t.querySelector("[data-sdi]"))return null;let i=c=>{let f=c.getAttribute("style");f&&r.add(f)};if(n&&t.querySelectorAll("[data-snapdom-asset][style]").forEach(i),e)try{let c=f=>{for(let l of f){if(l.type===CSSRule.IMPORT_RULE||l.type===CSSRule.NAMESPACE_RULE)throw new Error("External or namespaced CSS");if(l.selectorText){if(/\\[\\s*style\\b|data-sdi|\\[[^\\]]*\\\\|&/i.test(l.selectorText))throw new Error("Attribute-dependent or nested CSS");t.querySelectorAll(l.selectorText).forEach(i)}l.cssRules&&c(l.cssRules)}};for(let f of[...t.querySelectorAll("style")].slice(1)){let l=f.textContent||"";if(/@import\\b/i.test(l))return null;let u=new CSSStyleSheet;u.replaceSync(l),c(u.cssRules)}}catch{return null}let o=new Set,s=document.createElement("div"),a=new XMLSerializer;for(let c of r){s.setAttribute("style",c);let f=a.serializeToString(s).match(/ style="([^"]*)"/);f&&o.add(f[1])}return o}async function or(t,e){let{clipWindow:n,outerTransforms:r,outerShadows:i,rootTransform2D:o,fontsCSS:s}=e,a=t.options;if(t!==a){let{options:Q,...et}=t;t=Object.assign(a,et),Object.defineProperty(t,"options",{value:t,configurable:!0})}let c,f;zs(t,s),await Bt("beforeRender",t);let l=O(t.element),u=t.element.getBoundingClientRect(),p=Math.max(1,W(t.element.offsetWidth||parseFloat(l.width)||u.width||1)),h=Math.max(1,W(t.element.offsetHeight||parseFloat(l.height)||u.height||1)),m=t.element.ownerDocument||document;if(!n&&(t.element===m.body||t.element===m.documentElement)&&!t.__pinned){let Q=Math.max(t.element.scrollHeight||0,m.documentElement?.scrollHeight||0,m.body?.scrollHeight||0),et=Math.max(t.element.scrollWidth||0,m.documentElement?.scrollWidth||0,m.body?.scrollWidth||0);Q>0&&(h=Math.max(h,W(Q))),et>0&&(p=Math.max(p,W(et)));try{let Z=(t.scrollbarCSS||"").length+(t.baseCSS||"").length+(t.fontsCSS||"").length+(t.classCSS||"").length,ot=L.measureHints.get(t.element);if(ot&&ot.cssLen===Z&&ot.w0===p&&ot.docH===Q&&ot.docW===et)ot.csh>0&&(h=Math.max(h,W(ot.csh))),ot.csw>0&&(p=Math.max(p,W(ot.csw)));else{let it=m.createElement("div");tt(it),it.style.cssText="position:absolute!important;left:-9999px!important;top:0!important;width:"+p+"px!important;overflow:visible!important;visibility:hidden!important;";let Zt=it.attachShadow({mode:"open"}),te=m.createElement("style");te.textContent=(t.scrollbarCSS||"")+t.baseCSS+"svg{overflow:visible;} foreignObject{overflow:visible;}"+t.classCSS,Zt.appendChild(te),Zt.appendChild(t.clone.cloneNode(!0)),m.body.appendChild(it);let Ve=it.scrollHeight,jt=it.scrollWidth;m.body.removeChild(it),L.measureHints.set(t.element,{cssLen:Z,w0:p,docH:Q,docW:et,csh:Ve,csw:jt}),Ve>0&&(h=Math.max(h,W(Ve))),jt>0&&(p=Math.max(p,W(jt)))}}catch{}}if(t.options?.excludeMode==="remove"||typeof t.options?.filter=="function"&&t.options.filterMode==="remove"){let Q=bo(t.element,t.options),et=1,Z=bo(t.element,{}),ot=Math.max(2,h*.15);Number.isFinite(Z)&&Z>=h-ot&&Number.isFinite(Q)&&Q>0&&(h=Math.max(1,Math.min(h,W(Q+et))))}if(t.options?.reconcile)try{let Q=(t.scrollbarCSS||"")+t.baseCSS+"svg{overflow:visible;} foreignObject{overflow:visible;}"+t.classCSS;Us(t.element,t.clone,Q,t.nodeMap,p,h)}catch(Q){console.warn("[snapdom] reconcile pass failed:",Q)}let g=(Q,et=NaN)=>{let Z=typeof Q=="string"?parseFloat(Q):Q;return Number.isFinite(Z)?Z:et},y=g(t.options.width),b=g(t.options.height),S=n?W(n.width):p,k=n?W(n.height):h,v=S,w=k,M=Number.isFinite(y),A=Number.isFinite(b),C=k>0?S/k:1;M&&A?(v=Math.max(1,W(y)),w=Math.max(1,W(b))):M?(v=Math.max(1,W(y)),w=Math.max(1,W(v/(C||1)))):A&&(w=Math.max(1,W(b)),v=Math.max(1,W(w*(C||1))));let x=0,_=0,R=p,$=h;if(n){let Q=0,et=0;if(Co(t.element)){let Z=null;if(!r&&o&&Number.isFinite(o.a))Z={a:o.a,b:o.b||0,c:o.c||0,d:o.d||1,e:0,f:0};else{let ot=ce(t.element),it=yo(l.transform&&l.transform!=="none"?l.transform:"",ot);it&&it.is2D&&(Z={a:it.a,b:it.b,c:it.c,d:it.d,e:0,f:0})}if(Z&&!(Z.a===1&&Z.b===0&&Z.c===0&&Z.d===1)){let{ox:ot,oy:it}=cn(l,p,h),Zt=Oe(p,h,Z,ot,it);Q=Zt.minX,et=Zt.minY}}x=W(n.x+Q),_=W(n.y+et),R=W(x+n.width),$=W(_+n.height)}else if(!r&&o&&Number.isFinite(o.a)){let Q={a:o.a,b:o.b||0,c:o.c||0,d:o.d||1,e:0,f:0},et=Oe(p,h,Q,0,0);x=W(et.minX),_=W(et.minY),R=W(et.maxX),$=W(et.maxY)}else if(r&&Co(t.element)){let et=l.transform&&l.transform!=="none"?l.transform:"",Z=ce(t.element),ot=Jt({baseTransform:et,rotate:Z.rotate||"0deg",scale:Z.scale,translate:Z.translate,width:p,height:h}),{ox:it,oy:Zt}=cn(l,p,h),te=ot.is2D?ot:new DOMMatrix(ot.toString()),Ve={a:te.a,b:te.b,c:te.c,d:te.d,e:0,f:0},jt=Oe(p,h,Ve,it,Zt);x=W(jt.minX),_=W(jt.minY),R=W(jt.maxX),$=W(jt.maxY)}let T=lo(l),I=fo(l),B=uo(l),E=po(l),N=ho(l),P=u.width>0?(R-x)/u.width:1,F=u.height>0?($-_)/u.height:1,z=i==="subtree"&&!n?Rs(t.element,t.nodeMap,t.styleCache,P,F):{top:0,right:0,bottom:0,left:0},V=n?{top:0,right:0,bottom:0,left:0}:i?{top:W(Math.max(T.top,I.top,z.top)+B.top+E.top+N.bleed.top),right:W(Math.max(T.right,I.right,z.right)+B.right+E.right+N.bleed.right),bottom:W(Math.max(T.bottom,I.bottom,z.bottom)+B.bottom+E.bottom+N.bleed.bottom),left:W(Math.max(T.left,I.left,z.left)+B.left+E.left+N.bleed.left)}:{top:B.top,right:B.right,bottom:B.bottom,left:B.left};x=W(x-V.left),_=W(_-V.top),R=W(R+V.right),$=W($+V.bottom);let j=Math.max(1,W(R-x)),D=Math.max(1,W($-_)),K="http://www.w3.org/2000/svg",ht=Co(t.element)?2:0,ft=W(ht+(r?0:1)),at=Math.ceil(j+ft*2),ct=Math.ceil(D+ft*2),xt=W(-(W(x)-ft)),U=W(-(W(_)-ft)),G=Math.max(0,xt),q=Math.max(0,U),nt=W(at-Math.min(0,xt)),rt=W(ct-Math.min(0,U)),me=m.defaultView||window,J=!X()&&CSS.supports("zoom","2")&&me.devicePixelRatio||1,vt=document.createElementNS(K,"foreignObject");vt.setAttribute("x",String(Math.min(0,xt)*J)),vt.setAttribute("y",String(Math.min(0,U)*J)),vt.setAttribute("width",String(nt*J)),vt.setAttribute("height",String(rt*J)),vt.style.overflow="visible";let br=document.createElement("style"),ge="svg{overflow:visible;} foreignObject{overflow:visible;} foreignObject>div{-webkit-text-size-adjust:100%!important;text-size-adjust:100%!important;}";br.textContent=(t.scrollbarCSS||"")+t.baseCSS+t.fontsCSS+ge+t.classCSS,vt.appendChild(br);let ye=document.createElement("div");ye.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),ye.style.cssText=`all:initial;box-sizing:border-box;display:block;overflow:visible;width:${nt}px;height:${rt}px`+(G!==0||q!==0?`;padding:${q}px 0 0 ${G}px !important`:"")+(J!==1?`;zoom:${J} !important`:""),ye.appendChild(t.clone),vt.appendChild(ye);let wr=new XMLSerializer().serializeToString(vt),mn=M||A,gn=Object.freeze({w0:S,h0:k,vbW:at,vbH:ct,targetW:v,targetH:w,contentX:W(xt+(n?x:0)),contentY:W(U+(n?_:0)),clip:n?Object.freeze({x:W(x),y:W(_),width:S,height:k}):null});Object.defineProperty(a,"meta",{value:gn,enumerable:!0,writable:!1,configurable:!0});let Ht=!mn||X()?at:M?v:W(at*(w/ct)),tc=!mn||X()?ct:A?w:W(ct*(v/at)),ec=parseFloat(O(m.documentElement)?.fontSize)||16,Yo=J!==1,nc=`<svg xmlns="${K}" width="${Ht}" height="${tc}" viewBox="0 0 ${at} ${ct}" font-size="${ec}px">${Yo?`<g transform="scale(${1/J})">`:""}`,rc=Yo?"</g></svg>":"</svg>";f=nc+Nu(wr,vt)+rc,c=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(f)}`,t.svgString=f,t.dataURL=c,a.__artifacts={classCSS:t.classCSS||"",fontsCSS:t.fontsCSS||"",baseCSS:t.baseCSS||"",scrollbarCSS:t.scrollbarCSS||""},await Bt("afterRender",t),t.clone=t.nodeMap=t.styleCache=t.svgString=null;let Sr=[...document.querySelectorAll("#snapdom-sandbox")].find(qt);return Sr&&Sr.style.position==="absolute"&&Sr.remove(),t.dataURL}function Co(t){return Ts(t)}function Iu(t){let e=Array.isArray(t.plugins)?t.plugins:na(),n=[];for(let r of e){let i=fn(r);i&&typeof i.resolveNode=="function"&&n.push(i.resolveNode.bind(i))}return n.length?n:null}async function da(t,e){if(!t)throw new Error("Element cannot be null or undefined");e.__session=xo(e.cache),delete e.__compressedAssets,delete e.__compressedSnapshot,delete e.__compressionDensity,e.__resolveNodeHooks=Iu(e);let n=e;n.element=t,Object.defineProperty(n,"options",{value:n,configurable:!0});let r,i,o,s,a,c,f,l="",u=null,p=e.needs||_t,h=n.format,m=n.type;await Bt("beforeSnap",n);let d=n.format!==h&&/^(?:png|jpe?g|webp|svg)$/i.test(n.format),g=n.type!==m&&/^(?:png|jpe?g|webp|svg)$/i.test(n.type);if(d||g){let R=String(d?n.format:n.type).toLowerCase();n.format=R==="jpg"?"jpeg":R,n.type=n.format,n.__explicitFormat=n.format,/^(?:jpeg|webp)$/.test(n.format)&&(n.backgroundColor==null||n.backgroundColor==="transparent")&&(n.backgroundColor="#ffffff")}await Bt("beforeClone",n);let y=n.outerTransforms!==!1,b=n.outerShadows==="subtree"?"subtree":!!n.outerShadows,S=n.clip?Un(n.element,n.clip):null;if(e.__styleShare===void 0)try{e.__styleShare=Mi(n.element)&&(typeof n.element.getAnimations!="function"||n.element.getAnimations({subtree:!0}).length===0)}catch{e.__styleShare=!1}let k=mi(e.fast);for(;;){e.__slicer=k;let R=Yn(n.element,S);try{({clone:r,classCSS:i,classPrefixCSS:o,styleCache:s,nodeMap:a,reconcileRisk:c,clipWindow:f}=await Hs(n.element,n.options)),c>0&&!e.reconcile&&(At(e.__session,"reconcile-risk","text in inline/table-cell elements kept natural width and may re-wrap; pass { reconcile: true } for pixel-exact layout"),L.warnedReconcile||(L.warnedReconcile=!0,console.warn("[snapdom] Inline/table text may re-wrap with fallback fonts. Use { reconcile: true } to check layout (~2x capture time)."))),!y&&r&&(u=Fs(n.element,r)),!b&&r&&Ws(n.element,r,n.options),r&&(Ds(n.element,r,a),Os(n.element,r))}finally{R()}if(!k?.yielded||!e.__tornSinceStart?.())break;k=null,e.__session=xo(e.cache)}if(e.__slicer=null,n.clone=r,n.classCSS=i,n.styleCache=s,n.nodeMap=a,await Bt("afterClone",n),!Be(p,"render"))return null;if(k?.due()&&await k.pause(),zn(n.clone),n.options?.excludeMode==="remove"||typeof n.options?.filter=="function"&&n.options.filterMode==="remove")try{Bs(n.element,n.clone,n.styleCache,n.nodeMap)}catch(R){At(e.__session,"shrink-failed","shrink pass failed",R),console.warn("[snapdom] shrink pass failed:",R)}try{await $n(n.clone,n.element,n.nodeMap)}catch{}let v=R=>Promise.resolve().then(R),w=(async()=>{await Promise.all([v(()=>jn(n.clone,n.options)),v(()=>qn(n.element,n.clone,n.styleCache,n.options,n.nodeMap))]);try{qs(n.element,n.clone,n.nodeMap)}catch(R){At(e.__session,"backdrop-filter-failed","backdrop-filter emulation failed",R),console.warn("[snapdom] backdrop-filter emulation failed:",R)}if(e.compress&&(e.__compressionClip=f,e.__compressionRootTransform=u,await v(()=>rr(n.clone,n.options,n.nodeMap))),e.captureSelection)try{Zi(n.nodeMap)}catch(R){At(e.__session,"selection-compose-failed","field selection compose failed",R)}})(),M=Promise.resolve();(e.embedFonts==="auto"?((n.element.ownerDocument||document).fonts?.size||0)>0:e.embedFonts)&&(M=v(async()=>{let R=n.element.ownerDocument||document,$=S?B=>{try{let E=B.getBoundingClientRect();return E.right>=S.left-200&&E.left<=S.right+200&&E.bottom>=S.top-200&&E.top<=S.bottom+200}catch{return!0}}:null,{required:T,usedCodepoints:I}=!S&&e.__fontUsage||In(n.element,$);if(e.embedFonts==="auto"){let B=new Set;try{for(let N of R.fonts)B.add(String(N.family).replace(/["\']/g,"").toLowerCase())}catch{}if(!(B.size>0&&Array.from(T).some(N=>B.has(String(N).split("__")[0].toLowerCase()))))return}if(X()){let B=new Set(Array.from(T).map(E=>String(E).split("__")[0]).filter(Boolean));await Wn(B,1,R)}l=await ps({required:T,usedCodepoints:I,exclude:n.options.excludeFonts,localFonts:n.options.localFonts,useProxy:n.options.useProxy,fontStylesheetDomains:n.options.fontStylesheetDomains,iconMatchers:n.options.__iconMatchers,doc:R})})),await Promise.all([w,M]);let C=(n.options.plugins||[]).some(R=>R&&(typeof R.beforeRender=="function"||typeof R.afterRender=="function"));n.options.engine,k?.due()&&await k.pause();let x=n.clone;nr(x,e.__compressedAssets);let _=await or(n,{clipWindow:f,outerTransforms:y,outerShadows:b,rootTransform2D:u,fontsCSS:l});if(e.__compressedSnapshot=er(x,e.__compressedAssets),typeof e.__retain=="function")try{e.__retain({clone:r,nodeMap:a,styleCache:s,styleMap:e.__session.styleMap,classPrefixCSS:o,fontsCSS:l,clipWindow:f,outerTransforms:y,outerShadows:b,rootTransform2D:u,__compressedAssets:e.__compressedAssets,__compressionDensity:e.__compressionDensity})}catch{}return _}mt();kt();var Wu=new Set(["png","jpeg","jpg","webp","svg"]);function pa(t={}){let e=typeof t.type=="string"&&Wu.has(t.type.toLowerCase())?t.type.toLowerCase():null,n=t.format??e??"png";n==="jpg"&&(n="jpeg");let r=t.format!=null?n:e==="jpg"?"jpeg":e,i=Ko(t.cache),o=t.exclude==null?[]:Array.isArray(t.exclude)?t.exclude:[t.exclude],s=[],a=[];for(let u of o)typeof u=="string"?s.push(u):typeof u=="function"?a.push(u):u!=null&&console.warn("[snapdom] Invalid exclude entry; expected selector or predicate:",u);let c=t.excludeMode??"hide",f=u=>{if(!u||u.nodeType!==1)return!1;if(u.getAttribute("data-capture")==="exclude")return!0;for(let p of Array.isArray(l.exclude)?l.exclude:[])try{if(u.matches(p))return!0}catch{}for(let p of Array.isArray(l.excludePredicates)?l.excludePredicates:[])try{if(p(u))return!0}catch{}if(typeof l.filter=="function")try{if(!l.filter(u))return!0}catch{}return!1},l={debug:t.debug??!1,scale:t.scale??1,exclude:s,excludePredicates:a.length?a:null,excludeMode:c,filter:t.filter??null,filterMode:t.filterMode??"hide",shouldExclude:f,placeholders:t.placeholders!==!1,captureSelection:t.captureSelection??!1,canvas:st(t.canvas,"canvas")?t.canvas:null,embedFonts:t.embedFonts??"auto",iconFonts:Array.isArray(t.iconFonts)?t.iconFonts:t.iconFonts?[t.iconFonts]:[],__iconMatchers:rs(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:i,__styleShare:t.__styleShare,useProxy:typeof t.useProxy=="string"?t.useProxy:"",width:t.width??null,height:t.height??null,format:n,__explicitFormat:r,type:n,quality:t.quality??.92,dpr:t.dpr??(window.devicePixelRatio||1),backgroundColor:t.backgroundColor??(["jpeg","webp"].includes(n)?"#ffffff":null),filename:t.filename??"snapDOM",outerTransforms:t.outerTransforms??!0,outerShadows:t.outerShadows??!1,reconcile:t.reconcile??!1,burst:t.burst,fast:t.fast===!1||t.fast==="auto"?t.fast:!0,engine:t.engine,invalidate:t.invalidate??!1,__pinned:t.__pinned===!0,clip:t.clip??null,compress:t.compress!==!1,excludeStyleProps:t.excludeStyleProps??null,resolvePicturePlaceholders:t.resolvePicturePlaceholders!==!1};return l}yt();ne();bt();var ha="svg,iframe,canvas,video,audio,object,embed,slot,template,picture,style,pre";function Ou(t){try{return t.matches?.("dialog,[popover]")||!!t.querySelector?.("dialog,[popover]")}catch{return!0}}var Du=/(?:^|;)\\s*(?:-webkit-)?backdrop-filter:\\s*(?!none(?:\\s*!important)?(?:;|$))[^;]+/i;function Bu(t){if(t.__usesBackdropFilter!==void 0)return t.__usesBackdropFilter;let e=!1;for(let n of t.styleMap.values())if(Du.test(n)){e=!0;break}return t.__usesBackdropFilter=e,e}function Uu(t,e){let n=e.has("backdrop-filter")||e.has("-webkit-backdrop-filter");if(!n&&(n=(o=>/(?:^|;)\\s*(?:-webkit-)?backdrop-filter\\s*:/i.test(o.getAttribute?.("style")||""))(t),!n))try{n=!!t.querySelector?.(\'[style*="backdrop-filter" i]\')}catch{n=!0}if(!n)return!1;let r=[t];t.querySelectorAll&&r.push(...t.querySelectorAll("*"));for(let i of r){let o=getComputedStyle(i),s=o.getPropertyValue("backdrop-filter")||o.getPropertyValue("-webkit-backdrop-filter");if(s&&s!=="none")return!0}return!1}var ma=new WeakMap;function zu(t){let e=Dt(),n=ma.get(t);if(n&&n.epoch===e)return n.leaky;let r=!1,i={budget:2e4},o=s=>{for(let a=0;a<s.length&&!r;a++){if(--i.budget<0){r=!0;return}let c=s[a],f=c.selectorText;if(f&&/[+~]|:has\\(/.test(f)){r=!0;return}let l=c.style;if(l&&(l.counterReset||l.counterIncrement||l.counterSet||l.content&&l.content.includes("counter"))){r=!0;return}c.cssRules&&c.cssRules.length&&o(c.cssRules)}};try{for(let s of t.styleSheets){let a=null;try{a=s.cssRules}catch{r=!0}if(r)break;a&&o(a)}if(!r){let s=t.adoptedStyleSheets;if(Array.isArray(s))for(let a of s){if(r)break;try{o(a.cssRules)}catch{r=!0}}}}catch{r=!0}return ma.set(t,{epoch:e,leaky:r}),r}var Hu=1/16;function ju(t,e){if(t===e)return!0;if(!t.endsWith("px")||!e.endsWith("px"))return!1;let n=parseFloat(t),r=parseFloat(e);return Number.isFinite(n)&&Number.isFinite(r)&&Math.abs(n-r)<=Hu}var ir=new Map,Vu=["width","height","min-width","min-height"];function qu(t){let e=ir.get(t);if(e===void 0){e=null;for(let n of Vu){let r=t.match(new RegExp("(?:^|;)"+n+":([^;]+)"));r&&r[1].endsWith("px")&&((e||(e={}))[n]=r[1])}ir.size>5e3&&ir.clear(),ir.set(t,e)}return e}function Gu(t){if(!(!t.classList||!t.classList.length))for(let e of Array.from(t.classList))/^c\\d+$/.test(e)&&t.classList.remove(e)}function Xu(t,e){let n=[t];for(;n.length;){let r=n.pop();if(r.nodeType===1){let i=e.nodeMap.get(r);i!==void 0&&(e.nodeMap.delete(r),e.srcToClone.get(i)===r&&e.srcToClone.delete(i)),e.styleMap.delete(r)}for(let i=r.firstChild;i;i=i.nextSibling)n.push(i)}}var Ao={attempts:0,served:0,reconciled:0};async function ga(t,e,n){Ao.attempts++;try{let r=await Yu(t,e,n);return r&&Ao.served++,r}catch{return null}}async function Yu(t,e,n){let r=e.retained;if(!r||!r.clone||!r.styleMap||!r.srcToClone||n.reconcile||n.clip||n.captureSelection||r.clipWindow||t.scrollTop||t.scrollLeft||Ou(t)||Bu(r)||r.fontsCSS||Jn(n))return null;for(let u of n.plugins||[])if(u&&(typeof u.beforeSnap=="function"||typeof u.beforeClone=="function"||typeof u.resolveNode=="function"||typeof u.afterClone=="function"))return null;if(r.classPrefixCSS&&(r.classPrefixCSS.includes("::marker")||r.classPrefixCSS.includes("::first-line"))||n.excludeMode==="remove")return null;let i=t.ownerDocument||document,o=nn(t);if(!o||zu(i))return null;let s=[];t:for(let u of e.dirtyRoots){if(!u.isConnected||u===t||!t.contains(u))return null;for(let p of e.dirtyRoots)if(p!==u&&p!==t&&p.contains(u))continue t;s.push(u)}if(!s.length)return null;n.__compressedAssets=r.__compressedAssets,n.__compressionDensity=r.__compressionDensity,n.__compressionRootTransform=r.rootTransform2D;for(let u of s){if(u.parentElement===t||u.matches?.(ha)||u.querySelector?.(ha)||Uu(u,o))return null;let p=r.srcToClone.get(u);if(!p||!p.parentNode)return null;let h=new Map,m={styleMap:r.styleMap,styleCache:r.styleCache,nodeMap:h,options:n},d=Yn(u,null),g=Bn(u),y;try{y=await Qt(u,m,n)}finally{g(),d()}if(!y||y.nodeType!==1||y.querySelector?.("style[data-sd]")||(await We(u,y,m,n),m.__pseudoCSS))return null;await _n(y,m),zn(y);try{await $n(y,u,h)}catch{}if(await Promise.all([jn(y,n),qn(u,y,r.styleCache,n,h)]),n.compress)try{await rr(y,n,h)}catch{}for(let[b,S]of h.entries())So(b,S);p.replaceWith(y),Xu(p,r);for(let[b,S]of h.entries())r.nodeMap.set(b,S),r.srcToClone.set(S,b)}let a={styleMap:r.styleMap,styleCache:r.styleCache,nodeMap:r.nodeMap,options:n};for(let[u,p]of r.nodeMap.entries()){if(!p||p.nodeType!==1||!p.isConnected)continue;let h=r.styleMap.get(u);if(!h)continue;let m=qu(h);if(!m)continue;let d=null,g=!1;for(let y in m)if(d||(d=getComputedStyle(p)),!ju(d.getPropertyValue(y),m[y])){g=!0;break}if(g){if(n.__compressedAssets?.has(u))return null;Ao.reconciled++,await pt(p,u,a,n)}}let c=Ye(r.styleMap);for(let[u,p]of r.styleMap.entries())Gu(u),wo(u,p,c);let f=(r.classPrefixCSS||"")+Array.from(c.entries()).map(([u,p])=>`.${p}{${u}}`).join("");nr(r.clone,n.__compressedAssets);let l=await or({element:t,options:n,plugins:n.plugins,clone:r.clone,classCSS:f,styleCache:r.styleCache,nodeMap:r.nodeMap},{clipWindow:null,outerTransforms:r.outerTransforms,outerShadows:r.outerShadows,rootTransform2D:r.rootTransform2D,fontsCSS:r.fontsCSS||""});return n.__compressedSnapshot=er(r.clone,n.__compressedAssets),r.__compressedAssets=n.__compressedAssets,r.__compressionDensity=n.__compressionDensity,l}kt();var _o=new WeakMap,ar=new WeakMap,_a=new WeakSet,Mo=new WeakMap,Ku=64,un=new Map,Ea=["scroll","input","change","focusin","focusout","pointerdown","pointerup","pointercancel","keydown","keyup","beforetoggle","toggle"],Qu=["(prefers-color-scheme: dark)","(prefers-reduced-motion: reduce)","(prefers-contrast: more)","(forced-colors: active)","(inverted-colors: inverted)","(prefers-reduced-transparency: reduce)","(hover: hover)","(any-hover: hover)","(pointer: coarse)","(any-pointer: coarse)","(color-gamut: p3)","(dynamic-range: high)"];function Ju(t){let e=t?.defaultView;return typeof e?.matchMedia!="function"?"":Qu.map(n=>{try{return e.matchMedia(n).matches?"1":"0"}catch{return"?"}}).join("")}function ya(t){let e=[];for(let n=t;n;){try{let r=n.getBoundingClientRect();e.push(r.x,r.y,r.width,r.height)}catch{e.push("?")}n.parentElement?n=n.parentElement:n=n.getRootNode?.()?.host||null}return e.join("|")}function ba(t,e){if(e.disposed||(un.delete(t),un.set(t,e),un.size<=Ku))return;let[n,r]=un.entries().next().value;Ra(n,r)}function Ra(t,e){e.disposed=!0,un.delete(t),_o.delete(t);for(let n of e.observers)try{n.disconnect()}catch{}for(let n of Ea)t.removeEventListener(n,e.onMediaDirty,!0);for(let n of e.trackedShadowRoots.keys())for(let r of Ro)n.removeEventListener(r,e.onMediaDirty,!0);for(let[n,r]of e.trackedImages)n.removeEventListener("load",r),n.removeEventListener("error",r);e.trackedImages.clear(),e.trackedShadowRoots.clear(),e.images.length=0,e.controls.length=0,e.scrollNodes.length=0,e.observers.length=0,e.last=null,e.retained=null,e.retainedFrameDriven=!1}function Fa(t){if(_a.has(t))return!1;ar.delete(t);let e=[t],n=[],r=[];for(let i=0;i<e.length;i++){let o=e[i],s=[];o?.nodeType===1&&s.push(o);try{s.push(...o.querySelectorAll("*"))}catch{return!1}for(let a of s){a.shadowRoot&&e.push(a.shadowRoot);let c=String(a.localName||a.tagName||"").toLowerCase();if(/^(?:iframe|canvas|video|audio|object|embed|marquee|blink)$/.test(c)||c==="progress"&&!a.hasAttribute("value")||/^(?:animate|animatetransform|animatemotion|set)$/.test(c))return!1;let f="";if(c==="img"){r.push(a);try{f=a.currentSrc||a.src||""}catch{}}/^(?:input|textarea|select|option)$/.test(c)&&n.push(a);let l=a.getAttribute?.("style")||"",u=Mo.get(a);if(f||l){if((!u||u.src!==f||u.style!==l)&&(u={src:f,style:l,animated:He(f)||He(l)},Mo.set(a,u)),u.animated)return!1}else u&&Mo.delete(a)}}return ar.set(t,{roots:e.slice(1),controls:n,images:r}),!0}function Eo(t,e){if(!t.querySelectorAll)return!1;let n=ar.get(t);ar.delete(t);let r=new Set(n?.roots||[]);if(n&&(e.controls=n.controls,e.scannedImages=n.images),!n){let i=[t];for(let o=0;o<i.length;o++){let s=i[o];s.shadowRoot&&!r.has(s.shadowRoot)&&(r.add(s.shadowRoot),i.push(s.shadowRoot));for(let a of s.querySelectorAll("*"))a.shadowRoot&&!r.has(a.shadowRoot)&&(r.add(a.shadowRoot),i.push(a.shadowRoot))}}for(let[i,o]of e.trackedShadowRoots)if(!r.has(i)){try{o.disconnect()}catch{}for(let a of Ro)i.removeEventListener(a,e.onMediaDirty,!0);e.trackedShadowRoots.delete(i);let s=e.observers.indexOf(o);s>=0&&e.observers.splice(s,1)}for(let i of r)if(!e.trackedShadowRoots.has(i))try{let o=new MutationObserver(e.markDirty);o.observe(i,{subtree:!0,childList:!0,attributes:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),o.__flush=e.markDirty,e.observers.push(o),e.trackedShadowRoots.set(i,o);for(let s of Ro)i.addEventListener(s,e.onMediaDirty,{capture:!0,passive:!0});e.retained&&e.dirtyAll()}catch{}return!!n}var Ro=["scroll","change","beforetoggle","toggle"];function cr(t,e){return[t,...e.trackedShadowRoots.keys()]}function Fo(t,e){let n=e.scannedImages;if(e.scannedImages=null,!n){n=[],t.tagName==="IMG"&&n.push(t);for(let r of cr(t,e))r.querySelectorAll&&n.push(...r.querySelectorAll("img"))}if(e.images=n,e.trackedImages.size){let r=new Set(n);for(let[i,o]of e.trackedImages)r.has(i)||(i.removeEventListener("load",o),i.removeEventListener("error",o),e.trackedImages.delete(i))}for(let r of n){if(r.complete||e.trackedImages.has(r))continue;let i=()=>{e.capturing&&(e.torn=!0),e.dirty=!0,e.dirtyRoots=null,r.removeEventListener("load",i),r.removeEventListener("error",i),e.trackedImages.delete(r)};e.trackedImages.set(r,i),r.addEventListener("load",i),r.addEventListener("error",i)}}function wa(t){let e=new Map,n=new Map,r=new Map;for(let i of t)if(ie(i))if(i.type==="attributes"){let o=e.get(i.target);o||e.set(i.target,o=new Map),o.has(i.attributeName)||o.set(i.attributeName,i.oldValue)}else if(i.type==="characterData")n.has(i.target)||n.set(i.target,i.oldValue);else if(i.type==="childList"){let o=r.get(i.target);o||r.set(i.target,o=new Map);for(let s of i.addedNodes){if(s.nodeType!==3)return!0;o.set(s.data,(o.get(s.data)||0)+1)}for(let s of i.removedNodes){if(s.nodeType!==3)return!0;o.set(s.data,(o.get(s.data)||0)-1)}}else return!0;for(let[i,o]of e)for(let[s,a]of o)if(i.getAttribute(s)!==a)return!0;for(let[i,o]of n)if(i.data!==o)return!0;for(let i of r.values())for(let o of i.values())if(o!==0)return!0;return!1}var Zu=/(?:^data:image\\/(?:gif|apng)|\\.(?:gif|apng)(?=[?#)\'"\\s;]|$))/i,ze=t=>t&&(typeof t=="object"||typeof t=="function")?sr(t):"-";function td(t,e=131072){if(t=String(t||"").trim(),!/^data:/i.test(t))return"";let n=t.indexOf(",");if(n<0)return"";let r=t.slice(0,n),i=t.slice(n+1);try{if(/;base64/i.test(r)){let o=Math.ceil(e/3)*4;return atob(i.slice(0,o-o%4))}return i.slice(0,e*3).replace(/%([0-9a-f]{2})/gi,(o,s)=>String.fromCharCode(parseInt(s,16))).slice(0,e)}catch{return""}}function ed(t){let e=(t.match(/^data:([^;,]+)/i)?.[1]||"").toLowerCase();if(e==="image/gif"||e==="image/apng")return!0;if(!/image\\/(?:png|webp|avif|svg\\+xml)/.test(e))return!1;let n=td(t);return e==="image/png"?n.includes("acTL"):e==="image/webp"?n.includes("ANIM")||n.includes("ANMF")||n.includes("VP8X")&&!!(n.charCodeAt(n.indexOf("VP8X")+8)&2):e==="image/avif"?n.includes("avis"):/<(?:animate|animateTransform|animateMotion|set)\\b|@keyframes\\b|animation(?:-name)?\\s*:/i.test(n)}function Sa(t){let e=String(t||"").trim();return e?Zu.test(e)?!0:/^data:/i.test(e)?ed(e):!1:!1}function He(t){let e=String(t||"");if(Sa(e))return!0;for(let n of e.matchAll(/url\\(\\s*(?:"((?:\\\\.|[^"\\\\])*)"|\'((?:\\\\.|[^\'\\\\])*)\'|([^)]*))\\s*\\)/gi))if(Sa(n[1]??n[2]??n[3]))return!0;return!1}function xa(t,e=null){let n=t&&t.clone;if(!n)return!1;let r=e?e.map(i=>t.srcToClone?.get(i)).filter(Boolean):[n];for(let i of r)for(let o of Ta(i))if(He(o.getAttribute?.("src"))||He(o.getAttribute?.("href"))||He(o.getAttribute?.("style"))||He(t.styleMap?.get(o)))return!0;return!1}function Ta(t){let e=[];t&&t.nodeType===1&&e.push(t);try{e.push(...t.querySelectorAll("*"))}catch{}return e}function To(t,e){let n=[],r=new Set,i=o=>{o&&!r.has(o)&&(r.add(o),n.push(o))};t.matches?.("input,textarea,select,option")&&i(t);for(let o of cr(t,e))try{for(let s of o.querySelectorAll("input,textarea,select,option"))i(s)}catch{}e.controls=n}function $o(t,e){let n=[],r=new Set,i=(o,s=!1)=>{if(!(!o||r.has(o))){r.add(o);try{(s||o.scrollLeft||o.scrollTop||o.scrollWidth>o.clientWidth||o.scrollHeight>o.clientHeight)&&n.push(o)}catch{}}};for(let o=t;o;o=o.parentElement)i(o,!0);for(let o of cr(t,e))for(let s of Ta(o))i(s);e.scrollNodes=n}function va(t,e){let n=t.ownerDocument||document,r=n.defaultView,i=[r?.location?.hash||"",Ju(n),r?.innerWidth||0,r?.innerHeight||0,r?.devicePixelRatio||1,r?.screen?.orientation?.type||""];try{i.push(...[...n.adoptedStyleSheets||[]].map(ze))}catch{}for(let l of e.trackedShadowRoots.keys())try{i.push("#shadow",...[...l.adoptedStyleSheets||[]].map(ze))}catch{}let o=n.activeElement,s=n.fullscreenElement;(o?.contains(t)||t.contains(o))&&i.push(ze(o)),(s?.contains(t)||t.contains(s))&&i.push(ze(s));let a=[r?.scrollX||0,r?.scrollY||0];for(let l of e.scrollNodes)a.push(l.scrollLeft||0,l.scrollTop||0);let c=[];for(let l of e.controls){let u=String(l.localName||"").toLowerCase();u==="input"?c.push(l.type,Ge(l)?l.value.length:l.value,l.checked?1:0,l.indeterminate?1:0):u==="textarea"?c.push(l.value):u==="select"?c.push(l.selectedIndex,l.value):c.push(l.selected?1:0)}let f=[];for(let l of e.images){let u="";try{u=l.currentSrc||l.src||""}catch{}f.push(u,l.complete?1:0,l.naturalWidth||0,l.naturalHeight||0)}return{style:i.join("|"),scroll:a.join("|"),controls:c,images:f,frameDriven:e.retainedFrameDriven}}function Ue(t,e,n){if(!t)return!1;let r=t[n],i=e[n];if(r===i)return!0;if(!Array.isArray(r)||r.length!==i.length)return!1;for(let o=0;o<r.length;o++)if(r[o]!==i[o])return!1;return!0}function ka(t,e){let n=new Set;for(let r of cr(t,e))try{let i=r.getAnimations?.(r.nodeType===1?{subtree:!0}:void 0)||[];for(let o of i)n.add(o)}catch{}return[...n]}function Ca(t){return t.map(e=>[ze(e),e.playState,Math.round((Number(e.currentTime)||0)*10),e.playbackRate].join(":")).join("|")}function nd(t,e,n){if(!n||n.nodeType!==1)return null;if(n===t||t.contains(n))return t;for(let r of e.trackedShadowRoots.keys())if(r.contains(n))return r;return null}function rd(t){let e={dirty:!0,pending:[],torn:!1,dirtyRoots:new Set,retained:null,retainedFrameDriven:!1,disposed:!1,capturing:!1,last:null,inflight:Promise.resolve(),observers:[],trackedShadowRoots:new Map,trackedImages:new Map,images:[],scannedImages:null,scrollNodes:[],controls:[],envEpoch:Ee(),styleEpoch:Dt(),styleStamp:en(t),outsideMutations:tn(t),geometry:null,renderState:null},n=()=>{e.dirty=!0,e.dirtyRoots=null},r=a=>{if(!e.dirtyRoots)return;let c=a&&(a.nodeType===1?a:a.parentElement);if(!c||c===t||!t.contains(c)||e.dirtyRoots.size>=12){e.dirtyRoots=null;return}e.dirtyRoots.add(c)},i=a=>{if(e.capturing){for(let c of a)e.pending.push(c);return}for(let c of a)ie(c)&&(e.dirty=!0,r(c.target))},o=()=>{if(e.capturing){e.torn=!0;return}n()};e.dirtyAll=n;try{let a=new MutationObserver(i);a.observe(t,{subtree:!0,childList:!0,attributes:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),a.__flush=i,e.observers.push(a)}catch{}e.markDirty=i,e.onMediaDirty=o;try{for(let a of Ea)t.addEventListener(a,o,{capture:!0,passive:!0})}catch{}return Eo(t,e)||To(t,e),$o(t,e),Fo(t,e),e}var od=0,Aa=new WeakMap;function sr(t){let e=Aa.get(t);return e||(e="@"+ ++od,Aa.set(t,e)),e}function Po(t,e){let n=typeof t;if(n==="undefined")return null;if(t===null||n==="boolean"||n==="number"||n==="string")return JSON.stringify(t);if(n==="function"||n==="symbol")return n==="symbol"?null:JSON.stringify(sr(t));if(n!=="object")return null;if(typeof t.nodeType=="number")return JSON.stringify(sr(t));if(e.has(t))return null;e.add(t);try{if(Array.isArray(t)){let o=[];for(let s of t){let a=Po(s,e);if(a===null)return null;o.push(a)}return"["+o.join(",")+"]"}let r=Object.getPrototypeOf(t);if(r!==Object.prototype&&r!==null)return JSON.stringify(sr(t));let i=[];for(let o of Object.keys(t).sort()){let s=t[o];if(s===void 0)continue;let a=Po(s,e);if(a===null)return null;i.push(JSON.stringify(o)+":"+a)}return"{"+i.join(",")+"}"}finally{e.delete(t)}}function Ma(t,e){let{burst:n,invalidate:r,...i}=t||{};try{let o=Po(i,new Set);return o===null?null:`${(e||[]).map(ze).join(",")}:${o}`}catch{return null}}function $a(t,e,n,r,i=null){let o=_o.get(t);o||(o=rd(t),o.baselineSignature=Ma(e,n.plugins),_o.set(t,o));let s=Ma(e,n.plugins),a=async()=>{if(o.disposed)return r();let f=s===null||s!==o.baselineSignature;f&&s!==null?o.pendingSig===s?(o.baselineSignature=s,o.last=null,o.dirty=!0,o.dirtyRoots=null,o.pendingSig=null,f=!1):o.pendingSig=s:o.pendingSig=null,Eo(t,o),Fo(t,o);for(let M of o.observers)M.__flush(M.takeRecords());Tt();let l=tn(t);o.dirty&&o.outsideMutations!==l&&o.dirtyAll(),o.outsideMutations=l;let u=t.getRootNode?.(),p=[...o.trackedShadowRoots.keys()];u?.nodeType===11&&!p.includes(u)&&p.push(u),Cn(t.ownerDocument||document,p);let h=en(t);o.styleStamp!==h&&(o.styleStamp=h,o.dirty||o.dirtyAll());let m=va(t,o),d=ka(t,o);m.animation=Ca(d),o.renderState&&(!Ue(o.renderState,m,"style")&&(Re(),o.dirtyAll()),Ue(o.renderState,m,"scroll")||o.dirtyAll(),Ue(o.renderState,m,"controls")||(se(t),o.dirtyAll()),!Ue(o.renderState,m,"images")&&!o.dirty&&o.dirtyAll());let g=Ee();o.envEpoch!==g&&(o.dirtyAll(),o.envEpoch=g);let y=Dt();if(o.styleEpoch!==y&&(o.styleEpoch=y,!o.dirty)){let M=ya(t);o.geometry!==null&&M!==o.geometry&&(se(t),o.dirtyAll()),o.geometry=M}n.invalidate&&o.dirtyAll();let b=!1,S=!!o.renderState&&!Ue(o.renderState,m,"animation");try{let M=new Set;S&&d.length===0&&(M=null);for(let A of d){let C=A.playState==="running";if(!C&&!S)continue;C&&(b=!0),S=!0;let x=A.effect?.target;if(nd(t,o,x)===t)M.add(x);else{M=null;break}}if(S&&M&&M.size&&o.retained){o.dirty=!0;for(let A of M)o.dirtyRoots&&o.dirtyRoots.add(A),se(A)}else S&&!M&&o.dirtyAll()}catch{}let k=m.frameDriven,v=b||k;if(v&&(o.last=null),k&&o.dirtyAll(),!f&&!v&&!o.dirty&&o.last)return ba(t,o),o.last;o.capturing=!0;let w=null;try{let M=null,A=!1,C=null;if(!f&&o.dirty&&o.retained&&o.dirtyRoots&&o.dirtyRoots.size&&i){C=[...o.dirtyRoots];let x=await ga(t,o,n);x&&(M=await i(x),A=!0)}if(M||(f||(n.__retain=x=>{let _=new Map;for(let[R,$]of x.nodeMap.entries())_.set($,R);w={...x,srcToClone:_}}),n.__tornSinceStart=()=>{for(let x of o.observers)for(let _ of x.takeRecords())o.pending.push(_);return Tt(),o.torn||wa(o.pending)||tn(t)!==l},M=await r()),!f&&!o.disposed){o.dirty=!1,o.dirtyRoots=new Set,w?(o.retained=w,o.retainedFrameDriven=xa(w),To(t,o),$o(t,o)):A&&(o.retainedFrameDriven||(o.retainedFrameDriven=xa(o.retained,C)),To(t,o),$o(t,o));let x=va(t,o);x.animation=Ca(ka(t,o));let _=["style","scroll","controls","images"];b||_.push("animation");let R=_.every($=>Ue(m,x,$));o.renderState=x,o.styleEpoch=Dt(),o.styleStamp=en(t),o.geometry=ya(t),o.renderState.frameDriven?(_a.add(t),Ra(t,o)):R?!v&&!o.renderState.frameDriven&&(o.last=M,ba(t,o)):(o.dirtyAll(),o.last=null)}return M}finally{n.__retain=void 0,n.__tornSinceStart=void 0;for(let A of o.observers)for(let C of A.takeRecords())o.pending.push(C);Tt();let M=tn(t);(o.torn||wa(o.pending)||M!==l)&&(o.dirtyAll(),o.last=null),o.outsideMutations=M,o.styleEpoch=Dt(),o.styleStamp=en(t),o.pending.length=0,o.torn=!1,o.capturing=!1,o.disposed||(Eo(t,o),Fo(t,o))}},c=o.inflight.then(a,a);return o.inflight=c.catch(()=>{}),c}var lr=null;function La(t){lr=t}var id=\'button, a[href], [role="button"], input, select, summary, label, [tabindex]\',No=!1,dn=null,Lo=new WeakMap,Pa=!1;function Ia(t,e){!No||!dn||e&&e.burst===!1||Lo.set(dn.control,{element:t,options:e&&typeof e=="object"?{...e}:e})}function Wa(t){let e={control:t};dn=e,setTimeout(()=>{dn===e&&(dn=null)},0)}function Wo(t){let e=t.target,n=e&&(e.nodeType===1?e:e.parentElement);return n&&n.closest?n.closest(id):null}function Na(t){if(t.type==="keydown"&&t.key!=="Enter"&&t.key!==" ")return;let e=Wo(t);e&&(Wa(e),Io(t,!1))}function sd(t){let e=Wo(t);e&&Wa(e)}function Io(t,e=!0){if(!lr||document.visibilityState==="hidden")return;let n=Wo(t);if(!n||t.type==="pointerenter"&&t.target!==n)return;let r=Lo.get(n);if(r){if(!r.element.isConnected){Lo.delete(n);return}lr(r.element,r.options).catch(()=>{});return}e&&!Pa&&(Pa=!0,lr(document.body,{clip:"viewport",burst:!1}).catch(()=>{}))}function Oa(){if(No||typeof document>"u"||typeof document.addEventListener!="function")return;No=!0;let t={capture:!0,passive:!0};document.addEventListener("pointerdown",Na,t),document.addEventListener("keydown",Na,t),document.addEventListener("click",sd,t),document.addEventListener("pointerenter",Io,t),document.addEventListener("focusin",Io,t)}Ct();function Ad(...t){return Zs(...t),Y}async function Md(t,e){if(typeof t!="string"||!t.trim())throw new Error("[snapdom.fromString] html string required");let n=document.createElement("div");tt(n),n.style.cssText="position:fixed;left:-99999px;top:0;pointer-events:none;",n.innerHTML=t,document.body.appendChild(n);try{await gt();let r=Array.from(n.childNodes).some(o=>o.nodeType===3&&o.textContent.trim()),i=n.children.length===1&&!r?n.firstElementChild:n;return await Xo(i,{...e||{},burst:!1})}finally{n.remove()}}var _d="3.2.0",Y=Object.assign(Xo,{plugins:Ad,fromString:Md,version:_d,preCapture:Oa});La(Xo);var Go=Symbol("snapdom.internal"),Ed=Symbol("snapdom.internal.silent"),Ja=new Set(["png","jpeg","jpg","webp","svg"]);async function Xo(t,e){if(!t)throw new Error("Element cannot be null or undefined");let n=pa(e);n.element=t,n.invalidate&&Re(),ea(n,e&&e.plugins);let{stage:r,loweredBy:i}=Qs(n);n.needs=r,n.__needsLoweredBy=i;let o=Be(r,"render"),s=n.burst===!0||!Jn(n),a=typeof n.filter=="function"||!!n.excludePredicates||typeof n.excludeStyleProps=="function"||typeof n.fallbackURL=="function",f=o&&!n.captureSelection&&n.burst!==!1&&s&&!a&&Fa(t);return f&&Ia(t,e),n.snap||(n.snap={toPng:(l,u)=>Y.toPng(l,u),toSvg:(l,u)=>Y.toSvg(l,u)}),f?$a(t,e,n,()=>Y.capture(t,n,Go),l=>Za(l,n)):Y.capture(t,n,Go)}Y.capture=async(t,e,n)=>{if(n!==Go)throw new Error("[snapdom.capture] is internal. Use snapdom(...) instead.");if(Be(e.needs||_t,"render")&&X()){if(e.embedFonts)try{let o=t.ownerDocument||document,s=new Set;if(e.embedFonts==="auto"){try{for(let l of o.fonts)s.add(String(l.family).replace(/["\']/g,"").toLowerCase())}catch{}if(s.size===0)throw null}let a=In(t);e.clip||(e.__fontUsage=a);let c=a.required,f=new Set([...c].map(l=>String(l).split("__")[0]).filter(Boolean));if(e.embedFonts==="auto"&&(f=new Set([...f].filter(l=>s.has(l.toLowerCase()))),f.size===0))throw null;await Wn(f,1,o)}catch{}let i=Array.from(t.querySelectorAll("canvas"));t.tagName==="CANVAS"&&i.unshift(t);for(let o of i)try{if(sn(o))continue;let s=o.getContext("2d",{willReadFrequently:!0});s&&s.getImageData(0,0,1,1)}catch(s){H(e,"safari canvas poke failed",s)}}let r=await da(t,e);return Za(r,e)};async function Za(t,e){let n=e.needs||_t,r=Be(n,"render"),i=E=>Js(n,e.__needsLoweredBy||[],E),o=typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?t:null,s=o?null:t,a=()=>s??(s=o.toDataURL()),c=o||t;o&&(t="");let f=e.__compressedSnapshot,l=e.__compressionDensity;delete e.__compressedSnapshot,delete e.__compressedAssets;let u,p=e.meta||{},m=(Number.isFinite(e.width)||Number.isFinite(e.height))&&!X(),d=m?Number.isFinite(e.width)?p.targetW/p.vbW:p.targetH/p.vbH:1,g=m?Number.isFinite(e.height)?p.targetH/p.vbH:p.targetW/p.vbW:1,y=E=>{if(o||!f?.size)return c;let N=p.vbW,P=p.vbH,F=E.crop;F&&(N=Math.max(1,Math.min(N,F.x+F.width)-Math.max(0,F.x)),P=Math.max(1,Math.min(P,F.y+F.height)-Math.max(0,F.y)));let z=Number.isFinite(E.width),V=Number.isFinite(E.height);return(z&&V?Math.max(E.width/N,E.height/P):z?E.width/N*(F?Math.max(1,g/d):1):V?E.height/P*(F?Math.max(1,d/g):1):(E.scale||1)*Math.max(d,g))*(E.dpr||1)<=l?c:u??(u=ca(a(),f))},b=async(E,N)=>{let{rasterize:P}=await Promise.resolve().then(()=>(je(),hn));return P(c,{...E,...N||{},format:"png"})},S=()=>{if(!r)throw i("svgString");if(o)throw new Error("[snapdom] svgString: engine:\'html-in-canvas\' produces a raster capture; there is no serialized SVG");let E=t.indexOf(",");return E>=0?decodeURIComponent(t.slice(E+1)):""},k=E=>Object.defineProperty({...E||{},svgString:S},"url",r?{get:a,enumerable:!0}:{get(){throw i("export.url")},enumerable:!1,configurable:!0}),v={img:async(E,N)=>{if(o)return b(E,N);let{toImg:P}=await Promise.resolve().then(()=>(Ho(),zo)),F={...E,...N||{}};return P(y(F),F)},svg:async(E,N)=>{if(o)return b(E,N);let{toSvg:P}=await Promise.resolve().then(()=>(Ho(),zo)),F={...E,...N||{}};return P(y(F),F)},canvas:async(E,N)=>{let{toCanvas:P}=await Promise.resolve().then(()=>(he(),ja)),F={...E,...N||{}};return P(y(F),F)},blob:async(E,N)=>{let{toBlob:P}=await Promise.resolve().then(()=>(qo(),Xa)),F={...E,...N||{}};return P(y(F),F)},png:async(E,N)=>{let{rasterize:P}=await Promise.resolve().then(()=>(je(),hn)),F={...E,...N||{},format:"png"};return P(y(F),F)},jpeg:async(E,N)=>{let{rasterize:P}=await Promise.resolve().then(()=>(je(),hn)),F={...E,...N||{},format:"jpeg"};return P(y(F),F)},webp:async(E,N)=>{let{rasterize:P}=await Promise.resolve().then(()=>(je(),hn)),F={...E,...N||{},format:"webp"};return P(y(F),F)},download:async(E,N)=>{let{download:P}=await Promise.resolve().then(()=>(Qa(),Ka)),F={...E,...N||{}};return P(y(F),F)}};if(!r)for(let E of Object.keys(v)){let N=E==="download"?"download()":`to${E.charAt(0).toUpperCase()}${E.slice(1)}()`;v[E]=async()=>{throw i(N)}}let w={};for(let E of["img","svg","canvas","blob","png","jpeg","webp"])w[E]=async N=>v[E](e,{...R(E,N||{}),[Ed]:!0});w.jpg=w.jpeg;let M=E=>Object.defineProperty({...e,...E},"options",{value:e,configurable:!0}),A=M({artifacts:e.__artifacts||null,export:k(),exports:w}),C=await Qn("defineExports",A),x=Object.assign({},...C.filter(E=>E&&typeof E=="object").reverse()),_={...v,...x};_.jpeg&&!_.jpg&&(_.jpg=(E,N)=>_.jpeg(E,N));function R(E,N){let P=N||{},F={...e,...P},z=typeof P.type=="string"?P.type.toLowerCase():"",V=typeof P.format=="string"?P.format.toLowerCase():Ja.has(z)?z:"";V&&(F.format=V==="jpg"?"jpeg":V),F.__explicitFormat=V?F.format:e.__explicitFormat??null,E==="blob"&&!F.__explicitFormat&&(F.format=o?"png":"svg"),F.type=F.format;let j=K=>K==="jpeg"||K==="jpg"||K==="webp";return[E,F.format,z].map(K=>typeof K=="string"?K.toLowerCase():"").find(j)&&(F.backgroundColor==null||F.backgroundColor==="transparent")&&(F.backgroundColor="#ffffff"),F.scale!==1&&(Number.isFinite(F.width)||Number.isFinite(F.height))&&H(F,"scale ignored: width/height sets output size"),F}let $=!1,T=Promise.resolve();async function I(E,N){let P=Object.freeze(N&&typeof N=="object"?{...N}:{}),F=async()=>{let V=_[E];if(!V)throw new Error(`[snapdom] Unknown export type: ${E}`);let j=R(E,P),D=M({artifacts:e.__artifacts||null,export:k({type:E,options:j,requestedOptions:P})}),K=j.format,ht=j.type;await Qn("beforeExport",D,{format:E,options:j});let St=j.format!==K?j.format:j.type!==ht?j.type:"",ft=typeof St=="string"?St.toLowerCase():"";Ja.has(ft)&&(j.format=ft==="jpg"?"jpeg":ft,j.type=j.format,j.__explicitFormat=j.format,/^(?:jpeg|webp)$/.test(j.format)&&(j.backgroundColor==null||j.backgroundColor==="transparent")&&(j.backgroundColor="#ffffff"));let at=await V(D,j);return await Qn("afterExport",D,{format:E,options:j,result:at}),$||($=!0,await Bt("afterSnap",e)),at},z=T.then(F);return T=z.catch(()=>{}),z}let B={url:t,needs:n,warnings:e.__session&&e.__session.warnings||[],toRaw:()=>{if(!r)throw i("toRaw()");return a()},to:(E,N)=>I(E,N),toImg:E=>I("img",E),toSvg:E=>I("svg",E),toCanvas:E=>I("canvas",E),toBlob:E=>I("blob",E),toPng:E=>I("png",E),toJpg:E=>I("jpg",E),toWebp:E=>I("webp",E),download:E=>I("download",E)};r?o&&Object.defineProperty(B,"url",{get:a,enumerable:!0,configurable:!0}):Object.defineProperty(B,"url",{get(){throw i("url")},enumerable:!1,configurable:!0}),Object.defineProperty(B,"meta",r?{value:e.meta,enumerable:!0}:{get(){throw i("meta")},enumerable:!1,configurable:!0});for(let E of Object.keys(_)){let N="to"+E.charAt(0).toUpperCase()+E.slice(1);B[N]||(B[N]=P=>I(E,P))}return B}Y.toRaw=(t,e)=>Y(t,e).then(n=>n.toRaw());Y.toImg=(t,e)=>Y(t,e).then(n=>n.toImg());Y.toSvg=(t,e)=>Y(t,e).then(n=>n.toSvg());Y.toCanvas=(t,e)=>Y(t,e).then(n=>n.toCanvas());Y.toBlob=(t,e)=>Y(t,e).then(n=>n.toBlob());Y.toPng=(t,e)=>Y(t,{...e,format:"png"}).then(n=>n.toPng());Y.toJpg=(t,e)=>Y(t,{...e,format:"jpeg"}).then(n=>n.toJpg());Y.toWebp=(t,e)=>Y(t,{...e,format:"webp"}).then(n=>n.toWebp());Y.download=(t,e)=>Y(t,e).then(n=>n.download());typeof window<"u"&&(window.snapdom=Y);})();\n'}function HC(){let e=process.env.CHROME_PATH?.trim();return e&&ch(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=>ch(n))??null}async function VC(e,t,n,r){let o=fc(n,r),s=o.profile,i,l,a,c=()=>a??=(async()=>{try{i&&await JC(i,l)}finally{process.off("SIGINT",u),process.off("SIGTERM",p),process.off("SIGHUP",d),process.off("exit",f),(!i||i.exitCode!==null||i.signalCode!==null||!i.pid)&&o.release()}})(),u=()=>{c().finally(()=>process.exit(130))},p=()=>{c().finally(()=>process.exit(143))},d=()=>{c().finally(()=>process.exit(129))},f=()=>{i&&i.exitCode===null&&i.signalCode===null&&i.kill("SIGKILL")};process.once("SIGINT",u),process.once("SIGTERM",p),process.once("SIGHUP",d),process.once("exit",f);try{i=LC(e,[...t?[]:["--headless=new","--disable-gpu"],"--remote-debugging-port=0",`--user-data-dir=${s}`,"--no-first-run","--no-default-browser-check","--disable-extensions","--disable-background-networking","--hide-scrollbars","--window-size=1440,900","about:blank"],{stdio:["ignore","ignore","pipe"]}),o.setChromePid(i.pid);let m=await XC(i,wh);i.stderr?.on("data",()=>{}),l=await ZC(m);let g=l,S=await qC(g,t),b=(await g.send("Target.attachToTarget",{targetId:S,flatten:!0})).sessionId,k=(x,v)=>g.send(x,v,b);await k("Page.enable"),await k("Runtime.enable");let y=async(x,v=60)=>{try{let $=x?"png":"jpeg",A=await k("Page.captureScreenshot",{format:$,...x?{}:{quality:v},fromSurface:!0,captureBeyondViewport:!1,...x?{clip:x}:{}});return typeof A.data=="string"&&A.data?`data:image/${$};base64,${A.data}`:void 0}catch{return}};return{async open(x){try{await k("Page.navigate",{url:x}),await g.waitLoad(b,bh),await YC(800);let $=(await k("Page.getFrameTree")).frameTree?.frame?.url??x;return KC(x,$)?$:null}catch{return null}},async evaluate(x,v){let $=await k("Runtime.evaluate",{expression:x,awaitPromise:v,returnByValue:!0});if(!$.exceptionDetails)return $.result?.value},async screenshot(x,v){try{let A=(await k("Page.getLayoutMetrics")).cssVisualViewport;return y(Wm(x,{x:A?.pageX??0,y:A?.pageY??0},v))}catch{return}},async screenshotViewport(x=60){return y(void 0,x)},async location(){try{return(await k("Page.getFrameTree")).frameTree?.frame?.url??null}catch{return null}},close:c}}catch(m){throw await c(),m}}async function qC(e,t){if(t){let o=(await e.send("Target.getTargets")).targetInfos?.find(s=>s.type==="page");if(o)return o.targetId}return(await e.send("Target.createTarget",{url:"about:blank"})).targetId}async function JC(e,t,n=3e3){let r=()=>e.exitCode!==null||e.signalCode!==null||!e.pid,o=()=>new Promise(s=>{if(r()){s();return}let i=()=>{clearTimeout(l),e.off("exit",i),s()},l=setTimeout(i,n);e.once("exit",i)});try{if(r()||(t&&(t.send("Browser.close").catch(()=>{}),await o()),r()||(e.kill("SIGTERM"),await o()),r()||(e.kill("SIGKILL"),await o())),!r())throw new Error("Chrome did not close. Close Grum's capture window before trying again.")}finally{await t?.close()}}function KC(e,t){try{return new URL(e).host===new URL(t).host}catch{return!1}}function XC(e,t){return new Promise((n,r)=>{let o="",s=()=>{clearTimeout(i),e.stderr?.off("data",l),e.off("exit",c),e.off("error",a)},i=setTimeout(()=>{s(),r(new Error("Chrome did not open a debug port."))},t),l=u=>{o+=u.toString("utf8");let p=o.match(/DevTools listening on (ws:\/\/\S+)/);p?.[1]&&(s(),n(p[1]))};e.stderr?.on("data",l);let a=u=>{s(),r(u)},c=()=>{s(),r(new Error("Chrome couldn't start here. If an editor's agent ran this, run it from a normal terminal instead."))};e.once("exit",c),e.once("error",a)})}async function ZC(e){let t=new WebSocket(e);await new Promise((i,l)=>{let a=setTimeout(()=>{t.close(),l(new Error("Timed out connecting to Chrome."))},wh);t.addEventListener("open",()=>{clearTimeout(a),i()},{once:!0}),t.addEventListener("error",()=>{clearTimeout(a),t.close(),l(new Error("Could not talk to Chrome."))},{once:!0})});let n=1,r=new Map,o=new Set,s=()=>{for(let i of r.values())i.reject(new Error("Chrome closed."));r.clear()};return t.addEventListener("close",s),t.addEventListener("error",s),t.addEventListener("message",i=>{let l=typeof i.data=="string"?i.data:"";if(!l)return;let a;try{a=JSON.parse(l)}catch{return}if(a.method==="Page.loadEventFired")for(let u of[...o])u(a.sessionId??a.params?.sessionId);if(typeof a.id!="number")return;let c=r.get(a.id);if(c){if(r.delete(a.id),a.error){c.reject(new Error(a.error.message||"Chrome command failed."));return}c.resolve(a.result)}}),{send(i,l,a){let c=n++,u={id:c,method:i};return l&&(u.params=l),a&&(u.sessionId=a),new Promise((p,d)=>{let f=setTimeout(()=>{r.delete(c),d(new Error(`Chrome timed out: ${i}.`))},bh);r.set(c,{resolve:m=>{clearTimeout(f),p(m)},reject:m=>{clearTimeout(f),d(m)}});try{if(t.readyState!==WebSocket.OPEN)throw new Error("Chrome closed.");t.send(JSON.stringify(u))}catch(m){clearTimeout(f),r.delete(c),d(m)}})},waitLoad(i,l){return new Promise(a=>{let c=()=>{clearTimeout(u),o.delete(p),a()},u=setTimeout(c,l),p=d=>{d&&d!==i||c()};o.add(p)})},async close(){s(),o.clear(),t.close()}}}function YC(e){return new Promise(t=>setTimeout(t,e))}import{createInterface as kh}from"node:readline/promises";async function ge(e,t,n=`Please answer one of the options.
|
|
472
472
|
`){let r=kh({input:process.stdin,output:process.stderr}),o=!1;r.on("SIGINT",()=>{process.stderr.write(`
|
|
473
|
-
`),process.exit(130)}),r.on("close",()=>{o||process.exit(130)});try{for(;;){let s=t(await r.question(e));if(s!=null)return o=!0,s;process.stderr.write(n)}}finally{o=!0,r.close()}}var
|
|
473
|
+
`),process.exit(130)}),r.on("close",()=>{o||process.exit(130)});try{for(;;){let s=t(await r.question(e));if(s!=null)return o=!0,s;process.stderr.write(n)}}finally{o=!0,r.close()}}var Ne=()=>!!(process.stdin.isTTY&&process.stderr.isTTY);async function xh(e,t,n){process.stderr.write(`${t}...
|
|
474
474
|
`);let r=kh({input:process.stdin,output:process.stderr}),o=!1;r.on("line",()=>{o=!0}),r.on("SIGINT",()=>{process.stderr.write(`
|
|
475
|
-
`),process.exit(130)});let s=Date.now()+n;try{for(;!o&&Date.now()<s;){if(e())return!0;await new Promise(i=>setTimeout(i,1500))}return e()}finally{r.close()}}import{execFileSync as ni}from"node:child_process";import{existsSync as QC,readdirSync as eR,readFileSync as hc,statSync as tR}from"node:fs";import ut from"node:path";function le(e,t){try{return ni("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:64*1024*1024})}catch{return null}}function nR(e,t){try{return ni("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:15e3,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}})}catch{return null}}function Sh(e){let t=le(e.repoDir,["status","--porcelain"]),n=le(e.repoDir,["rev-parse","HEAD"])?.trim()||null,o=le(e.repoDir,["symbolic-ref","--quiet","refs/remotes/origin/HEAD"])?.trim().replace(/^refs\/remotes\/origin\//,"")||["main","master"].find(i=>le(e.repoDir,["rev-parse","--verify","--quiet",`refs/remotes/origin/${i}`]))||null,s=o&&nR(e.repoDir,["ls-remote","origin",`refs/heads/${o}`])?.split(/\s/)[0]||null;return{clean:t!==null&&t.trim()==="",branch:Se(e)||null,defaultBranch:o,head:n,remote:s}}function $h(e,t){try{return ni("git",["-c","core.quotePath=false","diff","-U0","--no-color","--no-ext-diff",...t],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:64*1024*1024})}catch(n){let r=n;return r.status===1&&typeof r.stdout=="string"?r.stdout:null}}function ir(e,t=""){let n=le(e,["rev-parse","--show-toplevel"])?.trim()||e;return{repoDir:n,root:
|
|
475
|
+
`),process.exit(130)});let s=Date.now()+n;try{for(;!o&&Date.now()<s;){if(e())return!0;await new Promise(i=>setTimeout(i,1500))}return e()}finally{r.close()}}import{execFileSync as ni}from"node:child_process";import{existsSync as QC,readdirSync as eR,readFileSync as hc,statSync as tR}from"node:fs";import ut from"node:path";function le(e,t){try{return ni("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:64*1024*1024})}catch{return null}}function nR(e,t){try{return ni("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:15e3,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}})}catch{return null}}function Sh(e){let t=le(e.repoDir,["status","--porcelain"]),n=le(e.repoDir,["rev-parse","HEAD"])?.trim()||null,o=le(e.repoDir,["symbolic-ref","--quiet","refs/remotes/origin/HEAD"])?.trim().replace(/^refs\/remotes\/origin\//,"")||["main","master"].find(i=>le(e.repoDir,["rev-parse","--verify","--quiet",`refs/remotes/origin/${i}`]))||null,s=o&&nR(e.repoDir,["ls-remote","origin",`refs/heads/${o}`])?.split(/\s/)[0]||null;return{clean:t!==null&&t.trim()==="",branch:Se(e)||null,defaultBranch:o,head:n,remote:s}}function $h(e,t){try{return ni("git",["-c","core.quotePath=false","diff","-U0","--no-color","--no-ext-diff",...t],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:64*1024*1024})}catch(n){let r=n;return r.status===1&&typeof r.stdout=="string"?r.stdout:null}}function ir(e,t=""){let n=le(e,["rev-parse","--show-toplevel"])?.trim()||e;return{repoDir:n,root:Ve(t),skipShared:[],stateDir:ut.join(n,".grum")}}function rR(e){if(!e||typeof e!="object")return!1;let t=e;return t.killed===!0||t.code==="ETIMEDOUT"||t.code==="ERR_CHILD_PROCESS_STDIO_MAXBUFFER"}function vh(e,t){try{return ni("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],maxBuffer:64*1024*1024,timeout:Ks})}catch(n){return rR(n)?"timeout":null}}function Vt(e,t){let n=new Map,r=new TextDecoder("utf-8",{fatal:!1}),o=Date.now(),s=0,i=0,l=!1,a=!1,c=!1,u=()=>({files:n,truncated:l,skipped:i,ms:Date.now()-o,stalled:a}),p=()=>{let S=Date.now()-o;return!c&&S>=Xl&&(c=!0,t?.onSlow?.()),S>=Ks?(a=!0,!0):!1},d=(S,h,b)=>{if(l||a||p())return;if(ln(S)){i++;return}let k=b;if(k===void 0)try{k=tR(h).size}catch{return}if(!Yl(S,k)){i++;return}let y;try{y=hc(h)}catch{return}if(tm(y)){i++;return}if(s+y.length>em){l=!0;return}s+=y.length,n.set(S,r.decode(y))},f=vh(e.repoDir,["ls-files","-z","--cached","--others","--exclude-standard","--",e.root||"."]);if(f==="timeout")return a=!0,u();if(f!==null){for(let S of f.split("\0")){if(!S||l||a||p())break;let h=Ht(S,e.root);h!==null&&d(h,ut.join(e.repoDir,S))}return g(),u()}let m=(S,h)=>{if(l||a||p())return;let b;try{b=eR(S,{withFileTypes:!0}).sort((k,y)=>k.name.localeCompare(y.name))}catch{return}for(let k of b){if(l||a||p())return;let y=h?`${h}/${k.name}`:k.name,x=ut.join(S,k.name);if(k.isDirectory()){Zl(y)&&m(x,y);continue}k.isFile()&&d(y,x)}};return m(ut.join(e.repoDir,e.root),""),g(),u();function g(){if(!e.root||l||a)return;let S=vh(e.repoDir,["ls-files","-z","--cached","--others","--exclude-standard"]);if(!S||S==="timeout")return;let h=S.split("\0").filter(Boolean),b=h.map(v=>({path:v})),k=new Map,y=0;for(let v of[...h].sort()){if(y>=200)break;if(!(v!=="package.json"&&!v.endsWith("/package.json"))&&!ln(v)){y++;try{k.set(v,hc(ut.join(e.repoDir,v),"utf8"))}catch{continue}}}let x=new Map;for(let[v,$]of n)x.set(Hd(v,e.root),$);for(let v of h)if(!(x.has(v)||!/(^|\/)tsconfig[^/]*\.json$/.test(v)))try{x.set(v,hc(ut.join(e.repoDir,v),"utf8"))}catch{continue}for(let v of Yg(e.root,b,k,x))for(let $ of h){if($!==v.folder&&!$.startsWith(`${v.folder}/`))continue;let A=Kg(e.root,$);!A||n.has(A)||d(A,ut.join(e.repoDir,$))}}}function Ch(e,t){let n=le(e.repoDir,["diff","--cached","--name-status","-z"]);if(n===null)return t;let r=om(n).map(({path:o,deleted:s})=>({path:o,content:s?null:le(e.repoDir,["show",`:${o}`])}));return{...t,files:rm(t.files,r,e.root)}}function ri(e){let t=le(e.repoDir,["remote","get-url","origin"])?.trim();return t?Xs(t):null}function Se(e){return le(e.repoDir,["symbolic-ref","--quiet","--short","HEAD"])?.trim()||""}function Rh(e){return le(e.repoDir,["config","--get","core.hooksPath"])?.trim()||le(e.repoDir,["rev-parse","--git-path","hooks"])?.trim()||null}function Ah(e){for(let t of["@{upstream}","origin/HEAD"]){let n=le(e.repoDir,["merge-base","HEAD",t])?.trim();if(n)return n}return"HEAD"}function yc(e,t,n,r=!1){let o=["--no-renames",...r?["--cached"]:[]],s=["--",e.root||"."],i=c=>{let u=new Map,p=$h(e.repoDir,[...o,c,...s]);for(let[d,f]of dl(p??"")){let m=Ht(d,e.root);m!==null&&u.set(m,f)}return u},a=i(le(e.repoDir,["rev-parse","-q","--verify",n])?n:"4b825dc642cb6eb9a060e54bf8d69288fbee4904");if(le(e.repoDir,["rev-parse","-q","--verify","MERGE_HEAD"])){let c=i("MERGE_HEAD");a=new Map([...a].map(([u,p])=>[u,$f(p,c.get(u)??[])]))}if(!r)for(let c of(le(e.repoDir,["ls-files","--others","--exclude-standard","-z",...s])??"").split("\0")){let u=c&&Ht(c,e.root);u&&a.set(u,[ds])}return Eh(t,a)}function Ih(e,t,n,r){let o=new Map,s=ut.join(e.repoDir,e.root);for(let i of n){if(!t.has(i))continue;let l=ut.join(r,i),a=QC(l)?$h(e.repoDir,["--no-index",l,ut.join(s,i)]):null;o.set(i,a===null?[ds]:[...dl(a).values()].flat())}return Eh(t,o)}function Eh(e,t){let n=new Map;for(let[r,o]of t){let s=e.get(r);s!==void 0&&o.length&&n.set(r,Cf(s,o))}return n}var pe=()=>Fs(V);async function he(e,t={}){let{token:n,timeout:r,...o}=t,s=new Headers(o.headers);n&&s.set("Authorization",`Bearer ${n}`),o.body&&!(o.body instanceof FormData)&&s.set("Content-Type","application/json");try{let i=await fetch(`${V}${e}`,{...o,headers:s,signal:AbortSignal.timeout(r??15e3)});return{status:i.status,body:await i.json().catch(()=>({}))??{}}}catch{return{status:0,body:{error:`Couldn't reach Grum at ${V}. The connection is down or too slow (Grum waits 15 seconds).`}}}}async function wc(e){try{return(await fetch(`${e.apiOrigin}/api/cli/login`,{method:"DELETE",headers:{Authorization:`Bearer ${e.token}`},signal:AbortSignal.timeout(1e4)})).ok}catch{return!1}}function _h(e){if(process.env.GRUM_NO_BROWSER)return;let t=process.platform==="darwin"?"open":process.platform==="win32"?"explorer.exe":"xdg-open";oR(t,[e],{timeout:5e3},()=>{})}async function ii(){let e=to(V);if(e)return{ok:!0,...e};let t=await he("/api/cli/login",{method:"POST"}),{code:n,poll:r,url:o,expiresIn:s}=t.body;if(t.status!==200||!n||!r||!o)return{ok:!1,message:`couldn't start sign-in (${t.status||"offline"}). Is Grum running at ${V}?`};let i=new Date(Date.now()+(s??600)*1e3).toISOString();return Em({apiOrigin:V,poll:r,code:n,url:o,expiresAt:i}),{ok:!0,code:n,url:o,expiresAt:i}}async function kc(){let e=oc(V);if(!e)return"expired";let t=await he("/api/cli/login/poll",{method:"POST",body:JSON.stringify({poll:e.poll})});return t.status===0?"offline":t.body.status==="approved"&&typeof t.body.token=="string"?(Lg({token:t.body.token,apiOrigin:V}),xn(V),"approved"):t.body.status==="expired"?(xn(V),"expired"):"pending"}async function io(){let e=await ii();if(!e.ok)return process.stderr.write(`grum: ${e.message}
|
|
476
476
|
`),1;process.stderr.write(`Sign in to Grum to connect this computer.
|
|
477
477
|
|
|
478
478
|
Code: ${e.code}
|
|
@@ -497,7 +497,7 @@ Live site for ${t}, so Grum can check its colors too.
|
|
|
497
497
|
For example: https://${is(t)||"acme"}.com. Type "none" to skip.
|
|
498
498
|
|
|
499
499
|
URL${n?` (${n})`:""}: `;return ge(r,o=>{let s=o.trim();if(/^(none|skip|no|n|-)$/i.test(s))return{site:null};let i=cn(s||n||"");return s||n?i?{site:i}:null:{site:null}},`That doesn't look like a URL. Try https://example.com, or type none.
|
|
500
|
-
`).then(o=>o.site)}async function ao(e,t,n,r,o){let s=new URLSearchParams({repo:t});return n&&s.set("project",n),o!==void 0&&s.set("root",o),he(`/api/cli/project?${s}`,{token:e,timeout:r})}function bc(e){return{line:e?.line??null,url:e?.workspaceId?mm(V,e.workspaceId):null}}async function ai(e){let t=pe();if(!t)return null;let n=await he(`/api/cli/extension?${new URLSearchParams({project:e})}`,{token:t.token,timeout:4e3}),r=n.body;return n.status!==200||typeof r.connected!="boolean"?null:{connected:r.connected,extensionId:typeof r.extensionId=="string"?r.extensionId:null,build:r.build==="dev"?"dev":"store"}}async function lo(e){let t=ri(e);if(!t)return{line:null,url:null,needsSetup:!1};let n=ym(
|
|
500
|
+
`).then(o=>o.site)}async function ao(e,t,n,r,o){let s=new URLSearchParams({repo:t});return n&&s.set("project",n),o!==void 0&&s.set("root",o),he(`/api/cli/project?${s}`,{token:e,timeout:r})}function bc(e){return{line:e?.line??null,url:e?.workspaceId?mm(V,e.workspaceId):null}}async function ai(e){let t=pe();if(!t)return null;let n=await he(`/api/cli/extension?${new URLSearchParams({project:e})}`,{token:t.token,timeout:4e3}),r=n.body;return n.status!==200||typeof r.connected!="boolean"?null:{connected:r.connected,extensionId:typeof r.extensionId=="string"?r.extensionId:null,build:r.build==="dev"?"dev":"store"}}async function lo(e){let t=ri(e);if(!t)return{line:null,url:null,needsSetup:!1};let n=ym(He(e),t,V),r=pe();if(!r)return{...bc(n),needsSetup:!1};let o=await ao(r.token,t,Kr(e)??void 0,2500,e.root);if(o.status===0||o.status===401||o.status>=500)return{...bc(n),needsSetup:!1};let s=o.status===404||o.body.code==="choose-project";return{...bc(hm(o.status,o.body)),needsSetup:s}}async function cR(e){let t=await he("/api/cli/github",{token:e,timeout:4e3});if(t.status===200&&t.body.ok===!0)return"ok";let n=typeof t.body.error=="string"?t.body.error:"";return t.body.code==="no_github"||$t(n)?"rejected":"unknown"}async function Oh(e,t,n,r,o=!1){let s=new qe,i=Date.now()+5*6e4;try{for(;Date.now()<i;){let l=await ao(e,t,n.id);if(l.status===200){s.stop();let c={schema:1,apiOrigin:V,fetchedAt:new Date().toISOString(),...l.body};return bn(r,c),{ok:!0,cached:c,...o?{created:!0}:{}}}let a=l.body.scan;if(l.body.code!=="not-scanned"||a?.status==="failed"){s.stop();let c=a?.error??(typeof l.body.error=="string"?l.body.error:`Grum answered ${l.status}.`);if(Un(c))return{ok:!1,reason:"needs-repo-access",repo:t,message:ro(t)};let u=`The scan of ${t} didn't finish. ${c}`;return{ok:!1,reason:$t(c)?"needs-github":"unavailable",message:u}}s.start(a?.label?`Reading ${t}: ${a.label.toLowerCase()}`:`Reading ${t}`),await new Promise(c=>setTimeout(c,1500))}}finally{s.stop()}return{ok:!1,reason:"not-scanned",message:`Still reading ${t}. Grum is waiting on its servers (usually GitHub). A slow connection can make this take a few minutes. Run \`${Q} check\` again, or watch it at ${V}.`}}function uR(e){return e.root||Js({repoDir:e.repoDir,cwd:process.cwd()})}async function pR(e,t,n){let r=await lR(e,n),o=Qd(n),s=c=>he("/api/cli/workspaces",{method:"POST",token:c,body:JSON.stringify({repo:n,name:o,site:r,root:uR(e)})}),i=t,l=await s(i);if(nc(l.status,l.body)==="github"){let c=typeof l.body.error=="string"?l.body.error:"GitHub rejected the token. Sign in with GitHub again.",u=await ge(`
|
|
501
501
|
${c}
|
|
502
502
|
|
|
503
503
|
Sign in with GitHub to continue? (Enter) sign in, (n) not now: `,kn)==="yes",p=u&&await oo()===0?pe():null;if(!p)return{ok:!1,reason:"unavailable",message:c,...u?{}:{declined:!0}};i=p.token,l=await s(i)}if(nc(l.status,l.body)==="github")return{ok:!1,reason:"unavailable",message:typeof l.body.error=="string"?l.body.error:"GitHub rejected the token. Sign in with GitHub again."};if(Sn(l.body.code)==="no-access"){let c=await ge(`
|
|
@@ -513,7 +513,7 @@ URL${s?` (${s})`:" (none)"}: `,a=>Kd(s,a),`That doesn't look like a URL. Try htt
|
|
|
513
513
|
`);if(i.site!==s)if(!r)process.stderr.write(`Not signed in, so the live site was left as it is.
|
|
514
514
|
`);else if(t.project.role!=="owner")process.stderr.write(`Only an owner can change the live site, so it was left as it is.
|
|
515
515
|
`);else{let a=await he("/api/cli/project",{method:"PATCH",token:r.token,body:JSON.stringify({projectId:t.project.id,site:i.site})});if(a.status!==200){let c=typeof a.body.error=="string"?a.body.error:`Grum answered ${a.status}.`;process.stderr.write(`Couldn't update the live site. ${c}
|
|
516
|
-
`)}else{let c=
|
|
516
|
+
`)}else{let c=He(e);c?.project.id===t.project.id&&bn(e,{...c,project:{...c.project,site:i.site}}),process.stderr.write(i.site?`Live site set to ${Wd(i.site)}. It applies on the next scan.
|
|
517
517
|
`:`Live site removed. It applies on the next scan.
|
|
518
518
|
`)}}if(r){let a=await dR(r.token,o);if(a&&a.length>1){let c=a.findIndex(g=>g.id===t.project.id),u=c>=0?c:0,p=a[u].workspace.name,d=a.map((g,S)=>` ${S+1} ${g.workspace.name}${g.repoRoot?` \xB7 ${g.repoRoot}`:""}${S===u?" (current)":""}`).join(`
|
|
519
519
|
`),f=await ge(`
|
|
@@ -543,14 +543,14 @@ Several workspaces use ${r}:
|
|
|
543
543
|
${c}
|
|
544
544
|
|
|
545
545
|
Which one? `,p=>{let d=Number(p.trim());return Number.isInteger(d)&&d>=1&&d<=a.length?d-1:null});o=a[u].id,er(e,o);continue}return i.body.code==="choose-project"?{ok:!1,reason:"no-project",message:`Several workspaces use this repository. Run \`${Q} setup\` in a terminal to pick one.`}:{ok:!1,reason:"unavailable",message:l}}return{ok:!1,reason:"unavailable",message:"Couldn't pick a project."}}function oi(e){if(!e||typeof e!="object")return null;let t=e;if(typeof t.id!="string"||!t.id)return null;let n=t.workspace?.name;return{id:t.id,name:typeof n=="string"&&n?n:t.id,role:t.role==="viewer"?"viewer":"owner",site:typeof t.site=="string"?t.site:null}}function Sn(e){return e==="no_github"||e==="needs_repo_scope"?"missing":e==="forbidden"||e==="not_found"?"no-access":null}async function Dh(e,t,n=!0){let r={offline:!1,offlineMessage:null,signedIn:!1,signInExpired:!1,github:null,githubMessage:null,projects:null,selectedId:null,staleProjectId:null,scan:"unknown",scanMessage:null,kit:null},o=ri(e);if(!o)return r;let s=pe();if(!s)return r;let i=await ao(s.token,o,t||void 0,void 0,e.root),l=typeof i.body.error=="string"?i.body.error:null;if(i.status===0)return{...r,signedIn:!0,offline:!0,offlineMessage:l,github:"connected"};if(i.status===401)return{...r,signInExpired:!0};let a=Sn(i.body.code);if(a)return{...r,signedIn:!0,github:a,githubMessage:l};if(i.status===404)return{...r,signedIn:!0,github:"connected",projects:[]};if(i.body.code==="choose-project"&&Array.isArray(i.body.projects)){let u=i.body.projects.map(oi).filter(p=>p!==null);return{...r,signedIn:!0,github:"connected",projects:u,staleProjectId:t&&!u.some(p=>p.id===t)?t:null}}let c=oi(i.body.project);if(i.body.code==="not-scanned"&&c){let u=i.body.scan,p=u?.status==="failed";return{...r,signedIn:!0,github:"connected",projects:[c],selectedId:c.id,scan:p?"failed":u?.status==="running"?"running":"needed",scanMessage:u?.error??l}}if(i.status===200&&c){let u={schema:1,apiOrigin:V,fetchedAt:new Date().toISOString(),...i.body};n&&bn(e,u);let p=i.body.pending,d=i.body.kit;return{...r,signedIn:!0,github:"connected",projects:[c],selectedId:c.id,scan:p?p.status==="failed"?"failed":p.status==="running"?"running":"needed":"done",scanMessage:p?.error??null,kit:d&&typeof d.id=="string"&&typeof d.version=="string"?{id:d.id,version:d.version}:null}}return{...r,signedIn:!0,github:"connected",offlineMessage:l,projects:null}}async function Ph(e,t){let n=pe();if(!n)return{ok:!1,github:null,message:"Not signed in.",signedOut:!0};let r=await he("/api/cli/workspaces",{method:"POST",token:n.token,body:JSON.stringify({repo:e,name:t.name,site:t.site,root:t.root??""})}),o=typeof r.body.error=="string"?r.body.error:`Grum answered ${r.status}.`,s=oi(r.body.project);if((r.status===201||r.status===409)&&s)return{ok:!0,project:s,reconciled:r.status===409};let i=Sn(r.body.code);return i?{ok:!1,github:i,message:o}:r.status===401?{ok:!1,github:null,message:o,signedOut:!0}:{ok:!1,github:null,message:o}}async function Lh(e){let t=pe();if(!t)return{ok:!1,github:null,message:"Not signed in.",signedOut:!0};let n=await he("/api/cli/scan",{method:"POST",token:t.token,body:JSON.stringify({projectId:e})}),r=typeof n.body.error=="string"?n.body.error:`Grum answered ${n.status}.`;if(n.status===202||n.status===200)return{ok:!0,project:{id:e,name:e,role:"owner",site:null}};let o=Sn(n.body.code);return o?{ok:!1,github:o,message:r}:n.status===401?{ok:!1,github:null,message:r,signedOut:!0}:{ok:!1,github:null,message:r}}async function Sc(e){let t=pe();if(!t)return{ok:!1,message:"Not signed in.",signedOut:!0};let n=await he(`/api/cli/starter?${new URLSearchParams({project:e})}`,{token:t.token});if(n.status===401)return{ok:!1,message:"Not signed in.",signedOut:!0};let r=n.body.project,o=n.body.kit;return n.status!==200||typeof r?.id!="string"||typeof r.name!="string"||typeof o?.name!="string"||typeof o.version!="string"?{ok:!1,message:typeof n.body.error=="string"?n.body.error:`Grum answered ${n.status}.`}:{ok:!0,project:{id:r.id,name:r.name,role:r.role==="viewer"?"viewer":"owner",repo:typeof r.repo=="string"?r.repo:null},kit:{name:o.name,version:o.version},starter:n.body.starter}}async function Nh(e,t){let n=pe();if(!n)return{ok:!1,github:null,message:"Not signed in.",signedOut:!0};let r=await he("/api/cli/project",{method:"PATCH",token:n.token,body:JSON.stringify({projectId:e,repo:t})}),o=typeof r.body.error=="string"?r.body.error:`Grum answered ${r.status}.`,s=oi(r.body.project);if(r.status===200&&s)return{ok:!0,project:s};let i=Sn(r.body.code);return i?{ok:!1,github:i,message:o}:r.status===401?{ok:!1,github:null,message:o,signedOut:!0}:{ok:!1,github:null,message:o}}async function Fh(e,t){let n=pe();if(!n)return{ok:!1,message:"Not signed in."};let r=await he("/api/cli/project",{method:"PATCH",token:n.token,body:JSON.stringify({projectId:e,site:t})});return r.status===200?{ok:!0}:{ok:!1,message:typeof r.body.error=="string"?r.body.error:`Grum answered ${r.status}.`}}var Th=1e3,Uh=e=>/[.!?]$/.test(e.trim())?e.trim():`${e.trim()}.`,Je=e=>({ok:!1,text:e});function fR(e,t,n){return ge(e,r=>kt(r.trim()||t||"",n,so),`Enter a URL like http://localhost:3000, or a file in this repo like ./index.html.
|
|
546
|
-
`)}var so=e=>{try{return sR(e).isFile()}catch{return!1}};async function gR(e,t,n,r,o,s){let l=Gn(r,f=>zh(e.repoDir,f)),a=l&&o.pageUrl?pn({url:o.pageUrl,query:l}):null;if(o.noCapture||!l)return{capture:null,locate:a,source:"none"};let c=cs({pageUrl:o.pageUrl,saved:St(e),packageJson:ne(no.join(e.repoDir,"package.json")),site:t.project.site,live:o.live,places:r.places,interactive:
|
|
547
|
-
`);try{let f=await s.capture({finding:r,site:t.project.site,pageUrl:u,onlyPage:p,repoDir:e.repoDir,browser:o.browser??d.browser,chromeProfile:d.chromeProfile,bridge:{apiOrigin:V,token:n.token,projectId:t.project.id}});return Ft(f)?{capture:f,locate:f.url?pn({url:f.url,query:l}):a,source:f.url?lf(f.url,t.project.site,!!o.pageUrl):"none"}:{failure:wf(f)}}catch(f){if(Hm(f))throw f;return{failure:Uh(f instanceof Error?f.message:String(f))}}}function zh(e,t){if(!t||t.includes("..")||no.isAbsolute(t))return;let n=ne(no.join(e,t));return n!==null&&n.length<=2e5?n:void 0}async function si(e,t,n,r={},o={capture:gc}){let s=await mR(e,t,n,r,o),i=Se(e);if(i){let l=Wt(e);wn(e,{...l,reviews:{...l.reviews,[t.key]:{branch:i,uses:t.uses,ok:s.ok,text:s.ok?s.state.status:s.text}}})}return s}async function $c(e,t,n,r={},o={capture:gc}){let s=async()=>{let f={};for(let m of t)f[m.key]=await si(e,m,n,r,o);return f};if(t.length<2||r.noCapture)return s();let i=pe(),l=
|
|
546
|
+
`)}var so=e=>{try{return sR(e).isFile()}catch{return!1}};async function gR(e,t,n,r,o,s){let l=Gn(r,f=>zh(e.repoDir,f)),a=l&&o.pageUrl?pn({url:o.pageUrl,query:l}):null;if(o.noCapture||!l)return{capture:null,locate:a,source:"none"};let c=cs({pageUrl:o.pageUrl,saved:St(e),packageJson:ne(no.join(e.repoDir,"package.json")),site:t.project.site,live:o.live,places:r.places,interactive:Ne()});if(c.action==="error")return{failure:c.message};if(c.action==="ask-agent")return{failure:df};let u=c.action==="open"?c.url:void 0,p=c.action==="open"?c.onlyPage:!0;c.action==="ask-person"?(u=await fR(ff(),null,e.repoDir),p=!0,tr(e,u)):c.action==="open"&&c.save&&tr(e,c.save);let d=Ws(e);o.browser&&Hs(e,{...d,browser:o.browser}),u&&(s.write??(f=>process.stderr.write(f)))(`Capturing from ${il(u,t.project.site)}: ${us(u,e.repoDir)}
|
|
547
|
+
`);try{let f=await s.capture({finding:r,site:t.project.site,pageUrl:u,onlyPage:p,repoDir:e.repoDir,browser:o.browser??d.browser,chromeProfile:d.chromeProfile,bridge:{apiOrigin:V,token:n.token,projectId:t.project.id}});return Ft(f)?{capture:f,locate:f.url?pn({url:f.url,query:l}):a,source:f.url?lf(f.url,t.project.site,!!o.pageUrl):"none"}:{failure:wf(f)}}catch(f){if(Hm(f))throw f;return{failure:Uh(f instanceof Error?f.message:String(f))}}}function zh(e,t){if(!t||t.includes("..")||no.isAbsolute(t))return;let n=ne(no.join(e,t));return n!==null&&n.length<=2e5?n:void 0}async function si(e,t,n,r={},o={capture:gc}){let s=await mR(e,t,n,r,o),i=Se(e);if(i){let l=Wt(e);wn(e,{...l,reviews:{...l.reviews,[t.key]:{branch:i,uses:t.uses,ok:s.ok,text:s.ok?s.state.status:s.text}}})}return s}async function $c(e,t,n,r={},o={capture:gc}){let s=async()=>{let f={};for(let m of t)f[m.key]=await si(e,m,n,r,o);return f};if(t.length<2||r.noCapture)return s();let i=pe(),l=He(e);if(!i||!l)return s();let a=cs({pageUrl:r.pageUrl,saved:St(e),packageJson:ne(no.join(e.repoDir,"package.json")),site:l.project.site,live:r.live,places:t[0]?.places,interactive:!1});if(a.action!=="open")return s();let c=[];for(let f of t){let m=Gn(f,h=>zh(e.repoDir,h)),g=r.live?cs({pageUrl:r.pageUrl,site:l.project.site,live:!0,places:f.places,interactive:!1}):a;if(g.action!=="open")return s();let S=m?Or({site:l.project.site,pageUrl:g.url,onlyPage:g.onlyPage,places:f.places,repoDir:e.repoDir}).find(h=>/^https?:\/\//.test(h)):void 0;if(!m||!S)return s();c.push({key:f.key,label:f.title,page:S,query:m,state:"waiting"})}let u={},p={};for(let f of Gm(c))try{(o.write??(g=>process.stderr.write(g)))(`Capturing from ${il(f.page,l.project.site)}: ${f.page}
|
|
548
548
|
`);let m=await(o.captureBatch??eh)({projectId:l.project.id,title:f.items.length===1?f.items[0].label:`${f.items.length} review items`,pages:[f.page],query:f.items[0].query,queries:f.items.map(g=>g.query),items:f.items,authRequired:!0},{apiOrigin:V,token:i.token});Object.assign(u,m.captures)}catch(m){let g=Uh(m instanceof Error?m.message:"Couldn't capture this page");for(let S of f.items)p[S.key]=g}let d={};for(let f of t){let m=u[f.key];d[f.key]=await si(e,f,n,r,{...o,write:()=>{},capture:async()=>{if(!m)throw new Error(p[f.key]??`Couldn't capture ${f.key}. Review wasn't sent.`);return m}})}return d}async function mR(e,t,n,r,o){if(n&&n.length>Th)return Je(`Send a reason of ${Th} characters or fewer.`);let s=r.pageUrl?kt(r.pageUrl,e.repoDir,so):void 0;if(r.pageUrl&&!s)return Je("Send an http or https page URL, or the path to an HTML file in this repo, with --url (MCP: url).");let i={...r,pageUrl:s??void 0},l=pe();if(!l)return Je(`Not signed in to Grum. Run \`${Q} login\`, then ask again.`);let a=Se(e);if(!a)return Je("This folder is not on a named git branch. A review is asked for on a branch, so check one out and ask again.");if(i.expected&&i.expected.branch!==a)return Je("The branch changed since this check. Check again before sending it for review.");let c=await pt(e,{interactive:!1});if(!c.ok)return Je(`${c.message}
|
|
549
549
|
Review wasn't sent.`);let{cached:u}=c;if(i.expected&&i.expected.projectId!==u.project.id)return Je("The project changed since this check. Check again before sending it for review.");let p=Dr(Vt(e).files,u,a).findings.find(z=>z.key===t.key);if(!p)return Je(`${t.key} isn't new drift in this checkout. Run \`${Q} check\` for the current keys.
|
|
550
550
|
Review wasn't sent.`);let d=Wn(p);if(i.expected&&i.expected.observed!==d)return Je("This change was edited since this check. Check again before sending it for review.");let f=Bn(u.requests,a).get(t.key);if(p.coverage==="pending"||p.coverage==="allowed"||p.coverage==="rejected"&&(!f?.observed||f.observed===d))return f?{ok:!0,state:f,captured:!1,created:!1}:Je(`${t.key} is already ${p.coverage}.`);let m=await gR(e,u,l,p,i,o);if("failure"in m)return Je(`${m.failure}
|
|
551
|
-
Review wasn't sent. Add --no-capture to send it without a picture.`);let{key:g,area:S,kind:h,title:b,found:k,foundColor:y,uses:x,places:v,input:$}=p,
|
|
551
|
+
Review wasn't sent. Add --no-capture to send it without a picture.`);let{key:g,area:S,kind:h,title:b,found:k,foundColor:y,uses:x,places:v,input:$}=p,A=new FormData;A.set("request",JSON.stringify({projectId:u.project.id,issue:{key:g,area:S,kind:h,title:b,found:k,foundColor:y,uses:x,places:v,...$?{input:$}:{}},reason:n,branch:a,observed:d,locate:m.locate,provenance:{source:m.source,revision:le(e.repoDir,["rev-parse","HEAD"])?.trim()||null,worktree:(z=>z===null?"unknown":z.trim()?"changed":"clean")(le(e.repoDir,["status","--porcelain"]))}})),m.capture&&yf(A,m.capture);let E=await he("/api/cli/requests",{method:"POST",token:l.token,body:A});if(E.status!==200){let z=typeof E.body.error=="string"?E.body.error:`Grum answered ${E.status}.`;return Je(E.status===0?`${z} The request may not have been sent; check Grum's Review page before asking again.`:z)}let{created:O,...L}=E.body,D=He(e)??u;return bn(e,{...D,requests:[...D.requests.filter(z=>!(z.driftKey===L.driftKey&&(z.branch??null)===(L.branch??null))),L]}),{ok:!0,state:L,captured:!!m.capture,created:O}}async function Gh(e,t,n){let r={addressed:0,reopened:0},o=pe(),s=Se(e);if(!o||!s)return r;let i=await he("/api/cli/reconcile",{method:"POST",token:o.token,body:JSON.stringify({projectId:t.project.id,branch:s,keys:n})});return i.status!==200?(process.stderr.write(`grum: couldn't update rejected reviews (${typeof i.body.error=="string"?i.body.error:i.status}). The local result still stands.
|
|
552
552
|
`),r):{addressed:Number(i.body.addressed)||0,reopened:Number(i.body.reopened)||0}}async function Bh(e,t,n,r){let o=pe(),s=Se(e);if(!o||!s)return;let i=le(e.repoDir,["rev-parse","HEAD"])?.trim()||null,l=await he("/api/cli/reports",{method:"POST",token:o.token,body:JSON.stringify({projectId:t.project.id,branch:s,commit:i,source:r,total:n.length,findings:n.map(a=>({key:a.key,title:a.title,coverage:a.coverage,file:a.places[0]?.file??null,line:a.places[0]?.line??null}))})});l.status!==200&&process.stderr.write(`grum: couldn't report this check (${typeof l.body.error=="string"?l.body.error:l.status}). The local result still stands.
|
|
553
|
-
`)}async function Cc(e,t,n,r){let o=v=>({ok:!1,text:v}),s=kt(r,e.repoDir,so);if(!s)return o("Send an http or https page URL, or the path to an HTML file in this repo, with --url.");let i=pe();if(!i)return o(`Not signed in to Grum. Run \`${Q} login\`, then ask again.`);let l=Se(e);if(!l)return o("This folder is not on a named git branch. A token is added on a branch, so check one out and ask again.");let a=await pt(e,{interactive:!1});if(!a.ok)return o(a.message);if(a.cached.project.role!=="owner")return o("Only workspace owners can change this.");let c=Vt(e);if(n.category==="button"&&(c.truncated||c.stalled))return o("The local source snapshot is incomplete. Resolve that before adding a button.");let u=Dr(c.files,a.cached,l).findings.find(v=>v.key===t.key);if(!u)return o(`${t.key} isn't new drift in this checkout. Run \`${Q} check\` for the current keys.`);let{key:p,area:d,kind:f,title:m,found:g,foundColor:S,uses:h,places:b}=u;if(n.category!=="button"&&(d==="button"||d==="input"))return o("Adding a token does not approve a component. Use category button to add a button design, or request review for an input change.");let k={projectId:a.cached.project.id,name:n.name,category:n.category,value:n.value,url:s,issue:{key:p,area:d,kind:f,title:m,found:g,foundColor:S,uses:h,places:b},branch:l,observed:Wn(u),...n.category==="button"?{files:[...c.files].filter(([v])=>ul.test(v))}:{}};if(n.category==="button"&&!Sf(k))return o("A button needs its current button drift key, a name of at most 40 characters, and at most 2 MB of source in 1000 files.");let y=await he("/api/cli/contract",{method:"POST",token:i.token,body:JSON.stringify(k)});if(y.status!==200){let v=typeof y.body.error=="string"?y.body.error:`Grum answered ${y.status}.`;return o(v)}let x=ps({schema:1,apiOrigin:V,fetchedAt:new Date().toISOString(),...y.body});return x?n.category==="button"&&(!x.buttonSpecs||!Vo(Ta(c.files),x.buttonSpecs).some(v=>v.result==="exact"&&v.spec?.name===n.name))?o("Grum did not return the approved button design. Fetch grum_contract before reporting success."):(bn(e,x),{ok:!0}):o("Grum did not return a readable contract. The addition could not be verified; fetch grum_contract before reporting success.")}var qh=e=>{try{return co(e)}catch{return!1}};function bR(){let e=process.versions.node?`v${process.versions.node}`:"";return{runtimeOk:Number(process.versions.node?.split(".")[0])>=Zs,runtimeVersion:e}}var wR={cursor:[".cursor/hooks.json",".cursor/mcp.json",Pe],codex:[lt,xt,Gt],claude:[Ye,zt,mn]},li=e=>wR[e];function kR(e,t){return t.map(n=>({rel:n,text:ne(
|
|
553
|
+
`)}async function Cc(e,t,n,r){let o=v=>({ok:!1,text:v}),s=kt(r,e.repoDir,so);if(!s)return o("Send an http or https page URL, or the path to an HTML file in this repo, with --url.");let i=pe();if(!i)return o(`Not signed in to Grum. Run \`${Q} login\`, then ask again.`);let l=Se(e);if(!l)return o("This folder is not on a named git branch. A token is added on a branch, so check one out and ask again.");let a=await pt(e,{interactive:!1});if(!a.ok)return o(a.message);if(a.cached.project.role!=="owner")return o("Only workspace owners can change this.");let c=Vt(e);if(n.category==="button"&&(c.truncated||c.stalled))return o("The local source snapshot is incomplete. Resolve that before adding a button.");let u=Dr(c.files,a.cached,l).findings.find(v=>v.key===t.key);if(!u)return o(`${t.key} isn't new drift in this checkout. Run \`${Q} check\` for the current keys.`);let{key:p,area:d,kind:f,title:m,found:g,foundColor:S,uses:h,places:b}=u;if(n.category!=="button"&&(d==="button"||d==="input"))return o("Adding a token does not approve a component. Use category button to add a button design, or request review for an input change.");let k={projectId:a.cached.project.id,name:n.name,category:n.category,value:n.value,url:s,issue:{key:p,area:d,kind:f,title:m,found:g,foundColor:S,uses:h,places:b},branch:l,observed:Wn(u),...n.category==="button"?{files:[...c.files].filter(([v])=>ul.test(v))}:{}};if(n.category==="button"&&!Sf(k))return o("A button needs its current button drift key, a name of at most 40 characters, and at most 2 MB of source in 1000 files.");let y=await he("/api/cli/contract",{method:"POST",token:i.token,body:JSON.stringify(k)});if(y.status!==200){let v=typeof y.body.error=="string"?y.body.error:`Grum answered ${y.status}.`;return o(v)}let x=ps({schema:1,apiOrigin:V,fetchedAt:new Date().toISOString(),...y.body});return x?n.category==="button"&&(!x.buttonSpecs||!Vo(Ta(c.files),x.buttonSpecs).some(v=>v.result==="exact"&&v.spec?.name===n.name))?o("Grum did not return the approved button design. Fetch grum_contract before reporting success."):(bn(e,x),{ok:!0}):o("Grum did not return a readable contract. The addition could not be verified; fetch grum_contract before reporting success.")}var qh=e=>{try{return co(e)}catch{return!1}};function bR(){let e=process.versions.node?`v${process.versions.node}`:"";return{runtimeOk:Number(process.versions.node?.split(".")[0])>=Zs,runtimeVersion:e}}var wR={cursor:[".cursor/hooks.json",".cursor/mcp.json",Pe],codex:[lt,xt,Gt],claude:[Ye,zt,mn]},li=e=>wR[e];function kR(e,t){return t.map(n=>({rel:n,text:ne(Fe.join(e,n))}))}function Hh(e,t){for(let n of t){let r=Fe.join(e,n.rel);n.text===null?yR(r,{force:!0}):xe(r,n.text)}}async function xR(e,t){let n=ne(Fe.join(e.repoDir,"package.json")),r=[n?ef(n):null,kt("./index.html",e.repoDir,qh)].filter(s=>!!s),o=[];for(let s of r){let i=await t(s);o.push({url:s,verified:i!==null&&i<500})}return o}async function Ac(e){let{request:t}=e,n=null,r=i=>(i.exit==="error"&&n&&n(),i);if(!t.probe&&!t.remove){if(to(V)){let l=await kc();if(l==="offline"){let a=await qt(e);return r(Re({...a,offline:!0,offlineMessage:"Couldn't reach Grum. The connection is down or too slow (the CLI waits 15 seconds)."},t).result)}if(!pe()){if(l==="expired"){let a=await ii();if(!a.ok){let c=await qt(e);return r(Re({...c,offline:!0,offlineMessage:a.message},t).result)}}return r(Re(await qt(e),t).result)}}else if(!(await qt(e)).signedIn){let l=await ii();if(!l.ok){let a=await qt(e);return r(Re({...a,offline:!0,offlineMessage:l.message},t).result)}return r(Re(await qt(e),t).result)}}let o="";for(let i=0;i<8;i++){let l=await qt(e),a=Re(l,t);if(!a.mutation)return r(a.result);let c=JSON.stringify(a.mutation);if(c===o)return r(Re({...l,offline:!0,offlineMessage:"Setup repeated a step without finishing it."},t).result);o=c;let u=await CR(e,a.mutation,l);if(u.restore&&(n=u.restore),u.result)return r(u.result)}let s=await qt(e);return r(Re({...s,offline:!0,offlineMessage:"Setup did not finish after its allowed steps."},t).result)}function vR(e,t){if(!t?.ok)return!1;let n=ic(t.starter);if(!n)return!1;let r=Fe.join(e.repoDir,e.root);return!n.markers.app.every(o=>co(Fe.join(r,o)))}async function SR(e,t,n,r){let o=!!t.projectId&&n.projects?.length===0,i=n.kit!==null&&n.selectedId!==null&&n.scan==="needed"?n.selectedId:o?t.projectId:null;if(!i)return null;let l=i===t.projectId&&r?r:await Sc(i);if(!l.ok)return null;let a=ic(l.starter);if(!a)return null;let c=Fe.join(e.repoDir,e.root),u={exists:d=>co(Fe.join(c,d)),read:d=>{try{return Rc(Fe.join(c,d),"utf8")}catch{return null}}},p=Sh(e);return{project:l.project,kit:l.kit,needsRepo:o&&l.project.repo===null,starter:a,state:Lm(a,u,p),defaultBranch:p.defaultBranch}}function $R(e,t){let n=Fe.resolve(e.repoDir,e.root),r=i=>{let l=Fe.resolve(n,i);return l.startsWith(n+Fe.sep)?l:null},o=r(t.tokensFile),s=Object.keys(t.values.light).length+Object.keys(t.values.dark).length;if(s>0&&(!o||!co(o)))return{ok:!1,message:`${t.tokensFile} is not in this app, so the contract's tokens were not written.`};try{if(s>0&&o){let i=Rc(o,"utf8"),l=ac(t,i);l!==i&&Wh(o,l)}for(let i of t.files){let l=r(i.path);if(!l)return{ok:!1,message:`${i.path} is outside this repository.`};let a=co(l)?Rc(l,"utf8"):null;Pm(i,a)&&(hR(Fe.dirname(l),{recursive:!0}),Wh(l,i.content))}}catch(i){return{ok:!1,message:`Couldn't write the starter: ${i instanceof Error?i.message:"unknown error"}.`}}return{ok:!0}}async function qt(e){let t=le(e.ws.repoDir,["remote","get-url","origin"])?.trim(),n=t?Xs(t):null,r=e.request.projectId??Kr(e.ws)??void 0,o=e.request.projectId?await Sc(e.request.projectId):null,s=vR(e.ws,o),i=await Dh(e.ws,r,!s),l=e.host(),a=e.request.agent,c=St(e.ws),u=to(V),p=i.projects?.find(S=>S.id===i.selectedId),d=p?Hg(e.ws,p.id):!1,f=i.selectedId&&i.scan==="done"?await ai(i.selectedId).catch(()=>null):null,m=null,g=null;if(p&&!p.site&&!d&&n){let S=new qe;S.start("Reading files");try{let h=Vt(e.ws,{onSlow:()=>S.start("Reading files is taking longer than usual")});m={ms:h.ms,stalled:h.stalled},g=h.files}finally{S.stop()}}return{cli:e.cli,serverOrigin:V,repoServer:e.repoServer(),...bR(),origin:t?n?"github":"unsupported":"absent",repoName:n,signedIn:i.signedIn,signInExpired:i.signInExpired,pendingLogin:u,github:i.github,githubMessage:i.githubMessage,projects:i.projects,selectedId:i.selectedId,staleProjectId:i.staleProjectId,scan:i.scan,scanMessage:i.scanMessage,localSaved:c,localSkipped:Bg(e.ws),localStatus:c?await e.probeLocal(c):void 0,localSuggestions:await xR(e.ws,e.probeLocal),siteSkipped:d,kit:await SR(e.ws,e.request,i,o),siteHints:g&&n?Jd(n,g):[],sourceRead:m,adapterWritten:a==="cursor"?l.cursorInstalled:a==="codex"?l.codexInstalled:a==="claude"?l.claudeInstalled:!0,tools:a==="cursor"?l.cursorInstalled?l.cursorTools:"unknown":a==="claude"?l.claudeInstalled?l.claudeTools:"unknown":"not-applicable",hooks:a!=="codex"?"not-applicable":l.codexInstalled?l.codexHooksSeen?"active":"inactive":"unknown",extension:f?{connected:f.connected}:null,extensionUrl:`${V}/extension`,offline:i.offline,offlineMessage:i.offlineMessage}}async function CR(e,t,n){let r=(s,i)=>Re({...n,...i?{github:i,githubMessage:s}:{offline:!0,offlineMessage:s}},e.request).result;if(t.kind==="switch-server")return{restore:e.switchServer()};if(t.kind==="remove")return await Vh(e.ws.repoDir,t.agent,()=>e.install(t.agent,!0,t.dropPreCommit))?{result:r("Couldn't remove Grum's files, so they were left as they were.")}:{result:am(n,e.request)};if(t.kind==="select")return n.kit?.state!=="no-app"&&er(e.ws,t.projectId),{};if(t.kind==="create"){let s=n.repoName;if(!s)return{result:r("This folder has no GitHub repository.")};let i=await Ph(s,{name:t.name,site:t.site,root:e.ws.root||Js({repoDir:e.ws.repoDir,cwd:process.cwd()})});return i.ok?(er(e.ws,i.project.id),{}):{result:i.signedOut?Re({...n,signedIn:!1,signInExpired:!0},e.request).result:r(i.message,i.github)}}if(t.kind==="link-repo"){let s=await Nh(t.projectId,t.repo);return s.ok?{}:{result:s.signedOut?Re({...n,signedIn:!1,signInExpired:!0},e.request).result:r(s.message,s.github)}}if(t.kind==="write-starter"){if(!n.kit)return{result:r("There is no starter to write.")};let s=$R(e.ws,n.kit.starter);return s.ok?{}:{result:r(s.message)}}if(t.kind==="start-scan"){let s=await Lh(t.projectId);return s.ok?{result:Re({...n,scan:"running"},e.request).result}:{result:s.signedOut?Re({...n,signedIn:!1,signInExpired:!0},e.request).result:r(s.message,s.github)}}if(t.kind==="set-site"){let s=await Fh(t.projectId,t.site);return s.ok?(t.site===null&&Hl(e.ws,t.projectId),{}):{result:r(s.message)}}if(t.kind==="skip-site")return Hl(e.ws,t.projectId),{};if(t.kind==="set-local"){if(t.url===null)return Wg(e.ws),{};let s=e.request.localKind==="file"?kt(t.url,e.ws.repoDir,qh):t.url;if(!s)return{result:r("That local app path is not a file in this repository, so it was not saved.")};let i=await e.probeLocal(s);return i===null||i>=500?{result:Re({...n,localSaved:s,localSkipped:!1,localStatus:i},{...e.request,localProvided:!1}).result}:(tr(e.ws,s),{})}return await Vh(e.ws.repoDir,t.agent,()=>e.install(t.agent,!1,!1))?{result:r("Couldn't write the agent files, so this repository was left as it was.")}:{}}async function Vh(e,t,n){let r=kR(e,[...li(t),".gitignore"]);try{let o=await n();return o&&Hh(e,r),o}catch(o){throw Hh(e,r),o}}function Jh(e){return ne(Fe.join(e.stateDir,Xn))!==null}function RR(e,t,n){let r=Bn(t.requests,n||null),o=[];for(let s of e)if(s.coverage==="open")o.push({finding:s,revised:!1});else if(s.coverage==="rejected"){let i=r.get(s.key);i?.observed&&i.observed!==Wn(s)&&o.push({finding:s,revised:!0})}return o}var AR={ask:ge,write:e=>{process.stderr.write(e)},request:si};async function Kh(e,t,n,r,o=AR){let s=Se(e),i=RR(n,t,s).map(c=>({...c,observed:Wn(c.finding)})),l=!0;if(i.length>1){let c=i.map(({finding:p,revised:d},f)=>` ${f+1}. ${p.title}${Ic(p)}${d?" (revised after a rejection)":""}`).join(`
|
|
554
554
|
`),u=await o.ask(`
|
|
555
555
|
${i.length} items aren't in the contract:
|
|
556
556
|
${c}
|
|
@@ -635,56 +635,56 @@ Usage:
|
|
|
635
635
|
|
|
636
636
|
Run this build as: ${Q} (use it wherever \`grum\` appears above)
|
|
637
637
|
Environment: GRUM_TOKEN (CI sign-in), GRUM_API_ORIGIN (another Grum), GRUM_NO_BROWSER.
|
|
638
|
-
`,DR=new Set(["--root","--files","--reason","--cli","--url","--browser","--category","--value","--key","--agent","--project","--name","--site","--local-url"]);function Cn(e){let t=[],n=new Map;for(let r=0;r<e.length;r++){let o=e[r];if(!o.startsWith("--")){t.push(o);continue}let s=o.indexOf("="),i=s===-1?o:o.slice(0,s),l=n.get(i)??[];if(s!==-1)l.push(o.slice(s+1));else if(i==="--files")for(;e[r+1]&&!e[r+1].startsWith("--");)l.push(e[++r]);else DR.has(i)&&e[r+1]!==void 0&&l.push(e[++r]);n.set(i,l)}return{positional:t,flags:n}}var W=(e,t)=>e.flags.has(t),Ae=(e,t)=>e.flags.get(t)?.[0],Z=e=>process.stdout.write(e),q=e=>process.stderr.write(e);function uy(e,t,n){return Qg({flag:Ae(t,"--root"),config:Bs(e).root,projectRoot:n})}function
|
|
638
|
+
`,DR=new Set(["--root","--files","--reason","--cli","--url","--browser","--category","--value","--key","--agent","--project","--name","--site","--local-url"]);function Cn(e){let t=[],n=new Map;for(let r=0;r<e.length;r++){let o=e[r];if(!o.startsWith("--")){t.push(o);continue}let s=o.indexOf("="),i=s===-1?o:o.slice(0,s),l=n.get(i)??[];if(s!==-1)l.push(o.slice(s+1));else if(i==="--files")for(;e[r+1]&&!e[r+1].startsWith("--");)l.push(e[++r]);else DR.has(i)&&e[r+1]!==void 0&&l.push(e[++r]);n.set(i,l)}return{positional:t,flags:n}}var W=(e,t)=>e.flags.has(t),Ae=(e,t)=>e.flags.get(t)?.[0],Z=e=>process.stdout.write(e),q=e=>process.stderr.write(e);function uy(e,t,n){return Qg({flag:Ae(t,"--root"),config:Bs(e).root,projectRoot:n})}function Ue(e,t=process.cwd()){let n=ir(t),r=He(n),o=ir(t,uy(n,e,r?.project.repoRoot));return o.skipShared=r?.project.skipShared??[],o}function PR(e,t,n){if(!n)return e;let r=ir(e.repoDir,uy(e,t,n.project.repoRoot));return r.skipShared=n.project.skipShared??[],r}function py(e){let t=Ae(e,"--browser")?.trim().toLowerCase();return t&&t!=="chrome"&&t!=="safari"?"--browser must be chrome or safari.":{pageUrl:Ae(e,"--url"),live:W(e,"--live"),browser:t,noCapture:W(e,"--no-capture")}}var Tc=async e=>await ge(e,kn)==="yes",LR=e=>Ne()&&!process.env.CURSOR_AGENT&&!(W(e,"--ci")||W(e,"--json")||W(e,"--staged"));async function NR(e,t){let n=Ue(e),r=Ls({repo:Qn(n),build:V,interactive:LR(e),command:Q});if(r.kind==="go")return null;if(r.kind==="refuse")return q(`grum: ${r.message}
|
|
639
639
|
`),1;if(q(`
|
|
640
640
|
${r.question}
|
|
641
641
|
${r.warning}
|
|
642
642
|
`),!await ge("(y) switch, (Enter) no: ",l=>{let a=l.trim().toLowerCase();return a==="y"||a==="yes"?!0:!a||a==="n"||a==="no"?!1:null},`Type y to switch, or press Enter to leave it.
|
|
643
643
|
`))return q(`Nothing was changed.
|
|
644
|
-
`),1;let s=zs(n),i=await Nc(e);return i&&s(),t==="setup"||i?i:null}async function dt(e,t){if(t.offline)return{cached:
|
|
644
|
+
`),1;let s=zs(n),i=await Nc(e);return i&&s(),t==="setup"||i?i:null}async function dt(e,t){if(t.offline)return{cached:He(e),fresh:null};let n=await pt(e,t);return!n.ok&&n.reason==="signed-out"&&t.interactive&&await Tc(`
|
|
645
645
|
Sign in to Grum to continue? (Enter) sign in, (n) not now: `)&&await io()===0&&(n=await pt(e,t)),!n.ok&&n.reason==="needs-github"&&t.interactive&&await Tc(`
|
|
646
646
|
${n.message}
|
|
647
647
|
|
|
648
648
|
Sign in with GitHub to continue? (Enter) sign in, (n) not now: `)&&await oo()===0&&(n=await pt(e,{...t,resume:!0})),!n.ok&&n.reason==="needs-repo-access"&&n.repo&&t.interactive&&await Tc(`
|
|
649
649
|
${n.message}
|
|
650
650
|
|
|
651
|
-
Open it now? (Enter) open, (n) not now: `)&&await oo(n.repo)===0&&(n=await pt(e,{...t,resume:!0})),{cached:n.ok?n.cached:
|
|
651
|
+
Open it now? (Enter) open, (n) not now: `)&&await oo(n.repo)===0&&(n=await pt(e,{...t,resume:!0})),{cached:n.ok?n.cached:He(e),fresh:n}}function Ct(e,t,n=!1,r){let o=Vt(e,r);return n&&(o=Ch(e,o)),{...Dr(o.files,t,Se(e)||null),tree:o}}function uo(e,t){let n={...Wt(e),checkedAt:new Date().toISOString(),findings:t};return wn(e,n),n}function dy(e,t){let n=Wt(e),r=Se(e),o=new Date().toISOString(),s=new Map;for(let i of t){let l=Tl(n,i,r,o);l&&s.set(i.key,`snoozed until ${_l(l,o)}`)}return s}async function FR(e){let t=Ue(e),n=W(e,"--ci")||W(e,"--json")||W(e,"--staged"),r=Ne()&&!n&&!process.env.CURSOR_AGENT,o=await dt(t,{offline:W(e,"--offline"),interactive:r}),{fresh:s}=o,i=o.cached;t=PR(t,e,i),s&&!s.ok&&q(`grum: ${s.message}${i?" Using the contract saved on this computer.":""}
|
|
652
652
|
`);let l=s?.ok&&s.created?await yy(t,e):0;if(!i)return q(`grum: no design contract to check against yet. Nothing was checked.
|
|
653
653
|
`),0;let a=W(e,"--staged"),c=new qe;c.start("Reading files");let u;try{u=Ct(t,i,a,{onSlow:()=>c.start("Reading files is taking longer than usual")})}finally{c.stop()}let{findings:p,known:d,present:f,tree:m}=u,g=Yr(Zr(m.ms,m.stalled));g&&q(`grum: ${g}
|
|
654
|
-
`),a||uo(t,p);let S=(e.flags.get("--files")??[]).map(
|
|
654
|
+
`),a||uo(t,p);let S=(e.flags.get("--files")??[]).map(E=>ee.relative(ee.join(t.repoDir,t.root),ee.resolve(E)).split(ee.sep).join("/")),h=pl(a?Pr(p,yc(t,m.files,"HEAD",!0)):p,S),b=i.project.workspace.name,k=dy(t,h);W(e,"--json")?Z(`${JSON.stringify({project:i.project,contractFetchedAt:i.fetchedAt,known:d,...g?{read:{ms:m.ms,stalled:m.stalled,note:g}}:{},findings:h.map(E=>k.has(E.key)?{...E,snoozedUntil:k.get(E.key)}:E)},null,2)}
|
|
655
655
|
`):Z(`${Rf(h,{files:m.files.size,skipped:m.skipped,truncated:m.truncated,known:d,project:b,readNote:g??void 0},k)}
|
|
656
656
|
`);let y=py(e);if(typeof y=="string")return q(`grum: ${y}
|
|
657
657
|
`),2;let x={addressed:0,reopened:0};s?.ok&&!a&&!S.length&&!W(e,"--json")&&!W(e,"--offline")&&(x=await Gh(t,i,f)),x.addressed&&Z(`Addressed ${x.addressed} rejected review${x.addressed===1?"":"s"} in Grum.
|
|
658
658
|
`),x.reopened&&Z(`Reopened ${x.reopened} rejected review${x.reopened===1?"":"s"} because the rejected style is present again.
|
|
659
|
-
`),s?.ok&&(W(e,"--ci")||W(e,"--report"))&&await Bh(t,i,h,W(e,"--ci")?"ci":"local");let v=r&&s?.ok&&!W(e,"--no-review")&&h.some(
|
|
660
|
-
`)}if(Qh({requested:W(e,"--cursor"),disabled:W(e,"--no-cursor"),machineOutput:n,agent:!!process.env.CURSOR_AGENT,actionable:Ec(h).length>0})==="open")try{let
|
|
659
|
+
`),s?.ok&&(W(e,"--ci")||W(e,"--report"))&&await Bh(t,i,h,W(e,"--ci")?"ci":"local");let v=r&&s?.ok&&!W(e,"--no-review")&&h.some(E=>E.coverage==="open"||E.coverage==="rejected")?await Kh(t,i,h,y):{failed:!1},$=Bs(t),A=Af(h,{enforce:W(e,"--ci")||$.block,strict:W(e,"--strict")});if(W(e,"--ci")&&!A){let E=h.filter(O=>O.coverage==="pending").length;E&&Z(`${E} review${E===1?"":"s"} pending; this run doesn't fail on them.
|
|
660
|
+
`)}if(Qh({requested:W(e,"--cursor"),disabled:W(e,"--no-cursor"),machineOutput:n,agent:!!process.env.CURSOR_AGENT,actionable:Ec(h).length>0})==="open")try{let E=Se(t),O=await ty({schema:1,repoDir:t.repoDir,root:t.root,branch:E,checkedAt:new Date().toISOString(),project:b,findings:h,canRequestReview:!!s?.ok,role:i.project.role,snoozeHours:i.snoozeHours??24,priorReviews:Yh(Wt(t),h,E)},t.stateDir);Z(O.opened?`Opened the issues in Cursor. Review the prompt to continue.
|
|
661
661
|
`:`Couldn't open Cursor. The issues are saved in ${O.reportPath}.
|
|
662
662
|
`)}catch{q(`grum: Couldn't prepare the Cursor handoff. Your check results are shown above.
|
|
663
|
-
`)}return Math.max(
|
|
663
|
+
`)}return Math.max(A,l,v.failed?1:0)}async function UR(e){let t=e.positional[1],n=e.positional[0]==="add-button",r=n?"button":Ae(e,"--category"),o=Ae(e,"--value"),s=Ae(e,"--key"),i=Ae(e,"--url");if(!t||!r||!n&&!o||!s||!i)return q(n?`Usage: grum add-button <name> --key <buttonDriftKey> --url <page>
|
|
664
664
|
`:`Usage: grum add-token <name> --category <color|typography|spacing|radius|other> --value <v> --key <driftKey> --url <page>
|
|
665
|
-
`),2;let l=
|
|
665
|
+
`),2;let l=Ue(e),{cached:a,fresh:c}=await dt(l,{interactive:!1});if(!a||!c?.ok)return q(`grum: ${c&&!c.ok?c.message:"No contract yet."}
|
|
666
666
|
`),1;let u=Ct(l,a).findings.find(d=>d.key===s);if(!u)return q(`grum: ${s} isn't new drift in this checkout. Run \`${Q} check\` for the current keys.
|
|
667
667
|
`),1;let p=await Cc(l,u,{name:t,category:r,value:o??""},i);return p.ok?(Z(n?`Added button ${t} to the contract. Existing approved buttons were kept.
|
|
668
668
|
`:`Added token ${t} to the contract. This does not add or update a button or input design.
|
|
669
669
|
`),0):(q(`grum: ${p.text}
|
|
670
|
-
`),1)}function fy(e,t){let n=Se(e);if(!n)return{ok:!1,text:"This folder is not on a named git branch, so there's nothing to snooze."};let r=Wt(e),o=t.map(d=>r.findings.find(f=>f.key===d)),s=t.filter((d,f)=>!o[f]);if(!t.length||s.length)return{ok:!1,text:`${s[0]??"A drift key"} isn't in the latest check. Run \`${Q} check\` first.`};let i=[...new Set(o.flatMap(d=>d.places.map(f=>f.file)))],l=
|
|
671
|
-
`),2;let n=fy(
|
|
670
|
+
`),1)}function fy(e,t){let n=Se(e);if(!n)return{ok:!1,text:"This folder is not on a named git branch, so there's nothing to snooze."};let r=Wt(e),o=t.map(d=>r.findings.find(f=>f.key===d)),s=t.filter((d,f)=>!o[f]);if(!t.length||s.length)return{ok:!1,text:`${s[0]??"A drift key"} isn't in the latest check. Run \`${Q} check\` first.`};let i=[...new Set(o.flatMap(d=>d.places.map(f=>f.file)))],l=He(e),a=typeof l?.snoozeHours=="number"?l.snoozeHours:24,c=new Date().toISOString(),u=dg(r,n,i,c,a);wn(e,u);let p=u.snoozes.find(d=>d.branch===n).until;return{ok:!0,text:`Grum has paused questions about ${i.join(", ")} on ${n} until ${_l(p,c)}. This does not schedule a reminder or notification. The drift stays listed, and a commit or push can still be blocked.`}}async function zR(e){let t=[...new Set(e.positional.slice(1))];if(!t.length)return q(`Usage: grum snooze <key> [<key>...]
|
|
671
|
+
`),2;let n=fy(Ue(e),t);return n.ok?(Z(`${n.text}
|
|
672
672
|
`),0):(q(`grum: ${n.text}
|
|
673
673
|
`),1)}async function GR(e){let t=[...new Set(e.positional.slice(1))];if(!t.length)return q(`Usage: grum request <key> [<key>...] [--reason "why this should stay"] [--url <page>] [--live] [--browser chrome|safari] [--no-capture]
|
|
674
674
|
`),2;let n=py(e);if(typeof n=="string")return q(`grum: ${n}
|
|
675
675
|
`),2;let r=n.noCapture?null:mc();if(r)return q(`grum: ${ys(r)}
|
|
676
676
|
${Hn}
|
|
677
|
-
`),1;let o=
|
|
677
|
+
`),1;let o=Ue(e),{cached:s,fresh:i}=await dt(o,{interactive:!1});if(!s||!i?.ok)return q(`grum: ${i&&!i.ok?i.message:"No contract yet."}
|
|
678
678
|
`),1;let l=Ct(o,s).findings,a=t.map(d=>l.find(f=>f.key===d)),c=t.filter((d,f)=>!a[f]);if(c.length){for(let d of c)q(`grum: ${d} isn't new drift in this checkout. Run \`${Q} check\` for the current keys.
|
|
679
679
|
`);return 1}let u=await $c(o,a,Ae(e,"--reason")?.trim()||null,n),p=!1;for(let d of t){let f=u[d];f.ok?(Z(`${d}: ${ci(f)}
|
|
680
680
|
`),f.state.status==="rejected"&&!f.created&&(p=!0)):(p=!0,q(`${d}: ${f.text}
|
|
681
681
|
${process.env.CURSOR_AGENT?`${Hn}
|
|
682
|
-
`:""}`))}return p?1:0}async function BR(e){let t=
|
|
682
|
+
`:""}`))}return p?1:0}async function BR(e){let t=Ue(e),{cached:n,fresh:r}=await dt(t,{interactive:!1});return n?(Z(`${JSON.stringify(gl(n,Q),null,2)}
|
|
683
683
|
`),0):(q(`grum: ${r&&!r.ok?r.message:"No contract yet."}
|
|
684
684
|
`),1)}async function Oc(e,t=!1,n="leave"){return ar(Cn(["init","cursor","--quiet",...t?["--remove"]:[],...!t&&n==="install"?["--pre-commit"]:[],...!t&&n==="remove"?["--no-pre-commit"]:[],...Ae(e,"--root")?["--root",Ae(e,"--root")]:[]]))}function di(e){return Bf(ne(ee.join(e,".cursor/hooks.json")),ne(ee.join(e,".cursor/mcp.json")),ne(ee.join(e,Pe)))}function pi(e,t){if(t==="cursor")return di(e);let[n,r,o]=li(t).map(s=>ne(ee.join(e,s)));return t==="codex"?Al(n??null,r??null,o??null):Zf(n??null,r??null,o??null)}function Pc(e){return Yf(ne(ee.join(cy(),".claude.json")),e)}function gy(e){return{cursorInstalled:di(e.repoDir),codexInstalled:pi(e.repoDir,"codex"),claudeInstalled:pi(e.repoDir,"claude"),cursorTools:$n(e.repoDir),claudeTools:Pc(e.repoDir),codexHooksSeen:Jh(e)}}function $n(e){let t=ee.join(cy(),".cursor","projects"),n=s=>{try{return ny(ee.join(t,s,"mcps"))}catch{return null}},r=Gf(n(yl(e)));if(r==="on")return r;let o=new RegExp(`^project-\\d+-${yl(ee.basename(e))}-grum$`);try{for(let s of ny(t))if(n(s)?.some(i=>o.test(i)))return"on"}catch{return r}return r}async function oy(e){if($n(e.repoDir)==="on"||(Z(`
|
|
685
685
|
Last step, in Cursor: ${Ze}
|
|
686
686
|
Without them, Cursor's agent can't ask for review.
|
|
687
|
-
`),!
|
|
687
|
+
`),!Ne()||$n(e.repoDir)==="unknown"))return;await xh(()=>$n(e.repoDir)==="on","Waiting for grum to be switched on in Cursor (Enter skips)",5*6e4)||Z(`Skipped. Grum's agents will remind you until the tools are on.
|
|
688
688
|
`)}async function Lc(e){try{if(e.startsWith("file:"))return ft(jR(e))?0:null;let t=await fetch(e,{signal:AbortSignal.timeout(3e3),redirect:"manual"});return await t.body?.cancel(),t.status}catch{return null}}async function my(e,t,n){let r=await ai(t.project.id).catch(()=>null),o=Mg(r?.extensionId?[r.extensionId]:[],r?.build??Ag(V));if(n&&o){let i=Ws(e);i.chromeProfile!==o.dir&&Hs(e,{...i,chromeProfile:o.dir})}let s=St(e);return{server:V,project:`${t.project.workspace.name} (${t.project.repo})`,extension:r&&{connected:r.connected,build:r.build},tools:di(e.repoDir)?$n(e.repoDir):"not-set-up",localApp:s?{url:s,status:await Lc(s)}:null,chromeProfile:o?.name??null}}async function _c(e,t){let n=Fl(await my(e,t,!0));Z(`
|
|
689
689
|
${Ul(n)}
|
|
690
690
|
|
|
@@ -695,17 +695,17 @@ Need attention:
|
|
|
695
695
|
Fix the items marked \u2717 so reviews work; \`${Q} doctor\` checks again.
|
|
696
696
|
`)}function sy(e){return Z(`${JSON.stringify(e,null,2)}
|
|
697
697
|
`),im(e)}async function hy(e,t){if(!W(e,"--json"))return q(`grum: --agent needs --json.
|
|
698
|
-
`),2;let n=Ql({agent:e.flags.get("--agent"),project:e.flags.get("--project"),name:e.flags.get("--name"),site:e.flags.get("--site"),localUrl:e.flags.get("--local-url"),root:e.flags.get("--root"),create:W(e,"--create"),remove:W(e,"--remove"),switchServer:W(e,"--switch-server"),dropPreCommit:W(e,"--no-pre-commit"),probe:t,serverOrigin:V});if(!n.ok)return sy(n.result);let r=
|
|
698
|
+
`),2;let n=Ql({agent:e.flags.get("--agent"),project:e.flags.get("--project"),name:e.flags.get("--name"),site:e.flags.get("--site"),localUrl:e.flags.get("--local-url"),root:e.flags.get("--root"),create:W(e,"--create"),remove:W(e,"--remove"),switchServer:W(e,"--switch-server"),dropPreCommit:W(e,"--no-pre-commit"),probe:t,serverOrigin:V});if(!n.ok)return sy(n.result);let r=Ue(e),o=await Ac({ws:r,cli:Q,repoServer:()=>Qn(r),request:n.request,host:()=>gy(r),probeLocal:Lc,install:(s,i,l)=>ar(Cn(["init",s,"--quiet",...i?["--remove"]:[],...Ae(e,"--root")?["--root",Ae(e,"--root")]:[]]),{keepPreCommit:i&&!l}),switchServer:()=>zs(r)});return sy(o)}async function iy(e,t,n){let r=i=>typeof t[i]=="string"?[t[i]]:void 0,o=Ql({agent:r("agent"),project:r("project"),name:r("name"),site:r("site"),localUrl:r("localUrl"),create:t.create===!0,remove:t.remove===!0,switchServer:t.switchServer===!0,dropPreCommit:t.dropPreCommit===!0,probe:n,serverOrigin:V});if(!o.ok)return{text:JSON.stringify(o.result,null,2),isError:!0};let s=await Ac({ws:e,cli:Q,repoServer:()=>Qn(e),request:o.request,host:()=>gy(e),probeLocal:Lc,install:(i,l,a)=>ar(Cn(["init",i,"--quiet",...l?["--remove"]:[]]),{keepPreCommit:l&&!a}),switchServer:()=>zs(e)});return{text:JSON.stringify(s,null,2),isError:s.exit==="error"}}async function WR(e){if(W(e,"--agent"))return hy(e,!0);let t=Ue(e),{cached:n,fresh:r}=await dt(t,{interactive:!1});if(!n)return q(`grum: ${r&&!r.ok?r.message:"Not set up yet."} Run \`${Q} setup\` in a terminal.
|
|
699
699
|
`),1;let o=Fl(await my(t,n,!1));return Z(`${Ul(o)}
|
|
700
700
|
`),o.every(s=>s.ok)?0:1}async function Mc(e,t){for(let n of["codex","claude"]){if(!(ft(ee.join(e.repoDir,`.${n}`))||pi(e.repoDir,n)))continue;let o=await ar(Cn(["init",n,"--quiet",...Ae(t,"--root")?["--root",Ae(t,"--root")]:[]]));if(o)return o;n==="codex"&&ne(ee.join(e.stateDir,Xn))===null&&Z(`
|
|
701
701
|
${Cl()}
|
|
702
702
|
`),n==="claude"&&Pc(e.repoDir)!=="on"&&Z(`
|
|
703
703
|
${xl()}
|
|
704
|
-
`)}return 0}async function yy(e,t){if(ft(ee.join(e.repoDir,".cursor"))){let n=await Oc(t);if(n)return n}return Mc(e,t)}async function Nc(e,t){if(W(e,"--agent"))return hy(e,!1);let n=
|
|
704
|
+
`)}return 0}async function yy(e,t){if(ft(ee.join(e.repoDir,".cursor"))){let n=await Oc(t);if(n)return n}return Mc(e,t)}async function Nc(e,t){if(W(e,"--agent"))return hy(e,!1);let n=Ue(e),{fresh:r}=await dt(n,{interactive:Ne()});if(!r?.ok)return t?.allowDecline&&r?.declined?0:(q(`grum: ${r?.message??"Setup isn't finished."}
|
|
705
705
|
`),1);if(Z(`Linked to ${r.cached.project.workspace.name} (${r.cached.project.repo}): ${r.cached.contract.length} contract tokens.
|
|
706
|
-
`),
|
|
706
|
+
`),Ne()&&!r.created){Z(`Enter keeps each current setting.
|
|
707
707
|
`);let s=di(n.repoDir),i=Zd(s,ft(ee.join(n.repoDir,".cursor"))),{cursor:l}=await Mh(n,r.cached,i),a=Yd(l,s,i);if(a!=="leave"){let u=ay(n),p=a==="install"?tl(await xc(u),u):"leave",d=await Oc(e,a==="remove",p);if(d)return d;a==="remove"&&Z(`Removed Grum from Cursor.
|
|
708
|
-
`)}a!=="remove"&&(a==="install"||s)&&await oy(n);let c=await Mc(n,e);return c||(await _c(n,r.cached),0)}if(
|
|
708
|
+
`)}a!=="remove"&&(a==="install"||s)&&await oy(n);let c=await Mc(n,e);return c||(await _c(n,r.cached),0)}if(Ne()){if(await vc(n,r.cached.project.repo),await ge(`
|
|
709
709
|
Setup for cursor agents? (Enter) yes, (n) not now: `,kn,`Enter sets it up, or type n to skip.
|
|
710
710
|
`)==="yes"){let l=ay(n),a=tl(await xc(l),l),c=await Oc(e,!1,a);if(c)return c;await oy(n)}let i=await Mc(n,e);return i||(await _c(n,r.cached),0)}let o=await yy(n,e);return o||(await _c(n,r.cached),0)}function Jt(e,t,n,r){return n.ok?(n.changed?n.text===""?(po(ee.join(e.repoDir,t),{force:!0}),r.push(`removed ${t}`)):(xe(ee.join(e.repoDir,t),n.text),r.push(`wrote ${t}`)):r.push(`unchanged ${t}`),!0):(q(`grum: ${n.error}
|
|
711
711
|
`),!1)}function by(e){let t=ft(ee.join(e.repoDir,".husky")),n=["lefthook.yml","lefthook.yaml",".lefthook.yml"].some(i=>ft(ee.join(e.repoDir,i))),r=Rh(e),o=t?".husky/pre-commit":r?`${r}/pre-commit`:null,s=o?ee.resolve(e.repoDir,o):null;return{husky:t,lefthook:n,hooksDir:r,hookRel:o,hookFile:s,hookText:s?ne(s):null}}function ay(e){let t=by(e);return t.lefthook?!1:wl(t.hookText)}function jc(e,t){(W(e,"--quiet")||!W(e,"--verbose"))&&Z(t)}function HR(e,t){return e==="husky"?t?`Updated the grum line in .husky/pre-commit.
|
|
@@ -717,7 +717,7 @@ Setup for cursor agents? (Enter) yes, (n) not now: `,kn,`Enter sets it up, or ty
|
|
|
717
717
|
${c.snippet}`;o.push(u),jc(t,`${u}
|
|
718
718
|
`);return}c.changed&&l.hookFile?(xe(l.hookFile,c.text),c.kind==="git"&&_R(l.hookFile,493),o.push(`wrote ${l.hookRel}${c.kind==="git"?" (local only; not shared through git)":""}`),jc(t,HR(c.kind,a))):o.push(`unchanged ${l.hookRel}`)}async function ar(e,t){let n=e.positional[1];if(n!=="cursor"&&n!=="codex"&&n!=="claude")return q(`Usage: grum init <cursor|codex|claude> [--remove] [--force] [--local-only] [--pre-commit] [--no-pre-commit] [--cli "<command>"] [--verbose]
|
|
719
719
|
`),2;let r=rr[n];if(W(e,"--pre-commit")&&W(e,"--no-pre-commit"))return q(`grum: pass either --pre-commit or --no-pre-commit.
|
|
720
|
-
`),2;let o=
|
|
720
|
+
`),2;let o=Ue(e),s=W(e,"--remove"),i=Ae(e,"--cli"),l=i?{hook:i,mcp:i,preCommit:i}:Bl;if(!s&&!W(e,"--local-only")&&!He(o)){let{fresh:d}=await dt(o,{interactive:Ne()&&!W(e,"--quiet")});if(!d?.ok)return q(`grum: ${r} setup needs a linked project first. ${d?.message??""}
|
|
721
721
|
Nothing was installed. For offline checks only, use \`${Q} init ${n} --local-only\`.
|
|
722
722
|
`),1}let a=[],c=n==="cursor"?qR(o,e,s,l,a):n==="codex"?JR(o,e,s,l,a):KR(o,s,l,a);if(c)return c;let u=d=>ne(ee.join(o.repoDir,d));if(!(s&&Object.keys(rr).some(d=>d!==n&&pi(o.repoDir,d)))){let d=s?Wf(u(".gitignore")):Es(u(".gitignore"));d.changed&&(xe(ee.join(o.repoDir,".gitignore"),d.text),a.push("wrote .gitignore")),t?.keepPreCommit||VR(o,e,l.preCommit,s,a)}return W(e,"--quiet")||(W(e,"--verbose")&&Z(`${a.join(`
|
|
723
723
|
`)}
|
|
@@ -733,27 +733,27 @@ ${xl()}
|
|
|
733
733
|
`),1;Jt(e,lt,i,o),Jt(e,xt,l,o);let a=s(Gt),c=n?Ds(a):Vr(a,r.mcp);return Jt(e,Gt,{ok:!0,...c},o),0}function KR(e,t,n,r){let o=c=>ne(ee.join(e.repoDir,c)),s=t?Jf(o(Ye)):qf(o(Ye),n.hook),i=t?Xf(o(zt)):Kf(o(zt),n.mcp);for(let c of[s,i])if(!c.ok)return q(`grum: ${c.error}
|
|
734
734
|
`),1;Jt(e,Ye,s,r),Jt(e,zt,i,r);let l=o(mn),a=t?Ts(l):zr(l,n.mcp);return Jt(e,mn,{ok:!0,...a},r),0}async function XR(){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{}}}async function ZR(e){let t=e.positional[1],n=vg(t);if(!n)return q(`grum: unknown hook ${String(t)}
|
|
735
735
|
`),2;let{op:r}=n,o=n.agent==="codex",s=n.agent!=="cursor",i=await XR(),l=r==="before-shell"&&!s?{permission:"allow"}:{},a=r==="before-shell"&&!s?wg({command:typeof i.command=="string"?i.command:"",sandbox:i.sandbox===!0}):null;if(a)return Z(`${JSON.stringify(a)}
|
|
736
|
-
`),0;try{let c=i.workspace_roots,u=Array.isArray(c)&&typeof c[0]=="string"&&ft(c[0])?c[0]:typeof i.cwd=="string"&&ft(i.cwd)?i.cwd:process.cwd(),p=
|
|
736
|
+
`),0;try{let c=i.workspace_roots,u=Array.isArray(c)&&typeof c[0]=="string"&&ft(c[0])?c[0]:typeof i.cwd=="string"&&ft(i.cwd)?i.cwd:process.cwd(),p=Ue({positional:[],flags:new Map},u),d=Ls({repo:Qn(p),build:V,interactive:!1,command:Q});if(d.kind==="refuse")return q(`grum hook ${t}: ${d.message}
|
|
737
737
|
`),Z(`${JSON.stringify(l)}
|
|
738
738
|
`),0;for(let k of Vl(p.repoDir,Q))q(`grum hook ${t}: updated ${k} to match this version of Grum
|
|
739
739
|
`);if(o){let k=ee.join(p.stateDir,Xn);ne(k)===null&&xe(k,`${JSON.stringify({at:new Date().toISOString()})}
|
|
740
|
-
`)}let f=
|
|
740
|
+
`)}let f=He(p),g={...Bs(p).hooks,canRequest:!!(f&&pe()),cli:Q,role:f?.project.role==="owner"?"owner":"viewer",snoozeHours:f?.snoozeHours??24,now:new Date().toISOString(),toolsOff:s?!1:$n(p.repoDir)==="off",...n.agent!=="cursor"?{host:n.agent}:{}},S=i,h=s?ml(S):typeof i.conversation_id=="string"?i.conversation_id:"",b=l;if(f&&r==="after-file-edit"){let k=s?Tf(S):[{file:typeof i.file_path=="string"?i.file_path:"",edits:i.edits}],y=s&&typeof i.cwd=="string"?i.cwd:p.repoDir,x=Wt(p),v=!1;for(let{file:$,edits:A}of k){let E=ee.resolve(y,$),O=ee.relative(p.repoDir,E).split(ee.sep).join("/"),L=Ht(O,p.root);if(L===null||!nm(L))continue;v=!0;let D=fg(x,h,L,new Date().toISOString());for(let z of D.forgotten)zg(p,z);D.first&&xe(ee.join(Gs(p,h),L),gg(ne(E)??"",A)??le(p.repoDir,["show",`HEAD:${O}`])??""),x=D.ledger}v&&(wn(p,x),uo(p,Ct(p,f).findings))}else if(f&&r==="stop"){let{findings:k,tree:y}=Ct(p,f),x=uo(p,k),v=bg(x,s?Ef(S,Se(p)):{...i,branch:Se(p)},g,Ih(p,y.files,x.edited[h]?.files??[],Gs(p,h)));wn(p,v.ledger),b=s?jf(v.output):v.output}else if(f&&r==="before-shell"){let k=s?_f(S):typeof i.command=="string"?i.command:"",y=Ol(k).filter(x=>g.denyGit.includes(x));if(f&&y.length){let{findings:x,tree:v}=Ct(p,f),$=kg(uo(p,x),{command:k},g,yc(p,v.files,y.includes("push")?Ah(p):"HEAD"));b=s?Of($):$}}Z(`${JSON.stringify(b)}
|
|
741
741
|
`)}catch(c){q(`grum hook ${t}: ${c instanceof Error?c.message:String(c)}
|
|
742
742
|
`),Z(`${JSON.stringify(l)}
|
|
743
|
-
`)}return 0}async function YR(e){let t=
|
|
743
|
+
`)}return 0}async function YR(e){let t=Ue(e),n=`No design contract on this computer yet. Run \`${Q} setup --agent <cursor|codex|claude|generic> --json\` and follow its JSON. Do not ask the user to open a terminal.`,r=()=>{let a=Ls({repo:Qn(t),build:V,interactive:!1,command:Q});return a.kind==="refuse"?{text:a.message,isError:!0}:null};if(!r())for(let a of Vl(t.repoDir,Q))q(`grum mcp: updated ${a} to match this version of Grum
|
|
744
744
|
`);let o=null,s=()=>{let a=c=>ne(ee.join(t.repoDir,c));return og({client:o,installed:Al(a(lt),a(xt),a(Gt)),seen:ne(ee.join(t.stateDir,Xn))!==null})},i=$g({contract:async()=>{let{cached:a}=await dt(t,{interactive:!1});return a?{text:JSON.stringify({notice:s()??void 0,...gl(a,Q)},null,2)}:{text:n,isError:!0}},check:async a=>{let c=await pt(t,{interactive:!1});if(!c.ok)return{text:`${c.message} Current review statuses and blocking findings are unknown.`,isError:!0};let{cached:u}=c,{findings:p,known:d,tree:f}=Ct(t,u);uo(t,p);let m=pl(p,a),g=dy(t,m),S=Yr(Zr(f.ms,f.stalled));return{text:JSON.stringify({notice:s()??void 0,...S?{read:{ms:f.ms,stalled:f.stalled,note:S}}:{},blocking:m.filter(h=>h.coverage==="open"||h.coverage==="rejected").length,known:d,findings:m.map(h=>g.has(h.key)?{...h,snoozedUntil:g.get(h.key)}:h)},null,2)}},request:async(a,c,u)=>{let{cached:p,fresh:d}=await dt(t,{interactive:!1});if(!p||!d?.ok)return{text:d&&!d.ok?d.message:n,isError:!0};let f=Ct(t,p).findings,m=a.map(b=>f.find(k=>k.key===b)),g=a.filter((b,k)=>!m[k]);if(!a.length||g.length)return{text:`${g[0]??"A drift key"} isn't new drift in this checkout. Call grum_check for current keys.`,isError:!0};let S=await $c(t,m,c.trim()||null,{pageUrl:u||void 0});return{text:a.map(b=>{let k=S[b];return k.ok?`${b}: ${ci(k)}`:`${b}: ${k.text}`}).join(`
|
|
745
745
|
`),isError:a.some(b=>{let k=S[b];return!k.ok||k.state.status==="rejected"&&!k.created})}},addToContract:async a=>{let c=typeof a.key=="string"?a.key:"",u=typeof a.name=="string"?a.name:"",p=typeof a.category=="string"?a.category:"",d=typeof a.value=="string"?a.value:"",f=typeof a.url=="string"?a.url:"",{cached:m,fresh:g}=await dt(t,{interactive:!1});if(!m||!g?.ok)return{text:g&&!g.ok?g.message:n,isError:!0};let S=Ct(t,m).findings.find(b=>b.key===c);if(!S)return{text:`${c||"A drift key"} isn't new drift in this checkout. Call grum_check for current keys.`,isError:!0};let h=await Cc(t,S,{name:u,category:p,value:d??""},f);return h.ok?{text:p==="button"?`Added button ${u} to the contract. Existing approved buttons were kept.`:`Added token ${u} to the contract. This does not add or update a button or input design.`}:{text:h.text,isError:!0}},snooze:async a=>{let c=fy(t,a);return{text:c.text,isError:!c.ok}},status:async a=>{let c=await pt(t,{interactive:!1});if(!c.ok)return{text:`${c.message} Current review statuses are unknown.`,isError:!0};let{cached:u}=c,p=u.requests.filter(d=>!a||d.driftKey===a);return{text:p.length?p.map(d=>`${d.driftKey} ${d.status}${d.note?` \u201C${d.note}\u201D`:""} ${d.url}`).join(`
|
|
746
746
|
`):a?`No review request for ${a}.`:"No review requests yet."}},setup:a=>iy(t,a,!1),doctor:a=>iy(t,a,!0)},Q).map(a=>({...a,run:async c=>r()??a.run(c)})),l=OR({input:process.stdin,crlfDelay:1/0});for await(let a of l){if(!a.trim())continue;let c;try{c=JSON.parse(a)}catch{Z(`${JSON.stringify({jsonrpc:"2.0",id:null,error:{code:-32700,message:"Parse error"}})}
|
|
747
747
|
`);continue}let u=c;u?.method==="initialize"&&(o=typeof u.params?.clientInfo?.name=="string"?u.params.clientInfo.name:null);let p=await Cg(c,i,{name:"grum",version:Yn});p&&Z(`${JSON.stringify(p)}
|
|
748
|
-
`)}return 0}async function QR(e){let t=ir(process.cwd()),n=Ns();if(!W(e,"--yes")){if(!
|
|
748
|
+
`)}return 0}async function QR(e){let t=ir(process.cwd()),n=Ns();if(!W(e,"--yes")){if(!Ne())return q(`grum: uninstall removes Grum from this repository and this computer. Run \`${Q} uninstall --yes\` to go ahead.
|
|
749
749
|
`),2;if(await ge($m(t.repoDir,n),Cm)==="no")return Z(`Nothing was removed.
|
|
750
750
|
`),0}let r={repo:t.repoDir,agents:[],failed:[],state:!1,signIns:[],config:null};for(let[s,i]of Object.entries(rr)){let l=li(s),a=()=>l.map(u=>ne(ee.join(t.repoDir,u))).join("\0"),c=a();await ar(Cn(["init",s,"--remove","--quiet"]))!==0?r.failed.push({agent:i,error:"one of them isn't valid (see above). Fix it and run uninstall again."}):a()!==c&&r.agents.push(i)}ft(t.stateDir)&&(po(t.stateDir,{recursive:!0,force:!0}),r.state=!0);let o=Fg();return r.signIns=await Promise.all(o.map(async s=>({origin:s.apiOrigin,revoked:await wc(s)}))),ft(n)&&(po(n,{recursive:!0,force:!0}),r.config=n),Z(Rm(r,Q)),Am(r)}function eA(){return new Promise(e=>{let t=(n,r)=>{process.stdin.off("keypress",t),e({name:r?.name,ctrl:r?.ctrl,sequence:r?.sequence??n})};process.stdin.on("keypress",t)})}async function tA(e,t,n=null){let r=process.stdin;MR(r);let o=()=>{r.isTTY&&r.isRaw&&r.setRawMode(!1),r.pause(),q("\x1B[?25h")};process.on("exit",o),r.isTTY&&r.setRawMode(!0),r.resume(),q("\x1B[?25l");let s=0,i=0;try{for(;;){let l=km(Yn,s,e,t,n);i&&q(`\x1B[${i}A`),q(l),i=l.split(`
|
|
751
751
|
`).length-1;let a=xm(s,await eA(),t);if(a.type==="interrupt"&&process.exit(130),a.type==="quit")return null;if(a.type==="select")return Qr(t)[a.index].name;a.type==="move"&&(s=a.index)}}finally{process.off("exit",o),o()}}function nA(){q("\x1B[?1049h\x1B[H")}function rA(){q("\x1B[?1049l")}function ui(){q("\x1B[2J\x1B[H")}async function ly(){await ge(`
|
|
752
|
-
Press Enter to continue. `,()=>!0)}async function oA(){let e=!!pe(),t=ir(process.cwd());if(!
|
|
753
|
-
`:ry),0;if(!r&&(n===void 0&&
|
|
752
|
+
Press Enter to continue. `,()=>!0)}async function oA(){let e=!!pe(),t=ir(process.cwd());if(!Ne()){let s=await lo(t);return Z(wm(Yn,s.line,e,s.url)),0}if(!e){let s=await io();if(s)return s;e=!0}let n=await lo(t),r=!1,o=()=>{r&&(r=!1,rA())};process.on("exit",o);try{for(nA(),r=!0,n.needsSetup&&(ui(),await Nc(Cn([]),{allowDecline:!0}),n=await lo(t),await ly(),ui());;){let s=await tA(n.line,e,n.url);if(!s)return 0;if(s!=="check"&&s!=="setup")return o(),Dc([s]);ui(),await Dc([s]),await ly(),ui(),n=await lo(t)}}finally{process.off("exit",o),o()}}async function Dc(e){let t=Cn(e),n=t.positional[0],r=(n==="setup"||n==="doctor")&&W(t,"--agent");if(W(t,"--version")||W(t,"--help")||n==="help")return Z(W(t,"--version")?`${Yn}
|
|
753
|
+
`:ry),0;if(!r&&(n===void 0&&Ne()||["check","request","add-token","add-button","snooze","contract","setup","doctor","capture","init"].includes(String(n)))){let o=await NR(t,n);if(o!==null)return o}switch(n){case void 0:return oA();case"login":return io();case"logout":{let o=Fs(V,{}),s=o?await wc(o):!0;return Ng(V),xn(V),Z(s?`Signed out.
|
|
754
754
|
`:`Signed out on this computer. Grum couldn't be reached, so remove this sign-in in Grum's Settings.
|
|
755
755
|
`),0}case"uninstall":return QR(t);case"check":return FR(t);case"request":return GR(t);case"add-token":case"add-button":return UR(t);case"snooze":return zR(t);case"contract":return BR(t);case"setup":return Nc(t);case"doctor":return WR(t);case"capture":return t.positional[1]!=="reset"||t.positional.length!==2?(q(`Usage: grum capture reset
|
|
756
|
-
`),2):(lh(
|
|
756
|
+
`),2):(lh(Ue(t).repoDir),Z(`Cleared this repository's capture-browser sign-ins. Sign in again in Grum's capture window when needed.
|
|
757
757
|
`),0);case"init":return ar(t);case"hook":return ZR(t);case"mcp":return YR(t);default:return q(`grum: unknown command ${n}
|
|
758
758
|
|
|
759
759
|
${ry}`),2}}Dc(process.argv.slice(2)).then(e=>{process.exitCode=e},e=>{q(`grum: ${e instanceof Error?e.message:String(e)}
|