@popmelt.com/core 0.27.1 → 0.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  2. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  3. package/dist/ParticipantRuntime-JUOBT3CY.mjs +139 -0
  4. package/dist/PopmeltTasteConnectedPane-JO4QR6ZT.mjs +221 -0
  5. package/dist/PreviewRuntime-JAZLAGQE.mjs +2 -0
  6. package/dist/bridge-entry.mjs +2 -229
  7. package/dist/browser-runtime-6KNOQXAJ.mjs +2 -0
  8. package/dist/browser.mjs +1 -1
  9. package/dist/chunk-35UEAIRA.mjs +289 -0
  10. package/dist/chunk-3LBOX7HQ.mjs +3 -0
  11. package/dist/chunk-3NTTM74X.mjs +1 -0
  12. package/dist/chunk-3THBMCJW.mjs +369 -0
  13. package/dist/chunk-A2UXK7AS.mjs +77 -0
  14. package/dist/chunk-GL4I4MI6.mjs +3 -0
  15. package/dist/chunk-HGW2U6PD.mjs +2 -0
  16. package/dist/chunk-JQHZFDY5.mjs +2 -0
  17. package/dist/chunk-LVEMYZOA.mjs +2 -0
  18. package/dist/chunk-MP7S5ALD.mjs +2 -0
  19. package/dist/chunk-O4HZP3RP.mjs +2 -0
  20. package/dist/chunk-QUNV5PNI.mjs +2 -0
  21. package/dist/chunk-QXVMGZFP.mjs +1 -0
  22. package/dist/chunk-SWTSMLHA.mjs +2 -0
  23. package/dist/{chunk-CLDWTCKX.mjs → chunk-VRFM3TLR.mjs} +1 -1
  24. package/dist/chunk-W4VRK56P.mjs +347 -0
  25. package/dist/chunk-XOGBFVWI.mjs +2 -0
  26. package/dist/chunk-XTOCFTVW.mjs +2 -0
  27. package/dist/cli.mjs +169 -106
  28. package/dist/focus-inspection-2FPCQIN2.mjs +2 -0
  29. package/dist/index-CHp2bgs1.d.mts +565 -0
  30. package/dist/index.mjs +1 -1
  31. package/dist/memory-legacy.d.mts +1 -489
  32. package/dist/memory-legacy.mjs +1 -1
  33. package/dist/memory-store.d.mts +2 -660
  34. package/dist/memory-store.mjs +1 -3
  35. package/dist/plugin-astro.mjs +1 -1
  36. package/dist/plugin-nuxt.mjs +1 -1
  37. package/dist/plugin-vite.mjs +1 -1
  38. package/dist/server.d.mts +3 -291
  39. package/dist/server.mjs +7 -234
  40. package/dist/taste-proposal-session-XU4N7RUV.mjs +2 -0
  41. package/dist/types-Bur49CLH.d.mts +349 -0
  42. package/dist/workspace-snapshot-EJQHHDQ4.mjs +2 -0
  43. package/package.json +1 -1
  44. package/dist/ParticipantRuntime-TWGYNKIS.mjs +0 -139
  45. package/dist/PopmeltTasteConnectedPane-WDF556E2.mjs +0 -81
  46. package/dist/PreviewRuntime-KGLZJGUN.mjs +0 -2
  47. package/dist/browser-runtime-PFJI3VEQ.mjs +0 -2
  48. package/dist/chunk-3PVLCKSV.mjs +0 -370
  49. package/dist/chunk-7MGWRICI.mjs +0 -77
  50. package/dist/chunk-7YCLSSQA.mjs +0 -2
  51. package/dist/chunk-D7HY2EDH.mjs +0 -2
  52. package/dist/chunk-TSY2K45H.mjs +0 -2
  53. package/dist/chunk-YC7B37F6.mjs +0 -1
  54. package/dist/chunk-YMCTJKYN.mjs +0 -345
  55. package/dist/server-J5NV3BMT.mjs +0 -241
@@ -0,0 +1,221 @@
1
+ "use client";
2
+ import{b as Vn}from"./chunk-QUNV5PNI.mjs";import{T as Ne,Ra as Ge,sa as Wt,cb as Vr,db as Yn,Ma as Jn,N as _n,A as Yr}from"./chunk-A2UXK7AS.mjs";import"./chunk-MP7S5ALD.mjs";import{x as Xe,w as vr,e as Tt,f as mt,r as yr,l as qt,v as Jr,t as _r,b as Gn,p as Ot,g as rr,d as nr,j as Gr,c as Zr,o as Qr,k as Zn,s as Xr,m as en,h as Qn,i as br,q as Xn,a as ea,n as ta,u as ra}from"./chunk-O4HZP3RP.mjs";import"./chunk-XTOCFTVW.mjs";import{a as na}from"./chunk-LVEMYZOA.mjs";import"./chunk-XOGBFVWI.mjs";import"./chunk-HGW2U6PD.mjs";import{createContext as aa,useRef as D,useState as T,useSyncExternalStore as wr,useLayoutEffect as Pe,useEffect as le,useCallback as tn,useMemo as Ht,isValidElement as ia,useId as xr,Fragment as oa,createElement as la,useContext as sa}from"react";import{Search as kr,X as St,ChevronLeft as Cr,Component as da,PenLine as ca,History as ua,Eye as pa,Ruler as ha,Fingerprint as Ut,Plus as Ft,ChevronRight as Kt,RotateCw as fa,RotateCcw as ga,ArrowLeftRight as rn,Minimize2 as ma,Info as va,ChevronDown as ya,Check as ba,User as wa,ArrowRight as xa}from"lucide-react";import{jsx as i,jsxs as k,Fragment as Le}from"react/jsx-runtime";import{createPortal as nn}from"react-dom";var ar=["display","boxSizing","width","height","flexDirection","flexWrap","alignItems","justifyContent","alignSelf","flexGrow","flexShrink","gridTemplateColumns","rowGap","columnGap","gap","padding","paddingInline","paddingBlock","border","borderRadius","paddingTop","paddingRight","paddingBottom","paddingLeft","marginTop","marginRight","marginBottom","marginLeft","borderTop","borderRight","borderBottom","borderLeft","borderColor","borderWidth","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","color","backgroundColor","backgroundImage","boxShadow","opacity","fontFamily","fontSize","fontWeight","fontStyle","lineHeight","letterSpacing","textAlign","textTransform","textDecoration","whiteSpace","overflow","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","objectFit"],an=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;function ka(e,t){return At(t)?e==="flexGrow"||e==="flexShrink"?an.test(t)&&Number.isFinite(Number(t))&&Number(t)>=0:["display","boxSizing","flexDirection","flexWrap","alignItems","justifyContent","alignSelf","textAlign","whiteSpace","overflow","strokeLinecap","strokeLinejoin","objectFit"].includes(e)?!an.test(t):/^(none|normal|auto|transparent|currentcolor)$/i.test(t)?!0:/^(?:width|height|gridTemplateColumns)$/.test(e)?/^(?:min-content|max-content|fit-content|subgrid)$/.test(t):/^(?:padding|margin|border.*Radius|gap|rowGap|columnGap|letterSpacing|strokeWidth)/.test(e)?/^0(?:px|em|rem|%)?$/.test(t):/^border(Top|Right|Bottom|Left)$/.test(e)?/^(?:0px\b|.*\bnone\b)/.test(t):e==="opacity"?t==="1":/^(?:backgroundColor|fill|stroke)$/.test(e)&&/^rgba\([^)]*,\s*0\)$/.test(t):!1}function Vt(e,t){return{...e,tokens:[...e.tokens,...t.tokens??[]]}}function Sr(e){return/^(width|height|marginTop|marginRight|marginBottom|marginLeft|gridTemplateColumns)$/.test(e)}var $t=e=>{throw new ra(e)},At=e=>typeof e=="string"&&e.length>0&&e.length<=512&&!/[;{}\\]|\b(?:url|expression|var)\s*\(/i.test(e)&&![...e].some(t=>t.charCodeAt(0)<32),$r=e=>typeof e=="string"&&/^[a-zA-Z0-9_-]{1,80}$/.test(e),Ca=new Set(["div","span","img","svg","path","circle","rect","line","polyline","polygon","ellipse","g"]),on=e=>typeof e=="string"&&e.length<=2e4&&/^(https?:\/\/|blob:https?:\/\/|data:image\/(png|jpeg|webp|gif);base64,)/i.test(e),Sa=new Set(["viewBox","d","cx","cy","r","rx","ry","x","y","x1","x2","y1","y2","width","height","points","transform","fillRule","clipRule"]);function $a(e){(!e||typeof e!="object"||JSON.stringify(e).length>24e4)&&$t("Invalid fragment capture.");let t=e,{evidence:r,draft:n}=t;(!r||!$r(r.id)||![r.width,r.height].every(d=>Number.isFinite(d)&&d>0&&d<=1e4)||!Array.isArray(r.values)||r.values.length>180||!n||!Array.isArray(n.constraints)||n.constraints.length>32||!Array.isArray(n.tokens)||n.tokens.length>128)&&$t("This component is too large to capture. Try a smaller element.");let o=new Set;for(let d of r.values)(!d||!$r(d.id)||o.has(d.id)||!ar.includes(d.property)||d.local!==void 0&&(d.local!==!0||!Sr(d.property))||!At(d.value))&&$t("Unsupported captured style."),o.add(d.id);let s=0,l=new Set,a=(d,f)=>{(!d||!$r(d.id)||l.has(d.id)||!Ca.has(d.tag)||++s>64||f>12||!Array.isArray(d.children)||d.children.length>128||!d.styles||typeof d.styles!="object")&&$t("This component is too complex. Try a smaller element."),l.add(d.id);for(let[u,g]of Object.entries(d.styles))r.values.some(y=>y.id===g&&y.property===u)||$t("Invalid captured style reference.");for(let[u,g]of Object.entries(d.attributes??{}))d.tag==="img"&&u==="src"&&on(g)||(!Sa.has(u)||typeof g!="string"||g.length>12e3||!/^[\d\w\s.,+()-]*$/.test(g))&&$t("Unsupported vector geometry.");for(let u of d.children)typeof u=="string"?u.length>2e3&&$t("Too much captured text."):a(u,f+1)};return a(r.root,0),t}function Yt(e,t,r){try{let n=["fontWeight","opacity","flexGrow","flexShrink","strokeWidth"].includes(r),o;if(t.kind==="token"){let s=e.tokens.find(l=>l.id===t.id);o=s?yr(s.value,e.constraints,!n):null}else{let s=Tt(e.constraints,t.id,t.step??0);o=mt(s),s.kind==="layout"&&!s.unit&&!n&&(o+="px")}return At(o)?o:null}catch{return null}}function ln(e,t){let r=["div","span","img"].includes(t.tag)?{all:"initial"}:{};for(let[n,o]of Object.entries(t.localStyles??{}))ar.includes(n)&&(ka(n,o)||Sr(n)&&At(o))&&(r[n]=["flexGrow","flexShrink","opacity","strokeWidth"].includes(n)&&Number.isFinite(Number(o))?Number(o):o);for(let[n,o]of Object.entries(t.styles)){if(!ar.includes(n))continue;let s=Yt(e,o,n);s!==null&&(r[n]=["fontWeight","opacity","flexGrow","flexShrink","strokeWidth"].includes(n)&&Number.isFinite(Number(s))?Number(s):s)}return r}function Rt(e,t=!1){if(typeof e!="string"||!e||e.length>800||!/^[a-z\d\s.,%+#()\-/]+$/i.test(e))return!1;let r=0;for(let s of e)if(s==="("&&++r>8||s===")"&&--r<0)return!1;if(r)return!1;let n=e.replace(/#[\da-f]{3,8}\b/gi,"").replace(/[-+]?(?:\d*\.)?\d+(?:e[-+]?\d+)?(?:px|rem|em|deg|turn|rad|%)?/gi,"").match(/[a-z][a-z-]*/gi)??[],o=new Set("none transparent black white currentcolor rgb rgba hsl hsla hwb oklch oklab lab lch color color-mix srgb srgb-linear display-p3 in shorter longer increasing decreasing hue solid dashed dotted double groove ridge inset outset".split(" "));if(t)for(let s of"linear-gradient radial-gradient conic-gradient repeating-linear-gradient repeating-radial-gradient repeating-conic-gradient to top right bottom left circle ellipse closest-side farthest-side closest-corner farthest-corner at center from".split(" "))o.add(s);return n.every(s=>o.has(s.toLowerCase()))}function Et(e){if(e.border===void 0)return e;let{border:t,...r}=e,n=String(t).match(/(?:[^\s(]+\([^)]*\)|[^\s]+)/g)??[],o=n.find(a=>/^(?:[\d.]+(?:[a-z%]+)?|thin|medium|thick)$/.test(a)),s=n.find(a=>/^(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/.test(a)),l=n.filter(a=>a!==o&&a!==s).join(" ");return{borderWidth:o??"medium",borderStyle:s??"none",borderColor:l||"currentColor",...r}}function vt(e){if(e.background===void 0)return e;let{background:t,...r}=e,n=String(t);if(typeof document<"u"){let o=document.createElement("span").style;if(o.background=n,o.background)return{backgroundColor:o.backgroundColor||"transparent",backgroundImage:o.backgroundImage||"none",...r}}return{backgroundColor:/gradient\(/i.test(n)||n==="none"?"transparent":n,backgroundImage:/gradient\(/i.test(n)?n:"none",...r}}function Rr(e){if(!e||typeof e!="object")return;let t={};for(let r of["body","heading","card","button","input"]){let n=e[r];if(!n||typeof n!="object")continue;let o={};for(let[s,l]of Object.entries(n)){let a=String(l??"");s==="fontFamily"&&a.length<=200&&/^[a-zA-Z][a-zA-Z0-9 ,"'_-]*$/.test(a.replace(/^["']/,""))&&(o[s]=a),s==="color"&&Rt(l)&&(o[s]=a),["background","backgroundColor","backgroundImage","border","borderColor","boxShadow","outline"].includes(s)&&Rt(l,s.startsWith("background"))&&(o[s]=a),s==="opacity"&&typeof l=="number"&&Number.isFinite(l)&&(o[s]=Math.max(0,Math.min(1,l))),s==="transform"&&a.length<150&&/^(?:none|(?:\s*(?:translate(?:X|Y)?\(-?[\d.]+(?:px|rem|%)(?:,\s*-?[\d.]+(?:px|rem|%))?\)|scale\(\d*\.?\d+\))\s*){1,3})$/.test(a)&&(o[s]=a),s==="transition"&&a.length<200&&/^(?:(?:all|color|background-color|border-color|box-shadow|transform|opacity)\s+\d*\.?\d+(?:ms|s)(?:\s+(?:ease|ease-in|ease-out|ease-in-out|linear))?\s*,?\s*){1,5}$/.test(a)&&(o[s]=a),s==="fontWeight"&&typeof l=="number"&&l>=100&&l<=900&&(o[s]=l),s==="fontStyle"&&["normal","italic"].includes(a)&&(o[s]=a),s==="textTransform"&&["none","uppercase","lowercase","capitalize"].includes(a)&&(o[s]=a),["fontSize","letterSpacing","lineHeight","padding","margin","marginTop","marginBottom","gap","borderRadius","borderWidth","outlineOffset"].includes(s)&&a.length<100&&/^-?\d*\.?\d+(?:px|rem|em|%)?(?:\s+-?\d*\.?\d+(?:px|rem|em|%)?){0,3}$/.test(a)&&(o[s]=a)}t[r]=o}return t}function Ze(e,t=640,r=!1){if(!e)return{};let n={...e};for(let[o,s]of Object.entries(n))o==="fontFamily"||o==="fontWeight"||!r&&typeof s=="string"&&(n[o]=s.replace(/(-?\d*\.?\d+)(px|rem)\b/g,(l,a,d)=>`${Math.max(-12,Math.min(12,Number(a)*(d==="rem"?16:1)/(t/100)))}cqw`));if(e.fontFamily){let o=sn(e.fontFamily);/^Geist\s?Mono$/i.test(o)?n.fontFamily='"Popmelt Geist Mono", ui-monospace, monospace':/^Geist$/i.test(o)?n.fontFamily='"Popmelt Geist", system-ui, sans-serif':o&&!dn(o)&&(n.fontFamily=`"Popmelt Taste ${o}", ${e.fontFamily}`)}return vt(Et(n))}var sn=e=>e.split(",")[0].trim().replace(/^["']|["']$/g,""),dn=e=>/^(inherit|initial|unset|serif|sans-serif|monospace|system-ui|ui-.+|Arial|Helvetica|Verdana|Georgia|Times New Roman|Courier New|SFMono-Regular|Menlo|Monaco|Consolas)$/i.test(e),Ir=new Map;function Ra(e){if(!e||typeof FontFace>"u"||!document.fonts)return Promise.resolve();let t=new Map;for(let r of Object.values(e)){if(!r?.fontFamily)continue;let n=sn(r.fontFamily);if(dn(n)||/^Geist(?:\s?Mono)?$/i.test(n)||!/^[a-zA-Z][a-zA-Z0-9 _-]{0,79}$/.test(n))continue;let o=Number(r.fontWeight)||400,s=r.fontStyle==="italic";t.set(`${n}:${o}:${s}`,{family:n,weight:o,italic:s})}return Promise.all([...t.entries()].slice(0,5).map(([r,n])=>{let o=Ir.get(r);if(o)return o;let s=(async()=>{let l=new AbortController,a=setTimeout(()=>l.abort(),8e3);try{let d=new URLSearchParams({family:`${n.family}:${n.italic?"ital,wght@1,":"wght@"}${n.weight}`,display:"swap"}),f=await fetch(`https://fonts.googleapis.com/css2?${d}`,{signal:l.signal,credentials:"omit",referrerPolicy:"no-referrer"});if(f.ok||(f=await fetch(`https://fonts.googleapis.com/css2?family=${encodeURIComponent(n.family)}&display=swap`,{signal:l.signal,credentials:"omit",referrerPolicy:"no-referrer"})),!f.ok)throw new Error("Font unavailable");if(![...(await f.text()).matchAll(/@font-face\s*\{([^}]+)\}/g)].slice(0,32).flatMap(u=>{let g=u[1],y=g.match(/url\((https:\/\/fonts\.gstatic\.com\/[^\s)"']+)\)/)?.[1];if(!y)return[];let v=new FontFace(`Popmelt Taste ${n.family}`,`url(${JSON.stringify(y)})`,{weight:g.match(/font-weight:\s*([^;]+);/)?.[1]??"400",style:g.match(/font-style:\s*([^;]+);/)?.[1]??"normal",unicodeRange:g.match(/unicode-range:\s*([^;]+);/)?.[1]??"U+0-10FFFF",display:"swap"});return document.fonts.add(v),[v]}).length)throw new Error("Font unavailable");await document.fonts.load(`${n.italic?"italic ":""}${n.weight} 16px "Popmelt Taste ${n.family}"`,"Your workspace A little space for big ideas. Create a project")}finally{clearTimeout(a)}})().catch(l=>{console.warn(`[Popmelt] Preview font ${n.family} unavailable; using its fallback.`,l instanceof Error?l.message:"Font request failed"),Ir.delete(r)});return Ir.set(r,s),s})).then(()=>{})}var et=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Mt=(e,t=512)=>typeof e=="string"&&e.length<=t,zt=e=>Mt(e,100)&&/^[a-zA-Z0-9_-]+$/.test(e),Nr=e=>Mt(e,4096)&&![...e].some(t=>t.charCodeAt(0)<9)&&!/[;{}<>]|\b(?:url|expression|javascript)\s*[:(]/i.test(e),yt=(e,t)=>Object.keys(e).every(r=>t.includes(r)),Dt=(e,t)=>new Set(e.map(r=>r[t])).size===e.length,Lr=new Set("display boxSizing width height flexDirection flexWrap alignItems justifyContent alignSelf flexGrow flexShrink gridTemplateColumns rowGap columnGap gap padding paddingInline paddingBlock border borderRadius paddingTop paddingRight paddingBottom paddingLeft marginTop marginRight marginBottom marginLeft borderTop borderRight borderBottom borderLeft borderColor borderWidth borderTopLeftRadius borderTopRightRadius borderBottomLeftRadius borderBottomRightRadius color backgroundColor backgroundImage boxShadow opacity fontFamily fontSize fontWeight fontStyle lineHeight letterSpacing textAlign textTransform textDecoration whiteSpace overflow fill stroke strokeWidth strokeLinecap strokeLinejoin objectFit".split(" ")),Ia=new Set("div span img svg path circle rect line polyline polygon ellipse g".split(" ")),Na=new Set("src alt viewBox d cx cy r x y x1 x2 y1 y2 rx ry width height points preserveAspectRatio transform fillRule clipRule".split(" "));function bt(e){return Array.isArray(e)?"["+e.map(bt).join(",")+"]":et(e)?"{"+Object.keys(e).sort().map(t=>JSON.stringify(t)+":"+bt(e[t])).join(",")+"}":JSON.stringify(e)}function La(e){try{if(!et(e)||!yt(e,["format","schemaVersion","draft"])||e.format!=="popmelt.taste.graph"||e.schemaVersion!==1||new TextEncoder().encode(JSON.stringify(e)).byteLength>512e3)return!1;let t=e.draft;if(!et(t)||!yt(t,["schemaVersion","name","constraints","tokens","usage","fragments","featuredComponentId"])||t.schemaVersion!==1||!Mt(t.name,80)||!t.name.trim()||!Array.isArray(t.constraints)||t.constraints.length<1||t.constraints.length>32||!t.constraints.every(a=>et(a)&&yt(a,["id","name","kind","group","typographyRole","scaleMode","value","parentId","derivative","scale"])&&zt(a.id)&&Mt(a.name,80)&&(a.group===void 0||a.group==="typography")&&(a.typographyRole===void 0||a.typographyRole==="body"||a.typographyRole==="heading")&&["layout","color","font"].includes(String(a.kind))&&Nr(a.value)&&(a.parentId===null||zt(a.parentId))&&Number.isFinite(a.derivative)&&Number.isFinite(a.scale)&&typeof a.scale=="number"&&a.scale>=0&&(a.scaleMode===void 0||a.scaleMode==="increment"))||!Dt(t.constraints,"id"))return!1;let r=new Map(t.constraints.map(a=>[String(a.id),a]));for(let a of t.constraints){let d=new Set,f=a;for(;f.parentId!==null;){if(d.has(f.id))return!1;d.add(f.id);let u=r.get(f.parentId);if(!u||u.kind!==f.kind)return!1;f=u}if(!f.value.trim())return!1}let n=a=>Array.isArray(a)&&a.length<=128&&a.every(d=>et(d)&&yt(d,["id","name","value"])&&zt(d.id)&&zt(d.name)&&Nr(d.value)&&d.value.trim()&&[...d.value.matchAll(/@([a-zA-Z0-9_-]+)/g)].every(f=>r.has(f[1])))&&Dt(a,"id")&&Dt(a,"name");if(!n(t.tokens))return!1;let o=t.tokens,s=(a,d)=>et(a)&&yt(a,["kind","id","step"])&&(a.kind==="dimension"?r.has(String(a.id)):a.kind==="token"&&d.some(f=>f.id===a.id))&&(a.step===void 0||typeof a.step=="number"&&Number.isInteger(a.step)&&Math.abs(a.step)<=100);if(t.usage!==void 0&&(!Array.isArray(t.usage)||t.usage.length>256||!t.usage.every(a=>et(a)&&yt(a,["target","property","source"])&&["page","heading","body","muted","card","button","input"].includes(String(a.target))&&Lr.has(String(a.property))&&s(a.source,o))))return!1;let l=t.fragments??[];if(!Array.isArray(l)||l.length>32||!Dt(l,"id"))return!1;for(let a of l){if(!et(a)||!yt(a,["id","name","width","height","root","tokens"])||!zt(a.id)||!Mt(a.name,80)||!a.name.trim()||![a.width,a.height].every(v=>typeof v=="number"&&Number.isFinite(v)&&v>0&&v<=2e4)||!n(a.tokens??[]))return!1;let d=a.tokens??[];if(!n(d))return!1;let f=[...o,...d];if(!Dt(f,"id")||!Dt(f,"name"))return!1;let u=new Set,g=0,y=(v,C)=>typeof v=="string"?v.length<=1e4:!et(v)||!yt(v,["id","tag","styles","localStyles","attributes","children"])||!zt(v.id)||u.has(v.id)||++g>256||C>16||!Ia.has(String(v.tag))||!et(v.styles)||!Array.isArray(v.children)||v.children.length>256||(u.add(v.id),!Object.entries(v.styles).every(([c,b])=>Lr.has(c)&&s(b,f)))||v.localStyles!==void 0&&(!et(v.localStyles)||!Object.entries(v.localStyles).every(([c,b])=>Lr.has(c)&&Nr(b)))||v.attributes!==void 0&&(!et(v.attributes)||!Object.entries(v.attributes).every(([c,b])=>Na.has(c)&&Mt(b,2e4)&&(c!=="src"||/^https:\/\//.test(b))))?!1:v.children.every(c=>y(c,C+1));if(!y(a.root,0))return!1}return t.featuredComponentId==null||l.some(a=>a.id===t.featuredComponentId)}catch{return!1}}function It(e){if(!La(e))return;let t=e;try{for(let r of t.draft.constraints)Tt(t.draft.constraints,r.id);for(let r of t.draft.fragments??[]){let n=Vt(t.draft,r),o=s=>Object.entries(s.styles).every(([l,a])=>Yt(n,a,l)!==null)&&s.children.every(l=>typeof l=="string"||o(l));if(!o(r.root))return}return t}catch{return}}function Tr(e){let t={format:"popmelt.taste.graph",schemaVersion:1,draft:e};if(!It(t))throw Error("This Taste has incomplete or invalid dimensions, tokens, or component bindings.");return t}function wt(e){if(!e||typeof e!="object")return;let t=e;for(let o of["background","surface","foreground","muted","accent","border"])if(!Rt(t[o],!0))return;for(let o of["radius","spacing"])if(typeof t[o]!="number"||!Number.isFinite(t[o])||t[o]<0||t[o]>32)return;let r={...t};delete r.savedDocument;let n=t.savedDocument;if(n&&typeof n.id=="string"&&Number.isSafeInteger(n.revision)&&n.revision>0&&It(n.document)&&(r.savedDocument=n),delete r.detail,t.detail!==void 0&&(r.detail=Rr(t.detail)),delete r.states,t.states&&typeof t.states=="object"){r.states={};for(let o of["card","button","input"]){let s=t.states[o];if(!(!s||typeof s!="object")){r.states[o]={};for(let l of["hover","focus","active"])r.states[o][l]=Rr({[o]:s[l]})?.[o]}}}if(delete r.parts,t.parts!==void 0){if(!t.parts||typeof t.parts!="object")return;let o={};for(let s of["card","button","content"]){let l=t.parts[s];if(!l||typeof l.radius!="number"||!Number.isFinite(l.radius)||l.radius<0||l.radius>999)return;let a=l.backdropFilter;o[s]={background:Rt(l.background,!0)?l.background:r.surface,border:Rt(l.border)?l.border:`1px solid ${r.border}`,radius:l.radius,shadow:Rt(l.shadow)?l.shadow:"none",...l.backgroundImage!==void 0?{backgroundImage:Rt(l.backgroundImage,!0)?l.backgroundImage:"none"}:{},...l.backgroundBlendMode!==void 0?{backgroundBlendMode:["normal","overlay","multiply","screen","soft-light","hard-light"].includes(l.backgroundBlendMode)?l.backgroundBlendMode:"normal"}:{},...a!==void 0?{backdropFilter:typeof a=="string"&&a.length<150&&/^(?:none|(?:\s*(?:blur\(\d*\.?\d+(?:px|rem)\)|saturate\(\d*\.?\d+%?\))\s*){1,3})$/.test(a)?a:"none"}:{},...l.opacity!==void 0?{opacity:Number.isFinite(l.opacity)?Math.max(0,Math.min(1,l.opacity)):1}:{}}}r.parts=o}return(!Number.isSafeInteger(r.recipeRevision)||r.recipeRevision<0)&&delete r.recipeRevision,(typeof r.contentRevision!="string"||!/^[a-f\d]{24}$/.test(r.contentRevision))&&delete r.contentRevision,r}function Ta({recipe:e}){let t=e.radius*.45,r=o=>o.replace(/(-?\d*\.?\d+)(px|rem)\b/g,(s,l,a)=>`${Math.max(-32,Math.min(32,Number(l)*(a==="rem"?16:1)*.45))}px`),n=o=>o?{background:o.background,...o.backgroundImage&&o.backgroundImage!=="none"?{backgroundImage:o.backgroundImage}:{},backgroundBlendMode:o.backgroundBlendMode,backdropFilter:o.backdropFilter?r(o.backdropFilter).replace(/saturate\(([\d.]+)%\)/g,(s,l)=>`saturate(${Math.min(400,Number(l))}%)`):void 0,WebkitBackdropFilter:o.backdropFilter?r(o.backdropFilter):void 0,opacity:o.opacity,border:r(o.border),borderRadius:o.radius*.45,boxShadow:r(o.shadow)}:{};return i("span",{"data-taste-specimen":!0,"aria-hidden":"true",style:{position:"absolute",inset:0,background:e.background,pointerEvents:"none",overflow:"hidden"},children:k("span",{"data-specimen-window":!0,style:{position:"absolute",left:"19.23%",top:"19.23%",width:"110%",height:"110%",background:e.surface,border:`1px solid ${e.border}`,borderRadius:t,overflow:"hidden",boxSizing:"border-box",...n(e.parts?.card),borderTopRightRadius:0,borderBottomRightRadius:0,borderBottomLeftRadius:0},children:[i("span",{"data-specimen-title":!0,style:{position:"absolute",left:0,top:0,width:"100%",height:"18.18%",background:e.parts?"transparent":e.accent}}),i("span",{"data-specimen-control":!0,style:{position:"absolute",left:"7.95%",top:"26.14%",width:"90.91%",height:"18.18%",background:e.muted,border:`1px solid ${e.border}`,borderRadius:t*.6,boxSizing:"border-box",...n(e.parts?.button)}}),i("span",{"data-specimen-content":!0,style:{position:"absolute",left:"7.95%",top:"53.41%",width:"90.91%",height:"67.05%",background:e.background,border:`1px solid ${e.border}`,borderRadius:t*.6,boxSizing:"border-box",...n(e.parts?.content)}})]})})}function Jt(e,t=!1,r=640){let[n,o]=T(!1),[s,l]=T(!1),[a,d]=T(!1);return{handlers:{onPointerEnter:()=>o(!0),onPointerLeave:()=>{o(!1),d(!1)},onPointerDown:()=>d(!0),onPointerUp:()=>d(!1),onPointerCancel:()=>d(!1),onKeyDown:f=>{t&&["Enter"," "].includes(f.key)&&d(!0)},onKeyUp:()=>d(!1),onFocus:()=>l(!0),onBlur:()=>{l(!1),d(!1)}},style:{...Ze(n?e?.hover:void 0,r),...Ze(s?e?.focus:void 0,r),...Ze(a?e?.active:void 0,r)}}}function Ar({recipe:e,usageStyles:t}){let r=t!==void 0,n=u=>Ze({...e.detail?.[u]??{},...t?.[u]},640,r),o=Jt(e.states?.button,!0),s=Jt(e.states?.input),l=Jt(e.states?.card),a=r?`${e.spacing}px`:`${e.spacing/6.4}cqw`;le(()=>{Ra({...e.detail,...t})},[e.detail,t]);let d=u=>u.replace(/(-?\d*\.?\d+)(px|rem)\b/g,(g,y,v)=>`${Math.max(-16,Math.min(16,Number(y)*(v==="rem"?16:1)/6.4))}cqw`),f=u=>u?{...vt({background:u.background}),...u.backgroundImage&&u.backgroundImage!=="none"?{backgroundImage:u.backgroundImage}:{},backgroundBlendMode:u.backgroundBlendMode,...Et({border:d(u.border)}),borderRadius:`${u.radius/6.4}cqw`,boxShadow:d(u.shadow),backdropFilter:u.backdropFilter?d(u.backdropFilter):void 0,WebkitBackdropFilter:u.backdropFilter?d(u.backdropFilter):void 0,opacity:u.opacity}:{};return i("div",{"data-taste-detail-specimen":!0,role:"group","aria-label":"Interactive taste preview",style:{position:r?"relative":"absolute",...r?{width:640,padding:0,boxSizing:"border-box"}:{inset:0},containerType:"inline-size",...vt({background:e.background}),color:e.foreground,fontSynthesis:"none",...n("body"),...n("page"),overflow:r?"visible":"hidden"},children:i("div",{"data-taste-component":"card",style:{position:r?"relative":"absolute",...r?{}:{inset:"9% 8%"},...vt({background:e.surface}),...Et({border:`1px solid ${e.border}`}),borderRadius:e.radius,...f(e.parts?.card),padding:r?0:"5cqw",boxSizing:"border-box",display:"flex",flexDirection:"column",gap:a,...n("card")},children:k("div",{style:{display:"grid",gridTemplateColumns:"1.35fr 1fr",gap:r?n("card").gap??a:`calc(${a} * 2)`,alignItems:"center",flex:1,minHeight:0},children:[k("div",{children:[k("h2",{"data-taste-component":"heading",style:{margin:0,fontWeight:"inherit",lineHeight:1.1,letterSpacing:"-0.03em",marginBottom:a,...n("heading"),...r?{}:{fontSize:`clamp(3.8cqw, ${Ze(e.detail?.heading).fontSize??"4.6cqw"}, 5.4cqw)`}},children:["A little space",i("br",{}),"for big ideas."]}),k("p",{"data-taste-component":"paragraph",style:{margin:0,fontSize:r?"inherit":"2.4cqw",lineHeight:1.5,marginBottom:a,...n("body"),...n("muted")},children:["Gather your thoughts.",i("br",{}),"Make something your own."]}),i("button",{"data-taste-component":"button",...o.handlers,type:"button",style:{fontFamily:"inherit",color:"inherit",display:"inline-block",...vt({background:e.accent}),...Et({border:`1px solid ${e.border}`}),borderRadius:e.radius,...f(e.parts?.button),padding:r?0:"1.5cqw 2.5cqw",fontSize:r?"inherit":"2.3cqw",fontWeight:"inherit",lineHeight:1.2,...n("button"),cursor:"pointer",...o.style},children:"Create a project \u2197"})]}),k("div",{"data-taste-component":"card",...l.handlers,style:{...vt({background:e.surface}),...Et({border:`1px solid ${e.border}`}),borderRadius:e.radius,...f(e.parts?.card),padding:r?0:"3cqw",fontSize:r?"inherit":"2.1cqw",lineHeight:1.5,...n("card"),...l.style},children:[i("h3",{"data-taste-component":"heading",style:{margin:0,fontWeight:"inherit",...n("heading"),...r?{}:{fontSize:"2.6cqw"},marginBottom:a},children:"In the works"}),i("input",{"data-taste-component":"input",...s.handlers,"aria-label":"Preview project name",defaultValue:"A fresh start",style:{appearance:"none",outline:"none",borderWidth:0,borderStyle:"none",borderColor:"transparent",...vt({background:"transparent"}),...f(e.parts?.content),font:"inherit",color:"inherit",padding:r?0:"1.5cqw",...n("input"),width:"100%",minWidth:0,boxSizing:"border-box",marginBottom:a,...s.style}}),i("div",{children:"02 \xA0 What comes next"})]})]})})})}function cn({children:e}){let t=Ge.dark,r=D(null),[n,o]=T(),[s,l]=T({scale:1,x:0,y:0}),a=D(s);return le(()=>{let d=r.current;if(!d)return;let f=()=>o({width:d.clientWidth,height:d.clientHeight});f();let u=typeof ResizeObserver<"u"?new ResizeObserver(f):void 0;u?.observe(d);let g=()=>window.matchMedia("(any-hover: hover) and (any-pointer: fine)").matches,y=(h,p,m)=>{h=Math.max(1,Math.min(4,h));let N={scale:h,x:Math.max(1-h,Math.min(0,p)),y:Math.max(1-h,Math.min(0,m))};a.current=N,l(N)},v=(h,p,m)=>{let N=d.getBoundingClientRect();if(!N.width||!N.height)return;let A=a.current,P=Math.max(1,Math.min(4,h)),q=Math.max(0,Math.min(1,(p-N.left)/N.width)),x=Math.max(0,Math.min(1,(m-N.top)/N.height));y(P,q-(q-A.x)*P/A.scale,x-(x-A.y)*P/A.scale)},C=null,c=h=>{if(!g()||!h.ctrlKey&&a.current.scale===1)return;h.preventDefault(),h.stopPropagation();let p=h.deltaMode===1?16:h.deltaMode===2?d.clientHeight:1;if(h.ctrlKey)C===null&&v(a.current.scale*Math.exp(-h.deltaY*p*.01),h.clientX,h.clientY);else{let m=d.getBoundingClientRect();m.width&&m.height&&y(a.current.scale,a.current.x-h.deltaX*p/m.width,a.current.y-h.deltaY*p/m.height)}},b=h=>{if(!g())return;h.preventDefault(),h.stopPropagation();let p=h;h.type==="gesturestart"?C=a.current.scale:h.type==="gestureend"?C=null:C!==null&&Number.isFinite(p.scale)&&v(C*p.scale,p.clientX,p.clientY)};d.addEventListener("wheel",c,{passive:!1});for(let h of["gesturestart","gesturechange","gestureend"])d.addEventListener(h,b,{passive:!1});return()=>{u?.disconnect(),d.removeEventListener("wheel",c);for(let h of["gesturestart","gesturechange","gestureend"])d.removeEventListener(h,b)}},[]),k("div",{ref:r,"data-preview-zoom":!0,style:{position:"relative",width:"100%",aspectRatio:"16 / 9",overflow:"hidden",borderRadius:8},children:[i("div",{"data-preview-zoom-content":!0,style:{width:n?.width||"100%",height:n?.height||"100%",zoom:s.scale,transformOrigin:"0 0",transform:`translate(${s.x*100/s.scale}%, ${s.y*100/s.scale}%)`},children:e}),s.scale>1&&k(Le,{children:[i("style",{children:`
3
+ [data-preview-zoom-reset] span { color: ${t.primary}; }
4
+ [data-preview-zoom-reset] svg { color: ${t.secondary}; }
5
+ [data-preview-zoom-reset]:hover span, [data-preview-zoom-reset]:focus-visible span { color: ${t.secondary}; }
6
+ [data-preview-zoom-reset]:hover svg, [data-preview-zoom-reset]:focus-visible svg { color: ${t.primary}; }
7
+ [data-preview-zoom-reset] span, [data-preview-zoom-reset] svg { transition: color 120ms ease; }
8
+ `}),k("button",{"data-preview-zoom-reset":!0,type:"button","aria-label":"Reset preview zoom",onClick:()=>{let d={scale:1,x:0,y:0};a.current=d,l(d)},style:{position:"absolute",right:8,bottom:8,display:"inline-flex",alignItems:"center",gap:6,border:0,borderRadius:8,padding:"4px 6px 4px 10px",background:t.control,color:t.primary,fontSize:12,cursor:"pointer"},children:[k("span",{children:[Math.round(s.scale*100),"%"]}),i(ma,{size:14,"aria-hidden":"true"})]})]})]})}function Aa(e){let t=e.ownerDocument.defaultView;if(!t||Yr(e))throw Error("Choose an element on the page.");let r=e.getBoundingClientRect(),n={id:`fragment-${crypto.randomUUID()}`,width:r.width,height:r.height,root:null,values:[]},o=new Map,s=0,l=(d,f)=>{if(d.matches("script,style,noscript,template,[hidden],[contenteditable]")||Yr(d))return null;let u=d.getBoundingClientRect(),g=t.getComputedStyle(d);if(!u.width||!u.height||u.bottom<=0||u.right<=0||u.top>=t.innerHeight||u.left>=t.innerWidth||g.display==="none"||g.visibility!=="visible"||g.opacity==="0")return null;if(++s>64||f>12)throw Error("This component is too complex. Click a smaller element.");if(d.matches("video,canvas,iframe,object,embed,use,foreignObject")||d.shadowRoot)throw Error("This component contains media or embedded content not supported by static capture yet. Try a text, button or layout element.");if(/url\(/i.test(g.backgroundImage))throw Error("Image backgrounds are not supported by static capture yet.");let y=d.namespaceURI==="http://www.w3.org/2000/svg",v=y?d.localName:d.localName==="img"?"img":g.display==="inline"?"span":"div",C={id:`n${s}`,tag:v,children:[],styles:{}};if(d instanceof HTMLImageElement){if(!on(d.currentSrc||d.src))throw Error("This image cannot be captured safely.");C.attributes={src:d.currentSrc||d.src}}if(y){C.attributes={};for(let c of["viewBox","d","cx","cy","r","rx","ry","x","y","x1","x2","y1","y2","width","height","points","transform","fill-rule","clip-rule"]){let b=d.getAttribute(c);b!==null&&(C.attributes[c.replace(/-([a-z])/g,(h,p)=>p.toUpperCase())]=b)}}for(let c of ar){if(["gap","padding","paddingInline","paddingBlock","border","borderRadius","borderColor","borderWidth"].includes(c)||!y&&["fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin"].includes(c)||y&&v!=="svg"&&["width","height"].includes(c))continue;let b=g[c],h=!1;if(Sr(c)){let N=d.computedStyleMap?.().get(c.replace(/[A-Z]/g,A=>`-${A.toLowerCase()}`))?.toString();N&&At(N)&&(b=N),h=!N||/^(auto|min-content|max-content|fit-content|none)$/.test(N)||c==="gridTemplateColumns"}if(!b)continue;if(!At(b))throw Error("This component has an unsupported style. Try a smaller element.");let p=`${c}:${b}:${h}`,m=o.get(p);m||(m=`s${o.size}`,o.set(p,m),n.values.push({id:m,property:c,value:b,...h?{local:!0}:{}})),C.styles[c]=m}if(!d.matches("input,textarea,select,option")){for(let c of d.childNodes)if(c.nodeType===3)c.textContent&&C.children.push(c.textContent);else if(c instanceof Element){let b=l(c,f+1);b&&C.children.push(b)}}return C},a=l(e,0);if(!a)throw Error("Choose a visible element on the page.");return n.root=a,$a({evidence:n,draft:ea()}),n}function ir({fragment:e,draft:t,height:r=160,highlightedNodes:n=[]}){let o=D(null),s=D(null),[l,a]=T(null),[d,f]=T({scale:1,width:e.width,height:e.height}),{scale:u}=d;Pe(()=>{o.current&&a(o.current.shadowRoot??o.current.attachShadow({mode:"open"}))},[]),Pe(()=>{let y=()=>{if(!o.current||!s.current)return;let C=s.current,c=Math.max(1,C.scrollWidth),b=Math.max(1,C.scrollHeight),h={width:c,height:b,scale:Math.min(1,o.current.clientWidth/c,r/b)};f(p=>p.width===h.width&&p.height===h.height&&p.scale===h.scale?p:h)};if(y(),typeof ResizeObserver>"u")return;let v=new ResizeObserver(y);return o.current&&v.observe(o.current),s.current&&v.observe(s.current),()=>v.disconnect()},[l,t,r]);let g=y=>{let v=ln(Vt(t,e),y);return la(y.tag,{...y.attributes,key:y.id,style:{...v,color:v.color??"inherit",fontFamily:v.fontFamily??"inherit",fontSize:v.fontSize??"inherit",lineHeight:v.lineHeight??"inherit",fontWeight:v.fontWeight??"inherit",...n.includes(y.id)?{outline:"2px solid #888",outlineOffset:"2px"}:{}},"data-fragment-node":y.id},...y.children.map(C=>typeof C=="string"?C:g(C)))};return i("div",{ref:o,role:"img","aria-label":`${e.name} static preview`,style:{height:r,width:"100%",overflow:"hidden",borderRadius:8,pointerEvents:"none",backgroundColor:ln(Vt(t,e),e.root).backgroundColor??_r(t).page?.backgroundColor},children:l&&nn(i("div",{style:{height:r,display:"grid",placeItems:"center",overflow:"hidden"},children:i("div",{style:{width:d.width*u,height:d.height*u},children:i("div",{ref:s,style:{width:e.width,transform:`scale(${u})`,transformOrigin:"top left"},children:g(e.root)})})}),l)})}function Ea(e){let{session:t,draft:r,visible:n,bridgeUrl:o}=e,[s,l]=T([]),a=D(null),d=D(new Map),f=D(null),u=D(null),g=D(e);g.current=e;let y=D(!1),v=t.getSnapshot().runId,C=t.getSnapshot().state,c=Ge[e.theme],b=h=>{if(t.getSnapshot().state==="running")return;let p=t.getSnapshot().draft;if(!p)return;let m={...p,featuredComponentId:h};t.history.current.past.push(p),t.history.current.future=[],t.edit(m),e.onDraft(m)};return Pe(()=>{let h=a.current?.closest(".tc-scroll");if(!h||!n)return;let p=()=>{f.current=null},m=N=>{["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(N.key)&&p()};return h.addEventListener("wheel",p,{passive:!0}),h.addEventListener("touchmove",p,{passive:!0}),h.addEventListener("pointerdown",p,{passive:!0}),h.addEventListener("keydown",m),()=>{h.removeEventListener("wheel",p),h.removeEventListener("touchmove",p),h.removeEventListener("pointerdown",p),h.removeEventListener("keydown",m)}},[n]),Pe(()=>{let h=f.current;if(!h||!n)return;let p=d.current.get(h),m=p?.closest(".tc-scroll");if(!p||!m)return;let N=p.getBoundingClientRect(),A=m.getBoundingClientRect(),P=N.bottom+16-A.bottom;P>0&&m.scrollTo({top:m.scrollTop+P,behavior:"instant"})},[s,n,r]),le(()=>(y.current=!0,()=>{y.current=!1,u.current?.abort(),u.current=null}),[]),le(()=>{if(n)return Vn(h=>{let p;try{let m=Aa(h);p={id:m.id,evidence:m,state:"pending"}}catch(m){p={id:crypto.randomUUID(),state:"error",message:m instanceof Error?m.message:"Could not capture this element."}}l(m=>m.length+(g.current.draft.fragments?.length??0)>=16?m:(f.current=p.id,[...m,p]))})},[n]),le(()=>{if(!n||u.current||C==="running")return;let h=s.find(A=>A.state==="pending"&&A.evidence);if(!h)return;let p=new AbortController;u.current=p;let m=A=>{y.current&&!p.signal.aborted&&l(P=>P.map(q=>q.id===h.id?{...q,...A}:q))};m({state:"running"});let N=setTimeout(()=>{m({state:"error",message:"Capture took too long. Try again."}),p.abort()},19e4);(async()=>{try{if(await Promise.resolve(),p.signal.aborted)return;if(!o)throw Error("Connect the local bridge to capture a component.");let A=t.getSnapshot(),P=await Ne(`${o}/cloud-taste/fragment`,{method:"POST",headers:{"Content-Type":"application/json"},signal:p.signal,body:JSON.stringify({evidence:h.evidence,draft:{...A.draft,fragments:void 0}})});if(!P.ok||!P.body)throw Error("Component capture is unavailable. Retry when the bridge is ready.");let q=P.body.getReader(),x=new TextDecoder,j="",E,B=H=>{if(!H.trim())return;let M=JSON.parse(H);if(M.type==="error")throw Error(M.message);M.type==="status"&&m({message:M.message}),M.type==="progress"&&m({name:M.draft.fragment.name}),M.type==="complete"&&(E=M.draft)};try{for(;;){let H=await q.read();if(H.done)break;if(j+=x.decode(H.value,{stream:!0}),j.length>256e3)throw Error("Component response was too large.");let M;for(;(M=j.indexOf(`
9
+ `))!==-1;)B(j.slice(0,M)),j=j.slice(M+1)}B(j+x.decode())}finally{q.releaseLock()}if(!E)throw Error("The component ended before its styles arrived. Retry capture.");!p.signal.aborted&&y.current&&(g.current.onDraft(t.addFragment(v,E)),l(H=>H.filter(M=>M.id!==h.id)))}catch(A){m({state:"error",message:A instanceof Error?A.message:"Capture failed. Please retry."})}finally{clearTimeout(N),u.current===p&&(u.current=null),y.current&&l(A=>[...A])}})()},[s,C,n,o,v,t]),k("section",{ref:a,"aria-label":"Components",style:{display:"flex",flexDirection:"column",gap:16},children:[i("h3",{style:{margin:0,fontSize:12,fontWeight:400,color:c.primary},children:"Components"}),!r.fragments?.length&&!s.length&&i("p",{style:{margin:0,fontSize:12,color:c.secondary},children:"Click an element on the page to capture a static component."}),r.fragments?.map(h=>k("div",{ref:p=>{p?d.current.set(h.id,p):d.current.delete(h.id)},style:{display:"flex",flexDirection:"column",gap:4},children:[i("button",{type:"button","aria-label":`Inspect ${h.name}`,onClick:()=>e.onInspect?.(h.id),style:{background:c.control,borderRadius:8,width:"100%",padding:0,display:"block"},children:i(ir,{draft:r,fragment:h})}),k("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"0 4px",color:c.secondary},children:[i("button",{type:"button",onClick:()=>e.onInspect?.(h.id),style:{flex:1,justifyContent:"flex-start",fontSize:12,letterSpacing:".12px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.name}),i("button",{type:"button",onClick:()=>b(h.id),"aria-label":`Use ${h.name} as preview`,"aria-pressed":r.featuredComponentId===h.id,disabled:C==="running",style:{fontSize:12},children:r.featuredComponentId===h.id?"Preview":"Use as preview"}),i("button",{type:"button",onClick:()=>e.onInspect?.(h.id),"aria-label":`Uses for ${h.name}`,title:"Styles are linked to this Taste\u2019s dimensions and tokens",style:{fontSize:14,fontWeight:500,letterSpacing:"-.14px"},children:"uses"})]})]},h.id)),s.map(h=>k("div",{ref:p=>{p?d.current.set(h.id,p):d.current.delete(h.id)},"data-taste-fragment-capture":h.id,style:{borderRadius:8,background:c.control,minHeight:160,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:8,padding:12,boxSizing:"border-box"},children:[i("span",{role:h.state==="error"?"alert":"status",className:"tc-proposal-status","data-state":h.state==="running"?"in-progress":h.state,style:{whiteSpace:"normal",textAlign:"center"},children:h.state==="error"?h.message:h.state==="pending"?"Pending":h.message??`Tracing ${h.name??"component"}\u2026`}),h.state==="error"&&k("div",{style:{display:"flex",gap:12},children:[h.evidence&&i("button",{type:"button",onClick:()=>l(p=>p.map(m=>m.id===h.id?{...m,state:"pending",message:void 0}:m)),children:"Retry"}),i("button",{type:"button",onClick:()=>l(p=>p.filter(m=>m.id!==h.id)),children:"Dismiss"})]})]},h.id))]})}function Er({document:e}){let t=D(null),[r,n]=T(160);Pe(()=>{let l=()=>n(t.current?.clientHeight||160);if(l(),typeof ResizeObserver>"u")return;let a=new ResizeObserver(l);return t.current&&a.observe(t.current),()=>a.disconnect()},[]);let o=e.draft,s=o.fragments?.find(l=>l.id===o.featuredComponentId);return i("div",{ref:t,"data-taste-document-preview":!0,style:{width:"100%",height:"100%"},children:s?i(ir,{fragment:s,draft:o,height:r}):null})}function un({preview:e,thumbnailUrl:t,zoom:r=!0,background:n}){let[o,s]=T(null),l=e?.savedDocument?.document.draft.featuredComponentId?i(Er,{document:e.savedDocument.document}):e?i(Ar,{recipe:e}):t&&t!==o?i("img",{src:t,alt:"",referrerPolicy:"no-referrer",onError:()=>s(t),style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):null;return i("div",{"data-detail-preview":!0,style:{aspectRatio:"16 / 9",width:"100%",position:"relative",border:0,padding:0,borderRadius:8,overflow:"hidden",background:n,font:"inherit"},children:r?i(cn,{children:l}):l})}var Mr=100,Pt=200,Ma=600,pn=220,za=120,Da=160;function zr(e){let t=new Map;if(!e)return t;let r=e.getBoundingClientRect();for(let n of e.querySelectorAll("[data-taste-tile]")){let o=n.dataset.tasteEntryId;if(!o)continue;let s=n.getBoundingClientRect();t.set(o,{x:s.x-r.x,y:s.y-r.y})}return t}function hn(e,t,r,n,o){if(!e)return;let s=zr(e);for(let l of e.querySelectorAll("[data-taste-tile]")){let a=l.dataset.tasteEntryId,d=a?t.get(a):null,f=a?s.get(a):null;if(!d||!f||!l.animate)continue;let u=(d.x-f.x)/(r||1),g=(d.y-f.y)/(r||1);Math.abs(u)<.5&&Math.abs(g)<.5||o.push(l.animate([{transform:`translate(${u}px, ${g}px)`},{transform:"translate(0, 0)"}],{duration:n,easing:"ease-in-out"}))}}function fn({entry:e,onAdd:t,onRemove:r,active:n,featured:o=!1,previewBackground:s,hasActiveTaste:l=!1,onOpenDetails:a,onPrefetchDetails:d}){let[f,u]=T(null),g=D(null),y=D(d);y.current=d;let v=D(e);v.current=e,le(()=>{if(!g.current||typeof IntersectionObserver>"u")return;let N=new IntersectionObserver(([A])=>{A?.isIntersecting&&(v.current.preview||y.current?.(v.current),N.disconnect())},{root:g.current.closest("[data-taste-scroll]"),rootMargin:"180px"});return N.observe(g.current),()=>N.disconnect()},[e.id]);let C=D(void 0),c=()=>clearTimeout(C.current);le(()=>()=>clearTimeout(C.current),[]);let b=!!e.documentRevision||!!e.preview?.savedDocument,h=n?r:b?a:t,p=n?"Remove":b?"View":l?"Switch":"Add",m=i("span",{"data-taste-add":!0,"aria-hidden":"true",style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:3,padding:n?"4px 9px 4px 10px":"4px 10px 4px 6px",border:0,borderRadius:8,font:"inherit",fontWeight:500,letterSpacing:"-.12px",whiteSpace:"nowrap"},children:n?k(Le,{children:["Remove",i(St,{size:12,"aria-hidden":"true"})]}):k(Le,{children:[b?i(Kt,{size:12,"aria-hidden":"true"}):i(Ft,{size:12,"aria-hidden":"true"}),p]})});return k("li",{"data-taste-tile":!0,"data-taste-entry-id":e.id,"data-taste-featured":o||void 0,ref:g,onMouseEnter:()=>{c(),C.current=setTimeout(()=>d?.(e),100)},onMouseLeave:c,onFocus:()=>{c(),d?.(e)},style:{minWidth:0,display:"flex",flexDirection:"column",gap:4},children:[o?k("div",{"data-taste-thumbnail":!0,style:{position:"relative",width:"100%",aspectRatio:"16 / 9",borderRadius:8,overflow:"hidden"},children:[i("div",{"data-taste-preview-art":!0,"aria-hidden":"true",inert:!0,children:i(un,{preview:e.preview,thumbnailUrl:e.thumbnailUrl,zoom:!1,background:s??"transparent"},e.id)}),i("button",{type:"button","data-taste-featured-action":!0,"aria-label":`${p} ${e.name}`,"aria-pressed":n,disabled:!h,onClick:()=>h?.(e),style:{position:"absolute",inset:0,width:"100%",padding:0,border:0,background:"transparent",font:"inherit",cursor:h?"pointer":"default"},children:m})]}):k("button",{type:"button","data-taste-thumbnail":!0,"aria-label":`${p} ${e.name}`,"aria-pressed":n,disabled:!h,onClick:()=>h?.(e),style:{display:"block",padding:0,border:0,font:"inherit",cursor:h?"pointer":"default",aspectRatio:"1",width:"100%",borderRadius:8,overflow:"hidden",position:"relative"},children:[i("span",{"data-taste-preview-art":!0,style:{position:"absolute",inset:0},children:e.preview?.savedDocument?.document.draft.featuredComponentId?i(Er,{document:e.preview.savedDocument.document}):e.thumbnailUrl&&e.thumbnailUrl!==f?i("img",{src:e.thumbnailUrl,alt:"",referrerPolicy:"no-referrer",onError:()=>u(e.thumbnailUrl??null),style:{display:"block",width:"100%",height:"100%",objectFit:"cover"}}):e.preview?i(Ta,{recipe:e.preview}):null}),m]}),k("button",{type:"button","data-taste-details":!0,"aria-label":`View ${e.name} details`,disabled:!a,onClick:()=>a?.(e),style:{width:"100%",padding:0,border:0,borderRadius:2,background:"transparent",font:"inherit",textAlign:"left",cursor:a?"pointer":"default",display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,minWidth:0,letterSpacing:".12px"},children:[k("span",{style:{display:"inline-flex",alignItems:"center",minWidth:0,overflow:"hidden"},children:[i("span",{"data-taste-name":!0,title:e.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500,minWidth:0},children:e.name}),a&&i("span",{"data-taste-detail-chevron":!0,"aria-hidden":"true",children:i(Kt,{size:13,strokeWidth:2})})]}),e.metadata&&i("span",{"data-taste-metadata":!0,title:e.metadata.label,"aria-label":e.metadata.label,style:{flexShrink:0,fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap"},children:e.metadata.value})]})]})}function Pa({theme:e,publicEntries:t,privateEntries:r,onClose:n,onRefresh:o,refreshDisabled:s=!1,refreshing:l=!1,onAdd:a,onRemove:d,activeEntryId:f=null,activeEntry:u,onOpenDetails:g,onPrefetchDetails:y,notice:v,action:C,headerAction:c,privateEmptyMessage:b,style:h}){let p=Ge[e],[m,N]=T(!1),A=D(null),P=D(null),q=D(null),x=D(null),j=D([]),E=D(new Map),B=D([]),H=D(null),[M,L]=T(null),R=D(null),K=D(null),[de,Q]=T(),[U,ae]=T(null),he=D(null);le(()=>()=>{for(let J of he.current?.timers??[])clearTimeout(J);he.current?.cleanup();for(let J of j.current)J.cancel();for(let J of B.current)J.cancel();he.current=null},[]);let ue=f?u?.id===f?u:[...t,...r].find(J=>J.id===f):null,me=U?.entry??ue,We=me?.id??null,ve=!!f&&M===f,Ee=U?.phase==="collapse",Ye=t.filter(J=>J.id!==We||Ee),I=r.filter(J=>J.id!==We||Ee);Pe(()=>{let J=x.current;if(!J||U?.phase!=="collapse"||(x.current=null,window.matchMedia?.("(prefers-reduced-motion: reduce)").matches))return;let pe=q.current,V=A.current,xe=V?V.getBoundingClientRect().width/(V.offsetWidth||1):1;hn(pe,J.positions,xe,Pt,j.current);for(let X of pe?.querySelectorAll("[data-taste-tile]")??[])if(!(X.dataset.tasteEntryId!==J.returningId||!X.animate)){j.current.push(X.animate([{opacity:0},{opacity:1}],{duration:Pt,easing:"ease-out"}));break}},[U?.phase]),Pe(()=>{let J=q.current;if(!J)return;let pe=E.current;if(!ve||H.current===f)return;H.current=f;let V=R.current,xe=K.current,X=P.current,Ke=X?.querySelector("[data-taste-collections]");if(!V||!xe||!X||!Ke||!V.animate||window.matchMedia?.("(prefers-reduced-motion: reduce)").matches){L(null);return}for(let rt of B.current)rt.cancel();B.current=[];let Je={duration:pn,easing:"ease-in-out"},Oe={delay:za,duration:Da,easing:"ease-out",fill:"backwards"},Me=V.offsetHeight,tt=xe.offsetHeight,qe=V.animate([{height:"0px"},{height:`${Me}px`}],Je);B.current.push(qe),B.current.push(V.animate([{opacity:0},{opacity:1}],Oe),xe.animate([{height:"0px"},{height:`${tt}px`}],Je),xe.animate([{opacity:0},{opacity:1}],Oe),X.animate([{gap:"0px"},{gap:"24px"}],Je),Ke.animate([{gap:"0px"},{gap:"16px"}],Je));let ze=A.current,De=ze?ze.getBoundingClientRect().width/(ze.offsetWidth||1):1;hn(J,pe,De,pn,B.current),qe.onfinish=()=>{H.current===f&&(H.current=null,L(null))}},[ve,f]),Pe(()=>{E.current=zr(q.current)});let te=J=>{a&&(!We&&!U&&(H.current=null,L(J.id)),a(J))},ge=J=>{if(!d||he.current)return;if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches){d(J);return}let pe={id:J.id,timers:[],cleanup:()=>{}};for(let Me of j.current)Me.cancel();j.current=[],he.current=pe,ae({entry:J,phase:"fade",activeHeight:R.current?.offsetHeight??0,headingHeight:K.current?.offsetHeight??0});let V=!1,xe=!1,X=!1,Ke=()=>{if(!(!V||!xe||he.current!==pe)){for(let Me of pe.timers)clearTimeout(Me);pe.cleanup(),he.current=null,ae(null)}},Je=P.current,Oe=Me=>{!X||Me.target!==Je||Me.propertyName!=="gap"||(V=!0,Ke())};Je?.addEventListener("transitionend",Oe),pe.cleanup=()=>Je?.removeEventListener("transitionend",Oe),pe.timers.push(setTimeout(()=>{he.current===pe&&(X=!0,x.current={returningId:J.id,positions:zr(q.current)},ae(Me=>Me?.entry.id===J.id?{...Me,phase:"collapse"}:Me))},Mr)),pe.timers.push(setTimeout(()=>{V=!0,Ke()},Ma));try{Promise.resolve(d(J)).then(()=>{xe=!0,Ke()},()=>{xe=!0,Ke()})}catch{xe=!0,Ke()}};return k("div",{ref:A,role:"region","aria-label":"Taste collection","aria-busy":l,"data-popmelt-taste":!0,"data-popmelt-font":"sans","data-popmelt-theme":e,style:{width:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",gap:16,padding:"16px 16px 0",border:`1px solid ${p.border}`,borderRadius:20,background:p.surface,backdropFilter:"blur(59.5px)",WebkitBackdropFilter:"blur(59.5px)",color:p.secondary,fontFamily:Wt,fontSize:12,lineHeight:1.3,letterSpacing:"-.12px",overflow:"hidden",...h,...l&&de?{height:de}:{}},children:[i("style",{children:`
10
+ [data-popmelt-taste] [data-taste-thumbnail] { background: ${p.control}; }
11
+ [data-popmelt-taste] [data-taste-preview-art] { transition: opacity 120ms ease; }
12
+ [data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-preview-art] { opacity: .2; }
13
+ [data-popmelt-taste] [data-taste-name] { color: ${p.secondary}; transition: color 120ms ease; }
14
+ [data-popmelt-taste] [data-taste-metadata] { color: ${p.muted}; transition: color 120ms ease; }
15
+ [data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-name] { color: ${p.primary}; }
16
+ [data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-metadata] { color: ${p.secondary}; }
17
+ [data-popmelt-taste] [data-taste-detail-chevron] { display: inline-flex; width: 0; flex: 0 0 auto; overflow: hidden; opacity: 0; color: ${p.primary}; transform: translateX(-6px); transition: width 160ms ease, opacity 120ms ease, transform 160ms ease; }
18
+ [data-popmelt-taste] [data-taste-details]:is(:hover, :focus-visible) [data-taste-detail-chevron] { width: 15px; opacity: 1; transform: translateX(0); }
19
+ [data-popmelt-taste] [data-taste-add] { background: ${p.actionSurface}; color: ${p.actionForeground}; opacity: 0; pointer-events: none; transition: opacity 120ms ease, background-color 120ms ease; }
20
+ [data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-add] { opacity: 1; }
21
+ [data-popmelt-taste] [data-taste-thumbnail]:hover [data-taste-add] { background: ${p.actionHover}; }
22
+ [data-popmelt-taste] button:focus-visible { outline: 2px solid ${p.primary}; outline-offset: 2px; }
23
+ [data-popmelt-taste] button[data-taste-close]:hover { background: ${p.hoverSurface} !important; color: ${p.primary} !important; }
24
+ [data-taste-refresh-icon] { opacity: 0; transform: translateX(-4px); transition: opacity 120ms ease, transform 160ms ease; }
25
+ [data-taste-refresh]:not(:disabled):is(:hover, :focus-visible) [data-taste-refresh-icon] { opacity: 1; transform: translateX(0); }
26
+ @media (hover: none) { [data-taste-refresh]:not(:disabled) [data-taste-refresh-icon] { opacity: 1; transform: none; } }
27
+ @media (prefers-reduced-motion: reduce) { [data-taste-refresh-icon] { transition: none; transform: none; } }
28
+ @media (hover: none) { [data-popmelt-taste] [data-taste-add] { opacity: 1; } }
29
+ @media (hover: none) { [data-popmelt-taste] [data-taste-detail-chevron] { width: 15px; opacity: 1; transform: none; } }
30
+ @media (prefers-reduced-motion: reduce) { [data-popmelt-taste] :is([data-taste-name], [data-taste-metadata], [data-taste-add], [data-taste-detail-chevron]) { transition: none; } }
31
+ `}),k("div",{"data-taste-collection-header":!0,style:{display:"flex",alignItems:"center",gap:4,flexShrink:0},children:[k("button",{type:"button","data-taste-refresh":!0,"aria-label":"Refresh taste collection",onClick:()=>{Q(A.current?.offsetHeight),o?.()},disabled:!o||s||l,style:{display:"inline-flex",alignItems:"center",gap:4,padding:0,border:0,borderRadius:4,background:"transparent",font:"inherit",cursor:o&&!s?"pointer":"default",color:p.primary,fontSize:14,fontWeight:600,letterSpacing:"-.14px"},children:[i(Ut,{size:16,"aria-hidden":"true",style:{transform:"scaleY(-1)"}}),"Taste",i(fa,{"data-taste-refresh-icon":!0,size:12,"aria-hidden":"true",style:{marginLeft:2}})]}),i("button",{type:"button","data-taste-close":!0,"aria-label":"Back to settings",onClick:n,style:{marginLeft:"auto",border:0,padding:0,width:20,height:20,display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:4,background:"transparent",color:p.muted,cursor:"pointer"},children:i(St,{size:16})})]}),k("div",{"data-taste-scroll":!0,onScroll:J=>N(J.currentTarget.scrollTop>0),style:{display:"flex",flexDirection:"column",gap:24,minHeight:0,overflowY:"auto",scrollbarGutter:"stable",marginLeft:-16,marginRight:-16,paddingLeft:16,paddingRight:16,paddingBottom:20,flex:"1 1 auto",maskImage:m?"linear-gradient(to bottom, transparent, #000 16px)":void 0,WebkitMaskImage:m?"linear-gradient(to bottom, transparent, #000 16px)":void 0,overscrollBehavior:"contain"},children:[k("div",{"data-taste-content":!0,ref:P,style:{display:"flex",flexDirection:"column",gap:me&&U?.phase!=="collapse"?24:0,transition:U?`gap ${Pt}ms ease-in-out`:void 0},children:[c,me&&k("section",{ref:R,"aria-label":"Active taste","data-taste-removal-phase":U?.phase,"aria-hidden":!!U,inert:!!U,style:{display:"flex",flexDirection:"column",gap:8,flexShrink:0,minHeight:0,height:U?U.phase==="collapse"?0:U.activeHeight:void 0,opacity:U?0:1,overflow:U||ve?"hidden":void 0,pointerEvents:U?"none":void 0,transition:U?`opacity ${Mr}ms ease-out, height ${Pt}ms ease-in-out`:void 0},children:[i("h3",{style:{margin:0,font:"inherit",fontWeight:500,lineHeight:"14px",color:p.secondary},children:"Active"}),i("ul",{style:{listStyle:"none",padding:0,margin:0},children:i(fn,{entry:me,active:!0,featured:!0,previewBackground:p.control,onRemove:ve?void 0:ge,onOpenDetails:g,onPrefetchDetails:y})})]}),k("div",{"data-taste-collections":!0,style:{display:"flex",flexDirection:"column",gap:me&&U?.phase!=="collapse"?16:0,transition:U?`gap ${Pt}ms ease-in-out`:void 0},children:[me&&i("h3",{ref:K,"data-taste-collections-heading":!0,style:{margin:0,font:"inherit",fontWeight:600,lineHeight:"12px",color:e==="light"?"#555555":"#aaaaaa",flexShrink:0,height:U?U.phase==="collapse"?0:U.headingHeight:void 0,opacity:U?.phase==="collapse"?0:1,overflow:U||ve?"hidden":void 0,transition:U?`height ${Pt}ms ease-in-out, opacity ${Mr}ms ease-out`:void 0},children:"Collections"}),i("div",{"data-taste-catalogs":!0,ref:q,style:{display:"flex",flexDirection:"column",gap:24},children:[{label:"Private",entries:I},{label:"Public",entries:Ye}].map(({label:J,entries:pe})=>k("section",{"aria-label":`${J} tastes`,style:{display:"flex",flexDirection:"column",gap:8},children:[k("h3",{style:{margin:0,font:"inherit",fontWeight:500,lineHeight:"14px"},children:[i("span",{children:J})," ",i("span",{"data-taste-count":!0,style:{color:p.muted},children:pe.length})]}),pe.length?i("ul",{style:{listStyle:"none",padding:0,margin:0,display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:8},children:pe.map(V=>i(fn,{entry:V,onAdd:U||!a?void 0:te,onRemove:d,active:!1,hasActiveTaste:!!We&&!Ee,onOpenDetails:g,onPrefetchDetails:y},V.id))}):i("span",{style:{color:p.muted},children:J==="Private"&&b?b:`No ${J.toLowerCase()} results found.`})]},J))})]})]}),v&&i("span",{role:"status",children:v}),C]})]})}function ja({entry:e,theme:t,active:r,onBack:n,onToggle:o,notice:s,style:l,facts:a,summaryNotice:d,drilldown:f,onOpenFact:u}){let g=Ge[t],[y,v]=T(!1),C=D(null),c=ia(f)?f.key:null;return le(()=>{C.current&&(C.current.scrollTop=0),v(!1)},[e.id,c]),k("div",{role:"region","aria-label":`${e.name} taste details`,"data-taste-detail":!0,"data-popmelt-font":"sans","data-popmelt-theme":t,style:{display:"flex",flexDirection:"column",gap:16,padding:"20px 16px 0",borderRadius:20,border:`1px solid ${g.border}`,background:g.surface,color:g.primary,fontFamily:Wt,fontVariantNumeric:"tabular-nums",fontSize:12,lineHeight:1.3,boxSizing:"border-box",overflow:"hidden",...l},children:[i("style",{children:`
32
+ [data-taste-detail] > div { flex-shrink: 0; }
33
+ [data-taste-detail] [data-taste-detail-body] { flex-shrink: 1; }
34
+ [data-taste-detail-body] > * { flex-shrink: 0; }
35
+ [data-taste-detail] button:focus-visible { outline: 2px solid ${g.primary}; outline-offset: 3px; }
36
+ [data-taste-detail] [data-detail-back]:hover { color: ${g.primary} !important; }
37
+ [data-taste-detail] [data-detail-cta]:enabled:hover { background: ${g.actionHover} !important; }
38
+ [data-taste-fact]:hover dt, [data-taste-fact]:focus-within dt { color: ${g.primary} !important; }
39
+ [data-taste-fact]:hover button, [data-taste-fact] button:focus-visible { background: ${g.control} !important; }
40
+ [data-taste-fact] button::after { content: ''; position: absolute; inset: 0; }
41
+ [data-taste-fact] button svg { opacity: 0; width: 0; transition: opacity 120ms, width 120ms; }
42
+ [data-taste-fact]:hover button svg, [data-taste-fact] button:focus-visible svg { opacity: 1; width: 14px; }
43
+ `}),k("div",{"data-taste-detail-header":!0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[k("button",{type:"button","data-detail-back":!0,"aria-label":"Back to taste collection",onClick:n,style:{display:"flex",alignItems:"center",gap:2,alignSelf:"flex-start",padding:0,border:0,background:"transparent",color:g.secondary,font:"inherit",fontVariantNumeric:"tabular-nums",fontWeight:600,cursor:"pointer"},children:[i(Cr,{size:16,color:g.primary}),i(Ut,{size:14,style:{transform:"scaleY(-1)"}}),e.name]}),i("button",{type:"button","data-detail-cta":!0,"aria-label":`${r?"Remove":"Add"} ${e.name}`,"aria-pressed":r,disabled:!o,onClick:o,style:{display:"flex",alignItems:"center",gap:3,padding:r?"4px 9px 4px 10px":"4px 10px 4px 6px",border:0,borderRadius:8,background:g.actionSurface,color:g.actionForeground,font:"inherit",fontVariantNumeric:"tabular-nums",fontWeight:600,opacity:o?1:.5,cursor:o?"pointer":"default"},children:r?k(Le,{children:["Remove",i(St,{size:12})]}):k(Le,{children:[i(Ft,{size:12}),"Add"]})})]}),i("div",{"data-taste-detail-body":!0,ref:C,onScroll:b=>v(b.currentTarget.scrollTop>0),style:{display:"flex",flexDirection:"column",gap:12,flex:"1 1 auto",minHeight:0,overflowY:"auto",marginLeft:-16,marginRight:-16,padding:"0 16px 16px",overscrollBehavior:"contain",maskImage:y?"linear-gradient(to bottom, transparent, #000 16px)":void 0,WebkitMaskImage:y?"linear-gradient(to bottom, transparent, #000 16px)":void 0},children:f??k(Le,{children:[i("div",{style:{display:"flex",flexDirection:"column",gap:8},children:i(un,{preview:e.preview,thumbnailUrl:e.thumbnailUrl,background:g.control},e.id)}),i("dl",{style:{display:"flex",flexDirection:"column",gap:0,padding:"0 4px",margin:"-4px 0"},children:[...e.metadata?[{key:"version",label:"Version",value:e.metadata.value}]:[],...(a??[]).filter(b=>b.key!=="version")].map(({key:b,label:h,value:p})=>k("div",{"data-taste-fact":!0,style:{position:"relative",display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,padding:"4px 0"},children:[i("dt",{style:{color:g.secondary},children:h}),i("dd",{"aria-label":`${h}: ${p}`,style:{margin:0,fontSize:14,fontWeight:500,fontVariantNumeric:"tabular-nums"},children:u?k("button",{type:"button","aria-label":`View ${h}`,onClick:()=>u(b),style:{display:"flex",alignItems:"center",gap:2,border:0,padding:"2px 4px 2px 8px",borderRadius:8,color:"inherit",background:"transparent",font:"inherit",cursor:"pointer"},children:[p,i(Kt,{size:14})]}):p})]},b))}),d&&i("div",{role:"status",style:{color:g.secondary,padding:"0 4px"},children:d}),s&&i("div",{role:"status",style:{color:g.secondary,padding:"0 4px"},children:s})]})})]})}function Ba(e,t){return t==="reconnect_required"?{message:"Reconnect to grant read-only taste inspection access.",reconnect:!0}:e===404?{message:"Taste inspection is not available on the running backend yet. The bridge and staging rollout need to be updated; reconnecting will not fix this.",reconnect:!1}:e===401||e===403?{message:"This browser does not have permission to inspect tastes through the local bridge. Check the project connection.",reconnect:!1}:{message:"Taste definitions are temporarily unavailable. Please try again after the backend is ready.",reconnect:!1}}var gn={position:"relative",margin:0,font:"inherit",fontWeight:"inherit",fontSize:12,display:"flex",alignItems:"center",padding:"4px 4px"};function mn({last:e,color:t,left:r=4}){return k("span",{"aria-hidden":"true","data-taste-nested-branch":!0,style:{position:"absolute",left:r,top:0,bottom:0,pointerEvents:"none",color:t},children:[!e&&i("span",{"data-taste-nested-trunk":!0,style:{position:"absolute",top:0,bottom:0,borderLeft:"1px solid currentColor"}}),i("span",{"data-taste-nested-elbow":!0,style:{position:"absolute",top:0,bottom:"calc(50% - 0.5px)",width:8,borderLeft:"1px solid currentColor",borderBottom:"1px solid currentColor",borderBottomLeftRadius:6,boxSizing:"border-box"}})]})}var vn=e=>{let t=e.replace(/([a-z])([A-Z])/g,"$1 $2");return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()};function Wa(e,t,r=!1,n=!1,o=!1){let s=new Map;for(let a of e){let d=a.path.slice(1).filter(c=>c!=="$value");n&&(d=d.slice(1).filter(c=>c!=="$children")),t&&d[0]==="copy"&&(d=d.slice(1)),t&&d[0]==="slots"&&(d=d.slice(1));let f=d.length-1;if(r&&(f=Math.min(1,f)),t){let c=d.findIndex(b=>["budget","rules","template"].includes(b));c>=0&&(f=c)}let u=d.slice(0,f),g=d.slice(f);t&&g[0]==="budget"&&g.shift();let y=g.map(c=>/^\d+$/.test(c)?String(Number(c)+1):vn(c)).join(" \xB7 "),v=JSON.stringify(u),C=s.get(v)??{heading:u.map(c=>t||r?vn(c):c).join(" \u2192 "),rows:[]};C.rows.push({...a,label:y}),s.set(v,C)}let l=[...s.values()];if(n){let a=["default","hover","active","disabled"],d=new Map,f=g=>{let y=g.split(" \u2192 "),v=y.pop()??"",C=y.join(" \u2192 ");d.has(C)||d.set(C,d.size);let c=a.indexOf(v);return[d.get(C),c<0?a.length:c]},u=new Map(l.map(g=>[g,f(g.heading)]));l.sort((g,y)=>{let[v=0,C=0]=u.get(g),[c=0,b=0]=u.get(y);return v-c||C-b})}return l.map(a=>a.rows.length>1||(n||o)&&a.heading?a:{heading:"",rows:a.rows.map(d=>({...d,label:[a.heading,d.label].filter(Boolean).join(" \xB7 ")}))})}var qa=["Palette","Semantic colors","Typography","Spacing & layout","Radii & borders","Shadows & effects","Motion","Other"],yn=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{},or=(e,t)=>e.localeCompare(t,"en",{numeric:!0,sensitivity:"base"}),Oa=new Map([["none",0],["xs",1],["sm",2],["base",3],["md",4],["lg",5],["xl",6]]),Ha=new Map([["xs",0],["sm",1],["base",2],["lg",3],["xl",4]]);function bn(e){return/^(text|space|spacing|radius|radii|shadow)(?:-|$)/i.exec(e)?.[1]?.toLowerCase()??null}function wn(e,t){let r=e.toLowerCase().slice(t.length).replace(/^-/,"");if(t==="space"||t==="spacing")return r==="px"?.25:/^\d+(?:\.\d+)?$/.test(r)?Number(r):null;if(r==="full"&&(t==="radius"||t==="radii"))return 100;if(!r)return t==="text"?null:3;let n=/^(\d+)xs$/.exec(r),o=/^(\d+)xl$/.exec(r)??/^(x{2,})l$/.exec(r);return t==="text"?n?1-Number(n[1]):r==="xxs"?-1:o?3+(/^x/.test(o[1])?o[1].length:Number(o[1])):Ha.get(r)??null:n?2-Number(n[1]):r==="xxs"?0:o?5+(/^x/.test(o[1])?o[1].length:Number(o[1])):Oa.get(r)??null}function Ua(e,t){let r=bn(e),n=bn(t);if(!r||r!==n)return or(e,t);let o=wn(e,r),s=wn(t,n);return o!==null&&s!==null?o-s||or(e,t):o!==null?-1:s!==null?1:or(e,t)}function Fa(e,t,r){let n=yn(t),o=String(n.$type??"").toLowerCase(),s=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),l=n.$value??t,a=yn(l),d=/^(?:background|foreground|primary|secondary|accent|muted|card|popover|sidebar|input|ring|border|destructive|success|warning|info|surface|text|chart)(?:-|$)/.test(s);return o==="color"||qt(l,r)?d?1:0:/^(typography|fontfamily|fontweight|fontstyle)$/.test(o)?2:/^(shadow|gradient|filter)$/.test(o)?5:/^(duration|cubicbezier|transition)$/.test(o)?6:/^(border|radius)$/.test(o)?4:/^(spacing|layout)$/.test(o)?3:o&&!["dimension","number","string","composite"].includes(o)?7:/^(font|text|heading|body|line-height|letter-spacing|typography)(?:-|$)/.test(s)||"fontFamily"in a||"fontSize"in a?2:/^(space|spacing|gap|padding|margin|layout|container|width|height|size|breakpoint)(?:-|$)/.test(s)||"maxWidth"in a?3:/^(radius|radii|border|stroke)(?:-|$)/.test(s)?4:/^(shadow|elevation|blur|opacity|gradient|filter)(?:-|$)/.test(s)?5:/^(transition|duration|easing|animation|motion)(?:-|$)/.test(s)?6:7}function Ka(e,t){let r=["fontFamily","fontSize","fontWeight","lineHeight","letterSpacing","color"],n=o=>{let s=r.indexOf(o.at(-1)??"");return s<0?r.length:s};return n(e)-n(t)||or(e.join("."),t.join("."))}function Va({taste:e,style:t,onClick:r,children:n}){let o=Jt(e?.states?.button,!0,320);return i("button",{type:"button",...o.handlers,onClick:r,style:{...vt(Et(t)),...Ze(e?.detail?.button,320),...o.style},children:n})}var Ya={textfield:"input","text-field":"input","radio-group":"radio","toggle-group":"toggle","alert-dialog":"dialog",drawer:"sheet","hover-card":"popover","context-menu":"dropdown-menu","navigation-menu":"menubar","data-table":"table","input-otp":"otp","scroll-area":"scroll","date-picker":"calendar",collapsible:"accordion"},Ja=["button","card","input","textarea","badge","avatar","label","separator","checkbox","radio","switch","toggle","slider","progress","skeleton","tabs","accordion","select","combobox","dropdown-menu","menubar","dialog","sheet","popover","tooltip","alert","toast","table","breadcrumb","pagination","calendar","command","form","otp","scroll","chart"];function xn(e){let t=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=Ya[t]??t;return Ja.includes(r)?r:void 0}var pt=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{};function lr(e,t){let r=(s,l=0)=>{if(l>12)return;if(s&&typeof s=="object")return r(pt(s).$value??pt(s).ref,l+1);if(typeof s!="string")return s;let a=s.trim();return Object.hasOwn(t,a)?r(t[a],l+1):a.replace(/var\(\s*(?:--|principles\.)([\w-]+)\s*\)|\{(?:principles\.)?([\w-]+)\}/g,(d,f,u)=>String(r(t[f??u],l+1)??""))},n=Object.fromEntries(Object.entries(pt(e)).slice(0,80).map(([s,l])=>[s,r(l)])),o=Ze(Rr({card:n})?.card,320);return["flex","inline-flex","grid","block","inline-block"].includes(String(n.display))&&(o.display=n.display),["row","column","row-reverse","column-reverse"].includes(String(n.flexDirection))&&(o.flexDirection=n.flexDirection),o}function _a({kind:e,style:t,handlers:r,definition:n,tokens:o,taste:s}){let l=xr(),[a,d]=T(0),[f,u]=T(!1),[g,y]=T(!0),[v,C]=T(60),[c,b]=T(""),h=pt(pt(n).$value),p=pt(h.$children??pt(n).$children),m=(L,R)=>{let K=pt(p[L]),de=pt(K.$value??K);return{...lr(de.default,o),...lr(R?de[R]:void 0,o)}},N=L=>L?lr(h.checked??h.selected??h.active,o):{},A={boxSizing:"border-box",maxWidth:"86%",font:"inherit",...Ze(s?.detail?.body,320),...t},P={padding:"5cqw",...A,width:"82%"},q={font:"inherit",color:"inherit",background:"transparent",borderWidth:0,borderStyle:"none",borderRadius:0,boxShadow:"none",padding:"1.5cqw 3cqw",cursor:"pointer"},x={display:"flex",flexDirection:"column",gap:"3cqw"},j={size:"1em","aria-hidden":!0},E=(L,R,K={})=>i(Va,{taste:s,onClick:R,style:{...q,...K},children:L},L),B=i("strong",{style:{...Ze(s?.detail?.heading,320),...m("title")},children:"A little space"}),H=i("span",{style:{fontSize:"0.85em",...Ze(s?.detail?.body,320),...m("description")},children:"Make something your own."}),M={...r,"data-specimen-kind":e};switch(e){case"button":return i("button",{...M,type:"button",style:{...A,cursor:"pointer"},children:"Button"});case"input":return i("input",{...M,"aria-label":"Preview input",defaultValue:"A fresh start",style:{...A,width:"76%",outline:"none"}});case"textarea":return i("textarea",{...M,"aria-label":"Preview textarea",defaultValue:"A little space for your ideas.",rows:3,style:{...A,width:"76%",resize:"none",outline:"none"}});case"card":return k("div",{...M,style:{...P,...x},children:[B,H,E("Get started",()=>y(!g),m("button"))]});case"badge":return i("span",{...M,style:A,children:"New"});case"avatar":return i("div",{...M,"aria-label":"Preview avatar",style:{...A,width:"18cqw",height:"18cqw",display:"grid",placeItems:"center"},children:i(wa,{...j})});case"label":return i("label",{...M,style:A,children:"Project name"});case"separator":return i("div",{...M,role:"separator",style:{...A,width:"76%",padding:0,...m("separator")}});case"checkbox":return k("label",{...M,style:{...A,display:"flex",gap:"3cqw",alignItems:"center"},children:[i("input",{type:"checkbox",checked:g,onChange:L=>y(L.target.checked),style:{width:"5cqw",height:"5cqw",...m("indicator",g?"checked":void 0)}}),"Stay inspired"]});case"radio":return i("div",{...M,role:"radiogroup","aria-label":"Preview options",style:{...A,...x},children:["Personal","Team"].map((L,R)=>k("label",{style:{display:"flex",gap:"3cqw",...m("item",a===R?"checked":void 0)},children:[i("input",{name:l,type:"radio",checked:a===R,onChange:()=>d(R)}),L]},L))});case"switch":return i("button",{...M,type:"button",role:"switch","aria-label":"Preview switch","aria-checked":g,onClick:()=>y(!g),style:{...A,width:"18cqw",padding:"1.5cqw",cursor:"pointer",...N(g)},children:i("span",{style:{display:"block",width:"6cqw",height:"6cqw",marginLeft:g?"auto":0,...m("thumb",g?"checked":void 0)}})});case"toggle":return k("button",{...M,type:"button","aria-pressed":g,onClick:()=>y(!g),style:{...A,cursor:"pointer",...N(g)},children:["Bold ",g&&i(ba,{...j})]});case"slider":return i("input",{...M,type:"range","aria-label":"Preview slider",value:v,onChange:L=>C(Number(L.target.value)),style:{...A,width:"76%"}});case"progress":return i("div",{...M,role:"progressbar","aria-label":"Preview progress","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":60,style:{...A,width:"76%",height:"4cqw",padding:0,overflow:"hidden"},children:i("div",{style:{width:"60%",height:"100%",...m("indicator")}})});case"skeleton":return i("div",{...M,"aria-label":"Preview loading placeholder",style:{...A,width:"76%",height:"22cqw"}});case"tabs":return k("div",{...M,style:P,children:[i("div",{role:"tablist","aria-label":"Preview tabs",style:{display:"flex",gap:"2cqw",...m("list")},children:["Overview","Activity"].map((L,R)=>i("button",{type:"button",role:"tab","aria-selected":a===R,onClick:()=>d(R),onKeyDown:K=>{(K.key==="ArrowLeft"||K.key==="ArrowRight")&&(K.preventDefault(),d(1-a))},style:{...q,...m("trigger",a===R?"active":void 0)},children:L},L))}),i("div",{role:"tabpanel",style:{paddingTop:"4cqw",...m("content")},children:a===0?"Your next big idea starts here.":"All caught up."})]});case"accordion":return i("div",{...M,style:P,children:["What is included?","Can I make it mine?"].map((L,R)=>k("div",{style:m("item"),children:[k("button",{type:"button","aria-expanded":f&&a===R,onClick:()=>{d(R),u(!(f&&a===R))},style:{...q,width:"100%",display:"flex",justifyContent:"space-between",...Ze(s?.detail?.heading,320),...m("trigger")},children:[L,i(ya,{...j})]}),f&&a===R&&i("div",{style:{padding:"3cqw",...Ze(s?.detail?.body,320),...m("content")},children:"Everything you need to get started."})]},L))});case"select":return i("select",{...M,"aria-label":"Preview select",value:a,onChange:L=>d(Number(L.target.value)),style:A,children:["Choose a project","Personal","Team"].map((L,R)=>i("option",{value:R,children:L},L))});case"combobox":case"command":return k("div",{...M,style:{...P,...x},children:[k("label",{style:{display:"flex",alignItems:"center",gap:"2cqw"},children:[i(kr,{...j}),i("input",{"aria-label":"Search preview options",value:c,onChange:L=>b(L.target.value),placeholder:"Search projects\u2026",style:{...q,minWidth:0,width:"100%",...m("input")}})]}),["Personal","Team","Archive"].filter(L=>L.toLowerCase().includes(c.toLowerCase())).map(L=>E(L,()=>b(L),m("item"))),!["Personal","Team","Archive"].some(L=>L.toLowerCase().includes(c.toLowerCase()))&&i("span",{children:"No results"})]});case"dropdown-menu":case"menubar":return k("div",{...M,style:{...P,...x},children:[E("Options \u25BE",()=>u(!f),m("trigger")),f&&i("div",{style:{...x,...m("content")},children:["New project","Duplicate","Archive"].map((L,R)=>E(`${a===R?"\u2713 ":""}${L}`,()=>{d(R),u(!1)},m("item")))})]});case"dialog":case"sheet":return i("div",{...M,style:{...P,...x,...e==="sheet"?{marginLeft:"auto",maxWidth:"65%",minHeight:"42cqw"}:{},...m("content")},children:f?k(Le,{children:[B,H,E("Done",()=>u(!1),m("button"))]}):k(Le,{children:[B,H,E("Open preview",()=>u(!0),m("trigger"))]})});case"popover":case"tooltip":return k("div",{...M,style:{...A,...x},children:[i("button",{type:"button",onClick:()=>u(!f),onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),onFocus:()=>u(!0),onBlur:()=>u(!1),style:{...q,...m("trigger")},children:"Learn more"}),f&&i("span",{role:"tooltip",style:m("content"),children:"A little room for your ideas."})]});case"alert":case"toast":return k("div",{...M,role:"status",style:{...P,display:"flex",gap:"3cqw",alignItems:"center"},children:[i(va,{...j}),k("div",{style:x,children:[i("strong",{style:m("title"),children:g?"Changes saved":"Ready when you are"}),i("span",{style:m("description"),children:"Your project is up to date."})]}),e==="toast"&&i("button",{type:"button","aria-label":"Dismiss preview toast",onClick:()=>y(!g),style:q,children:i(St,{...j})})]});case"table":return i("div",{...M,style:{...P,padding:0,overflow:"hidden",textAlign:"left"},children:k("table",{style:{width:"100%",borderCollapse:"separate",borderSpacing:0,font:"inherit",color:"inherit"},children:[i("thead",{style:m("header"),children:i("tr",{children:["Project","Status"].map(L=>i("th",{style:{padding:"2cqw",...m("head")},children:L},L))})}),i("tbody",{children:["Personal","Team"].map(L=>k("tr",{style:m("row"),children:[i("td",{style:{padding:"2cqw",...m("cell")},children:L}),i("td",{style:{padding:"2cqw",...m("cell")},children:"Active"})]},L))})]})});case"breadcrumb":return k("nav",{...M,"aria-label":"Preview breadcrumb",style:{...A,display:"flex",gap:"2cqw",alignItems:"center"},children:[E("Home",()=>d(0),m("link")),i(Kt,{...j}),i("span",{"aria-current":"page",style:m("page"),children:a?"Settings":"Projects"})]});case"pagination":return i("nav",{...M,"aria-label":"Preview pagination",style:{...A,display:"flex",gap:"2cqw"},children:[0,1,2].map(L=>i("button",{type:"button","aria-current":a===L?"page":void 0,onClick:()=>d(L),style:{...q,...m("item",a===L?"active":void 0)},children:L+1},L))});case"calendar":return k("div",{...M,style:{...P,padding:"2cqw",fontSize:"3.5cqw"},children:[i("div",{style:{textAlign:"center",...m("caption")},children:"September 2026"}),k("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:"0.5cqw"},children:[["M","T","W","T","F","S","S"].map((L,R)=>i("span",{style:{textAlign:"center",...m("head")},children:L},R)),i("span",{"aria-hidden":"true"}),Array.from({length:30},(L,R)=>i("button",{type:"button","aria-label":`September ${R+1}`,"aria-pressed":a===R,onClick:()=>d(R),style:{...q,border:0,padding:0,...m("day",a===R?"selected":void 0)},children:R+1},R))]})]});case"form":return k("form",{...M,onSubmit:L=>{L.preventDefault(),u(!0)},style:{...P,...x},children:[i("label",{htmlFor:l,style:m("label"),children:"Project name"}),i("input",{id:l,required:!0,placeholder:"A fresh start",style:{...q,...m("input")}}),i("button",{type:"submit",style:{...q,...m("button")},children:"Create project"}),f&&i("span",{role:"status",children:"Project created (preview)"})]});case"otp":return i("div",{...M,style:{...A,display:"flex",gap:"1cqw"},children:[0,1,2,3].map(L=>i("input",{"aria-label":`Preview digit ${L+1}`,inputMode:"numeric",maxLength:1,pattern:"[0-9]",style:{...q,width:"8cqw",padding:"2cqw 0",textAlign:"center",...m("slot")}},L))});case"scroll":return i("div",{...M,tabIndex:0,"aria-label":"Preview scroll area",style:{...P,maxHeight:"35cqw",overflow:"auto",overscrollBehavior:"contain"},children:Array.from({length:12},(L,R)=>k("div",{style:{padding:"2cqw",...m("item")},children:["Project ",R+1]},R))});case"chart":return k("figure",{...M,"aria-label":"Preview project activity chart",style:{...P,margin:0},children:[i("figcaption",{style:m("title"),children:"Activity"}),i("div",{style:{display:"flex",alignItems:"end",gap:"3cqw",height:"25cqw"},children:[35,60,45,85,70].map((L,R)=>i("div",{title:`${L} projects`,style:{flex:1,height:`${L}%`,...m("bar")}},R))})]});default:return null}}var ht=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{};function kn(e,t,r){return!!r&&!!xn(e)&&!!Object.keys(ht(ht(ht(t).$value).default)).length}function Cn(e,t,r=[]){if(t.length>12||r.length>=500)return r;if(t.includes("$value")&&["string","number","boolean"].includes(typeof e))r.push({path:t,value:e});else if(e&&typeof e=="object")for(let[n,o]of Object.entries(e))["__proto__","constructor","prototype","$type"].includes(n)||Cn(o,[...t,n],r);return r}function Ga({bridgeUrl:e,id:t,collection:r,section:n,theme:o,onPreview:s,onReconnect:l,cache:a,query:d=""}){let f=Ge[o],[u,g]=T(),[y,v]=T(""),[C,c]=T(!1),[b,h]=T(!1),[p,m]=T(null),N=D(null),A=`${e??""}/cloud-taste/definition?id=${encodeURIComponent(t)}&collection=${encodeURIComponent(r)}`;le(()=>{let R=new AbortController;return N.current=R,g(void 0),v(""),c(!1),m(null),(a?a.read(A):Ne(A,{signal:R.signal})).then(async K=>{if(!K.ok){let Q=await K.json().catch(()=>null),U=Ba(K.status,Q?.error);R.signal.aborted||(v(U.message),c(U.reconnect));return}let de=await K.json();if(!de.sections||!Array.isArray(de.overrides))throw new Error("Invalid taste definition");if(!R.signal.aborted){g(de);let Q=wt(de.preview);Q&&s(Q)}}).catch(K=>{R.signal.aborted||v(K instanceof TypeError?"Could not reach the local bridge. Check that the project is running, then try again.":"The backend returned an invalid taste definition. Please try again after the backend is updated.")}),()=>R.abort()},[A,s,a]);async function P(R,K,de=!1){if(!u||b)return;let Q=N.current;if(!(!Q||Q.signal.aborted)){h(!0),v("");try{let U=await Ne(A,{signal:Q.signal,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:R,value:K,reset:de,sourceHash:u.hash,expectedRevision:u.revision})});if(!U.ok)throw new Error("Save failed. Your remote taste is unchanged. Reopen this section to reload before trying again.");let ae=await U.json();if(Q.signal.aborted)return;a?.put(A,ae),g(ae);let he=wt(ae.preview);he&&s(he)}catch(U){a?.invalidate(A),Q.signal.aborted||v(U.message)}finally{Q.signal.aborted||h(!1)}}}let q=n==="tokens"||n==="principles"?"principles":n==="visual-directions"?"assets":n==="copy-guidance"?"content":n,x=d.trim().toLocaleLowerCase(),j=R=>!x||String(R).toLocaleLowerCase().includes(x),E=Object.entries(ht(u?.sections[q])),B=q==="principles",H=new Map(E.map(([R,K])=>[R,B?Fa(R,K,ht(u?.sections.principles)):7]));if(B&&E.sort(([R],[K])=>H.get(R)-H.get(K)||Ua(R,K)),q==="components"){let R=(K,de)=>kn(K,de,wt(u?.componentPreviews?.[K]));E.sort(([K,de],[Q,U])=>Number(R(Q,U))-Number(R(K,de))||K.localeCompare(Q,void 0,{sensitivity:"base",numeric:!0}))}let M=E.filter(([R,K])=>j(R)||j(JSON.stringify(K))),L=u?.versions?.filter(R=>j(`${R.version} ${R.saved_at??"Not recorded"} ${R.saved_at?new Date(R.saved_at).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):""}`));return n==="version"?i("div",{"data-taste-versions":!0,children:y?k("div",{role:"alert",children:[y,C&&i("div",{style:{marginTop:8},children:i("button",{type:"button",onClick:l,children:"Reconnect"})})]}):u?r==="public"?i("div",{children:"Public version history is not available yet."}):u.versions?k("dl",{style:{margin:0},children:[L?.map(R=>k("div",{style:{display:"flex",justifyContent:"space-between",gap:16,padding:"8px 4px"},children:[i("dt",{children:R.version}),i("dd",{style:{margin:0,color:f.secondary},children:R.saved_at?i("time",{dateTime:R.saved_at,title:new Date(R.saved_at).toLocaleString(),children:new Date(R.saved_at).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}):"Not recorded"})]},R.version)),!u.versions.length&&i("div",{children:"No version history recorded."}),!!u.versions.length&&!L?.length&&i("div",{role:"status",children:"No matching versions."})]}):i("div",{role:"status",children:"Version history is currently unavailable."}):i("div",{role:"status",children:"Loading versions\u2026"})}):k("div",{"data-taste-drilldown":!0,style:{display:"flex",flexDirection:"column",gap:0,fontVariantNumeric:"tabular-nums"},children:[i("style",{children:`
44
+ [data-preview-zoom] + [data-taste-component-header] { margin-top: -4px; }
45
+ [data-taste-component-header]:hover:not(:disabled), [data-taste-component-header]:focus-visible { color: ${f.primary} !important; }
46
+ [data-taste-component-header]:hover:not(:disabled) svg { background: ${f.control}; }
47
+ [data-taste-value-row]:hover, [data-taste-value-row]:focus-within { color: ${f.primary} !important; }
48
+ [data-taste-token-group]:has(> [data-taste-token-child] [data-taste-value-row]:hover) > [data-taste-token-parent],
49
+ [data-taste-token-parent]:hover,
50
+ [data-taste-token-parent]:hover ~ [data-taste-token-child] [data-taste-value-row] > label { color: ${f.primary} !important; }
51
+ [data-taste-value-row]:hover input, [data-taste-value-row] input:focus { background: ${f.control} !important; }
52
+ [data-taste-value-row]:hover input, [data-taste-value-row]:focus-within input { color: ${f.primary} !important; }
53
+ [data-taste-value-row] input:focus-visible { outline: 1px solid ${f.secondary}; }
54
+ [data-taste-value-row] input { cursor: inherit; }
55
+ [data-taste-value-row] input:not([type="checkbox"]):focus { cursor: text; text-overflow: clip !important; }
56
+ `}),!u&&!y&&i("div",{role:"status",children:"Loading definitions\u2026"}),y&&k("div",{role:"alert",style:{color:f.secondary},children:[y,!u&&C&&i("button",{type:"button",onClick:l,style:{display:"block",marginTop:8},children:"Reconnect"})]}),!!u?.conflicts.length&&i("div",{role:"status",children:"Some source values changed remotely. Conflicting overrides are not applied; reset or edit them to resolve."}),u&&!M.length&&i("div",{role:"status",children:x&&E.length?"No matching definitions.":"No definitions in this section."}),M.map(([R,K],de)=>{let Q=Cn(K,[q,R]).filter(ae=>j(R)||j(ae.path.join(" "))||j(JSON.stringify(ae.value))),U=q==="components";return B&&Q.sort((ae,he)=>Ka(ae.path,he.path)),k("div",{"data-taste-group-path":JSON.stringify([q,R]),style:{display:"flex",flexDirection:"column",gap:U?8:0,marginBottom:U?8:0},children:[B&&(de===0||H.get(M[de-1][0])!==H.get(R))&&i("h2",{"data-taste-token-section":!0,style:{font:"inherit",fontWeight:500,color:f.primary,margin:de===0?"0 4px 8px":"16px 4px 8px"},children:qa[H.get(R)]}),U&&i(Za,{name:R,definition:K,taste:wt(u?.preview),tokens:ht(u?.sections.principles),recipe:wt(u?.componentPreviews?.[R])}),U&&k("button",{type:"button","data-taste-component-header":!0,disabled:!Q.length,onClick:()=>m(p===R?null:R),"aria-expanded":Q.length?p===R||!!x:void 0,style:{display:"flex",justifyContent:"space-between",alignItems:"center",border:0,padding:"6px 4px",font:"inherit",background:"transparent",borderRadius:8,color:f.secondary,cursor:Q.length?"pointer":"default"},children:[i("span",{children:R}),!!Q.length&&i(Kt,{size:14,style:{boxSizing:"content-box",padding:"2px 4px",borderRadius:8,transform:p===R||x?"rotate(90deg)":void 0,transition:"transform 120ms"}})]}),(!U||p===R||!!x)&&Wa(Q,n==="copy-guidance",n==="visual-directions",U,B).map((ae,he,ue)=>k("div",{"data-taste-state-group":U?"":void 0,"data-taste-token-group":B&&ae.heading?"":void 0,style:{position:"relative",display:"flex",flexDirection:"column",gap:0,paddingLeft:U?12:0},children:[U&&ae.heading&&he<ue.length-1&&i("span",{"aria-hidden":"true","data-taste-state-trunk":!0,style:{position:"absolute",left:4,top:-8,bottom:0,borderLeft:"1px solid currentColor",pointerEvents:"none",color:`color-mix(in srgb, ${f.secondary} 40%, ${f.surface})`}}),ae.heading&&k("h3",{"data-taste-token-parent":B?"":void 0,style:{position:"relative",margin:B?0:U?"2px 4px 0":"12px 4px 0",font:"inherit",fontWeight:B?"inherit":500,fontSize:B?12:void 0,color:B?f.secondary:f.primary,display:B?"flex":void 0,alignItems:B?"center":void 0,padding:B?"4px 4px":void 0,...B?gn:{}},children:[U&&i("span",{"aria-hidden":"true","data-taste-state-connector":!0,style:{position:"absolute",left:-12,top:-10,bottom:"calc(50% - 0.5px)",width:8,borderLeft:"1px solid currentColor",borderBottom:"1px solid currentColor",borderBottomLeftRadius:6,boxSizing:"border-box",pointerEvents:"none",color:`color-mix(in srgb, ${f.secondary} 40%, ${f.surface})`}}),ae.heading,B&&i("span",{"aria-hidden":"true",style:{visibility:"hidden",fontSize:14,padding:"2px 0"},children:"\xA0"})]}),ae.rows.map((me,We)=>{let ve=JSON.stringify(me.path),Ee=u.overrides.some(I=>JSON.stringify(I.path)===ve),Ye=i(Qa,{path:me.path,label:me.label,value:me.value,disabled:b,overridden:Ee,colors:f,componentValue:U,colorTokens:q==="principles"||q==="components"?ht(u?.sections.principles):void 0,onSave:I=>{P(me.path,I)},onReset:()=>{P(me.path,me.value,!0)}},ve);return B&&ae.heading?k("div",{"data-taste-token-child":!0,style:{position:"relative",paddingLeft:12},children:[i(mn,{last:We===ae.rows.length-1,color:`color-mix(in srgb, ${f.secondary} 40%, ${f.surface})`}),Ye]},ve):Ye})]},he)),!U&&!Q.length&&k("div",{style:{color:f.secondary,padding:"0 4px",overflowWrap:"anywhere"},children:[R,": ",JSON.stringify(K)]})]},R)})]})}function Za({name:e,definition:t,recipe:r,tokens:n,taste:o}){let s=xn(e),l=/button/i.test(e)?"button":/input|text.?field|textarea/i.test(e)?"input":"card",a=Jt(r?.states?.[l],!0,320);if(!r||!s||!kn(e,t,r))return null;let d={backgroundColor:"transparent",backgroundImage:"none",borderWidth:0,borderStyle:"none",borderRadius:0,boxShadow:"none",padding:l==="button"?"3cqw 5cqw":16,fontSize:"4.6cqw",lineHeight:l==="button"?1.2:void 0,color:r.foreground,...Ze(o?.detail?.body,320),...lr(ht(ht(t).$value).default,n),...a.style};return i(cn,{children:i("div",{"aria-label":`${e} style preview`,style:{aspectRatio:"16 / 9",borderRadius:8,background:r.background,display:"grid",placeItems:"center",overflow:"hidden",containerType:"inline-size"},children:i(_a,{kind:s,style:d,handlers:a.handlers,definition:t,tokens:n,accent:r.accent,taste:o})})})}function Qa({path:e,label:t,value:r,disabled:n,overridden:o,colors:s,onSave:l,onReset:a,colorTokens:d,componentValue:f=!1}){let u=f&&typeof r=="string"?/^var\(principles\.([^,)]+)\)$/.exec(r.trim())?.[1]:void 0,g=u&&d&&Object.hasOwn(d,u)?u:String(r),[y,v]=T(g),C=D(null),c=D(!1),b=d&&typeof r=="string"?qt(y,d):void 0;le(()=>v(g),[g]);function h(){let p=typeof r=="number"?Number(y):f&&d&&Object.hasOwn(d,y.trim())?`var(principles.${y.trim()})`:y;if(typeof p=="number"&&(!y.trim()||!Number.isFinite(p))||p===r||y===g){v(g);return}l(p)}return k("div",{"data-taste-value-row":!0,"data-taste-path":JSON.stringify(e),onClick:p=>{n||p.target instanceof Element&&p.target.closest("input, button")||(C.current?.focus({preventScroll:!0}),typeof r=="boolean"&&C.current?.click())},style:{display:"flex",alignItems:"center",gap:8,color:s.secondary,padding:"4px 4px",cursor:n?"default":"pointer"},children:[i("label",{style:{flex:1,minWidth:0,overflowWrap:"anywhere",fontSize:12},children:t}),typeof r=="boolean"?i("input",{ref:C,"aria-label":t,type:"checkbox",checked:r,disabled:n,onChange:p=>l(p.target.checked)}):k("span",{"data-taste-value-field":!0,style:{position:"relative",display:"inline-grid",maxWidth:"52%",marginRight:b?0:-8,minWidth:0},children:[i("span",{"aria-hidden":"true",style:{visibility:"hidden",whiteSpace:"pre",overflow:"hidden",font:"inherit",fontVariantNumeric:"tabular-nums",fontSize:14,padding:"2px 8px"},children:y||" "}),i("input",{ref:C,"data-taste-value-input":!0,"aria-label":t,value:y,title:y,disabled:n,onChange:p=>v(p.target.value),onBlur:()=>{if(c.current){c.current=!1;return}h()},onKeyDown:p=>{p.key==="Enter"&&p.currentTarget.blur(),p.key==="Escape"&&(c.current=!0,v(g),p.preventDefault(),p.stopPropagation(),p.currentTarget.blur())},style:{position:"absolute",inset:0,boxSizing:"border-box",width:"100%",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",border:0,background:"transparent",borderRadius:8,padding:"2px 8px",textAlign:"right",color:`color-mix(in srgb, ${s.primary} 50%, ${s.secondary})`,font:"inherit",fontVariantNumeric:"tabular-nums",fontSize:14}})]}),b&&i("span",{"data-taste-color-swatch":!0,title:b,"aria-label":`Color preview: ${b}`,style:{width:14,height:14,flex:"0 0 14px",borderRadius:3,overflow:"hidden",background:"repeating-conic-gradient(#aaa 0% 25%, #fff 0% 50%) 0 / 6px 6px",boxShadow:`0 0 0 1px ${s.border}`},children:i("span",{style:{display:"block",width:"100%",height:"100%",backgroundColor:b}})}),o&&i("button",{type:"button",disabled:n,onClick:a,"aria-label":`Reset ${t}`,style:{border:0,background:"transparent",color:s.secondary,padding:0},children:i(ga,{size:12})})]})}var Xa=["display","paddingTop","paddingRight","paddingBottom","paddingLeft","rowGap","columnGap","borderTopLeftRadius","fontFamily","fontSize","lineHeight","fontWeight","letterSpacing","color","backgroundColor","borderTopColor","borderTopWidth","boxShadow"];function ei(e=document){let t=e.defaultView;if(!t||!e.body)throw Error("The current page is not ready.");let r=new URL(e.URL);r.search="",r.hash="",r.username="",r.password="";let n=new Map,o=new Map,s=[],l=new Map,a=new Map,d=e.createTreeWalker(e.body,1),f=0;for(;d.nextNode()&&f++<4e3;){let u=d.currentNode;if(u.closest('script, style, template, noscript, [hidden], [aria-hidden="true"], [contenteditable], [data-popmelt], [data-popmelt-toolbar], [data-taste-editor], [data-taste-navigation]'))continue;let g=u.getBoundingClientRect();if(!g.width||!g.height)continue;let y=t.getComputedStyle(u);if(y.display==="none"||y.visibility!=="visible"||y.opacity==="0")continue;let v={};for(let m of Xa)v[m]=y[m].slice(0,160);let C=u.tagName.toLowerCase(),c=JSON.stringify([C,v]),b=n.get(c),h=(/^(input|textarea|select|option)$/.test(C)?"":[...u.childNodes].filter(m=>m.nodeType===3).map(m=>m.textContent??"").join(" ").replace(/\s+/g," ").trim())||/^(main|nav|aside|header|footer|section|article|form|button|input)$/.test(C)||/^(flex|grid)$/.test(y.display);if(s.length<40&&h&&g.bottom>0&&g.right>0&&g.top<t.innerHeight&&g.left<t.innerWidth&&(b||n.size<160)){let m=u.parentElement;for(;m&&!l.has(m);)m=m.parentElement;let N=m?l.get(m):null,A=`${N}:${C}`,P=a.get(A)??0;if(P<3){a.set(A,P+1);let q=s.length;s.push({id:q,parent:N,sample:o.get(c)??n.size,box:[g.left/t.innerWidth,g.top/t.innerHeight,g.width/t.innerWidth,g.height/t.innerHeight].map(x=>Math.round(x*100))}),l.set(u,q)}}if(b){b.count++;continue}if(n.size>=160)continue;let p=/^(input|textarea|select|option)$/.test(C)?"":[...u.childNodes].filter(m=>m.nodeType===3).map(m=>m.textContent??"").join(" ").replace(/\s+/g," ").trim().slice(0,160);o.set(c,n.size),n.set(c,{tag:C,text:p,count:1,styles:v})}return{url:r.href,title:e.title.slice(0,160),viewport:{width:t.innerWidth,height:t.innerHeight},samples:[...n.values()],...s.length?{outline:s}:{}}}var ti=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:px|rem|em|vw|vh|vmin|vmax|ch)?$/i;function Dr(e,t){let r=Ot(e,t),n=[],o=[],s=0,l=[],a,d=!1,f=()=>l.length<2||l.length>4?!1:(l.forEach((u,g)=>n.push({...u,layer:s,dimension:["x","y","blur","spread"][g]})),a&&o.push(a),l=[],a=void 0,d=!1,s++,!0);for(let u=0;u<e.length;){if(/\s/.test(e[u])){u++;continue}if(e[u]===","){if(!f())return null;u++;continue}let g=u,y=r.findIndex(p=>p.start===u),v=r[y];if(v)u=v.end;else{let p=0;do{if(e[u]==="(")p++;else if(e[u]===")"){if(!p)return null;p--}u++}while(u<e.length&&(p||!/[\s,]/.test(e[u])));if(p)return null}let C=e.slice(g,u),c={start:g,end:u,text:C,...v?{referenceIndex:y}:{}},b=v&&t.find(p=>p.name.toLowerCase()===v.name.toLowerCase()),h=/^calc\(/i.test(C)?en(C,t):null;if(C.toLowerCase()==="inset"){if(d)return null;d=!0}else if(b?.kind==="color"||!v&&qt(C,{})){if(a)return null;a=c}else if(b?.kind==="layout"||!v&&ti.test(C)||h?.kind==="length"){if(h&&(h.css.includes("%")||l.length===2&&h.value!==void 0&&h.value<0)||v?.opacity!==void 0||l.length>=4||l.length===2&&!v&&parseFloat(C)<0)return null;l.push(c)}else return null}return f()?{dimensions:n,colors:o,references:r}:null}function ri(e,t){let r=ta(e,t);if(r===null)return null;e=r;let n=Dr(e,t);if(!n)return null;let o=e,s=[];for(let l of n.dimensions)l.referenceIndex===void 0&&/^[+-]?(?:\d+\.?\d*|\.\d+)$/.test(l.text)&&Number(l.text)!==0&&s.push({...l,value:`${l.text}px`});for(let l of n.references){let a=br(t,e.slice(l.start,l.end));if(!a)return null;let d=n.dimensions.find(u=>u.start===l.start);if(d&&(a.kind!=="layout"||a.unit==="%"||d.dimension==="blur"&&a.value<0))return null;let f=a.kind==="layout"?`${Math.round(a.value)}${a.unit||"px"}`:mt(a);s.push({...l,value:f})}for(let l of s.sort((a,d)=>d.start-a.start))o=o.slice(0,l.start)+l.value+o.slice(l.end);return o}function Pr(e,t,r,n,o){let s=Dr(e,r);if(o!==void 0){let l=s?.dimensions[o];return!l||t.kind!=="layout"?null:l.referenceIndex!==void 0?Xr(e,t,r,l.referenceIndex):e.slice(0,l.start)+`@${t.name}`+e.slice(l.end)}if(s&&n!==void 0){let l=s.references[n];if(!l)return null;let a=s.dimensions.some(d=>d.referenceIndex===n||l.start>=d.start&&l.end<=d.end);if(t.kind==="layout"!==a)return null}return Xr(e,t,r,n)}function ni(e,t){try{if(Object.entries(t.root.styles).some(([r,n])=>Yt(e,n,r)===null))return!1;for(let r of["basis","padding","gap","body-family","body-size","body-height","body-weight"]){let n=Tt(e.constraints,r);if(n.kind==="layout"&&(n.value<0||["basis","body-size","body-height","body-weight"].includes(r)&&n.value===0))return!1}for(let r of["fontFamily","fontSize","lineHeight","fontWeight","color","backgroundColor"]){let n=t.root.styles[r],o=n&&Yt(e,n,r);if(!o||(r==="color"||r==="backgroundColor")&&!qt(o,{}))return!1}return!0}catch{return!1}}function sr(e,t,r=0){try{return Tt(e,t,r)}catch{return null}}function dr(e,t){let r=Ge[t],n=g=>sr(e.constraints,g),o=(g,y)=>{let v=n(g);return v?.kind!=="layout"?y:v.unit==="rem"||v.unit==="em"?v.value*16:v.unit===""||v.unit==="px"?v.value:y},s=(g,y)=>{let v=n(g);return v?.kind==="layout"?`${v.value}${v.unit||"px"}`:`${y}px`},l=(g,y)=>{let v=e.tokens.find(c=>g.includes(c.name)),C=v&&yr(v.value,e.constraints);return C&&qt(C,{})?C:y},a=n("primary"),d=a?.kind==="color"?mt(a):r.primary,f=g=>{let y=n(g);return y?.kind==="font"?y.value:"system-ui, sans-serif"},u=(g,y)=>{let v=n(g);return v?.kind==="layout"?v.value:y};return{background:l(["page-surface","background"],r.control),surface:l(["card-surface","surface"],r.surface),foreground:l(["body-text","text"],r.primary),muted:l(["muted-text"],r.secondary),accent:d,border:r.border,radius:o("radii",8),spacing:o("gap",12),detail:{body:{fontFamily:f("body-family"),fontSize:s("body-size",16),lineHeight:s("body-height",22),fontWeight:u("body-weight",400)},heading:{fontFamily:f("heading-family"),fontSize:s("heading-size",24),lineHeight:s("heading-height",26),fontWeight:u("heading-weight",600),color:l(["heading-text"],r.primary)},card:{padding:s("padding",0),borderRadius:s("radii",8),gap:s("gap",12)},button:{backgroundColor:d,color:a?.kind==="color"?a.l>.6?"#111":"#fff":r.surface,borderRadius:s("radii",8)}}}}function ai({recipe:e,styles:t}){let r=D(null),n=D(null),[o,s]=T({scale:.5,width:640,height:320});return Pe(()=>{let l=r.current,a=n.current;if(!l||!a)return;let d=()=>{let u=Math.max(640,a.scrollWidth),g=Math.max(1,a.scrollHeight),y=Math.min(1,l.clientWidth/u,l.clientHeight/g);y>0&&s(v=>v.scale===y&&v.width===u&&v.height===g?v:{scale:y,width:u,height:g})};d();let f=typeof ResizeObserver>"u"?null:new ResizeObserver(d);return f?.observe(l),f?.observe(a),()=>f?.disconnect()},[e,t]),i("div",{ref:r,className:"tc-preview-demo",style:{backgroundColor:t.page?.backgroundColor??e.background},inert:!0,children:i("div",{style:{position:"absolute",left:"50%",top:"50%",width:o.width*o.scale,height:o.height*o.scale,transform:"translate(-50%, -50%)"},children:i("div",{ref:n,"data-taste-preview-canvas":!0,style:{width:640,transform:`scale(${o.scale})`,transformOrigin:"top left"},children:i(Ar,{recipe:e,usageStyles:t})})})})}function Sn({draft:e,dimensionId:t,theme:r,preferPageComponent:n=!1,waitForPageFoundations:o=!1}){let s=Ht(()=>dr(e,r),[e,r]),l=Ht(()=>_r(e),[e]),a=e.fragments?.find(p=>p.id===e.featuredComponentId),d=e.constraints.find(p=>p.id===t),f=d&&sr(e.constraints,d.id),u=d&&f&&f.kind!=="font"?[-2,-1,0,1,2].map(p=>({step:p,value:sr(e.constraints,d.id,p)})):[],g=Math.max(1,...u.map(({value:p})=>p?.kind==="layout"?p.value:0)),y=e.constraints.filter(p=>sr(e.constraints,p.id)).length,v=d?.scaleMode==="increment",C=d?.name.endsWith("size"),c=d?.name.endsWith("height"),b=d?.id==="radii",h=d?`${d.name} preview`:"Taste demonstration preview";return k("div",{className:"tc-dimension-preview","data-taste-constraint-preview":!0,"data-preview-dimension":d?.id,role:"group","aria-label":h,children:[i("style",{children:`
57
+ [data-taste-editor] .tc-dimension-preview { position: sticky; top: 16px; z-index: 3; flex: 0 0 176px; height: 176px; min-width: 0; overflow: hidden; isolation: isolate; border-radius: 12px; background: var(--tc-control); box-shadow: 0 -16px 0 var(--tc-surface), 0 0 0 4px var(--tc-surface); }
58
+ [data-taste-editor] .tc-preview-demo { position: relative; height: 100%; pointer-events: none; }
59
+ [data-taste-editor] .tc-preview-steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; padding: 8px 10px 10px; height: 100%; }
60
+ [data-taste-editor] .tc-preview-step { display: flex; flex-direction: column; align-items: center; justify-content: space-between; min-width: 0; padding: 6px 2px; border-radius: 8px; font-size: 10px; }
61
+ [data-taste-editor] .tc-preview-step[data-base=true] { background: var(--tc-surface); color: var(--tc-primary); }
62
+ [data-taste-editor] .tc-preview-sample { width: 100%; height: 52px; display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--tc-primary); }
63
+ [data-taste-editor] .tc-preview-step-label { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
64
+ [data-taste-editor] .tc-preview-empty { height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; text-align: center; font-size: 12px; }
65
+ [data-taste-editor] .tc-preview-family { padding: 18px 16px 16px; overflow: hidden; }
66
+ `}),d?f?f.kind==="font"?k("div",{className:"tc-preview-family",style:{fontFamily:f.value},children:[i("div",{style:{fontSize:32,lineHeight:1.4,color:"var(--tc-primary)"},children:"Aa Bb Cc"}),i("div",{style:{fontSize:13,lineHeight:1.5},children:"The quick brown fox jumps."}),i("div",{className:"tc-preview-step-label",title:f.value,style:{marginTop:8,fontSize:10},children:f.value})]}):i("div",{className:"tc-preview-steps","aria-label":`${d.name} steps`,children:u.map(({step:p,value:m})=>{let N=m&&mt(m),A=m?.kind==="color"?`${Number((m.l*100).toFixed(1))}% L`:N,P={};return m?.kind==="color"?P={width:32,height:44,borderRadius:5,background:N,boxShadow:"inset 0 0 0 1px color-mix(in srgb, var(--tc-primary) 18%, transparent)"}:m?.kind==="layout"&&(b?P={width:34,height:34,border:"1px solid currentColor",borderRadius:Math.min(17,m.value*(m.unit==="rem"||m.unit==="em"?16:1))}:v?P={fontSize:24,fontWeight:Math.max(1,Math.min(1e3,m.value))}:C?P={fontSize:Math.max(6,m.value/g*30),lineHeight:1}:c?P={fontSize:10,lineHeight:`${Math.max(6,m.value/g*24)}px`,whiteSpace:"pre",background:"repeating-linear-gradient(transparent 0 48%, color-mix(in srgb, var(--tc-primary) 12%, transparent) 48% 52%, transparent 52% 100%)"}:P={height:Math.max(1,m.value/g*46),width:18,borderRadius:3,background:"var(--tc-secondary)"}),k("div",{className:"tc-preview-step","data-base":p===0,"aria-label":`Step ${p}: ${N??"unresolved"}`,title:N??void 0,children:[i("span",{children:p>0?`+${p}`:p===0?"Base":p}),i("span",{className:"tc-preview-sample","aria-hidden":"true",children:i("span",{style:P,children:v||C?"Aa":c?`Ab
67
+ Ab`:""})}),i("span",{className:"tc-preview-step-label",children:A??"\u2014"})]},p)})}):i("div",{className:"tc-preview-empty",children:d.value||d.parentId?"This dimension does not resolve yet.":"Waiting for this dimension\u2026"}):a&&(!o||ni(e,a))?i(ir,{fragment:a,draft:e,height:176}):y&&!n?i(ai,{recipe:s,styles:l}):i("div",{className:"tc-preview-empty",children:i("span",{className:"tc-proposal-status","data-state":"in-progress",children:"tracing stylenet"})})]})}function $n(e){let t=e.map(r=>{let n=r/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4});return t[0]*.2126+t[1]*.7152+t[2]*.0722}function ii(e,t){let r=$n(e),n=$n(t);if(!((Math.max(r,n)+.05)/(Math.min(r,n)+.05)>=1.6))return n<.179?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.18)"}var _t=new Map;function oi(e,t){if(!e||typeof CanvasRenderingContext2D>"u")return;let r=`${t}|${e}`;if(_t.has(r))return _t.get(r);let n=document.createElement("canvas");n.width=n.height=1;let o=n.getContext("2d",{willReadFrequently:!0});if(!o)return;let s=(a,d)=>{o.fillStyle=d,o.fillRect(0,0,1,1),o.fillStyle=a,o.fillRect(0,0,1,1);let f=o.getImageData(0,0,1,1).data;return[f[0],f[1],f[2]]},l=ii(s(e,"#d5d5d5"),s(t,"#fff"));return _t.size>=256&&_t.clear(),_t.set(r,l),l}function jr(e){let t=[],r=/url\([^)]*\)|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|#[\w-]+|@[\w-]+|[a-z_][\w-]*|[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:[a-z]+|%)?/gi;for(let n of e.matchAll(r))/^[+\-.\d]/.test(n[0])&&t.push({start:n.index,end:n.index+n[0].length,text:n[0]});return t}function li(e,t,r){let n=e.slice(0,t).match(/(rgba?|hsla?|oklch|oklab|lch|lab|color)\(([^()]*)$/i),o=r.match(/[a-z%]+$/i)?.[0]?.toLowerCase(),s=o==="rem"||o==="em"?.01:1,l,a;if(n){let d=jr(n[2]).length,f=n[1].toLowerCase();n[2].includes("/")||["rgba","hsla"].includes(f)&&d===3?(s=o==="%"?1:.01,l=0,a=o==="%"?100:1):f.startsWith("rgb")?(l=0,a=o==="%"?100:255):o==="%"?(l=0,a=100):f.startsWith("ok")&&d<2?(s=.01,l=d===0||f==="oklch"?0:void 0,a=d===0?1:void 0):f==="color"&&(s=.01,l=0,a=1)}else!o&&r.includes(".")&&(s=10**-Math.min(4,r.split(".")[1].length));return{step:s,shiftStep:s*5,min:l,max:a}}var Rn=/^([+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)([a-z]+|%)?$/i;function si(e,t,r){let n=e.ownerDocument,o=n.defaultView.getComputedStyle(e),s=n.createElement("span");Object.assign(s.style,{position:"fixed",visibility:"hidden",whiteSpace:"pre",font:o.font,letterSpacing:o.letterSpacing}),s.textContent=t,n.body.append(s);try{let l=e.getBoundingClientRect(),a=s.getBoundingClientRect().width,d=parseFloat(o.paddingLeft)||0,f=parseFloat(o.paddingRight)||0,u=l.width-d-f,g=o.textAlign==="right"||o.textAlign==="end"?Math.max(0,u-a):o.textAlign==="center"?Math.max(0,(u-a)/2):0,y=r-l.left-d-g+e.scrollLeft,v=s.getBoundingClientRect().left;return jr(t).find(C=>{let c=n.createRange();c.setStart(s.firstChild,C.start),c.setEnd(s.firstChild,C.end);let b=c.getBoundingClientRect();return y>=b.left-v&&y<=b.right-v})}finally{s.remove()}}function In({value:e,spec:t,preview:r,commit:n,cancel:o}){let s=D(null),l=D(0),a=D(!1),d=D(!1),[f,u]=T(null);le(()=>()=>s.current?.(),[]);let g=t?(e.trim()||(t.defaultValue===void 0?"":String(t.defaultValue))).match(Rn):null,y=!!g&&Number.isFinite(Number(g[1]))||!!t?.compound&&jr(e).length>0;return{enabled:y,dragging:a,consumedClick:d,start:v=>{if(d.current=!1,!y||!t||v.button!==0||v.pointerType==="touch")return;let C=t.compound?g?{start:e.indexOf(e.trim()),end:e.indexOf(e.trim())+e.trim().length,text:e.trim()}:si(v.currentTarget,e,v.clientX):null,c=C?C.text.match(Rn):g;if(!c)return;let b=C?li(e,C.start,C.text):t;v.preventDefault(),v.stopPropagation(),s.current?.();let h=++l.current,p=v.currentTarget,m=p.ownerDocument,N=m.defaultView,A=p.getRootNode(),P=()=>A.pointerLockElement===p||m.pointerLockElement===p,q=Number(c[1]),x=c[2]??"",j=/^(rem|em)$/i.test(x)&&b.step===1?.01:b.step,E=!1,B=!1,H=!1,M=v.clientX,L=M,R=0,K=0,de=e,Q=v.clientY,U=()=>{P()&&m.exitPointerLock()},ae=()=>{B=!0,a.current=!1,N.removeEventListener("pointermove",me,!0),N.removeEventListener("pointerup",We,!0),N.removeEventListener("pointercancel",ve,!0),N.removeEventListener("keydown",Ee,!0),N.removeEventListener("keyup",Ee,!0),N.removeEventListener("blur",ve),m.removeEventListener("pointerlockchange",Ye),p.hasPointerCapture?.(v.pointerId)&&p.releasePointerCapture(v.pointerId),U(),u(null),s.current=null},he=()=>{if(!p.requestPointerLock)return;let I=()=>{m.removeEventListener("pointerlockchange",te),m.removeEventListener("pointerlockerror",I),B&&h===l.current&&U()},te=()=>{P()&&I()};m.addEventListener("pointerlockchange",te),m.addEventListener("pointerlockerror",I);try{let ge=p.requestPointerLock();ge&&ge.then(I,I)}catch{I()}},ue=I=>{let te=q+Math.round(R/4)*j,ge=b.shiftStep??.05,J=Math.min(b.max??1/0,Math.max(b.min??-1/0,I?Math.round(te/ge)*ge:te));if(!Number.isFinite(J))return;let pe=`${Number(J.toFixed(4))}${x}`;de=C?e.slice(0,C.start)+pe+e.slice(C.end):pe,r(de)},me=I=>{let te=P(),ge=te?I.movementX:I.clientX-M;M=I.clientX,K+=ge,R+=ge,L=te?((L+ge)%N.innerWidth+N.innerWidth)%N.innerWidth:I.clientX,te&&u({x:L,y:Q,doc:m}),!(!E&&Math.abs(K)<4)&&(I.preventDefault(),I.stopImmediatePropagation(),E||(E=!0,a.current=!0),ue(I.shiftKey))},We=I=>{I.preventDefault(),I.stopImmediatePropagation(),ae(),d.current=E,E?n(de):(p.focus(),p instanceof N.HTMLInputElement&&p.select())},ve=()=>{ae(),o()},Ee=I=>{if(I.key==="Shift"){E&&ue(I.type==="keydown");return}I.type==="keydown"&&I.key==="Escape"&&(I.preventDefault(),I.stopImmediatePropagation(),ve())},Ye=()=>{if(B){U();return}P()?(H=!0,u({x:L,y:Q,doc:m})):H&&ve()};p.setPointerCapture?.(v.pointerId),N.addEventListener("pointermove",me,{capture:!0,passive:!1}),N.addEventListener("pointerup",We,!0),N.addEventListener("pointercancel",ve,!0),N.addEventListener("keydown",Ee,!0),N.addEventListener("keyup",Ee,!0),N.addEventListener("blur",ve),m.addEventListener("pointerlockchange",Ye),s.current=ae,he()},cursor:f&&nn(i("div",{"data-taste-scrub-cursor":!0,"aria-hidden":"true",style:{position:"fixed",left:f.x,top:f.y,transform:"translate(-50%, -50%)",pointerEvents:"none",zIndex:2147483647,color:"white",filter:"drop-shadow(0 1px 2px black)"},children:i(rn,{size:18})}),f.doc.body)}}function di(e,t,r){let n=D(!1),o=D(0),s=D(t);Pe(()=>{let l=e.current;if(!l||t!=="running")return;n.current=!1,o.current=l.scrollTop;let a=()=>{n.current=!0},d=()=>{Math.abs(l.scrollTop-o.current)>1&&a()},f=u=>{u.target.closest("input, textarea, [contenteditable]")||["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(u.key)&&a()};return l.addEventListener("wheel",a,{passive:!0}),l.addEventListener("touchmove",a,{passive:!0}),l.addEventListener("keydown",f),l.addEventListener("scroll",d,{passive:!0}),()=>{l.removeEventListener("wheel",a),l.removeEventListener("touchmove",a),l.removeEventListener("keydown",f),l.removeEventListener("scroll",d)}},[e,t]),Pe(()=>{let l=s.current==="running";s.current=t;let a=e.current;if(!a||n.current||t==="error"||t!=="running"&&!l)return;let d=()=>{if(n.current)return;let u=a.querySelectorAll('[data-proposal-status="done"], [data-token-id]'),g=u[u.length-1];if(!g)return;let y=g.getBoundingClientRect().bottom,v=a.getBoundingClientRect().top+a.clientHeight;y+16>v&&(a.scrollTop+=y+16-v,o.current=a.scrollTop)};if(d(),t!=="running")return;let f=typeof ResizeObserver>"u"?null:new ResizeObserver(d);f?.observe(a);for(let u of a.children)f?.observe(u);return()=>f?.disconnect()},[e,t,r])}var Nn=aa(()=>!1),ci=()=>sa(Nn);function ui(e){let t="",r=new Map,n=o=>{if(o.nodeType===Node.TEXT_NODE){t+=o.textContent??"";return}if(o instanceof HTMLElement&&!o.matches("[data-token-preview], .tc-swatch, .tc-available")){if(o.matches(".tc-field")){let s=o.querySelector("input");if(s){let l=t.length;t+=s.value,r.set(s,{start:l,end:t.length})}return}if(o.dataset.valueText!==void 0){t+=o.dataset.valueText;return}for(let s of o.childNodes)n(s)}};for(let o of e.childNodes)n(o);return{value:t.replace(/\u00a0/g," "),fields:r}}function Ln(e,t,r){let n=e.findIndex(a=>r?t>a.start&&t<=a.end:t>=a.start&&t<a.end),o=e.findIndex(a=>r?a.start===t:a.end===t),s=n>=0?n:o,l=s>=0?e[s+(r?-1:1)]:r?[...e].reverse().find(a=>a.end<t):e.find(a=>a.start>t);return l?r?l.start:l.end:r?0:e.at(-1)?.end??t}function Tn({label:e,onCommit:t,onSelectionStart:r,children:n,...o}){let s=D(null),l=D(null),[a,d]=T(null),[f,u]=T(""),[g,y]=T(""),v=D(!1);Pe(()=>{!a||!l.current||(l.current.focus({preventScroll:!0}),l.current.setSelectionRange(Math.min(a.anchor,a.focus),Math.max(a.anchor,a.focus),a.focus<a.anchor?"backward":"forward"))},[a]);let C=(c,b,h)=>{if(!s.current)return!1;let{value:p,fields:m}=ui(s.current),N=m.get(c);if(!N||m.size<2)return!1;let A=c.selectionDirection==="backward",P=N.start+((A?c.selectionEnd:c.selectionStart)??0),q=N.start+((A?c.selectionStart:c.selectionEnd)??0),x=[...m.values()],j=h?Ln(x,q,b):Math.max(0,Math.min(p.length,q+(b?-1:1)));return j===q?!1:(u(p),d({value:p,ranges:x,anchor:P,focus:j,dirty:[...m.keys()].some(E=>E.hasAttribute("data-taste-field-dirty"))}),y(""),r?.(),!0)};return i(Nn.Provider,{value:C,children:i("div",{...o,ref:s,children:a?k("span",{className:"tc-field tc-fit",style:{flex:"1 1 auto",minWidth:0},children:[i("span",{className:"tc-measure","aria-hidden":"true",children:f||"\u200B"}),i("input",{ref:l,"aria-label":e,"aria-invalid":!!g,"data-taste-value-input":!0,"data-taste-field-dirty":a.dirty||f!==a.value||void 0,value:f,onChange:c=>{u(c.target.value),y("")},onBlur:()=>{if(v.current){v.current=!1;return}try{(a.dirty||f!==a.value)&&t(f.trim()),d(null)}catch(c){y(c instanceof Error?c.message:"Check this value")}},onKeyDown:c=>{if(c.stopPropagation(),c.key==="Escape")c.preventDefault(),v.current=!0,c.currentTarget.blur(),d(null);else if(c.key==="Enter")c.preventDefault(),c.currentTarget.blur();else if(c.altKey&&c.shiftKey&&!c.metaKey&&!c.ctrlKey&&!c.nativeEvent.isComposing&&f===a.value&&(c.key==="ArrowLeft"||c.key==="ArrowRight")){let b=c.currentTarget,h=b.selectionDirection==="backward",p=(h?b.selectionEnd:b.selectionStart)??0,m=(h?b.selectionStart:b.selectionEnd)??0,N=Ln(a.ranges,m,c.key==="ArrowLeft");c.preventDefault(),b.setSelectionRange(Math.min(p,N),Math.max(p,N),N<p?"backward":"forward")}}}),g&&i("span",{role:"alert",className:"tc-field-error",children:g})]}):n})})}function Br(e,t){let r=t,n=(e.x+t.x)/2;if(t.blockedLeft){let{top:o,bottom:s,width:l}=t.blockedLeft,a=e.y<=t.y,d=Math.min(8,l/2,(s-o)/2)*(1-Math.SQRT1_2);r={x:t.x+d,y:a?o+d:s-d};let f=Math.min(64,Math.abs(r.y-e.y)/2),u=r.y+(a?-1:1)*Math.min(24,f);return{from:e,to:r,path:`M ${e.x} ${e.y} C ${n} ${e.y}, ${r.x-f} ${u}, ${r.x} ${r.y}`}}return{from:e,to:r,path:`M ${e.x} ${e.y} C ${n} ${e.y}, ${n} ${r.y}, ${r.x} ${r.y}`}}var Gt=({parent:e,child:t})=>JSON.stringify([e,t]),cr=128;function An(e){let t=e.getBoundingClientRect(),r=t.width/e.offsetWidth||1,n=t.height/e.offsetHeight||1,o=new Map;e.querySelectorAll("[data-constraint-id], [data-token-id], [data-connection-id]").forEach(l=>{let a=l.dataset.connectionId??l.dataset.constraintId??`token:${l.dataset.tokenId}`;o.has(a)||o.set(a,l)});let s=new Map;return(l,a)=>{let d=`${a}:${l}`;if(s.has(d))return s.get(d);let f=o.get(l),u=f?.matches(".tc-reference")?f:f?.querySelector(a==="source"?".tc-name":".tc-reference");if(!u)return s.set(d,null),null;let g=u.getBoundingClientRect(),y=a==="target"&&u.parentElement?.classList.contains("tc-compound")&&Array.from(u.parentElement.children).some(C=>{if(C===u)return!1;let c=C.getBoundingClientRect();return c.width>0&&c.right<=g.left+1&&c.right>g.left-8&&c.bottom>g.top&&c.top<g.bottom}),v={x:((a==="source"?g.right:g.left)-t.left)/r-e.clientLeft,y:(g.top+g.height/2-t.top)/n-e.clientTop,...y?{blockedLeft:{top:(g.top-t.top)/n-e.clientTop,bottom:(g.bottom-t.top)/n-e.clientTop,width:g.width/r}}:{}};return s.set(d,v),v}}function pi({pane:e,edges:t,visible:r,revision:n,suspended:o,color:s}){let[l,a]=T(new Map),d=new Set(r.map(Gt)),f=JSON.stringify(t),u=JSON.stringify(r),g=D(null),y=D(r);return y.current=r,le(()=>{let v=e.current;if(!v)return;let C=JSON.parse(f),c=C.length>cr,b=new Set,h,p=!1,m=()=>{if(p)return;let x=An(v),j=y.current.length<=cr?new Set(y.current.map(Gt)):new Set,E=c?C.filter(H=>b.has(H.child)||j.has(Gt(H))):C,B=new Map;for(let H of E){let M=x(H.parent,"source"),L=x(H.child,"target");M&&L&&B.set(Gt(H),Br(M,L))}a(H=>H.size===B.size&&[...B].every(([M,L])=>H.get(M)?.path===L.path)?H:B)},N=()=>{h===void 0&&(h=requestAnimationFrame(()=>{h=void 0,m()}))};g.current=m;let A=typeof ResizeObserver>"u"?null:new ResizeObserver(N);A?.observe(v),v.querySelectorAll(".tc-scroll, .tc-row, .tc-reference, .tc-literal").forEach(x=>A?.observe(x));let P=new Map;v.querySelectorAll("[data-connection-id]").forEach(x=>P.set(x,x.dataset.connectionId)),v.querySelectorAll("[data-constraint-id] .tc-reference").forEach(x=>P.set(x,x.closest("[data-constraint-id]").dataset.constraintId));let q=c&&typeof IntersectionObserver<"u"?new IntersectionObserver(x=>{for(let j of x){let E=P.get(j.target);E&&(j.isIntersecting?b.add(E):b.delete(E))}N()},{root:v.querySelector(".tc-scroll"),rootMargin:"160px 0px"}):null;return P.forEach((x,j)=>q?.observe(j)),c&&!q&&C.slice(0,cr).forEach(x=>b.add(x.child)),m(),v.addEventListener("scroll",N,!0),window.addEventListener("resize",N),()=>{p=!0,g.current=null,h!==void 0&&cancelAnimationFrame(h),A?.disconnect(),q?.disconnect(),v.removeEventListener("scroll",N,!0),window.removeEventListener("resize",N)}},[e,f,n]),Pe(()=>{!o&&y.current.length<=cr&&y.current.some(v=>!l.has(Gt(v)))&&g.current?.()},[u,o,l]),i("svg",{"data-taste-connection-layer":!0,"aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",overflow:"visible"},children:[...l].map(([v,{from:C,to:c,path:b}])=>{let h=!o&&d.has(v);return k("g",{"data-taste-cached-connection":v,"data-taste-connection":h?"":void 0,style:{visibility:h?"visible":"hidden"},children:[i("path",{d:b,fill:"none",stroke:s,strokeWidth:1}),i("circle",{cx:C.x,cy:C.y,r:3,fill:s}),i("circle",{cx:c.x,cy:c.y,r:3,fill:s})]},v)})})}function hi({value:e,label:t,className:r,onEdit:n,onCommit:o,onPreview:s}){let l=In({value:e,spec:{step:1,compound:!0},preview:s,commit:a=>{o(a),s(null)},cancel:()=>s(null)});return k(Le,{children:[i("button",{className:r,"aria-label":t,"data-scrubbable":l.enabled||void 0,onPointerDown:l.start,onClick:()=>{l.consumedClick.current||n()},children:e}),l.cursor]})}function st({label:e,value:t,onCommit:r,onDraftChange:n,onCancel:o,arrowNavigation:s=!1,compact:l=!1,decimal:a=!1,scrub:d,clearable:f=!1,onScrubPreview:u,onDelete:g,sourceSuggestions:y,bareSource:v=!1,...C}){let c=ci(),[b,h]=T(null),[p,m]=T(""),N=D(!1),A=xr(),P=b??t,[q,x]=T(!1),[j,E]=T(!0),[B,H]=T(!1),M=v?P.match(/^@?([\w-]+)$/)?.[1]:P.match(/(?:^|\s)@([\w-]+)$/)?.[1],L=(q&&b!==null&&j&&!B&&M&&!y?.some(I=>I.toLowerCase()===M.toLowerCase())?y?.find(I=>I.length>M.length&&I.toLowerCase().startsWith(M.toLowerCase())):void 0)?.slice(M.length)??"",R=D(null),[K,de]=T(0);Pe(()=>{de(R.current?.getBoundingClientRect().width??0)},[L]);let Q=I=>{try{r(I.trim()),u?.(null),h(null),m("")}catch(te){m(te instanceof Error?te.message:"Check this value")}},U=In({value:P,spec:d,preview:I=>{h(I),m(""),u?.(I)},commit:Q,cancel:()=>{h(null),m(""),u?.(null),o?.()}}),ae=typeof a=="number"?a:2,he=3-ae,ue=a?P.match(/^(-?)(\d*)(\.?)(\d*)$/):null,me=ue?`${ue[3]?"":"."}${"0".repeat(Math.max(0,ae-ue[4].length))}`:"",We=ue?"0".repeat(Math.max(0,he-ue[2].length)):"",ve=D(null),[Ee,Ye]=T(0);return Pe(()=>{let I=ve.current;if(!I)return;let te=()=>Ye(I.getBoundingClientRect().width);if(te(),typeof ResizeObserver>"u")return;let ge=new ResizeObserver(te);return ge.observe(I),()=>ge.disconnect()},[me]),k("span",{className:`tc-field${l?" tc-fit":""}${a?" tc-decimal":""}`,children:[l&&i("span",{className:"tc-measure","aria-hidden":"true",children:a?`${"0".repeat(Math.max(4,t.length,ue?`${ue[1]}${We}${ue[2]}${ue[3]}${ue[4]}${me}`.length:P.length)-ae-1)}.${"0".repeat(ae)}`:P+L||C.placeholder||"\u200B"}),L&&k("span",{className:"tc-source-completion","aria-hidden":"true",children:[i("span",{style:{visibility:"hidden"},children:P}),i("span",{ref:R,children:L})]}),a&&ue&&k("span",{className:"tc-decimal-display","aria-hidden":"true",children:[ue[1],i("span",{className:"tc-digit-placeholder",children:We}),ue[2],ue[3],ue[4],i("span",{ref:ve,className:"tc-digit-placeholder",children:me})]}),i("input",{...C,autoComplete:y?"off":void 0,"aria-autocomplete":y?"inline":void 0,onFocus:()=>{x(!0),N.current=!1},onSelect:I=>{let te=I.currentTarget;E(te.selectionStart===te.value.length&&te.selectionEnd===te.value.length)},onCompositionStart:()=>H(!0),onCompositionEnd:()=>H(!1),"data-scrubbable":U.enabled||void 0,onPointerDown:U.start,onContextMenu:f||g?I=>{I.preventDefault(),I.stopPropagation(),g?g():Q("")}:void 0,placeholder:a?`${"0".repeat(he)}.${"0".repeat(ae)}`:C.placeholder,inputMode:a?"decimal":void 0,style:a&&ue?{color:"transparent",caretColor:"var(--tc-primary)",paddingRight:6+Ee}:L?{paddingRight:`calc(var(--tc-field-inline-padding, 6px) + ${K}px)`}:void 0,"data-taste-value-input":!0,"data-value-arrow-navigation":s||void 0,"data-taste-field-dirty":b!==null||void 0,"aria-label":e,"aria-invalid":!!p,"aria-describedby":p?A:void 0,value:b??t,onChange:I=>{if(E(I.target.selectionStart===I.target.value.length&&I.target.selectionEnd===I.target.value.length),n?.(I.target.value)){N.current=!0,h(null),m("");return}a&&!new RegExp(`^-?\\d*(?:\\.\\d{0,${ae}})?$`).test(I.target.value)||(h(I.target.value),m(""))},onBlur:I=>{if(x(!1),!U.dragging.current){if(N.current){N.current=!1;return}if(b===null){(!s||!I.currentTarget.closest(".tc-reference")?.contains(I.relatedTarget))&&o?.();return}Q(b)}},onKeyDown:I=>{if(I.stopPropagation(),L&&!I.nativeEvent.isComposing&&!I.shiftKey&&!I.altKey&&!I.metaKey&&!I.ctrlKey&&(I.key==="Enter"||I.key==="Tab")){I.preventDefault(),h(P+L),m("");return}if(s&&I.shiftKey&&!I.metaKey&&!I.ctrlKey&&!I.nativeEvent.isComposing&&(I.key==="ArrowLeft"||I.key==="ArrowRight")){let te=I.currentTarget,ge=te.selectionDirection==="backward"?te.selectionStart:te.selectionEnd;if((I.altKey||ge===(I.key==="ArrowLeft"?0:te.value.length))&&c(I.currentTarget,I.key==="ArrowLeft",I.altKey)){N.current=!0,I.preventDefault();return}}if(s&&!I.shiftKey&&!I.metaKey&&!I.ctrlKey&&!I.nativeEvent.isComposing&&(I.key==="ArrowLeft"||I.key==="ArrowRight")){let te=I.currentTarget,ge=I.key==="ArrowLeft",J=ge?0:te.value.length;if(I.altKey||te.selectionStart===J&&te.selectionEnd===J){let pe=Array.from(te.closest(".tc-value")?.querySelectorAll("input[data-value-arrow-navigation]")??[]),V=pe[pe.indexOf(te)+(ge?-1:1)];if(V){I.preventDefault(),V.focus({preventScroll:!0});let xe=I.altKey?ge?0:V.value.length:ge?V.value.length:0;V.setSelectionRange(xe,xe)}}}I.key==="Enter"&&(I.preventDefault(),I.currentTarget.blur()),I.key==="Escape"&&(I.preventDefault(),h(null),m(""),N.current=!0,I.currentTarget.blur(),o?.())}}),U.cursor,p&&i("span",{id:A,role:"alert",className:"tc-field-error",children:p})]})}function En({color:e,background:t}){let r=oi(e,t);return i("span",{"aria-hidden":"true",className:"tc-swatch","data-color-value":e??"",style:{boxShadow:r?`0 0 0 1px ${r}`:"none",background:e?"repeating-conic-gradient(#aaa 0% 25%, #fff 0% 50%) 0 / 6px 6px":void 0},children:i("span",{style:{display:"block",width:"100%",height:"100%",backgroundColor:e}})})}function fi({value:e,constraints:t,name:r,background:n}){let o=ri(e,t),s=br(t,e),l=/\bcalc\(/i.test(e)?yr(e,t):null,a=s?.kind==="layout"?`${Math.round(s.value)}${s.unit}`:s?mt(s):l??void 0,d=Xn(e,t);return!o&&!s&&!l&&!d.length?null:k("span",{className:"tc-token-preview","data-token-preview":!0,"aria-label":`${r} resolves to ${o??a??d.join(", ")}`,children:[i("span",{className:"tc-separator","aria-hidden":"true",children:i(xa,{size:12})}),o?i("span",{className:"tc-resolved-value",children:i("span",{className:"tc-shadow-preview","data-shadow-value":o,"aria-hidden":"true",children:i("span",{style:{boxShadow:o}})})}):d.length?d.map((f,u)=>i("span",{className:"tc-resolved-value",children:i(En,{color:f,background:n})},`${u}:${f}`)):i("span",{className:"tc-resolved-value",children:a})]})}function gi({row:e,constraints:t,background:r}){if(e.kind==="color"){let n;try{n=mt(Tt(t,e.id))}catch{}return n?i("span",{className:"tc-resolved-value",children:i(En,{color:n,background:r})}):null}return null}var Mn=e=>e.dataset.connectionId??e.dataset.constraintId??`token:${e.dataset.tokenId}`,xt=e=>{let t=e.match(/^(token:.*):(ref|dim):(\d+)$/);return{row:t?.[1]??e,index:t?.[2]==="ref"?Number(t[3]):void 0,dimensionIndex:t?.[2]==="dim"?Number(t[3]):void 0}};function mi({drag:e,pane:t,color:r}){let[n,o]=T(null);if(Pe(()=>{let d=t.current;if(!d)return;let f=()=>{let g=An(d),y=g(e.id,e.port);if(!y)return;let v=(e.target&&e.validTarget?g(e.target,e.port==="source"?"target":"source"):null)??{x:e.toX-d.clientLeft,y:e.toY-d.clientTop};o(e.port==="source"?Br(y,v):Br(v,y))};f(),d.addEventListener("scroll",f,!0),window.addEventListener("resize",f);let u=typeof ResizeObserver>"u"?null:new ResizeObserver(f);return d.querySelectorAll(".tc-row, .tc-reference, .tc-literal").forEach(g=>u?.observe(g)),()=>{d.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f),u?.disconnect()}},[e,t]),!n)return null;let{from:s,to:l,path:a}=n;return k("svg",{"data-taste-connection":!0,"aria-hidden":"true",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",overflow:"visible"},children:[i("path",{d:a,fill:"none",stroke:r,strokeWidth:1}),i("circle",{cx:s.x,cy:s.y,r:3,fill:r}),i("circle",{cx:l.x,cy:l.y,r:3,fill:r})]})}function zn({draft:e,onChange:t,history:r,theme:n,onBack:o,style:s,proposalState:l,preferPageComponent:a,proposalRecovery:d,fragments:f,detail:u,onSave:g,saving:y,saveNotice:v,saveAction:C}){let c=Gn(e),b=l==="running",h=Ge[n],p=D(null),m=D(null);di(m,l,e);let N=D({past:[],future:[]}),A=r??N,P=w=>{b||JSON.stringify(w)!==JSON.stringify(c)&&(A.current.past=[...A.current.past.slice(-99),c],A.current.future=[],t(w))},q=D(null),[x,j]=T(null),[E,B]=T(null),[H,M]=T(null),[L,R]=T(null),[K,de]=T(null),[Q,U]=T(null),[ae,he]=T(null),ue=c.constraints.flatMap(w=>w.parentId?[{parent:w.parentId,child:w.id}]:[]);for(let w of c.tokens)Ot(w.value,c.constraints).forEach((F,_)=>{let S=F&&c.constraints.find(Ce=>Ce.name.toLowerCase()===F.name.toLowerCase());S&&ue.push({parent:S.id,child:rr(w.value)?`token:${w.id}`:`token:${w.id}:ref:${_}`})});let me=ue.filter(({parent:w,child:F})=>H?.port==="source"?w===H.id:F===H?.id||xt(F).row===H?.id).map(({parent:w,child:F})=>({id:w,target:F,port:"source",active:!0,validTarget:!0,x:0,y:0,toX:0,toY:0})),We=new Set(H?.port==="source"?me.map(({target:w})=>xt(w).row):[]),ve=x?[x]:E?[E]:me,Ee=D(!1),[Ye,I]=T(""),[te,ge]=T(null),[J,pe]=T(null),V=te?c.constraints.map(w=>w.id===te.id?{...w,...te.patch}:w):c.constraints,xe=Ht(()=>({...c,constraints:V,tokens:J?c.tokens.map(w=>w.id===J.id?{...w,value:J.value}:w):c.tokens}),[c,V,J]),[X,Ke]=T(null);le(()=>{let w=p.current?.ownerDocument;if(!w)return;let F=_=>{let S=_.key.toLowerCase();if(!(_.metaKey||_.ctrlKey)||_.altKey||S!=="z"&&S!=="y")return;let Ce=_.composedPath()[0],we=Ce instanceof Node&&p.current?.contains(Ce);if(_n(_)&&(!we||Ce instanceof Element&&Ce.hasAttribute("data-taste-field-dirty"))||(_.preventDefault(),_.stopImmediatePropagation(),te||J||q.current))return;let G=S==="y"||_.shiftKey,oe=(G?A.current.future:A.current.past).pop();oe&&((G?A.current.past:A.current.future).push(c),B(null),I(""),t(oe))};return w.addEventListener("keydown",F,!0),()=>w.removeEventListener("keydown",F,!0)},[c,A,t,te,J]),le(()=>{if(!X)return;let w=setTimeout(()=>Ke(null),220);return()=>clearTimeout(w)},[X]);let Je=xr(),Oe=D(0),Me=()=>`${Je}-${++Oe.current}`,tt=(w,F)=>{B(null),P({...c,constraints:c.constraints.map(_=>_.id===w?{..._,...F}:_)}),I("")},qe=(w,F)=>P({...c,tokens:c.tokens.map(_=>_.id===w?{..._,value:F}:_)}),ze=(w,F)=>{if(w.startsWith("token:")){let _=c.constraints.find(we=>we.id===F),S=xt(w),Ce=c.tokens.find(we=>`token:${we.id}`===S.row);return _&&Ce&&Pr(Ce.value,_,c.constraints,S.index,S.dimensionIndex)!==null?null:"Choose a compatible, unambiguous value"}return nr(c.constraints,w,F)},De=(w,F,_=!1)=>{let S=ze(w,F);if(S)throw Error(S);if(w.startsWith("token:")){let Ce=xt(w),we=c.tokens.find(oe=>`token:${oe.id}`===Ce.row),G=c.constraints.find(oe=>oe.id===F);qe(we.id,Pr(we.value,G,c.constraints,Ce.index,Ce.dimensionIndex));return}tt(w,{parentId:F,..._?{derivative:Gr(c.constraints,w,F)}:{}})},rt=(w,F)=>{let _=p.current,S=_.getBoundingClientRect();return{x:(w-S.left)/(S.width/_.offsetWidth||1),y:(F-S.top)/(S.height/_.offsetHeight||1)}},Nt=(w,F,_)=>{if(w.button!==0)return;Ke(null),M(null),B(null),Ee.current=!1;let S=rt(w.clientX,w.clientY);q.current={id:F,port:_,...S,toX:S.x,toY:S.y,active:!1,target:null,validTarget:!1},w.currentTarget.setPointerCapture(w.pointerId)},pr=w=>{let F=q.current;if(!F&&!E)return;let _=p.current.getRootNode().elementFromPoint(w.clientX,w.clientY);if(!F){let Se=p.current.contains(_)?_?.closest(".tc-row"):null;Se&&Mn(Se)!==xt(E.target??"").row&&B(null);return}let S=rt(w.clientX,w.clientY),Ce=F.active||Math.hypot(S.x-F.x,S.y-F.y)>5,we=p.current.contains(_)?_?.closest("[data-connection-id], [data-constraint-id], [data-token-id]"):null,G=we?Mn(we):null,oe=F.landing;if(oe&&F.validTarget&&p.current.contains(oe.row)){let Se=oe.row.getBoundingClientRect(),He=w.clientX-Se.left,Te=w.clientY-Se.top,fe=6;He>=oe.left-fe&&He<=oe.right+fe&&Te>=oe.top-fe&&Te<=oe.bottom+fe&&Te>=-fe&&Te<=Se.height+fe&&(G=F.target)}let Ve=!!G&&!ze(F.port==="source"?G:F.id,F.port==="source"?F.id:G);if(G!==F.target&&(oe=void 0),!oe&&Ve&&F.port==="source"&&G?.startsWith("token:")&&we){let Se=we.closest("[data-token-id]"),He=_?.closest(".tc-shadow-dimension, .tc-reference, .tc-value")??we;if(Se){let Te=Se.getBoundingClientRect(),fe=He.getBoundingClientRect();fe.width>0&&fe.height>0&&(oe={row:Se,left:fe.left-Te.left,right:fe.right-Te.left,top:fe.top-Te.top,bottom:fe.bottom-Te.top})}}q.current={...F,active:Ce,toX:S.x,toY:S.y,target:G,validTarget:Ve,landing:oe},Ce&&(Ee.current=!0,j(q.current))},hr=()=>{let w=q.current;if(q.current=null,j(null),!(!w?.active||!w.target))try{De(w.port==="source"?w.target:w.id,w.port==="source"?w.id:w.target,!0),B({...w})}catch{I(""),Ke(w.port==="source"?w.id:w.target)}},at=w=>{if(!w||!Number.isFinite(Number(w)))throw Error("Enter a finite number");return Number(w)};return k("div",{ref:p,role:"region","aria-label":u?`${u.name} uses`:"New taste","data-taste-editor":!0,"data-popmelt-font":"sans","data-popmelt-theme":n,onMouseOver:u?w=>{let F=w.target.closest("[data-token-id], [data-constraint-id]"),_=F?.getAttribute("data-token-id"),S=F?.getAttribute("data-constraint-id");u.onHover?.(_?{kind:"token",id:_}:S?{kind:"dimension",id:S}:null)}:void 0,onMouseLeave:u?()=>u.onHover?.(null):void 0,onPointerMove:pr,onPointerUp:hr,onPointerCancel:()=>{q.current=null,j(null)},onKeyDown:w=>{w.key==="Escape"&&(w.preventDefault(),w.stopPropagation(),q.current||E?(q.current=null,j(null),B(null)):o())},style:{...s,width:"min(360px, 100%)",marginInline:"auto",boxSizing:"border-box",position:"relative",display:"flex",flexDirection:"column",maxHeight:s?.maxHeight??"calc(100dvh - 80px)",border:`1px solid ${h.border}`,borderRadius:20,background:h.surface,color:h.secondary,fontFamily:Wt,fontVariantNumeric:"tabular-nums",fontSize:12,lineHeight:1.3,letterSpacing:"-.12px",overflow:"hidden","--tc-primary":h.primary,"--tc-muted":h.muted,"--tc-control":h.control,"--tc-secondary":h.secondary,"--tc-border":h.border,"--tc-surface":h.surface},children:[i("style",{children:`
68
+ [data-taste-editor] { --tc-row-height: 22px; --tc-row-slop: 3px; --tc-value-font-size: 14px; }
69
+ [data-taste-editor] * { box-sizing: border-box; }
70
+ [data-taste-editor] button, [data-taste-editor] input { font: inherit; font-variant-numeric: tabular-nums; color: inherit; letter-spacing: inherit; }
71
+ [data-taste-editor] button { border: 0; background: transparent; cursor: pointer; border-radius: 8px; padding: 2px 6px; display: inline-flex; align-items: center; justify-content: center; gap: 2px; }
72
+ [data-taste-editor] button:hover { color: var(--tc-primary); background: var(--tc-control); }
73
+ [data-taste-editor] button:focus-visible { outline: 1px solid var(--tc-secondary); outline-offset: 1px; }
74
+ [data-taste-editor] input:focus-visible { outline: none; box-shadow: none; }
75
+ [data-taste-editor] input { width: 100%; min-width: 0; border: 0; background: transparent; border-radius: 8px; padding: 2px 6px; text-align: right; text-overflow: ellipsis; }
76
+ [data-taste-editor] input:hover, [data-taste-editor] input:focus { background: var(--tc-control); color: var(--tc-primary); }
77
+ [data-taste-editor] input[data-scrubbable] { cursor: ew-resize; touch-action: none; }
78
+ [data-taste-editor] button[data-scrubbable] { cursor: ew-resize; touch-action: none; }
79
+ [data-taste-editor] input[data-scrubbable]:focus { cursor: text; }
80
+ [data-taste-editor] input::placeholder { color: var(--tc-secondary); opacity: 1; }
81
+ [data-taste-editor] .tc-field { position: relative; display: grid; min-width: 0; }
82
+ [data-taste-editor] .tc-fit > input, [data-taste-editor] .tc-measure { grid-area: 1 / 1; }
83
+ [data-taste-editor] .tc-fit > input { position: absolute; inset: 0; width: 100%; min-width: 1px; }
84
+ [data-taste-editor] .tc-measure { visibility: hidden; white-space: pre; padding: 2px 6px; overflow: hidden; }
85
+ [data-taste-editor] .tc-source-completion { position: absolute; inset: 0; padding: 2px 6px; text-align: right; white-space: pre; pointer-events: none; color: var(--tc-secondary); overflow: hidden; z-index: 1; }
86
+ [data-taste-editor] .tc-decimal { flex: 0 0 auto; }
87
+ [data-taste-editor] .tc-decimal-display { position: absolute; inset: 0; padding: 2px 6px; text-align: right; white-space: pre; pointer-events: none; z-index: 1; overflow: hidden; }
88
+ [data-taste-editor] .tc-decimal:focus-within .tc-decimal-display { color: var(--tc-primary); }
89
+ [data-taste-editor] .tc-digit-placeholder { display: inline-block; color: var(--tc-secondary); }
90
+ [data-taste-editor] .tc-decimal input::placeholder { color: transparent; }
91
+ [data-taste-editor] .tc-field-error { position: absolute; top: 100%; right: 0; z-index: 2; width: max-content; max-width: 280px; border-radius: 8px; background: ${n==="dark"?"#302024":"#f9e9ec"}; color: ${n==="dark"?"#f08a95":"#c4253d"}; font-size: 11px; padding: 6px 8px; text-align: center; }
92
+ [data-taste-editor] .tc-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 0 15px 16px; scroll-padding-top: 208px; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 16px; }
93
+ [data-taste-editor] .tc-scroll > header { margin-top: 19px; }
94
+ [data-taste-editor] header { display: flex; align-items: center; gap: 2px; flex-shrink: 0; height: 16px; }
95
+ [data-taste-editor] header button { padding: 0; color: var(--tc-primary); }
96
+ [data-taste-editor] header > svg { flex-shrink: 0; transform: scaleY(-1); }
97
+ [data-taste-editor] header .tc-field { flex: 0 1 auto; font-weight: 600; }
98
+ [data-taste-editor] header .tc-measure { padding: 0; }
99
+ [data-taste-editor] input.tc-title { padding: 0; text-align: left; }
100
+ [data-taste-editor] section { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
101
+ [data-taste-editor] h3 { font-size: 12px; line-height: 1.3; font-weight: 500; color: var(--tc-primary); margin: 0; }
102
+ [data-taste-editor] .tc-type-role { color: var(--tc-secondary); letter-spacing: normal; height: 30.2px; flex-shrink: 0; }
103
+ [data-taste-editor] .tc-type-role[data-typography-role="body"]:has(~ .tc-row[data-typography-role="body"]:is(:hover, :focus-within)),
104
+ [data-taste-editor] .tc-type-role[data-typography-role="heading"]:has(~ .tc-row[data-typography-role="heading"]:is(:hover, :focus-within)) { color: var(--tc-primary); }
105
+ [data-taste-editor] .tc-row[data-typography-role] { --tc-row-height: 30.2px; --tc-row-slop: 0px; margin-left: 12px; margin-top: -6px; letter-spacing: normal; }
106
+ [data-taste-editor] .tc-row[data-typography-role] .tc-name { padding-inline: 4px; letter-spacing: normal; }
107
+ [data-taste-editor] .tc-row { display: flex; align-items: center; justify-content: space-between; height: var(--tc-row-height); min-width: 0; border-radius: 8px; }
108
+ [data-taste-editor] .tc-row { position: relative; isolation: isolate; }
109
+ [data-taste-editor] .tc-row::before { content: ''; position: absolute; inset: calc(-1 * var(--tc-row-slop)) 0; z-index: -1; }
110
+ [data-taste-editor] .tc-row:hover, [data-taste-editor] .tc-row:focus-within { color: var(--tc-primary); }
111
+ [data-taste-editor] .tc-row:hover input { background: var(--tc-control); color: var(--tc-primary); }
112
+ [data-taste-editor] [data-connection-active=true] { background: var(--tc-control); color: var(--tc-primary); }
113
+ [data-taste-editor] .tc-name { height: 22px; justify-content: flex-start; min-width: 0; touch-action: none; user-select: none; text-align: left; letter-spacing: .12px; flex-shrink: 1; gap: 4px; }
114
+ [data-taste-editor] .tc-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
115
+ [data-taste-editor] .tc-row[data-proposal-status=pending] .tc-name { color: var(--tc-muted); }
116
+ [data-taste-editor] .tc-proposal-status { font-size: var(--tc-value-font-size); font-weight: 400; padding: 2px 6px; color: var(--tc-muted); white-space: nowrap; }
117
+ [data-taste-editor] .tc-proposal-recovery { flex-shrink: 0; padding: 12px 15px 15px; border-top: 1px solid var(--tc-border); }
118
+ [data-taste-editor] .tc-proposal-recovery p { margin: 0 0 10px; color: var(--tc-secondary); }
119
+ [data-taste-editor] .tc-proposal-recovery nav { display: flex; gap: 8px; }
120
+ [data-taste-editor] .tc-proposal-recovery button { padding: 6px 10px; background: var(--tc-control); color: var(--tc-primary); }
121
+ [data-taste-editor] .tc-proposal-status[data-state=in-progress] {
122
+ color: var(--tc-primary);
123
+ background: linear-gradient(100deg, var(--tc-muted) 35%, var(--tc-primary) 50%, var(--tc-muted) 65%);
124
+ background-size: 250% 100%;
125
+ background-clip: text;
126
+ -webkit-background-clip: text;
127
+ -webkit-text-fill-color: transparent;
128
+ animation: tc-proposal-sweep 2.4s linear infinite;
129
+ }
130
+ @keyframes tc-proposal-sweep {
131
+ 0% { background-position: 100% 0; }
132
+ 80%, 100% { background-position: 0% 0; }
133
+ }
134
+ @media (prefers-reduced-motion: reduce) {
135
+ [data-taste-editor] .tc-proposal-status[data-state=in-progress] {
136
+ animation: none;
137
+ background: none;
138
+ -webkit-text-fill-color: currentColor;
139
+ }
140
+ }
141
+ [data-taste-editor] .tc-name:disabled { cursor: default; background: transparent; }
142
+ [data-taste-editor] .tc-swatch { width: 14px; height: 14px; flex: 0 0 14px; margin-left: 8px; border-radius: 3px; overflow: hidden; pointer-events: none; box-shadow: 0 0 0 1px var(--tc-border); }
143
+ @keyframes tc-rejection-shake { ${Jn} }
144
+ [data-taste-editor] .tc-name[data-connection-rejected=true] { animation: tc-rejection-shake 220ms ease-out; background: var(--tc-control); color: var(--tc-primary); }
145
+ @media (prefers-reduced-motion: reduce) { [data-taste-editor] .tc-name[data-connection-rejected=true] { animation: none; } }
146
+ [data-taste-editor] .tc-row:focus-within .tc-name, [data-taste-editor] .tc-row:focus-within > .tc-field { color: var(--tc-primary); }
147
+ [data-taste-editor] .tc-row > .tc-field { flex: 1; letter-spacing: .12px; }
148
+ [data-taste-editor] .tc-row > .tc-field.tc-fit { flex: 0 1 auto; max-width: 50%; }
149
+ [data-taste-editor] .tc-row > .tc-field input { text-align: left; }
150
+ [data-taste-editor] input.tc-derived-name-active { color: var(--tc-primary); }
151
+ [data-taste-editor] .tc-value { display: flex; align-items: center; justify-content: flex-end; min-width: 0; max-width: 78%; font-size: var(--tc-value-font-size); font-weight: 500; letter-spacing: -.14px; font-variant-numeric: lining-nums tabular-nums; }
152
+ [data-taste-editor] .tc-token-preview { display: inline-flex; align-items: center; flex: 0 0 auto; }
153
+ [data-taste-editor] .tc-resolved-value { display: inline-flex; align-items: center; justify-content: center; padding: 2px 6px; border-radius: 8px; white-space: nowrap; }
154
+ [data-taste-editor] .tc-resolved-value .tc-swatch { width: 16px; height: 16px; flex-basis: 16px; margin-left: 0; border-radius: 4px; box-shadow: none; }
155
+ [data-taste-editor] .tc-shadow-preview { position: relative; width: 16px; height: 16px; border-radius: 4px; background: #ededed; overflow: hidden; }
156
+ [data-taste-editor] .tc-shadow-preview > span { position: absolute; width: 10px; height: 12px; left: 2px; top: 2px; border-radius: 1px; background: white; }
157
+ [data-taste-editor] .tc-shadow-dimension { display: inline-flex; align-items: center; flex-shrink: 0; }
158
+ [data-taste-editor] .tc-separator { flex: 0 0 16px; width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; }
159
+ [data-taste-editor] .tc-reference { position: relative; display: flex; align-items: center; min-width: 0; border-radius: 8px; padding: 2px 6px; }
160
+ /* Only extend above/below the visible badge: never cover its port or scrub fields. */
161
+ [data-taste-editor] .tc-reference:not(:has(.tc-reference))::before,
162
+ [data-taste-editor] .tc-reference:not(:has(.tc-reference))::after { content: ''; position: absolute; left: 0; right: 0; }
163
+ [data-taste-editor] .tc-reference:not(:has(.tc-reference))::before { top: calc((100% - var(--tc-row-height)) / 2 - var(--tc-row-slop)); bottom: 100%; }
164
+ [data-taste-editor] .tc-reference:not(:has(.tc-reference))::after { top: 100%; bottom: calc((100% - var(--tc-row-height)) / 2 - var(--tc-row-slop)); }
165
+ [data-taste-editor] .tc-compound { display: flex; align-items: center; min-width: 0; }
166
+ [data-taste-editor] .tc-compound > .tc-reference { flex: 0 0 auto; }
167
+ [data-taste-editor] .tc-opacity-separator { white-space: pre; }
168
+ [data-taste-editor] .tc-reference > .tc-port,
169
+ [data-taste-editor] .tc-reference > span:not(.tc-field),
170
+ [data-taste-editor] .tc-reference > .tc-field:has(.tc-token-step),
171
+ [data-taste-editor] .tc-reference > .tc-field:has(.tc-token-opacity) { flex-shrink: 0; }
172
+ [data-taste-editor] .tc-literal { white-space: pre; overflow: hidden; text-overflow: ellipsis; display: block; min-width: 0; padding: 2px 0; }
173
+ [data-taste-editor] .tc-literal-prefix { flex-shrink: 0; }
174
+ [data-taste-editor] .tc-available { background: var(--tc-control); flex-shrink: 0; }
175
+ [data-taste-editor] .tc-row:hover .tc-reference, [data-taste-editor] .tc-reference:hover, [data-taste-editor] .tc-reference:focus-within { background: var(--tc-control); color: var(--tc-primary); }
176
+ [data-taste-editor] .tc-row .tc-reference input { background: transparent; }
177
+ [data-taste-editor] .tc-reference input, [data-taste-editor] .tc-reference .tc-measure { padding: 0; }
178
+ [data-taste-editor] .tc-reference .tc-field { --tc-field-inline-padding: 0px; }
179
+ [data-taste-editor] .tc-reference .tc-source-completion { padding: 0; }
180
+ [data-taste-editor] .tc-port { padding: 0; touch-action: none; user-select: none; }
181
+ [data-taste-editor] .tc-port:hover { background: transparent; }
182
+ [data-taste-editor] .tc-add-token { align-self: flex-start; height: 22px; background: var(--tc-control); font-weight: 500; }
183
+ [data-taste-editor] .tc-save { flex-shrink: 0; margin: 0 15px 15px; height: 32px; border-radius: 10px; background: ${h.actionSurface}; color: ${h.actionForeground}; font-weight: 500; }
184
+ [data-taste-editor] .tc-save:hover { background: ${h.actionHover}; color: ${h.actionForeground}; }
185
+ `}),k("div",{ref:m,className:"tc-scroll",style:{overflowAnchor:"none"},tabIndex:b?0:void 0,children:[k("header",{children:[i("button",{"aria-label":u?"Back to taste":"Back to taste collection",onClick:o,children:i(Cr,{size:16})}),i(Ut,{size:14}),u?i("span",{className:"tc-title",children:u.name}):i(st,{label:"Taste name",readOnly:b,compact:!0,value:c.name,placeholder:"Name this taste",className:"tc-title",onCommit:w=>P({...c,name:w})})]}),u?u.preview(xe):i(Sn,{draft:xe,preferPageComponent:a,waitForPageFoundations:b&&a,dimensionId:L??K,theme:n}),u&&i("h3",{children:"Uses"}),["layout","typography","color"].map(w=>{let F=w==="color"?"color":"layout",_=S=>(!u||u.constraintIds.includes(S.id))&&(S.group??(S.id==="text"?"typography":S.kind))===w;return u&&!c.constraints.some(_)?null:k("section",{"aria-label":w==="typography"?"Typography constraints":F==="layout"?"Layout constraints":"Color constraints",children:[i("h3",{children:w==="typography"?"Typography":F==="layout"?"Layout":"Color"}),i("datalist",{id:`${Je}-${w}`,children:c.constraints.filter(S=>S.kind===F).map(S=>i("option",{value:S.name},S.id))}),c.constraints.filter(_).map((S,Ce,we)=>{let G=S.kind,oe=c.constraints.filter(O=>!nr(c.constraints,S.id,O.id)).map(O=>O.name),Ve=c.constraints.find(O=>O.id===S.parentId),Se=!!S.parentId,He=ve.some(O=>!!O.active&&(O.port==="source"&&O.id===S.id||O.port==="target"&&O.validTarget&&O.target===S.id)),Te=ve.some(O=>!!O.active&&(O.port==="target"&&O.id===S.id||O.port==="source"&&O.validTarget&&O.target===S.id)),fe=x?.active&&x.validTarget?x.port==="source"&&x.target===S.id?x.id:x.port==="target"&&x.id===S.id?x.target:null:null,dt=c.constraints.find(O=>O.id===fe)?.name,nt=!!x?.active&&x.port==="source"&&!Se&&!Te&&!nr(c.constraints,S.id,x.id),it=fe?Gr(c.constraints,S.id,fe):S.derivative,Ue=Se||Te||!!S.value,ie=i(gi,{row:S,background:h.surface,constraints:fe?V.map(O=>O.id===S.id?{...O,parentId:fe,derivative:it}:O):V}),ct=O=>{if(!O){B(null),S.parentId?P({...c,constraints:Zn(c.constraints,S.id)}):tt(S.id,{value:""});return}let je=c.constraints.find(ot=>ot.name.toLowerCase()===O.replace(/^@/,"").toLowerCase());if(!je)throw Error("Choose an existing constraint");De(S.id,je.id)};return k(oa,{children:[S.typographyRole&&we[Ce-1]?.typographyRole!==S.typographyRole&&i("h4",{className:"tc-type-role","data-typography-role":S.typographyRole,style:gn,children:S.typographyRole==="body"?"Body":"Heading"}),k("div",{"data-typography-role":S.typographyRole,className:"tc-row","data-constraint-id":S.id,onPointerEnter:()=>R(S.id),onPointerLeave:()=>R(null),onFocusCapture:()=>de(S.id),onBlurCapture:O=>{O.currentTarget.contains(O.relatedTarget)||de(null)},"data-proposal-status":l?S.value||S.parentId?"done":"pending":void 0,children:[S.typographyRole&&i(mn,{left:-8,color:`color-mix(in srgb, ${h.secondary} 40%, ${h.surface})`,last:we[Ce+1]?.typographyRole!==S.typographyRole}),i("button",{type:"button",disabled:b,className:"tc-name","data-connection-active":He,"data-connection-rejected":X===S.id,"aria-label":`Drag ${S.name} to connect`,onPointerDown:O=>Nt(O,S.id,"source"),onPointerEnter:()=>M({id:S.id,port:"source"}),onPointerLeave:()=>M(null),children:i("span",{style:H?.port==="source"&&S.parentId===H.id?{color:"var(--tc-primary)"}:void 0,children:S.typographyRole?S.name.replace(`${S.typographyRole}-`,""):S.name})}),(b||l==="error")&&!S.value&&!S.parentId?i("span",{className:"tc-proposal-status",role:"status","data-state":"pending","aria-label":`${S.name}: ${l==="error"?"Not returned":"Pending"}`,children:l==="error"?"Not returned":"Pending"}):i("div",{inert:b,style:{display:"contents"},children:k(Tn,{className:"tc-value",label:`${S.name} expression`,onCommit:O=>{let[je="",ot,...Qe]=O.split("\u21C6");if(Qe.length)throw Error("Use one scale value");let[W="",Z,...ce]=je.split("\xD7");if(ce.length)throw Error("Use one multiplier or rotation");let ye={};if(W.trim().startsWith("@")){let se=W.trim().slice(1).trim(),Be=c.constraints.find(ne=>ne.name.toLowerCase()===se.toLowerCase());if(!Be)throw Error("Choose an existing constraint");let kt=nr(c.constraints,S.id,Be.id);if(kt)throw Error(kt);if(ye.parentId=Be.id,ye.derivative=Z===void 0?S.derivative:at(Z.trim().replace(/deg$/,"")),G==="layout"&&ye.derivative<0)throw Error("Use zero or a positive multiplier")}else{if(Z!==void 0)throw Error("A multiplier needs a source reference");W.trim()&&Zr(G,W.trim()),ye.value=W.trim(),ye.parentId=null}if(ot!==void 0&&(ye.scale=at(ot.trim())/(G==="color"?100:1),G==="layout"&&(S.scaleMode==="increment"?ye.scale<=0:ye.scale<0)))throw Error("Use a nonnegative growth rate or a positive weight increment");tt(S.id,ye)},onPointerEnter:()=>M({id:S.id,port:"target"}),onPointerLeave:()=>M(null),children:[Se||Te?k("span",{className:"tc-reference","data-connection-active":Te,onContextMenu:O=>{S.parentId&&(O.preventDefault(),O.stopPropagation(),ct(""))},children:[i("button",{className:"tc-port","aria-label":`Connect ${S.name} to parent`,onPointerDown:O=>Nt(O,S.id,"target"),onClick:O=>{Ee.current||O.currentTarget.parentElement?.querySelector("input")?.focus()},children:"@"}),i(st,{compact:!0,label:`${S.name} parent reference`,sourceSuggestions:oe,bareSource:!0,arrowNavigation:!0,value:dt??(Se?Ve?.name??"":""),onCommit:ct})]}):k(Le,{children:[nt&&i("span",{className:"tc-reference tc-available","data-connection-available":!0,"aria-hidden":"true",children:"@"}),(!nt||!!S.value)&&i(st,{compact:!0,label:`${S.name} base value`,sourceSuggestions:oe,arrowNavigation:!0,value:S.value,onScrubPreview:O=>ge(O===null?null:{id:S.id,patch:{value:O}}),placeholder:"\u2013",scrub:G==="layout"?{step:1,min:0}:G==="color"?{step:1,compound:!0}:void 0,clearable:!0,onCommit:O=>{O.startsWith("@")?ct(O):(O&&Zr(G,O),tt(S.id,{value:O}))}})]}),G!=="font"&&(Se||Te)&&k(Le,{children:[i("span",{className:"tc-separator","aria-hidden":"true","data-value-text":" \xD7 ",children:i(St,{size:12})}),i(st,{compact:!0,label:`${S.name} derivative`,arrowNavigation:!0,onScrubPreview:O=>ge(O===null?null:{id:S.id,patch:{derivative:Number(O.replace(/deg$/,""))}}),decimal:G==="layout",scrub:G==="color"?{step:1,shiftStep:5}:{step:.01,min:0},value:G==="color"?`${it}deg`:it.toFixed(2),onCommit:O=>{let je=at(G==="color"?O.replace(/deg$/,""):O);if(G==="layout"&&je<0)throw Error("Use zero or a positive multiplier");tt(S.id,{derivative:je})}})]}),G!=="font"&&Ue&&k(Le,{children:[i("span",{className:"tc-separator","aria-hidden":"true","data-value-text":" \u21C6 ",children:i(rn,{size:12})}),i(st,{compact:!0,label:`${S.name} scaling`,title:G==="color"?"OKLCH lightness points per step":S.scaleMode==="increment"?"Weight units per step":"Growth per step: 0.75 means +75%; stepped results round to the nearest whole number",arrowNavigation:!0,onScrubPreview:O=>ge(O===null?null:{id:S.id,patch:{scale:Number(O)/(G==="color"?100:1)}}),decimal:G==="color"?1:S.scaleMode!=="increment",scrub:S.scaleMode==="increment"?{step:1,min:1,shiftStep:5}:G==="color"?{step:.1,shiftStep:.5}:{step:.01,min:0},value:G==="layout"&&S.scaleMode!=="increment"?S.scale.toFixed(4).replace(/0{1,2}$/,""):(S.scale*(G==="color"?100:1)).toFixed(G==="color"?1:S.scaleMode==="increment"?0:2),onCommit:O=>{let je=at(O)/(G==="color"?100:1);if(G==="layout"&&(S.scaleMode==="increment"?je<=0:je<0))throw Error("Use a nonnegative growth rate or a positive weight increment");tt(S.id,{scale:je})}})]}),G==="color"&&ie]})})]},S.id)]},S.id)})]},w)}),k("section",{"aria-label":"Ad-hoc tokens",inert:b,children:[i("h3",{children:"Tokens"}),c.tokens.filter(w=>!u||u.tokenIds.includes(w.id)).map(w=>{let F=`token:${w.id}`,_=Ot(w.value,c.constraints),S=x?.port==="source"?x.target:x?.id,Ce=x?.active&&x.validTarget&&S&&xt(S).row===F?x.port==="source"?x.id:x.target:null,we=c.constraints.find(W=>W.id===Ce),G=we?Pr(w.value,we,c.constraints,xt(S).index,xt(S).dimensionIndex)??w.value:J?.id===w.id?J.value:w.value,oe=Ot(G,c.constraints),Ve=!!rr(G),Se=Dr(G,c.constraints),He=W=>ve.some(Z=>Z.active&&(Z.port==="target"?Z.id===W:Z.validTarget&&Z.target===W)),Te=x?.active&&x.port==="source"&&c.constraints.find(W=>W.id===x.id)?.kind==="layout"?(Se?.dimensions??[]).flatMap((W,Z)=>W.referenceIndex===void 0&&!oe.some(ce=>ce.start>=W.start&&ce.end<=W.end)?[{...W,index:Z}]:[]):[],fe=x?.active&&x.port==="source"&&!He(F)&&!ze(F,x.id),dt=fe?Qr(G,c.constraints).find(W=>!W.reference):void 0,nt=dt&&(dt.start>0||dt.end<G.length)?dt:void 0,it=i("span",{className:"tc-reference tc-available","data-connection-available":!0,"aria-hidden":"true",children:"@"},"available"),Ue=(W,Z)=>{let ce=_[W];return ce?w.value.slice(0,ce.start)+Z+w.value.slice(ce.end):Z},ie=(W,Z)=>{let ce={..._[W]??oe[W],...Z};return Ue(W,`@${ce.name}${ce.step===null||ce.step===0?"":`: ${ce.step}`}${ce.opacity===void 0?"":` / ${ce.opacity}`}`)},ct=(W,Z)=>{let ce=Se?.dimensions.findIndex((ee,$e)=>ee.start===W.start&&He(`${F}:dim:${$e}`)),ye=we?.kind==="color"&&S===F&&Qr(w.value,c.constraints)[0]?.start===W.start?F:ce!==void 0&&ce>=0?`${F}:dim:${ce}`:Ve?F:`${F}:ref:${Z}`,se=Ve?w.name:`${w.name} mention ${Z+1}`,Be=c.constraints.find(ee=>ee.name.toLowerCase()===W.name.toLowerCase()),kt=He(ye)||He(F),ne=ae?.id===w.id&&ae.index===Z?ae:null,ut=!!ne||W.step!==null&&W.step!==0||J?.id===w.id&&_[Z]?.step!=null&&_[Z]?.step!==0;return k("span",{className:"tc-reference","data-connection-id":ye,"data-connection-active":kt,onBlur:ee=>{ne&&!ee.currentTarget.contains(ee.relatedTarget)&&he(null)},onPointerEnter:()=>M({id:ye,port:"target"}),onPointerLeave:()=>M(null),onContextMenu:ee=>{ee.preventDefault(),ee.stopPropagation(),B(null);let $e=_[Z],Ct=$e&&br(c.constraints,w.value.slice($e.start,$e.end));qe(w.id,Ue(Z,$e?.math?en(`calc(${w.value.slice($e.start,$e.end)})`,c.constraints)?.css??"":Ct?mt(Ct):""))},children:[i("button",{className:"tc-port","aria-label":`Connect ${se} to constraint`,onPointerDown:ee=>Nt(ee,ye,"target"),onClick:ee=>{Ee.current||ee.currentTarget.parentElement?.querySelector("input")?.focus()},children:"@"}),i(st,{compact:!0,label:`${se} reference`,sourceSuggestions:c.constraints.filter(ee=>!ze(ye,ee.id)).sort((ee,$e)=>+($e.kind===Be?.kind)-+(ee.kind===Be?.kind)).map(ee=>ee.name),bareSource:!0,arrowNavigation:!0,value:ne?.name??W.name,onDraftChange:ee=>{if(ut||!ee.endsWith(":"))return!1;let $e=ee.slice(0,-1).trim().replace(/^@/,"");return rr(`@${$e}`)?(he({id:w.id,index:Z,name:$e}),!0):!1},onCommit:ee=>{if(!ee){qe(w.id,Ue(Z,""));return}let $e=rr(ee.startsWith("@")?ee:`@${ee}`);if(!$e)throw new Error("Use a source name with an optional : step");qe(w.id,ie(Z,{name:$e.name,...ee.includes(":")?{step:$e.step}:{},...ee.includes("/")?{opacity:$e.opacity}:{}}))}}),ut&&k(Le,{children:[k("span",{"aria-hidden":"true",children:[":","\xA0"]}),i(st,{compact:!0,className:"tc-token-step",label:`${se} step`,arrowNavigation:!0,value:ne||W.step===null?"":String(W.step),placeholder:"step",autoFocus:!!ne,onCancel:()=>he(null),scrub:{step:1,defaultValue:0},onScrubPreview:ee=>pe(ee===null?null:{id:w.id,value:ie(Z,{...ne?{name:ne.name}:{},step:at(ee)})}),onCommit:ee=>{qe(w.id,ie(Z,{...ne?{name:ne.name}:{},step:ee?at(ee):null})),he(null)}})]}),(Be?.kind==="color"||W.opacity!==void 0)&&k(Le,{children:[k("span",{className:"tc-opacity-separator","aria-hidden":"true",children:[" ","/"," "]}),i(st,{compact:!0,label:`${se} opacity`,arrowNavigation:!0,className:"tc-token-opacity",value:W.opacity??"1",scrub:{step:W.opacity?.endsWith("%")?1:.01,min:0,max:W.opacity?.endsWith("%")?100:1,shiftStep:W.opacity?.endsWith("%")?5:.05},onScrubPreview:ee=>pe(ee===null?null:{id:w.id,value:ie(Z,{opacity:ee})}),onCommit:ee=>{if(ee&&Qn(ee)===null)throw Error("Use opacity from 0 to 1, or 0% to 100%");qe(w.id,ie(Z,{opacity:ee||void 0}))}})]})]},Z)},O=[],je=(W,Z)=>{if(Z<=W)return;let ce=W,ye=[...nt?[{...nt,index:-1,dimension:"color"}]:[],...Te].filter(se=>se.start>=W&&se.start<Z).sort((se,Be)=>se.start-Be.start);for(let se of ye)ot(ce,se.start),se.index===-1?(O.push(it),ce=se.start):(O.push(k("span",{className:"tc-shadow-dimension","data-connection-id":`${F}:dim:${se.index}`,"data-shadow-dimension":se.dimension,children:[it,i("button",{className:"tc-literal","aria-label":`Edit ${w.name} ${se.dimension}`,onClick:()=>U(w.id),children:G.slice(se.start,se.end)})]},`dimension-${se.index}`)),ce=se.end);ot(ce,Z)},ot=(W,Z)=>{if(Z<=W)return;let ce=ye=>G.slice(0,W)+ye+G.slice(Z);O.push(i(hi,{className:`tc-literal${Z===nt?.start?" tc-literal-prefix":""}`,label:`Edit ${w.name} value`,onEdit:()=>U(w.id),value:G.slice(W,Z),onPreview:ye=>pe(ye===null?null:{id:w.id,value:ce(ye)}),onCommit:ye=>qe(w.id,ce(ye))},`text-${W}`))},Qe=0;return oe.forEach((W,Z)=>{je(Qe,W.start),O.push(ct(W,Z)),Qe=W.end}),je(Qe,G.length),k("div",{className:"tc-row","data-token-id":w.id,"data-token-value":G,children:[i(st,{label:`${w.name} name`,className:We.has(F)?"tc-derived-name-active":void 0,compact:!0,value:w.name,onDelete:u?void 0:()=>{B(null),P({...c,tokens:c.tokens.filter(W=>W.id!==w.id)})},onCommit:W=>{if(!W)throw Error("Give this token a name");P({...c,tokens:c.tokens.map(Z=>Z.id===w.id?{...Z,name:W}:Z)})}}),k(Tn,{className:"tc-value",label:`${w.name} expression`,onSelectionStart:()=>he(null),onCommit:W=>qe(w.id,W),onPointerEnter:()=>M({id:F,port:"target"}),onPointerLeave:()=>M(null),children:[(oe.length>0||nt||Te.length>0)&&Q!==w.id?i("span",{className:"tc-compound",onDoubleClick:W=>{W.target.closest("input, .tc-port")||U(w.id)},children:O}):k("span",{className:He(F)?"tc-reference":"tc-compound","data-connection-active":He(F),children:[fe&&!nt&&it,i(st,{compact:!0,label:`${w.name} value`,sourceSuggestions:c.constraints.map(W=>W.name),scrub:{step:1,shiftStep:5,compound:!0},onScrubPreview:W=>pe(W===null?null:{id:w.id,value:W}),clearable:!0,autoFocus:Q===w.id,value:G,placeholder:"\u2013",onCommit:W=>{qe(w.id,W),U(null)}})]}),i(fi,{value:G,background:h.surface,constraints:V,name:w.name})]})]},w.id)}),!u&&k("button",{className:"tc-add-token","aria-label":"Add token",onClick:()=>P({...c,tokens:[...c.tokens,{id:Me(),name:`Token ${c.tokens.length+1}`,value:""}]}),children:[i(Ft,{size:12}),"Add token"]})]}),f,(v||Ye)&&i("p",{role:"status",style:{margin:0,padding:10,borderRadius:8,background:h.control,textAlign:"center"},children:v||Ye})]}),C,d?k("div",{className:"tc-proposal-recovery",children:[k("p",{role:"alert",children:[d.message," Values already received are kept above."]}),k("nav",{"aria-label":"Proposal recovery",children:[i("button",{type:"button",onClick:d.onRetry,children:"Retry"}),i("button",{type:"button",onClick:d.onTemplate,children:"Use template"})]})]}):u?null:i("button",{className:"tc-save",disabled:y,onClick:()=>b?o():g?g(c):I("Prototype only \u2014 your taste has not been saved"),children:b?"Cancel proposal":y?"Saving\u2026":"Save this taste"}),i(pi,{pane:p,edges:ue,visible:me.map(w=>({parent:w.id,child:w.target})),suspended:!!x||!!E,revision:JSON.stringify([c,te,J,Q,x?.id,x?.target,x?.validTarget]),color:h.primary}),(x?[x]:E?[E]:[]).filter(w=>w.active).map(w=>i(mi,{drag:w,pane:p,color:h.primary},`${w.id}:${w.target}`))]})}function vi(e,t){let r=e.ownerDocument.defaultView;if(!r||!t.isConnected)return!1;let n=t.getBoundingClientRect();if(n.width<=0||n.height<=0||n.top<0||n.bottom>r.innerHeight||n.left<0||n.right>r.innerWidth)return!1;for(let s=t;s;s=s.parentElement){let l=r.getComputedStyle(s);if(l.display==="none"||l.visibility==="hidden"||l.visibility==="collapse")return!1;if(s!==t){let a=s.getBoundingClientRect();if(/(auto|scroll|hidden|clip)/.test(l.overflowY)&&(n.top<a.top||n.bottom>a.bottom)||/(auto|scroll|hidden|clip)/.test(l.overflowX)&&(n.left<a.left||n.right>a.right))return!1}if(s===e)break}let o=e.querySelector(".tc-dimension-preview");if(o){let s=o.getBoundingClientRect();if(s.width>0&&s.height>0&&n.bottom>s.top-16&&n.top<s.bottom+4&&n.right>s.left-4&&n.left<s.right+4)return!1}return!0}function yi(e,t){if(!t)return e.querySelector("[data-taste-editor] header");let r=t.kind==="dimension"?"data-constraint-id":"data-token-id";return[...e.querySelectorAll(`[${r}]`)].find(n=>n.getAttribute(r)===t.id)??null}function bi({root:e,session:t,visible:r=!0}){let n=wr(t.subscribeLook,t.getLookSnapshot,t.getLookSnapshot),[o,s]=T(null);return Pe(()=>{let l=e.current;if(!r||!l||!n||n.expiresAt<=Date.now()){s(null);return}let a=l.ownerDocument.defaultView,d,f=()=>{if(n.expiresAt<=Date.now()){s(null);return}let u=yi(l,n.target),g=u&&vi(l,u)?u:null;g instanceof HTMLElement&&na(g,g),s(y=>y?.lookId===n.id&&y.element===g?y:{lookId:n.id,element:g}),d=a.requestAnimationFrame(f)};return f(),()=>a.cancelAnimationFrame(d)},[e,n,r]),!r||!n||o?.lookId!==n.id||!o.element||n.expiresAt<=Date.now()?null:i(Vr,{element:o.element,engaged:!1,label:n.target?`AI is looking at this ${n.target.kind}`:"AI is looking at this Taste",inverse:!0},n.id)}function wi(e,t){t=Vt(t,e);let r=new Map,n=s=>{let l=t.constraints.find(a=>a.id===s);return l?l.parentId?`@${t.constraints.find(a=>a.id===l.parentId)?.name??l.parentId}${l.kind==="font"?"":l.kind==="color"?` \xB7 hue ${l.derivative}\xB0`:` \xD7 ${l.derivative}`}`:l.value:"Missing dimension"},o=s=>{let l=s.children.filter(a=>typeof a=="string").join(" ").trim();for(let[a,d]of Object.entries(s.styles)){let f=`${d.kind}:${d.id}:${d.step??0}`,u=r.get(f);if(!u){let y=d.kind==="token"?t.tokens.find(h=>h.id===d.id):void 0,v=d.kind==="dimension"?t.constraints.find(h=>h.id===d.id):void 0,C=[],c=new Set(d.kind==="dimension"?[d.id]:[]),b=h=>{if(c.has(h))return;c.add(h);let p=t.constraints.find(N=>N.id===h);if(!p)return;let m="Unresolved";try{m=mt(Tt(t.constraints,h))}catch{}C.push({id:h,name:p.name,expression:n(h),value:m}),p.parentId&&b(p.parentId)};y&&Ot(y.value,t.constraints).forEach(h=>{let p=t.constraints.find(m=>m.name===h.name);p&&b(p.id)}),v?.parentId&&b(v.parentId),u={key:f,source:d,name:y?.name??v?.name??d.id,expression:y?.value??n(d.id),derived:C.length>0,dependencies:C,values:[],targets:[]},r.set(f,u)}let g=Yt(t,d,a)??"Unresolved";u.values.includes(g)||u.values.push(g),u.targets.push({nodeId:s.id,label:l.slice(0,64)||`${s.tag} \xB7 ${s.id}`,property:a})}s.children.forEach(a=>{typeof a!="string"&&o(a)})};return o(e.root),[...r.values()]}function xi({fragment:e,draft:t,theme:r,onBack:n,onChange:o}){let s=D(null),[l,a]=T(null),d=wi(e,t),f=[...new Set(d.flatMap(c=>[...c.source.kind==="dimension"?[c.source.id]:[],...c.dependencies.map(b=>b.id)]))],u=d.filter(c=>c.source.kind==="token").map(c=>c.source.id),g=d.filter(c=>l&&(c.source.kind===l.kind&&c.source.id===l.id||l.kind==="dimension"&&c.dependencies.some(b=>b.id===l.id))).flatMap(c=>c.targets.map(b=>b.nodeId)),y=[],v=c=>{let b=Object.entries(c.localStyles??{});b.length&&y.push({id:c.id,entries:b}),c.children.forEach(h=>{typeof h!="string"&&v(h)})};v(e.root),le(()=>{s.current?.querySelector("button")?.focus()},[e.id]);let C=Ge[r];return i("section",{ref:s,"aria-label":`${e.name} details`,"data-fragment-detail":!0,"data-popmelt-panel":!0,style:{position:"absolute",inset:0,display:"flex"},children:i(zn,{draft:Vt(t,e),theme:r,onBack:n,style:{flex:1,minHeight:0,border:0,maxHeight:"100%"},onChange:c=>{let b=new Set((e.tokens??[]).map(h=>h.id));o({...t,constraints:c.constraints,tokens:c.tokens.filter(h=>!b.has(h.id)),fragments:t.fragments?.map(h=>h.id===e.id?{...h,tokens:c.tokens.filter(p=>b.has(p.id))}:h)})},detail:{name:e.name,constraintIds:f,tokenIds:u,onHover:a,preview:c=>i("div",{style:{position:"sticky",top:16,zIndex:1,flexShrink:0,borderRadius:8,background:C.control},children:i(ir,{fragment:{...e,tokens:[]},draft:c,height:240,highlightedNodes:g})})},fragments:k(Le,{children:[i("button",{type:"button","aria-pressed":t.featuredComponentId===e.id,onClick:()=>o({...t,featuredComponentId:e.id}),children:t.featuredComponentId===e.id?"Featured preview":"Use as preview"}),k("details",{children:[i("summary",{children:"Affected parts"}),d.map(c=>k("details",{"data-fragment-use":c.key,children:[k("summary",{children:[c.name,c.source.step?`: ${c.source.step}`:""," \xB7"," ",new Set(c.targets.map(b=>b.nodeId)).size," ","parts"]}),c.targets.map(b=>k("div",{children:[b.label," \xB7 ",b.property]},`${b.nodeId}:${b.property}`))]},c.key))]}),y.length>0&&k("details",{children:[i("summary",{children:"Local structure"}),y.map(c=>k("section",{children:[i("h3",{children:c.id}),c.entries.map(([b,h])=>k("div",{className:"tc-row",children:[i("span",{className:"tc-name",children:b}),i("span",{className:"tc-value",children:h})]},b))]},c.id))]})]})})})}function ki(e){let t=D(null),[r,n]=T(null),o=D(null),[s]=T(()=>{let b=vr(e.draft);return e.draft||b.create("extract"),b}),l=e.session??s,a=wr(l.subscribe,l.getSnapshot,l.getSnapshot),{draft:d,state:f,message:u,runId:g}=a,y=d?.fragments?.find(b=>b.id===r);Pe(()=>{y||o.current?.isConnected&&(o.current.focus({preventScroll:!0}),o.current=null)},[y]);let v=D(e.onDraft),C=D(null);v.current=e.onDraft,le(()=>{if(l.getSnapshot().state!=="running")return;let b=Symbol();C.current=b;let h=x=>l.stream(g,{draft:x}),p=x=>l.stream(g,{state:x}),m=x=>l.stream(g,{message:x}),N=new AbortController,A=setTimeout(()=>{m("This is taking longer than expected. Please try again or use the template."),p("error"),N.abort()},19e4),P=!1,q;return(async()=>{try{if(await Promise.resolve(),N.signal.aborted)return;if(!e.bridgeUrl)throw Error("Connect the local bridge to propose a taste.");let x=ei(),j=await Ne(`${e.bridgeUrl}/cloud-taste/propose`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x),signal:N.signal});if(!j.ok)throw Error((await j.json().catch(()=>null))?.error||`Taste proposal unavailable (${j.status}).`);if(!j.body)throw Error("The bridge returned no proposal stream.");let E=j.body.getReader(),B=new TextDecoder,H="",M=L=>{if(!L.trim()||N.signal.aborted)return;let R=JSON.parse(L);if(R.type==="status"&&m(R.message),R.type==="error")throw q=R.message,Error(R.message);R.type==="progress"?h(R.draft):R.type==="complete"&&(P=!0,h(R.draft),v.current(R.draft),p("complete"))};try{for(;;){let{value:L,done:R}=await E.read();if(R)break;if(H+=B.decode(L,{stream:!0}),H.length>256e3)throw Error("The proposal stream is too large.");let K;for(;(K=H.indexOf(`
186
+ `))!==-1;)M(H.slice(0,K)),H=H.slice(K+1)}M(H+B.decode())}finally{E.releaseLock()}if(!P&&!N.signal.aborted)throw Error("The proposal ended before all dimensions were returned.")}catch(x){N.signal.aborted||(m(q??(x instanceof Error&&/template|dimensions were returned/.test(x.message)?x.message:"We couldn\u2019t finish the proposal. Please try again or use the template.")),p("error"),N.abort())}finally{clearTimeout(A)}})(),()=>{clearTimeout(A),N.abort(),Promise.resolve().then(()=>{C.current===b&&l.stream(g,{state:"error",message:"Extraction stopped. Retry or continue editing the partial draft."})})}},[e.bridgeUrl,g,l]);let c=Ge[e.theme];return k("div",{ref:t,style:{...e.style,display:"flex",flexDirection:"column",background:c.surface,color:c.primary,fontFamily:Wt,borderRadius:20,overflow:"hidden",position:"relative",minHeight:0},children:[i("div",{inert:!!y||e.saving,style:{display:"flex",flex:1,minHeight:0,visibility:y?"hidden":void 0,opacity:y?0:void 0},children:i(zn,{history:l.history,theme:e.theme,draft:d??Jr(),onChange:b=>{l.edit(b),e.onDraft(b)},onBack:e.onBack,onSave:e.onSave,saving:e.saving,saveNotice:e.saveNotice,saveAction:e.saveAction,proposalState:f==="idle"?"complete":f,preferPageComponent:a.mode==="extract",fragments:i(Ea,{draft:d??Jr(),session:l,bridgeUrl:e.bridgeUrl,theme:e.theme,visible:e.visible!==!1&&!e.saving,onDraft:e.onDraft,onInspect:b=>{o.current=document.activeElement instanceof HTMLElement?document.activeElement:null,n(b)}},g),proposalRecovery:f==="error"?{message:u,onRetry:()=>{l.create("extract")},onTemplate:e.onTemplate}:void 0,style:{flex:1,minHeight:0,border:0}},g)}),y&&d&&i(xi,{fragment:y,draft:d,theme:e.theme,onBack:()=>n(null),onChange:b=>{l.edit(b),e.onDraft(b)}},y.id),i(bi,{root:t,session:l,visible:e.visible})]})}var ur="popmelt:taste-recovery:v1:",Zt=e=>typeof e=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e),Ci=e=>Number.isSafeInteger(e)&&Number(e)>=0;function Wr(e){if(!(!Zt(e.accountId)||!["production","staging"].includes(String(e.environment))||typeof e.projectKey!="string"||!e.projectKey||e.projectKey.length>256))return JSON.stringify([e.environment,e.accountId,e.projectKey])}function Dn(e,t){if(!e||typeof e!="object")return;let r=e;if(!(r.version!==1||r.scope!==t||!Zt(r.key)||!Zt(r.id)||!Ci(r.revision)||!Number.isFinite(r.updatedAt)||!It(r.document))&&!(r.pending!==null&&(!r.pending||r.pending.id!==r.id||r.pending.expectedRevision!==r.revision||!Zt(r.pending.requestId)||!It(r.pending.document))))return r}function Pn(e,t=localStorage){let r=[];for(let n=0;n<t.length;n++){let o=t.key(n);if(!o?.startsWith(ur))continue;let s=t.getItem(o);if(!(!s||s.length>45e5))try{let l=Dn(JSON.parse(s),e);l&&o===ur+l.key&&r.push(l)}catch{}}return r.sort((n,o)=>o.updatedAt-n.updatedAt)}function jn(e,t=localStorage){if(!Dn(e,e.scope))throw Error("Invalid recovery record");let r=JSON.stringify(e);if(r.length>45e5)throw Error("Recovery record too large");t.setItem(ur+e.key,r)}function Bn(e,t=localStorage){if(!Zt(e))throw Error("Invalid recovery key");t.removeItem(ur+e)}function Si({theme:e,records:t,onResume:r}){let n=Ge[e];return t.length?k("section",{"aria-label":"Unsaved tastes","data-taste-recovery":!0,style:{display:"flex",flexDirection:"column",gap:8,marginBottom:24,color:n.secondary},children:[i("style",{children:`
187
+ [data-taste-recovery] button:focus-visible {
188
+ outline: 2px solid ${n.primary};
189
+ outline-offset: 4px;
190
+ }
191
+ [data-taste-recovery] button:hover [data-recovery-name],
192
+ [data-taste-recovery] button:focus-visible [data-recovery-name] {
193
+ color: ${n.primary};
194
+ }
195
+ `}),i("h3",{style:{margin:0,font:"inherit",fontWeight:500,lineHeight:"14px",letterSpacing:"-.12px"},children:"Unsaved"}),i("ul",{style:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:16},children:t.map(o=>{let s=o.name||"Untitled Taste",l=o.preview?.savedDocument?.document;return k("li",{style:{minWidth:0,position:"relative"},children:[i("div",{"aria-hidden":"true",inert:!0,style:{position:"relative",height:104,overflow:"hidden",borderRadius:8,background:n.control},children:l?.draft.featuredComponentId?i(Er,{document:l}):o.preview?i(Ar,{recipe:o.preview}):null}),k("button",{type:"button","aria-label":`View ${s} details`,title:`Resume ${s}`,onClick:()=>r(o.key),style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:16,width:"100%",marginTop:-104,padding:"108px 0 0",position:"relative",border:0,borderRadius:8,background:"transparent",color:"inherit",font:"inherit",lineHeight:1.3,letterSpacing:".12px",textAlign:"left",cursor:"pointer"},children:[i("span",{"data-recovery-name":!0,style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500},children:s}),i("span",{style:{flexShrink:0,color:n.muted},children:o.pending?"Save unconfirmed":"Draft"})]})]},o.key)})})]}):null}function $i({theme:e,pending:t,disabled:r=!1,onDiscard:n}){let o=Ge[e];return k("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"8px 16px",fontSize:12},children:[i("p",{style:{margin:0,color:o.secondary,lineHeight:1.4},children:t?"Save unconfirmed. Discard removes this browser draft; any remote save is unchanged.":"Unsaved work on this browser. Discard removes this draft."}),i("button",{type:"button",disabled:r,onClick:n,style:{font:"inherit",color:o.primary,background:o.control,padding:8,border:0,borderRadius:8,cursor:r?"default":"pointer",opacity:r?.5:1},children:"Discard draft"})]})}var Wn=new WeakMap;function qr(e){let[t,r]=T(!1),[n,o]=T(null),[s,l]=T(!1),[a,d]=T(!1),[f,u]=T(null),[g,y]=T(null),v=D({}),C=Ge[e.theme],c=D(!1),b=()=>{let x=e.session??v.current,j=e.session?.getSnapshot().runId??"",E=Wn.get(x);return(!E||E.runId!==j)&&(E={runId:j,recoveryKey:e.recovery?.key??crypto.randomUUID(),id:e.recovery?.id??e.saved?.id??crypto.randomUUID(),revision:e.recovery?.revision??e.saved?.revision??0,pending:e.recovery?.pending??null,recoveryScope:e.recovery?.scope??e.recoveryScope},Wn.set(x,E)),E},h=(x,j)=>{x.recoveryScope&&(jn({version:1,key:x.recoveryKey,scope:x.recoveryScope,updatedAt:Date.now(),id:x.id,revision:x.revision,document:j,pending:x.pending}),e.onRecoveryChange?.())},p=x=>{x.recoveryScope&&(Bn(x.recoveryKey),e.onRecoveryChange?.())},m=D(()=>{});m.current=()=>{if(!e.recoveryScope)return;let x=e.session?.getSnapshot(),j=x?.draft??e.draft;if(!j||x?.state==="running")return;let E;try{E=Tr(j)}catch{return}try{let B=b();if(B.recoveryScope&&B.recoveryScope!==e.recoveryScope)return;B.recoveryScope=e.recoveryScope,!B.pending&&!e.recovery&&e.saved&&bt(E)===bt(e.saved.document)?p(B):h(B,E),y(null)}catch{y("Browser recovery storage is unavailable. Keep this tab open until a remote save is confirmed.")}},le(()=>(m.current(),e.session?.subscribe(()=>m.current())),[e.session,e.recoveryScope,e.draft]);let N=async x=>{if(!(c.current||!e.bridgeUrl)){c.current=!0,r(!0),o(null);try{let j=Tr(x),E=b(),B=await Ne(`${e.bridgeUrl}/cloud-taste/status`,{cache:"no-store"});if(!B.ok)throw Error("Could not check the remote connection. Your draft is kept.");let H=await B.json(),M=Wr(H);if(E.recoveryScope&&M!==E.recoveryScope)throw Error("The connected account, project, or environment changed. Reconnect the original account to save this draft.");if(H.canSave!==!0)throw l(!0),Error("Enable remote saving to save this private Taste to your Popmelt account.");l(!1);let L=JSON.stringify([e.bridgeUrl,H.environment,H.accountId]);if(E.identity&&E.identity!==L)throw Error("The connected account or environment changed. Your draft and pending save are kept; reconnect the original account before retrying.");E.identity=L,E.recoveryScope??(E.recoveryScope=M);for(let R=0;R<2;R++){let K=E.pending??{id:E.id,expectedRevision:E.revision,requestId:crypto.randomUUID(),document:j};E.pending=K;try{h(E,j)}catch{throw Error("Could not protect this save in browser recovery storage. No remote request was sent. Keep this tab open and free browser storage before retrying.")}let de=await Ne(`${e.bridgeUrl}/cloud-taste/document`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(K)}),Q=await de.json();if(!de.ok){Q.error==="revision_conflict"&&d(!0),Q.error==="reconnect_required"&&l(!0);let U={create_not_allowed:"Your account cannot save Tastes right now. Check your subscription or account access on Popmelt, then retry. Your draft is kept.",quota_exceeded:"Your account has reached its Taste limit. Remove an unused Taste in Popmelt, then retry. Your draft is kept.",reconnect_required:"Reconnect your Popmelt account and enable remote saving, then retry. Your draft is kept.",invalid_document:"Popmelt could not validate this Taste. Your draft is kept. Update Popmelt and try again; if it still fails, contact support.",request_conflict:"This save request conflicts with an earlier request. Your draft is kept. Contact support before retrying; do not create a duplicate Taste.",revision_conflict:"This Taste changed remotely. Your draft is kept. The remote revision must be reviewed and reconciled before these edits can be saved."};throw Error(Object.hasOwn(U,Q.error)?U[Q.error]:"Remote save failed. Your draft is kept; retry safely.")}if(Q.id!==K.id||Q.revision!==K.expectedRevision+1||!It(Q.document)||bt(Q.document)!==bt(K.document))throw Error("Could not confirm the saved Taste. Your draft is kept; retry safely.");if(E.revision=Q.revision,E.pending=null,h(E,j),bt(K.document)===bt(j)){o("Saved privately to Popmelt. Not applied."),p(E),d(!1),e.onSaved(Q);return}}}catch(j){o(j instanceof Error?j.message:"Remote save failed. Your draft is kept.")}finally{c.current=!1,r(!1)}}},A=async()=>{try{let x=await Ne(`${e.bridgeUrl}/cloud-taste/status`,{cache:"no-store"}),j=await x.json(),E=b();if(!x.ok||E.recoveryScope&&Wr(j)!==E.recoveryScope)throw Error("Reconnect the original account to review this Taste.");let B=await Ne(`${e.bridgeUrl}/cloud-taste/document?id=${encodeURIComponent(E.id)}`,{cache:"no-store"}),H=await B.json();if(!B.ok||H.id!==E.id||!Number.isSafeInteger(H.revision)||H.revision<1||!It(H.document))throw Error("Could not load the saved version. Your draft is kept.");u(H)}catch(x){o(x instanceof Error?x.message:"Could not review the saved version.")}},P=async()=>{try{let x=await Ne(`${e.bridgeUrl}/cloud-taste/creation-eligibility`,{cache:"no-store"});if(!x.ok||(await x.json()).activeSubscription!==!0)throw Error("An active subscription is required to save a new Taste.");let j=b(),E={...j,id:crypto.randomUUID(),revision:0,pending:null},B=e.session?.getSnapshot().draft??e.draft;if(!B)return;h(E,Tr(B)),Object.assign(j,E),d(!1),u(null),o("Your draft is now a new, unsaved Taste. Save explicitly to create the remote copy.")}catch(x){o(x instanceof Error?x.message:"Could not prepare a copy.")}},q={font:"inherit",color:C.primary,background:C.control,padding:8,border:0,borderRadius:8,cursor:"pointer"};return i(ki,{...e,onSave:x=>{a||N(x)},saving:t,saveNotice:n??g,saveAction:k(Le,{children:[e.recovery&&i($i,{theme:e.theme,pending:!!b().pending,disabled:t,onDiscard:()=>{if(!c.current)try{p(b()),e.onBack()}catch{o("Could not discard browser recovery. Your draft is kept.")}}}),a?k("div",{style:{padding:12,color:C.primary},children:[i("p",{children:"Your draft is retained. Review the saved version before choosing what to keep."}),i("button",{style:q,onClick:()=>{A()},children:"Review saved version"}),f&&k(Le,{children:[k("p",{children:["Saved revision ",f.revision," \xB7"," ",f.document.draft.name]}),i(Sn,{draft:f.document.draft,theme:e.theme,preferPageComponent:!0}),i("button",{style:q,onClick:()=>{try{let x=b();x.id=f.id,x.revision=f.revision,x.pending=null,e.session?.edit(f.document.draft),p(x),d(!1),u(null),e.onSaved(f)}catch{o("Could not discard the recovery record. Your draft is kept.")}},children:"Discard my edits and load saved version"}),i("button",{style:q,onClick:()=>{P()},children:"Keep my draft as a new Taste"})]})]}):s?i("button",{type:"button",onClick:e.onEnableSaving,style:{font:"inherit",color:C.primary,background:C.control,padding:8,border:0,borderRadius:8,cursor:"pointer"},children:"Enable remote saving"}):void 0]})})}var Ri=class{constructor(){this.entries=new Map}clear(){for(let e of this.entries.values())e.abort.abort();this.entries.clear()}invalidate(e){this.entries.get(e)?.abort.abort(),this.entries.delete(e)}put(e,t){this.invalidate(e),this.entries.set(e,{response:new Response(JSON.stringify(t)),expires:Date.now()+6e4,abort:new AbortController})}async read(e){let t=this.entries.get(e);if(t?.response&&t.expires>Date.now())return t.response.clone();if(t?.pending)return(await t.pending).clone();this.invalidate(e),this.entries.size>=12&&this.invalidate(this.entries.keys().next().value);let r={expires:0,abort:new AbortController};return this.entries.set(e,r),r.pending=Ne(e,{signal:r.abort.signal}).then(async n=>{if(n.ok){let o=await n.clone().json();if(!o.sections||!Array.isArray(o.overrides))throw new Error("Invalid taste definition");this.entries.get(e)===r&&(r.response=n.clone(),r.expires=Date.now()+6e4)}else this.entries.get(e)===r&&this.entries.delete(e);return n}).catch(n=>{throw this.entries.get(e)===r&&this.entries.delete(e),n}).finally(()=>{r.pending=void 0}),(await r.pending).clone()}},Ii={principles:"tokens",components:"components",assets:"visual-directions",content:"copy-guidance"};function Ni(e,t,r){if(t.kind==="search")return e.querySelector(r.searchOpen?"[data-taste-search] input":"[data-taste-search-trigger]");let n=`${t.collection}:${t.id}`;if(!r.showingDetail)return[...e.querySelectorAll("[data-taste-entry-id]")].find(o=>o.getAttribute("data-taste-entry-id")===n)??null;if(r.detailEntryId!==n)return null;if(t.kind==="path"&&r.drilldownVisible&&Ii[t.path[0]??""]===r.drilldown){let o=e.querySelector('[data-taste-layer="drilldown"]'),s=[...o?.querySelectorAll("[data-taste-path]")??[]].find(l=>l.getAttribute("data-taste-path")===JSON.stringify(t.path));if(s)return s;if(t.path.length>=2){let l=[...o?.querySelectorAll("[data-taste-group-path]")??[]].find(a=>a.getAttribute("data-taste-group-path")===JSON.stringify(t.path.slice(0,2)));if(l)return l}}return e.querySelector("[data-taste-nav-title]")}var qn=e=>typeof e=="string"&&e.length>0&&e.length<=200&&!["__proto__","prototype","constructor"].includes(e);function Li(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid Taste looking target");let t=e;if(t.kind==="search"&&typeof t.query=="string"&&t.query.length<=200)return{kind:"search",query:t.query};if((t.kind==="taste"||t.kind==="path")&&(t.collection==="public"||t.collection==="private")&&qn(t.id)){let r={collection:t.collection,id:t.id};if(t.kind==="taste")return{kind:"taste",...r};if(Array.isArray(t.path)&&t.path.length>=1&&t.path.length<=12&&t.path.every(qn)&&["principles","components","assets","content"].includes(t.path[0]??""))return{kind:"path",...r,path:[...t.path]}}throw new Error("Invalid Taste looking target")}var Or=(e,t)=>`${e}:${t}`;function Ti(e){let t=D(e.onDirectionChange);t.current=e.onDirectionChange;let[r,n]=T([]),o=D(null),s=D(null),[l,a]=T(0),[d,f]=T(!1),[u,g]=T(null),[y,v]=T(!1),[C,c]=T(!1),b=wr(Xe.subscribe,Xe.getSnapshot,Xe.getSnapshot),h=b.open,[p,m]=T(null),N=D(new Map),{onEditorVisibilityPinChange:A,visible:P}=e;Pe(()=>(A?.((h||!!p)&&P!==!1),()=>A?.(!1)),[h,p,P,A]);let q=D(null),[x,j]=T(null),[E,B]=T(null),[H,M]=T(),L=()=>{let $=q.current?.offsetHeight;$&&M($),c(!0)},[R,K]=T(!1),de=D(null),Q=D(null),U=D(!1);le(()=>{C?de.current?.focus({preventScroll:!0}):U.current&&Q.current?.focus({preventScroll:!0}),U.current=C},[C]);let ae=()=>{c(!1),ue("")},[he,ue]=T(""),me=D(void 0);le(()=>()=>clearTimeout(me.current),[]);let[We,ve]=T(),[Ee,Ye]=T(!1),[I,te]=T(null),ge=D(void 0),J=$=>{clearTimeout(ge.current),te(e.visible===!1?null:$),ge.current=setTimeout(()=>te(null),200)};le(()=>{e.visible===!1&&(clearTimeout(ge.current),te(null))},[e.visible]),le(()=>()=>clearTimeout(ge.current),[]);let pe=D(void 0);le(()=>()=>clearTimeout(pe.current),[]);let[V,xe]=T(null),X=!!V&&d,[Ke,Je]=T(!1),[Oe,Me]=T(null),[tt,qe]=T(),ze=tt!==void 0?tt:Oe?.direction,De=ze?Or(ze.sourceCollection,ze.sourceModelId):null,[rt,Nt]=T(!1),[pr,hr]=T(!1),[at,w]=T(!1),F=D(null);le(()=>()=>F.current?.abort(),[]);let[_,S]=T(!1),[Ce,we]=T(!0),[G,oe]=T("Loading collection\u2026"),[Ve,Se]=T(0),[He,Te]=T(0),[fe,dt]=T(),[nt,it]=T([]),Ue=tn(()=>{try{it(fe?Pn(fe):[])}catch{it([])}},[fe]);le(()=>{Ue();let $=()=>Ue();return window.addEventListener("storage",$),window.addEventListener("focus",$),()=>{window.removeEventListener("storage",$),window.removeEventListener("focus",$)}},[Ue]),le(()=>{p&&p.record.scope!==fe&&m(null)},[p,fe]);let ie=e.bridgeUrl;le(()=>{let $=new AbortController;return w(!1),Xe.setCreationAllowed(!1),ie&&Ne(`${ie}/cloud-taste/creation-eligibility`,{signal:$.signal,cache:"no-store"}).then(async z=>{let Y=z.ok?await z.json():null;if($.signal.aborted)return;let re=Y?.activeSubscription===!0;w(re),Xe.setCreationAllowed(re)}).catch(()=>{}),()=>{$.abort(),Xe.setCreationAllowed(!1)}},[ie,Ve,He]);let ct=async($,z=!1)=>{let Y=se.current;try{let re=await Ne(`${ie}/cloud-taste/creation-eligibility`,{cache:"no-store"}),be=re.ok?await re.json():null;if(Y!==se.current)return;let ke=be?.activeSubscription===!0;if(w(ke),Xe.setCreationAllowed(ke),!ke)return;ae(),Xe.create($,z)}catch{if(Y!==se.current)return;w(!1),Xe.setCreationAllowed(!1)}},O=D(0),je=D(!1),ot=D(""),Qe=D([]),W=D(void 0),Z=D(void 0),ce=D(!1),ye=D(0),se=D(0);le(()=>{if(!ie||e.visible===!1){j(null);return}let $=!0,z=!1,Y=async()=>{if(!z){z=!0;try{let be=await Ne(`${ie}/cloud-taste/agent-look`,{cache:"no-store"}),ke=await be.json();$&&j(be.ok&&ke.status==="looking"&&ke.expiresAt>Date.now()?Li(ke.target):null)}catch{$&&j(null)}finally{z=!1}}};Y();let re=setInterval(()=>{Y()},750);return()=>{$=!1,clearInterval(re)}},[ie,e.visible]);let Be=Ht(()=>({bridgeUrl:ie,revision:Ve,cache:new Ri}),[ie,Ve]).cache;le(()=>{let $=q.current;if(!$||!x||e.visible===!1){B(null);return}let z=()=>{let re=Ni($,x,{searchOpen:C,showingDetail:X,detailEntryId:V?.id??null,drilldown:u,drilldownVisible:y});B(be=>be===re?be:re)};z();let Y=new MutationObserver(z);return Y.observe($,{childList:!0,subtree:!0}),()=>Y.disconnect()},[x,V,u,y,e.visible,C,X]),le(()=>()=>Be.clear(),[Be]);let[,kt]=T(0),ne=Ht(()=>({bridgeUrl:ie,revision:Ve,requests:new Map}),[ie,Ve]).requests;le(()=>()=>{for(let $ of ne.values())$.abort.abort();ne.clear()},[ne]);let ut=tn($=>{let z=ne.get($.id);if(z&&(z.fetchedAt===void 0||Date.now()-z.fetchedAt<3e4))return z.promise;let Y=new AbortController,[re="",be=""]=$.id.split(":"),ke={preview:z?.preview,facts:z?.facts,abort:Y,promise:Promise.resolve([])};return ke.promise=(async()=>{if(!ie)throw Error("Connection unavailable.");if($.documentRevision){let Re=await Ne(`${ie}/cloud-taste/document?${new URLSearchParams({id:be})}`,{signal:Y.signal,cache:"no-store"});if(!Re.ok)throw Error("Saved Taste unavailable.");let Fe=await Re.json();if(Fe.id!==be||!Number.isSafeInteger(Fe.revision)||Fe.revision<1||!It(Fe.document))throw Error("Invalid saved Taste.");return Y.signal.aborted||(ke.facts=[],ke.fetchedAt=Date.now(),ke.preview={...dr(Fe.document.draft,"dark"),savedDocument:Fe,contentRevision:String(Fe.revision)},kt(gt=>gt+1)),[]}let Bt=await Ne(`${ie}/cloud-taste/summary?${new URLSearchParams({id:be,collection:re})}`,{signal:Y.signal,cache:"no-store"});if(!Bt.ok)throw Error("Summary unavailable.");let lt=await Bt.json();if(!Array.isArray(lt.facts))throw Error("Summary unavailable.");if(!Y.signal.aborted){ke.facts=lt.facts,ke.fetchedAt=Date.now();let Re=wt(lt.preview),Fe=Qe.current.find(gt=>gt.id===$.id)?.preview;ke.preview=Fe&&Fe!==$.preview||Fe&&(Fe.recipeRevision??0)>(Re?.recipeRevision??0)?Fe:Re,kt(gt=>gt+1)}return lt.facts})(),ne.set($.id,ke),ke.promise.catch(()=>{ne.get($.id)===ke&&(z?.preview||z?.facts?ne.set($.id,z):ne.delete($.id))}),ke.promise},[ie,ne]),[ee,$e]=T(null);le(()=>{let $=r.find(Y=>Y.id===De),z=[...$?[$]:[],...["private","public"].flatMap(Y=>r.filter(re=>re.sourceCollection===Y&&re.id!==De))].slice(0,20);for(let Y of z)Y.preview||ut(Y).catch(()=>{})},[De,r,ut]),le(()=>{if(!V||!ie)return;let $=!0;return $e({id:V.id,cache:ne,notice:"Loading details\u2026"}),(async()=>{try{let z=await ut(V);$&&$e({id:V.id,cache:ne,facts:z})}catch{$&&$e({id:V.id,cache:ne,notice:"Summary unavailable. Reopen this taste to retry."})}})(),()=>{$=!1}},[V,ie,ut,ne]),le(()=>{let $=()=>{O.current>0&&!je.current&&!ce.current&&Date.now()-O.current>=3e4&&Te(Y=>Y+1)};if($(),e.visible===!1)return;let z=setInterval($,3e4);return window.addEventListener("focus",$),()=>{clearInterval(z),window.removeEventListener("focus",$)}},[e.visible,e.prefetchSignal]),le(()=>{let $=++se.current,z=ye.current,Y=new AbortController,re;je.current=!0;let be=`${ie}:${Ve}`,ke=ot.current===be&&Qe.current.length>0;ot.current=be,ke||(we(!0),Me(null),qe(void 0),Nt(!1),Je(!1),n([]),Qe.current=[]);async function Bt(){try{if(!ie)throw Error("Connection unavailable.");let lt=await Ne(`${ie}/cloud-taste/status`,{signal:Y.signal,cache:"no-store"});if(!lt.ok)throw Error("Connection unavailable.");let Re=await lt.json();if($!==se.current)return;if(Re.pending){oe("Complete sign-in in the browser."),re=setTimeout(Bt,1e3);return}if(Re.state!=="signed_in"){dt(void 0),N.current.clear(),t.current?.(null),Be.clear(),n([]),Qe.current=[],xe(null);for(let Ae of ne.values())Ae.abort.abort();throw ne.clear(),Error("Sign in to activate a taste.")}if(W.current!==void 0&&(W.current!==Re.accountId||Z.current!==Re.environment)){Be.clear(),N.current.clear(),F.current?.abort(),ve(void 0);for(let Ae of ne.values())Ae.abort.abort();ne.clear(),Qe.current=[],n([]),xe(null)}W.current=Re.accountId,Z.current=Re.environment,dt(Wr(Re)),Re.canInspect||Be.clear();let[Fe,gt,er]=await Promise.all([Ne(`${ie}/cloud-taste/catalog`,{signal:Y.signal,cache:"no-store"}),Ne(`${ie}/cloud-taste/direction`,{signal:Y.signal,cache:"no-store"}),Re.canBrowsePrivate===!0?Ne(`${ie}/cloud-taste/private-catalog`,{signal:Y.signal,cache:"no-store"}):null]);if(!Fe.ok||!gt.ok||er&&!er.ok)throw Error("Could not load tastes. Please retry or reconnect in Settings.");let Fn=await Fe.json(),Kn=er?await er.json():{items:[]},mr=await gt.json();if($!==se.current)return;let tr=["private","public"].flatMap(Ae=>(Ae==="private"?Kn.items:Fn.items).map(Ie=>({id:Or(Ae,Ie.id),sourceModelId:Ie.id,sourceCollection:Ae,thumbnailUrl:Ie.thumbnailUrl,preview:wt(Ie.preview),name:Ie.name,documentRevision:Ie.documentRevision,...Ie.version?{metadata:{value:Ie.version,label:`Version ${Ie.version}`}}:{}}))).sort((Ae,Ie)=>Ae.name.localeCompare(Ie.name));for(let Ae of tr){let Ie=ne.get(Ae.id);if(Ie?.preview?.savedDocument&&Ie.preview.savedDocument.revision!==Ae.documentRevision){Ie.abort.abort(),ne.delete(Ae.id);continue}Ie&&Ae.preview&&(Ie.preview?.recipeRevision!==Ae.preview.recipeRevision||Ie.preview?.contentRevision!==Ae.preview.contentRevision)&&(Ie.abort.abort(),ne.delete(Ae.id))}Qe.current=tr,n(tr),ke&&xe(Ae=>Ae?tr.find(Ie=>Ie.id===Ae.id)??null:null),O.current=Date.now(),z===ye.current&&(Me(mr),typeof Re.accountId=="string"&&t.current?.({accountId:Re.accountId,environment:Re.environment,name:mr.direction?.name??null,generation:mr.generation})),Nt(Re.canWrite===!0),hr(Re.canInspect===!0),Je(Re.canBrowsePrivate===!0),oe(null)}catch(lt){$===se.current&&oe(lt instanceof Error?lt.message:"Connection unavailable.")}finally{$===se.current&&(we(!1),je.current=!1,O.current=Date.now())}}return Bt(),()=>{se.current=$+1,Y.abort(),clearTimeout(re)}},[ie,Ve,He,ne,Be]);async function Ct($){if(!ie||!Oe||!rt||ce.current)return;let z=$?r.find(re=>re.id===$.id):void 0;if($&&!z){oe("Reload the collection before choosing this taste.");return}ce.current=!0,ye.current+=1,qe(z?{sourceModelId:z.sourceModelId,sourceCollection:z.sourceCollection,name:z.name,sourceVersion:z.metadata?.value??null}:null),z&&!z.preview&&!ne.get(z.id)?.preview&&ut(z).catch(()=>{}),S(!0),oe("Saving taste\u2026");let Y=se.current;try{let re=await Ne(`${ie}/cloud-taste/direction`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedGeneration:Oe.generation,...z?{sourceModelId:z.sourceModelId,sourceCollection:z.sourceCollection}:{}})});if(!re.ok)throw Error("The change could not be confirmed. Reload the collection before trying again.");let be=await re.json();if(Y!==se.current)return;Me(be),qe(void 0),typeof W.current=="string"&&t.current?.({accountId:W.current,environment:Z.current,name:be.direction?.name??null,generation:be.generation}),oe(null)}catch(re){Y===se.current&&(Me(null),qe(void 0),t.current?.(null),oe(re instanceof Error?re.message:"Could not save taste. Reload to check its state."))}finally{ce.current=!1,Y===se.current&&S(!1)}}async function jt($=!1){if(!ie||ce.current)return;let z=window.open("about:blank","_blank");if(!z){oe("Allow popups, then try again.");return}z.opener=null,ce.current=!0,S(!0);try{let Y=await Ne(`${ie}/cloud-taste/${$?"enable-saving":"enable-activation"}`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!Y.ok)throw Error("Could not start sign-in. Retry in Settings.");let re=await Y.json(),be=Yn(re.authorizationUrl);z.location.replace(be.href),Se(ke=>ke+1)}catch(Y){z.close(),oe(Y instanceof Error?Y.message:"Could not start sign-in.")}finally{ce.current=!1,S(!1)}}let Qt=r.find($=>$.id===De),On=ze&&De?Qt?{...Qt,preview:ne.get(Qt.id)?.preview??Qt.preview}:{id:De,name:ze.name,sourceModelId:ze.sourceModelId,sourceCollection:ze.sourceCollection,...ze.sourceVersion?{metadata:{value:ze.sourceVersion,label:`Version ${ze.sourceVersion}`}}:{}}:null,Hr=$=>r.filter(z=>z.sourceCollection===$).map(z=>({...z,preview:ne.get(z.id)?.preview??z.preview})),Hn=!!Oe&&(!rt||!Ke),Ur=V?ne.get(V.id)?.facts:void 0,Fr=ee?.id===V?.id&&ee?.cache===ne?ee:null,_e=Ge[e.theme],fr=!X||y,ft=C&&fr,Kr=y&&u?u==="components"?da:u==="copy-guidance"?ca:u==="version"?ua:u==="visual-directions"?pa:ha:Ut;le(()=>{X&&s.current?.focus({preventScroll:!0})},[X]);let Xt=()=>{if(K(!1),clearTimeout(ge.current),te(null),c(!1),ue(""),y){v(!1),clearTimeout(me.current),me.current=setTimeout(()=>g(null),220);return}f(!1),clearTimeout(pe.current),pe.current=setTimeout(()=>xe(null),220)},Un=()=>{we(!0),Se($=>$+1)};le(()=>{if(e.visible===!1||h)return;let $=z=>{if(z.key==="Tab"&&K(!0),z.defaultPrevented||z.isComposing||z.metaKey||z.ctrlKey||z.altKey)return;let Y=z.composedPath().some(re=>re instanceof HTMLElement&&(re.matches('input, textarea, select, [role="textbox"], [role="combobox"]')||re.isContentEditable));if(!(z.key==="Escape"&&z.composedPath().some(re=>re instanceof HTMLElement&&re.matches("[data-taste-value-input]")))){if(z.key===" "&&fr&&!Y)K(!1),z.preventDefault(),z.stopImmediatePropagation(),z.repeat||L();else if(z.key==="Escape"){if(K(!1),z.preventDefault(),z.stopImmediatePropagation(),z.repeat)return;ft?ae():X?Xt():e.onClose()}}};return document.addEventListener("keydown",$,!0),()=>document.removeEventListener("keydown",$,!0)});let Lt=(We??ne.get(V?.id??"")?.preview??V?.preview)?.savedDocument,gr=$=>{m(null),Ue();let z=N.current.get($.id);z&&(z.saved=$);let Y={id:Or("private",$.id),sourceModelId:$.id,sourceCollection:"private",name:$.document.draft.name,documentRevision:$.revision,preview:{...dr($.document.draft,e.theme),savedDocument:$,contentRevision:String($.revision)}};ne.get(Y.id)?.abort.abort(),ne.delete(Y.id),n(re=>[...re.filter(be=>be.id!==Y.id),Y]),xe(Y),ve(Y.preview),f(!0),Xe.close(),Se(re=>re+1)};if(p&&p.record.scope===fe)return i(qr,{session:p.session,draft:p.record.document.draft,recovery:p.record,recoveryScope:fe,onRecoveryChange:Ue,theme:e.theme,style:e.style,bridgeUrl:ie,visible:e.visible,onDraft:()=>{},onBack:()=>{m(null),Ue()},onTemplate:()=>{},onSaved:gr,onEnableSaving:()=>{jt(!0)}},p.record.key);if(!h&&X&&Lt){let $=N.current.get(Lt.id);return $||($={saved:Lt,session:vr(Lt.document.draft)},N.current.set(Lt.id,$)),i(qr,{saved:$.saved,recoveryScope:fe,onRecoveryChange:Ue,session:$.session,draft:$.saved.document.draft,theme:e.theme,style:e.style,bridgeUrl:ie,visible:e.visible,onDraft:()=>{},onBack:Xt,onTemplate:()=>{},onSaved:gr,onEnableSaving:()=>{jt(!0)}},Lt.id)}return h?i(qr,{visible:e.visible,session:Xe,recoveryScope:fe,onRecoveryChange:Ue,theme:e.theme,style:e.style,bridgeUrl:e.bridgeUrl,draft:b.draft,onDraft:()=>{},onBack:()=>Xe.close(),onTemplate:()=>{ct("template",!0)},onSaved:gr,onEnableSaving:()=>{jt(!0)}}):k("div",{"data-popmelt-font":"sans",ref:q,"data-taste-keyboard-focus":R,onPointerDownCapture:()=>K(!1),"data-taste-navigation":X?"detail":"collection","data-taste-animated":Ee||void 0,"data-taste-entering":e.visible===!1?void 0:I??void 0,"data-taste-depth":y?"drilldown":"overview",style:{position:"relative",height:ft?H:e.style?.height,maxHeight:e.style?.maxHeight,overflow:"hidden",borderRadius:20,background:_e.surface,fontFamily:Wt},children:[i("style",{children:`
196
+ [data-taste-navigation] { user-select: none; -webkit-user-select: none; }
197
+ [data-taste-navigation] input, [data-taste-navigation] textarea, [data-taste-navigation] [contenteditable="true"] { user-select: text; -webkit-user-select: text; }
198
+ [data-taste-keyboard-focus="false"] [data-taste-navigation-header] :focus { outline: none !important; box-shadow: none !important; }
199
+ [data-taste-navigation] [data-taste-collection-header], [data-taste-navigation] [data-taste-detail-header] { display: none !important; }
200
+ [data-taste-navigation] [data-popmelt-taste], [data-taste-navigation] [data-taste-detail] { padding-top: 60px !important; }
201
+ [data-taste-navigation] [data-taste-detail] { position: absolute; inset: 0; z-index: 1; background: transparent !important; overflow: hidden !important; }
202
+ [data-taste-navigation] [data-taste-detail-body] { min-height: 0; overflow-y: auto; flex-shrink: 1; }
203
+ [data-taste-navigation] [data-taste-scroll], [data-taste-navigation] [data-taste-detail-body] { transition: transform 200ms cubic-bezier(.2,.8,.2,1), opacity 160ms ease; }
204
+ [data-taste-navigation="detail"] [data-taste-scroll] { transform: translateX(-100%); opacity: 0; }
205
+ [data-taste-navigation="collection"] [data-taste-detail-body] { transform: translateX(100%); opacity: 0; }
206
+ [data-taste-entering="overview"] [data-taste-layer="overview"] [data-taste-detail-body],
207
+ [data-taste-entering="drilldown"] [data-taste-layer="drilldown"] [data-taste-detail-body] { animation: taste-detail-enter 200ms cubic-bezier(.2,.8,.2,1); }
208
+ [data-taste-depth="drilldown"] [data-taste-layer="overview"] [data-taste-detail-body] { transform: translateX(-100%); opacity: 0; }
209
+ [data-taste-depth="overview"] [data-taste-layer="drilldown"] [data-taste-detail-body] { transform: translateX(100%); opacity: 0; }
210
+ @keyframes taste-detail-enter { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
211
+ [data-taste-navigation] [data-taste-nav-title], [data-taste-navigation] [data-taste-nav-title] svg, [data-taste-navigation] [data-taste-nav-action] { transition: color 160ms ease, font-size 200ms ease, width 200ms ease, height 200ms ease, opacity 140ms ease, transform 200ms ease; }
212
+ [data-taste-navigation] [data-taste-nav-title]:hover [data-taste-refresh-icon] { opacity: 1; transform: none; }
213
+ [data-taste-navigation] [data-taste-nav-action]:enabled:hover { background: ${_e.actionHover} !important; }
214
+ [data-taste-navigation] [data-taste-search-trigger]:hover, [data-taste-navigation] [data-taste-search-trigger]:focus-visible { color: ${_e.primary} !important; }
215
+ [data-taste-navigation-header] > [data-taste-search], [data-taste-navigation-header] > [data-taste-header-default] { transition: opacity 160ms ease, transform 200ms cubic-bezier(.2,.8,.2,1), visibility 0s 200ms; }
216
+ [data-taste-navigation-header] > [data-taste-search] { opacity: 0; transform: translateX(12px); visibility: hidden; pointer-events: none; }
217
+ [data-taste-navigation-header][data-search-open="true"] > [data-taste-search] { opacity: 1; transform: none; visibility: visible; pointer-events: auto; transition-delay: 0s; }
218
+ [data-taste-navigation-header] > [data-taste-header-default] { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }
219
+ [data-taste-navigation-header][data-search-open="true"] > [data-taste-header-default] { opacity: 0; transform: translateX(-12px); visibility: hidden; pointer-events: none; transition-delay: 0s, 0s, 200ms; }
220
+ @media (prefers-reduced-motion: reduce) { [data-taste-navigation] *, [data-taste-navigation] [data-taste-detail-body] { animation: none !important; transition: none !important; } }
221
+ `}),k("div",{"data-taste-navigation-header":!0,"data-search-open":ft,style:{position:"absolute",top:16,left:16,right:16,height:28,zIndex:2,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[k("div",{"data-taste-search":!0,inert:!ft,"aria-hidden":!ft,style:{position:"absolute",inset:0,display:"flex",alignItems:"center",gap:8,width:"100%",color:_e.secondary},children:[i(kr,{size:16}),i("input",{ref:de,"aria-label":X?"Search taste definitions":"Search tastes",placeholder:X?"Search keys and values\u2026":"Search tastes\u2026",value:he,onChange:$=>ue($.target.value),onKeyDown:$=>{$.stopPropagation(),$.key==="Escape"&&ae()},style:{flex:1,minWidth:0,border:0,outline:"none",background:"transparent",color:_e.primary,font:"inherit",fontSize:12}}),i("button",{type:"button","aria-label":"Close search",onClick:ae,style:{border:0,padding:4,background:"transparent",color:_e.secondary,cursor:"pointer"},children:i(St,{size:16})})]}),k("div",{"data-taste-header-default":!0,inert:ft,"aria-hidden":ft,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,width:"100%"},children:[k("button",{ref:s,type:"button","data-taste-nav-title":!0,"aria-label":X?y?"Back to taste details":"Back to taste collection":"Back to settings",onClick:X?Xt:e.onClose,style:{display:"flex",alignItems:"center",gap:3,padding:0,border:0,background:"transparent",color:X?_e.secondary:_e.primary,fontFamily:"inherit",fontSize:X?12:14,fontWeight:600,letterSpacing:X?"-.12px":"-.14px",minWidth:0,cursor:"pointer"},children:[i(Cr,{size:16,style:{width:16,color:_e.primary}}),i(Kr,{"data-taste-nav-icon":!0,style:{width:X?14:16,height:X?14:16,transform:Kr===Ut?"scaleY(-1)":void 0,transitionProperty:"color, width, height, opacity"}}),i("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:X?V.name:void 0,children:X?u&&y?{version:"Versions",tokens:"Tokens",components:"Components","visual-directions":"Visual directions","copy-guidance":"Copy guidance"}[u]??u:V.name:"Taste"})]}),k("div",{style:{position:"relative",height:28,width:X?80:at?135:28,flexShrink:0},children:[!X&&at&&i("button",{type:"button","aria-label":"Open template taste",onClick:()=>{ct("template",!0)},style:{position:"absolute",right:56,top:0,border:0,padding:6,background:"transparent",color:_e.muted,font:"inherit",fontSize:12,cursor:"pointer"},children:"Template"}),!X&&at&&i("button",{type:"button","aria-label":"Create a taste","data-taste-create":!0,onClick:()=>{ct("extract")},style:{position:"absolute",right:28,top:0,border:0,padding:6,background:"transparent",color:_e.muted,cursor:"pointer"},children:i(Ft,{size:16})}),fr?i("button",{type:"button","aria-label":X?"Search definitions":"Search tastes",ref:Q,"data-taste-search-trigger":!0,onClick:()=>{K(!1),L()},style:{position:"absolute",right:0,border:0,padding:6,background:"transparent",color:_e.muted,transition:"color 160ms ease",cursor:"pointer"},children:i(kr,{size:16})}):i(Le,{children:i("button",{type:"button","data-taste-nav-action":!0,"aria-label":`${V?.id===De?"Remove":"Add"} ${V?.name??"taste"}`,"aria-pressed":!!V&&V.id===De,inert:!X,disabled:!rt||!Oe||_,onClick:()=>{V&&Ct(V.id===De?void 0:V)},style:{position:"absolute",right:0,top:0,display:"flex",alignItems:"center",gap:3,padding:V?.id===De?"4px 7px 4px 8px":"4px 8px",border:0,borderRadius:8,background:_e.actionSurface,color:_e.actionForeground,font:"inherit",fontSize:12,fontWeight:600,cursor:"pointer",opacity:X?1:0,transform:X?"translateX(0)":"translateX(5px)",pointerEvents:X?"auto":"none"},children:V?.id===De?k(Le,{children:["Remove",i(St,{size:12})]}):k(Le,{children:[i(Ft,{size:12}),"Add"]})})})]})]})]}),V&&(u?["overview","drilldown"]:["overview"]).map($=>i("div",{"data-taste-layer":$,inert:!X||$==="drilldown"!==y,"aria-hidden":!X||$==="drilldown"!==y,children:i(ja,{theme:e.theme,style:{...e.style,...l>0?{minHeight:`min(${l}px, ${typeof e.style?.maxHeight=="number"?`${e.style.maxHeight}px`:e.style?.maxHeight??"calc(100dvh - 64px)"})`}:{}},entry:{...V,preview:We??ne.get(V.id)?.preview??V.preview},facts:Ur??Fr?.facts,onOpenFact:z=>{K(!1),J("drilldown"),clearTimeout(me.current),c(!1),ue(""),g(z),v(!0)},drilldown:$==="drilldown"&&u?i(Ga,{cache:Be,bridgeUrl:e.bridgeUrl,id:V.sourceModelId,collection:V.sourceCollection,section:u,query:he,theme:e.theme,onPreview:ve,onReconnect:()=>{jt()}},`${V.id}:${u}`):void 0,summaryNotice:Ur?void 0:Fr?.notice??"Loading details\u2026",active:V.id===De,onBack:Xt,onToggle:rt&&Oe&&!_?()=>{Ct(V.id===De?void 0:V)}:void 0,notice:G},V.id)},$)),i("div",{ref:o,inert:X,"aria-hidden":X,style:{display:"contents"},children:i(Pa,{...e,style:{...e.style,...ft&&H?{height:"100%"}:{}},publicEntries:Hr("public").filter($=>X||`${$.name} ${$.metadata?.value??""}`.toLowerCase().includes(he.trim().toLowerCase())),privateEntries:Hr("private").filter($=>X||`${$.name} ${$.metadata?.value??""}`.toLowerCase().includes(he.trim().toLowerCase())),activeEntryId:De,activeEntry:On,onRefresh:Un,refreshing:Ce,refreshDisabled:_,onAdd:rt&&Oe&&!_?$=>{Ct($)}:void 0,onRemove:rt&&Oe&&!_?()=>Ct():void 0,onOpenDetails:$=>{if(K(!1),J("overview"),clearTimeout(pe.current),Ye(!0),a(o.current?.firstElementChild?.offsetHeight??0),xe($),g(null),v(!1),c(!1),ue(""),ve(void 0),F.current?.abort(),pr&&e.bridgeUrl&&!$.documentRevision){let z=new AbortController;F.current=z,Be.read(`${e.bridgeUrl}/cloud-taste/definition?id=${encodeURIComponent($.sourceModelId)}&collection=${$.sourceCollection}`).then(async Y=>{if(!Y.ok)return;let re=await Y.json(),be=wt(re.preview);!z.signal.aborted&&be&&ve(be)}).catch(()=>{})}f(!0)},onPrefetchDetails:$=>{ut($).catch(()=>{})},privateEmptyMessage:Ke?"No private results found.":"Reconnect to browse your private tastes.",notice:G,headerAction:k(Le,{children:[i(Si,{theme:e.theme,records:nt.map($=>({key:$.key,name:$.document.draft.name,pending:!!$.pending,preview:{...dr($.document.draft,e.theme),savedDocument:$}})),onResume:$=>{let z=nt.find(Y=>Y.key===$);if(z)try{let Y=Pn(z.scope).find(be=>be.key===z.key);if(!Y){Ue();return}let re={...Y,key:crypto.randomUUID(),updatedAt:Date.now()};jn(re),Bn(Y.key),m({record:re,session:vr(re.document.draft)}),Ue()}catch{oe("Could not resume browser recovery. The original record is kept.")}}}),Hn?i("button",{type:"button",disabled:_,onClick:()=>{jt()},style:{border:0,borderRadius:8,padding:"6px 10px",cursor:"pointer",font:"inherit"},children:"Reconnect account"}):null]})})}),i(Vr,{element:E,label:"AI is looking at this Taste",inverse:!0})]})}export{Ti as PopmeltTasteConnectedPane};