@popmelt.com/core 0.24.2 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -2
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/dist/ParticipantRuntime-5WM2XJT7.mjs +139 -0
- package/dist/PopmeltTasteConnectedPane-IXJ2KAPX.mjs +81 -0
- package/dist/PreviewRuntime-ATSECGMB.mjs +2 -0
- package/dist/bridge-entry.mjs +84 -71
- package/dist/browser-runtime-O5GITMZB.mjs +2 -0
- package/dist/browser.mjs +1 -1
- package/dist/{chunk-NV55QGKG.mjs → chunk-7IVK4FEU.mjs} +1 -1
- package/dist/chunk-CWVRJOGB.mjs +370 -0
- package/dist/chunk-EH5Y2F4E.mjs +77 -0
- package/dist/chunk-FRHGK5ZV.mjs +2 -0
- package/dist/chunk-J2OX47QB.mjs +345 -0
- package/dist/{chunk-TJVWZRAF.mjs → chunk-MGIH5NQE.mjs} +1 -1
- package/dist/chunk-NXMPY7RX.mjs +2 -0
- package/dist/chunk-ZJPPZLXU.mjs +2 -0
- package/dist/cli.mjs +109 -96
- package/dist/index.mjs +1 -1
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-next.d.mts +6 -2
- package/dist/plugin-next.mjs +1 -1
- package/dist/plugin-nuxt.mjs +1 -1
- package/dist/plugin-vite.mjs +1 -1
- package/dist/server-QHSVIUQW.mjs +241 -0
- package/dist/server.d.mts +7 -0
- package/dist/server.mjs +87 -74
- package/package.json +4 -1
- package/dist/ParticipantRuntime-6QPULJPO.mjs +0 -139
- package/dist/PreviewRuntime-NGTLOEX3.mjs +0 -2
- package/dist/browser-runtime-3UZPA2SA.mjs +0 -2
- package/dist/chunk-3XSTOVWX.mjs +0 -2
- package/dist/chunk-D4ZJC7OV.mjs +0 -301
- package/dist/chunk-ENERPQJN.mjs +0 -2
- package/dist/chunk-ZL4X7KBW.mjs +0 -413
- package/dist/server-M6OXW7FE.mjs +0 -228
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{x as me,va as He,Z as ht,Ia as ra,Ja as ia}from"./chunk-EH5Y2F4E.mjs";import"./chunk-ZJPPZLXU.mjs";import{useRef as z,useState as $,useEffect as X,useMemo as Pt,useCallback as na,isValidElement as oa,useLayoutEffect as ft,useId as la}from"react";import{Search as gt,X as Fe,ChevronLeft as At,Component as sa,PenLine as da,History as ca,Eye as ua,Ruler as pa,Fingerprint as Qe,Plus as mt,ChevronRight as et,RotateCw as ha,RotateCcw as fa,Minimize2 as ga,Info as ma,ChevronDown as ba,Check as ya,User as va}from"lucide-react";import{jsxs as h,jsx as t,Fragment as be}from"react/jsx-runtime";function Te(e,a=!1){if(typeof e!="string"||!e||e.length>800||!/^[a-z\d\s.,%+#()\-/]+$/i.test(e))return!1;let r=0;for(let n of e)if(n==="("&&++r>8||n===")"&&--r<0)return!1;if(r)return!1;let i=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(a)for(let n 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(n);return i.every(n=>o.has(n.toLowerCase()))}function Ue(e){if(e.border===void 0)return e;let{border:a,...r}=e,i=String(a).match(/(?:[^\s(]+\([^)]*\)|[^\s]+)/g)??[],o=i.find(l=>/^(?:[\d.]+(?:[a-z%]+)?|thin|medium|thick)$/.test(l)),n=i.find(l=>/^(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)$/.test(l)),s=i.filter(l=>l!==o&&l!==n).join(" ");return{borderWidth:o??"medium",borderStyle:n??"none",borderColor:s||"currentColor",...r}}function Oe(e){if(e.background===void 0)return e;let{background:a,...r}=e,i=String(a);if(typeof document<"u"){let o=document.createElement("span").style;if(o.background=i,o.background)return{backgroundColor:o.backgroundColor||"transparent",backgroundImage:o.backgroundImage||"none",...r}}return{backgroundColor:/gradient\(/i.test(i)||i==="none"?"transparent":i,backgroundImage:/gradient\(/i.test(i)?i:"none",...r}}function bt(e){if(!e||typeof e!="object")return;let a={};for(let r of["body","heading","card","button","input"]){let i=e[r];if(!i||typeof i!="object")continue;let o={};for(let[n,s]of Object.entries(i)){let l=String(s??"");n==="fontFamily"&&l.length<=200&&/^[a-zA-Z][a-zA-Z0-9 ,"'_-]*$/.test(l.replace(/^["']/,""))&&(o[n]=l),n==="color"&&Te(s)&&(o[n]=l),["background","backgroundColor","backgroundImage","border","borderColor","boxShadow","outline"].includes(n)&&Te(s,n.startsWith("background"))&&(o[n]=l),n==="opacity"&&typeof s=="number"&&Number.isFinite(s)&&(o[n]=Math.max(0,Math.min(1,s))),n==="transform"&&l.length<150&&/^(?:none|(?:\s*(?:translate(?:X|Y)?\(-?[\d.]+(?:px|rem|%)(?:,\s*-?[\d.]+(?:px|rem|%))?\)|scale\(\d*\.?\d+\))\s*){1,3})$/.test(l)&&(o[n]=l),n==="transition"&&l.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(l)&&(o[n]=l),n==="fontWeight"&&typeof s=="number"&&s>=100&&s<=900&&(o[n]=s),n==="fontStyle"&&["normal","italic"].includes(l)&&(o[n]=l),n==="textTransform"&&["none","uppercase","lowercase","capitalize"].includes(l)&&(o[n]=l),["fontSize","letterSpacing","lineHeight","padding","margin","marginTop","marginBottom","gap","borderRadius","borderWidth","outlineOffset"].includes(n)&&l.length<100&&/^-?\d*\.?\d+(?:px|rem|em|%)?(?:\s+-?\d*\.?\d+(?:px|rem|em|%)?){0,3}$/.test(l)&&(o[n]=l)}a[r]=o}return a}function Q(e,a=640){if(!e)return{};let r={...e};for(let[i,o]of Object.entries(r))i==="fontFamily"||i==="fontWeight"||typeof o=="string"&&(r[i]=o.replace(/(-?\d*\.?\d+)(px|rem)\b/g,(n,s,l)=>`${Math.max(-12,Math.min(12,Number(s)*(l==="rem"?16:1)/(a/100)))}cqw`));if(e.fontFamily){let i=Mt(e.fontFamily);/^Geist\s?Mono$/i.test(i)?r.fontFamily='"Popmelt Geist Mono", ui-monospace, monospace':/^Geist$/i.test(i)?r.fontFamily='"Popmelt Geist", system-ui, sans-serif':i&&!Tt(i)&&(r.fontFamily=`"Popmelt Taste ${i}", ${e.fontFamily}`)}return Oe(Ue(r))}var Mt=e=>e.split(",")[0].trim().replace(/^["']|["']$/g,""),Tt=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),yt=new Map;function wa(e){if(!e||typeof FontFace>"u"||!document.fonts)return Promise.resolve();let a=new Map;for(let r of Object.values(e)){if(!r?.fontFamily)continue;let i=Mt(r.fontFamily);if(Tt(i)||/^Geist(?:\s?Mono)?$/i.test(i)||!/^[a-zA-Z][a-zA-Z0-9 _-]{0,79}$/.test(i))continue;let o=Number(r.fontWeight)||400,n=r.fontStyle==="italic";a.set(`${i}:${o}:${n}`,{family:i,weight:o,italic:n})}return Promise.all([...a.entries()].slice(0,5).map(([r,i])=>{let o=yt.get(r);if(o)return o;let n=(async()=>{let s=new AbortController,l=setTimeout(()=>s.abort(),8e3);try{let c=new URLSearchParams({family:`${i.family}:${i.italic?"ital,wght@1,":"wght@"}${i.weight}`,display:"swap"}),p=await fetch(`https://fonts.googleapis.com/css2?${c}`,{signal:s.signal,credentials:"omit",referrerPolicy:"no-referrer"});if(p.ok||(p=await fetch(`https://fonts.googleapis.com/css2?family=${encodeURIComponent(i.family)}&display=swap`,{signal:s.signal,credentials:"omit",referrerPolicy:"no-referrer"})),!p.ok)throw new Error("Font unavailable");if(![...(await p.text()).matchAll(/@font-face\s*\{([^}]+)\}/g)].slice(0,32).flatMap(f=>{let g=f[1],w=g.match(/url\((https:\/\/fonts\.gstatic\.com\/[^\s)"']+)\)/)?.[1];if(!w)return[];let P=new FontFace(`Popmelt Taste ${i.family}`,`url(${JSON.stringify(w)})`,{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(P),[P]}).length)throw new Error("Font unavailable");await document.fonts.load(`${i.italic?"italic ":""}${i.weight} 16px "Popmelt Taste ${i.family}"`,"Your workspace A little space for big ideas. Create a project")}finally{clearTimeout(l)}})().catch(s=>{console.warn(`[Popmelt] Preview font ${i.family} unavailable; using its fallback.`,s instanceof Error?s.message:"Font request failed"),yt.delete(r)});return yt.set(r,n),n})).then(()=>{})}function Ae(e){if(!e||typeof e!="object")return;let a=e;for(let i of["background","surface","foreground","muted","accent","border"])if(!Te(a[i],!0))return;for(let i of["radius","spacing"])if(typeof a[i]!="number"||!Number.isFinite(a[i])||a[i]<0||a[i]>32)return;let r={...a};if(delete r.detail,a.detail!==void 0&&(r.detail=bt(a.detail)),delete r.states,a.states&&typeof a.states=="object"){r.states={};for(let i of["card","button","input"]){let o=a.states[i];if(!(!o||typeof o!="object")){r.states[i]={};for(let n of["hover","focus","active"])r.states[i][n]=bt({[i]:o[n]})?.[i]}}}if(delete r.parts,a.parts!==void 0){if(!a.parts||typeof a.parts!="object")return;let i={};for(let o of["card","button","content"]){let n=a.parts[o];if(!n||typeof n.radius!="number"||!Number.isFinite(n.radius)||n.radius<0||n.radius>999)return;let s=n.backdropFilter;i[o]={background:Te(n.background,!0)?n.background:r.surface,border:Te(n.border)?n.border:`1px solid ${r.border}`,radius:n.radius,shadow:Te(n.shadow)?n.shadow:"none",...n.backgroundImage!==void 0?{backgroundImage:Te(n.backgroundImage,!0)?n.backgroundImage:"none"}:{},...n.backgroundBlendMode!==void 0?{backgroundBlendMode:["normal","overlay","multiply","screen","soft-light","hard-light"].includes(n.backgroundBlendMode)?n.backgroundBlendMode:"normal"}:{},...s!==void 0?{backdropFilter:typeof s=="string"&&s.length<150&&/^(?:none|(?:\s*(?:blur\(\d*\.?\d+(?:px|rem)\)|saturate\(\d*\.?\d+%?\))\s*){1,3})$/.test(s)?s:"none"}:{},...n.opacity!==void 0?{opacity:Number.isFinite(n.opacity)?Math.max(0,Math.min(1,n.opacity)):1}:{}}}r.parts=i}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 xa({recipe:e}){let a=e.radius*.45,r=o=>o.replace(/(-?\d*\.?\d+)(px|rem)\b/g,(n,s,l)=>`${Math.max(-32,Math.min(32,Number(s)*(l==="rem"?16:1)*.45))}px`),i=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,(n,s)=>`saturate(${Math.min(400,Number(s))}%)`):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 t("span",{"data-taste-specimen":!0,"aria-hidden":"true",style:{position:"absolute",inset:0,background:e.background,pointerEvents:"none",overflow:"hidden"},children:h("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:a,overflow:"hidden",boxSizing:"border-box",...i(e.parts?.card),borderTopRightRadius:0,borderBottomRightRadius:0,borderBottomLeftRadius:0},children:[t("span",{"data-specimen-title":!0,style:{position:"absolute",left:0,top:0,width:"100%",height:"18.18%",background:e.parts?"transparent":e.accent}}),t("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:a*.6,boxSizing:"border-box",...i(e.parts?.button)}}),t("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:a*.6,boxSizing:"border-box",...i(e.parts?.content)}})]})})}function Ve(e,a=!1,r=640){let[i,o]=$(!1),[n,s]=$(!1),[l,c]=$(!1);return{handlers:{onPointerEnter:()=>o(!0),onPointerLeave:()=>{o(!1),c(!1)},onPointerDown:()=>c(!0),onPointerUp:()=>c(!1),onPointerCancel:()=>c(!1),onKeyDown:p=>{a&&["Enter"," "].includes(p.key)&&c(!0)},onKeyUp:()=>c(!1),onFocus:()=>s(!0),onBlur:()=>{s(!1),c(!1)}},style:{...Q(i?e?.hover:void 0,r),...Q(n?e?.focus:void 0,r),...Q(l?e?.active:void 0,r)}}}function ka({recipe:e}){let a=Ve(e.states?.button,!0),r=Ve(e.states?.input),i=Ve(e.states?.card),o=`${e.spacing/6.4}cqw`;X(()=>{wa(e.detail)},[e.detail]);let n=l=>l.replace(/(-?\d*\.?\d+)(px|rem)\b/g,(c,p,f)=>`${Math.max(-16,Math.min(16,Number(p)*(f==="rem"?16:1)/6.4))}cqw`),s=l=>l?{...Oe({background:l.background}),...l.backgroundImage&&l.backgroundImage!=="none"?{backgroundImage:l.backgroundImage}:{},backgroundBlendMode:l.backgroundBlendMode,...Ue({border:n(l.border)}),borderRadius:`${l.radius/6.4}cqw`,boxShadow:n(l.shadow),backdropFilter:l.backdropFilter?n(l.backdropFilter):void 0,WebkitBackdropFilter:l.backdropFilter?n(l.backdropFilter):void 0,opacity:l.opacity}:{};return t("div",{"data-taste-detail-specimen":!0,role:"group","aria-label":"Interactive taste preview",style:{position:"absolute",inset:0,containerType:"inline-size",background:e.background,color:e.foreground,fontSynthesis:"none",...Q(e.detail?.body),overflow:"hidden"},children:t("div",{"data-taste-component":"card",style:{position:"absolute",inset:"9% 8%",background:e.surface,border:`1px solid ${e.border}`,borderRadius:e.radius,...s(e.parts?.card),padding:"5cqw",boxSizing:"border-box",display:"flex",flexDirection:"column",gap:o,...Q(e.detail?.card)},children:h("div",{style:{display:"grid",gridTemplateColumns:"1.35fr 1fr",gap:`calc(${o} * 2)`,alignItems:"center",flex:1,minHeight:0},children:[h("div",{children:[h("h2",{"data-taste-component":"heading",style:{margin:0,fontWeight:"inherit",lineHeight:1.1,letterSpacing:"-0.03em",marginBottom:o,...Q(e.detail?.heading),fontSize:`clamp(3.8cqw, ${Q(e.detail?.heading).fontSize??"4.6cqw"}, 5.4cqw)`},children:["A little space",t("br",{}),"for big ideas."]}),h("p",{"data-taste-component":"paragraph",style:{margin:0,fontSize:"2.4cqw",lineHeight:1.5,marginBottom:o,...Q(e.detail?.body)},children:["Gather your thoughts.",t("br",{}),"Make something your own."]}),t("button",{"data-taste-component":"button",...a.handlers,type:"button",style:{fontFamily:"inherit",color:"inherit",display:"inline-block",...Oe({background:e.accent}),...Ue({border:`1px solid ${e.border}`}),borderRadius:e.radius,...s(e.parts?.button),padding:"1.5cqw 2.5cqw",fontSize:"2.3cqw",fontWeight:"inherit",lineHeight:1.2,...Q(e.detail?.button),cursor:"pointer",...a.style},children:"Create a project \u2197"})]}),h("div",{"data-taste-component":"card",...i.handlers,style:{...Oe({background:e.surface}),...Ue({border:`1px solid ${e.border}`}),borderRadius:e.radius,...s(e.parts?.card),padding:"3cqw",fontSize:"2.1cqw",lineHeight:1.5,...Q(e.detail?.card),...i.style},children:[t("h3",{"data-taste-component":"heading",style:{margin:0,fontWeight:"inherit",...Q(e.detail?.heading),fontSize:"2.6cqw",marginBottom:o},children:"In the works"}),t("input",{"data-taste-component":"input",...r.handlers,"aria-label":"Preview project name",defaultValue:"A fresh start",style:{appearance:"none",outline:"none",borderWidth:0,borderStyle:"none",borderColor:"transparent",...Oe({background:"transparent"}),...s(e.parts?.content),font:"inherit",color:"inherit",padding:"1.5cqw",...Q(e.detail?.input),width:"100%",minWidth:0,boxSizing:"border-box",marginBottom:o,...r.style}}),t("div",{children:"02 \xA0 What comes next"})]})]})})})}function Et({children:e}){let a=He.dark,r=z(null),[i,o]=$(),[n,s]=$({scale:1,x:0,y:0}),l=z(n);return X(()=>{let c=r.current;if(!c)return;let p=()=>o({width:c.clientWidth,height:c.clientHeight});p();let f=typeof ResizeObserver<"u"?new ResizeObserver(p):void 0;f?.observe(c);let g=()=>window.matchMedia("(any-hover: hover) and (any-pointer: fine)").matches,w=(m,k,v)=>{m=Math.max(1,Math.min(4,m));let _={scale:m,x:Math.max(1-m,Math.min(0,k)),y:Math.max(1-m,Math.min(0,v))};l.current=_,s(_)},P=(m,k,v)=>{let _=c.getBoundingClientRect();if(!_.width||!_.height)return;let A=l.current,N=Math.max(1,Math.min(4,m)),D=Math.max(0,Math.min(1,(k-_.left)/_.width)),W=Math.max(0,Math.min(1,(v-_.top)/_.height));w(N,D-(D-A.x)*N/A.scale,W-(W-A.y)*N/A.scale)},I=null,S=m=>{if(!g()||!m.ctrlKey&&l.current.scale===1)return;m.preventDefault(),m.stopPropagation();let k=m.deltaMode===1?16:m.deltaMode===2?c.clientHeight:1;if(m.ctrlKey)I===null&&P(l.current.scale*Math.exp(-m.deltaY*k*.01),m.clientX,m.clientY);else{let v=c.getBoundingClientRect();v.width&&v.height&&w(l.current.scale,l.current.x-m.deltaX*k/v.width,l.current.y-m.deltaY*k/v.height)}},T=m=>{if(!g())return;m.preventDefault(),m.stopPropagation();let k=m;m.type==="gesturestart"?I=l.current.scale:m.type==="gestureend"?I=null:I!==null&&Number.isFinite(k.scale)&&P(I*k.scale,k.clientX,k.clientY)};c.addEventListener("wheel",S,{passive:!1});for(let m of["gesturestart","gesturechange","gestureend"])c.addEventListener(m,T,{passive:!1});return()=>{f?.disconnect(),c.removeEventListener("wheel",S);for(let m of["gesturestart","gesturechange","gestureend"])c.removeEventListener(m,T)}},[]),h("div",{ref:r,"data-preview-zoom":!0,style:{position:"relative",width:"100%",aspectRatio:"16 / 9",overflow:"hidden",borderRadius:8},children:[t("div",{"data-preview-zoom-content":!0,style:{width:i?.width||"100%",height:i?.height||"100%",zoom:n.scale,transformOrigin:"0 0",transform:`translate(${n.x*100/n.scale}%, ${n.y*100/n.scale}%)`},children:e}),n.scale>1&&h(be,{children:[t("style",{children:`
|
|
3
|
+
[data-preview-zoom-reset] span { color: ${a.primary}; }
|
|
4
|
+
[data-preview-zoom-reset] svg { color: ${a.secondary}; }
|
|
5
|
+
[data-preview-zoom-reset]:hover span, [data-preview-zoom-reset]:focus-visible span { color: ${a.secondary}; }
|
|
6
|
+
[data-preview-zoom-reset]:hover svg, [data-preview-zoom-reset]:focus-visible svg { color: ${a.primary}; }
|
|
7
|
+
[data-preview-zoom-reset] span, [data-preview-zoom-reset] svg { transition: color 120ms ease; }
|
|
8
|
+
`}),h("button",{"data-preview-zoom-reset":!0,type:"button","aria-label":"Reset preview zoom",onClick:()=>{let c={scale:1,x:0,y:0};l.current=c,s(c)},style:{position:"absolute",right:8,bottom:8,display:"inline-flex",alignItems:"center",gap:6,border:0,borderRadius:8,padding:"4px 6px 4px 10px",background:a.control,color:a.primary,fontSize:12,cursor:"pointer"},children:[h("span",{children:[Math.round(n.scale*100),"%"]}),t(ga,{size:14,"aria-hidden":"true"})]})]})]})}function qt({preview:e,thumbnailUrl:a,zoom:r=!0,background:i}){let[o,n]=$(null),s=e?t(ka,{recipe:e}):a&&a!==o?t("img",{src:a,alt:"",referrerPolicy:"no-referrer",onError:()=>n(a),style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):null;return t("div",{"data-detail-preview":!0,style:{aspectRatio:"16 / 9",width:"100%",position:"relative",border:0,padding:0,borderRadius:8,overflow:"hidden",background:i,font:"inherit"},children:r?t(Et,{children:s}):s})}var vt=100,Ne=200,$a=600,jt=220,Sa=120,Ca=160;function wt(e){let a=new Map;if(!e)return a;let r=e.getBoundingClientRect();for(let i of e.querySelectorAll("[data-taste-tile]")){let o=i.dataset.tasteEntryId;if(!o)continue;let n=i.getBoundingClientRect();a.set(o,{x:n.x-r.x,y:n.y-r.y})}return a}function Lt(e,a,r,i,o){if(!e)return;let n=wt(e);for(let s of e.querySelectorAll("[data-taste-tile]")){let l=s.dataset.tasteEntryId,c=l?a.get(l):null,p=l?n.get(l):null;if(!c||!p||!s.animate)continue;let f=(c.x-p.x)/(r||1),g=(c.y-p.y)/(r||1);Math.abs(f)<.5&&Math.abs(g)<.5||o.push(s.animate([{transform:`translate(${f}px, ${g}px)`},{transform:"translate(0, 0)"}],{duration:i,easing:"ease-in-out"}))}}function Dt({entry:e,onAdd:a,onRemove:r,active:i,featured:o=!1,previewBackground:n,hasActiveTaste:s=!1,onOpenDetails:l,onPrefetchDetails:c}){let[p,f]=$(null),g=z(null),w=z(c);w.current=c;let P=z(e);P.current=e,X(()=>{if(!g.current||typeof IntersectionObserver>"u")return;let v=new IntersectionObserver(([_])=>{_?.isIntersecting&&(P.current.preview||w.current?.(P.current),v.disconnect())},{root:g.current.closest("[data-taste-scroll]"),rootMargin:"180px"});return v.observe(g.current),()=>v.disconnect()},[e.id]);let I=z(void 0),S=()=>clearTimeout(I.current);X(()=>()=>clearTimeout(I.current),[]);let T=i?r:a,m=i?"Remove":s?"Switch":"Add",k=t("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:i?"4px 9px 4px 10px":"4px 10px 4px 6px",border:0,borderRadius:8,font:"inherit",fontWeight:500,letterSpacing:"-.12px",whiteSpace:"nowrap"},children:i?h(be,{children:["Remove",t(Fe,{size:12,"aria-hidden":"true"})]}):h(be,{children:[t(mt,{size:12,"aria-hidden":"true"}),m]})});return h("li",{"data-taste-tile":!0,"data-taste-entry-id":e.id,"data-taste-featured":o||void 0,ref:g,onMouseEnter:()=>{S(),I.current=setTimeout(()=>c?.(e),100)},onMouseLeave:S,onFocus:()=>{S(),c?.(e)},style:{minWidth:0,display:"flex",flexDirection:"column",gap:4},children:[o?h("div",{"data-taste-thumbnail":!0,style:{position:"relative",width:"100%",aspectRatio:"16 / 9",borderRadius:8,overflow:"hidden"},children:[t("div",{"data-taste-preview-art":!0,"aria-hidden":"true",inert:!0,children:t(qt,{preview:e.preview,thumbnailUrl:e.thumbnailUrl,zoom:!1,background:n??"transparent"},e.id)}),t("button",{type:"button","data-taste-featured-action":!0,"aria-label":`${m} ${e.name}`,"aria-pressed":i,disabled:!T,onClick:()=>T?.(e),style:{position:"absolute",inset:0,width:"100%",padding:0,border:0,background:"transparent",font:"inherit",cursor:T?"pointer":"default"},children:k})]}):h("button",{type:"button","data-taste-thumbnail":!0,"aria-label":`${m} ${e.name}`,"aria-pressed":i,disabled:!T,onClick:()=>T?.(e),style:{display:"block",padding:0,border:0,font:"inherit",cursor:T?"pointer":"default",aspectRatio:"1",width:"100%",borderRadius:8,overflow:"hidden",position:"relative"},children:[t("span",{"data-taste-preview-art":!0,style:{position:"absolute",inset:0},children:e.thumbnailUrl&&e.thumbnailUrl!==p?t("img",{src:e.thumbnailUrl,alt:"",referrerPolicy:"no-referrer",onError:()=>f(e.thumbnailUrl??null),style:{display:"block",width:"100%",height:"100%",objectFit:"cover"}}):e.preview?t(xa,{recipe:e.preview}):null}),k]}),h("button",{type:"button","data-taste-details":!0,"aria-label":`View ${e.name} details`,disabled:!l,onClick:()=>l?.(e),style:{width:"100%",padding:0,border:0,borderRadius:2,background:"transparent",font:"inherit",textAlign:"left",cursor:l?"pointer":"default",display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,minWidth:0,letterSpacing:".12px"},children:[h("span",{style:{display:"inline-flex",alignItems:"center",minWidth:0,overflow:"hidden"},children:[t("span",{"data-taste-name":!0,title:e.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontWeight:500,minWidth:0},children:e.name}),l&&t("span",{"data-taste-detail-chevron":!0,"aria-hidden":"true",children:t(et,{size:13,strokeWidth:2})})]}),e.metadata&&t("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 Ra({theme:e,publicEntries:a,privateEntries:r,onClose:i,onRefresh:o,refreshDisabled:n=!1,refreshing:s=!1,onAdd:l,onRemove:c,activeEntryId:p=null,activeEntry:f,onOpenDetails:g,onPrefetchDetails:w,notice:P,action:I,privateEmptyMessage:S,style:T}){let m=He[e],[k,v]=$(!1),_=z(null),A=z(null),N=z(null),D=z(null),W=z([]),H=z(new Map),J=z([]),F=z(null),[de,C]=$(null),y=z(null),d=z(null),[R,G]=$(),[x,O]=$(null),B=z(null);X(()=>()=>{for(let M of B.current?.timers??[])clearTimeout(M);B.current?.cleanup();for(let M of W.current)M.cancel();for(let M of J.current)M.cancel();B.current=null},[]);let ge=p?f?.id===p?f:[...a,...r].find(M=>M.id===p):null,ue=x?.entry??ge,ae=ue?.id??null,ye=!!p&&de===p,pe=x?.phase==="collapse",E=a.filter(M=>M.id!==ae||pe),ve=r.filter(M=>M.id!==ae||pe);ft(()=>{let M=D.current;if(!M||x?.phase!=="collapse"||(D.current=null,window.matchMedia?.("(prefers-reduced-motion: reduce)").matches))return;let U=N.current,Z=_.current,ce=Z?Z.getBoundingClientRect().width/(Z.offsetWidth||1):1;Lt(U,M.positions,ce,Ne,W.current);for(let oe of U?.querySelectorAll("[data-taste-tile]")??[])if(!(oe.dataset.tasteEntryId!==M.returningId||!oe.animate)){W.current.push(oe.animate([{opacity:0},{opacity:1}],{duration:Ne,easing:"ease-out"}));break}},[x?.phase]),ft(()=>{let M=N.current;if(!M)return;let U=H.current;if(!ye||F.current===p)return;F.current=p;let Z=y.current,ce=d.current,oe=A.current,ee=oe?.querySelector("[data-taste-collections]");if(!Z||!ce||!oe||!ee||!Z.animate||window.matchMedia?.("(prefers-reduced-motion: reduce)").matches){C(null);return}for(let Ee of J.current)Ee.cancel();J.current=[];let Y={duration:jt,easing:"ease-in-out"},he={delay:Sa,duration:Ca,easing:"ease-out",fill:"backwards"},le=Z.offsetHeight,rt=ce.offsetHeight,Xe=Z.animate([{height:"0px"},{height:`${le}px`}],Y);J.current.push(Xe),J.current.push(Z.animate([{opacity:0},{opacity:1}],he),ce.animate([{height:"0px"},{height:`${rt}px`}],Y),ce.animate([{opacity:0},{opacity:1}],he),oe.animate([{gap:"0px"},{gap:"24px"}],Y),ee.animate([{gap:"0px"},{gap:"16px"}],Y));let Ce=_.current,Re=Ce?Ce.getBoundingClientRect().width/(Ce.offsetWidth||1):1;Lt(M,U,Re,jt,J.current),Xe.onfinish=()=>{F.current===p&&(F.current=null,C(null))}},[ye,p]),ft(()=>{H.current=wt(N.current)});let q=M=>{l&&(!ae&&!x&&(F.current=null,C(M.id)),l(M))},_e=M=>{if(!c||B.current)return;if(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches){c(M);return}let U={id:M.id,timers:[],cleanup:()=>{}};for(let le of W.current)le.cancel();W.current=[],B.current=U,O({entry:M,phase:"fade",activeHeight:y.current?.offsetHeight??0,headingHeight:d.current?.offsetHeight??0});let Z=!1,ce=!1,oe=!1,ee=()=>{if(!(!Z||!ce||B.current!==U)){for(let le of U.timers)clearTimeout(le);U.cleanup(),B.current=null,O(null)}},Y=A.current,he=le=>{!oe||le.target!==Y||le.propertyName!=="gap"||(Z=!0,ee())};Y?.addEventListener("transitionend",he),U.cleanup=()=>Y?.removeEventListener("transitionend",he),U.timers.push(setTimeout(()=>{B.current===U&&(oe=!0,D.current={returningId:M.id,positions:wt(N.current)},O(le=>le?.entry.id===M.id?{...le,phase:"collapse"}:le))},vt)),U.timers.push(setTimeout(()=>{Z=!0,ee()},$a));try{Promise.resolve(c(M)).then(()=>{ce=!0,ee()},()=>{ce=!0,ee()})}catch{ce=!0,ee()}};return h("div",{ref:_,role:"region","aria-label":"Taste collection","aria-busy":s,"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 ${m.border}`,borderRadius:20,background:m.surface,backdropFilter:"blur(59.5px)",WebkitBackdropFilter:"blur(59.5px)",color:m.secondary,fontFamily:ht,fontSize:12,lineHeight:1.3,letterSpacing:"-.12px",overflow:"hidden",...T,...s&&R?{height:R}:{}},children:[t("style",{children:`
|
|
9
|
+
[data-popmelt-taste] [data-taste-thumbnail] { background: ${m.control}; }
|
|
10
|
+
[data-popmelt-taste] [data-taste-preview-art] { transition: opacity 120ms ease; }
|
|
11
|
+
[data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-preview-art] { opacity: .2; }
|
|
12
|
+
[data-popmelt-taste] [data-taste-name] { color: ${m.secondary}; transition: color 120ms ease; }
|
|
13
|
+
[data-popmelt-taste] [data-taste-metadata] { color: ${m.muted}; transition: color 120ms ease; }
|
|
14
|
+
[data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-name] { color: ${m.primary}; }
|
|
15
|
+
[data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-metadata] { color: ${m.secondary}; }
|
|
16
|
+
[data-popmelt-taste] [data-taste-detail-chevron] { display: inline-flex; width: 0; flex: 0 0 auto; overflow: hidden; opacity: 0; color: ${m.primary}; transform: translateX(-6px); transition: width 160ms ease, opacity 120ms ease, transform 160ms ease; }
|
|
17
|
+
[data-popmelt-taste] [data-taste-details]:is(:hover, :focus-visible) [data-taste-detail-chevron] { width: 15px; opacity: 1; transform: translateX(0); }
|
|
18
|
+
[data-popmelt-taste] [data-taste-add] { background: ${m.actionSurface}; color: ${m.actionForeground}; opacity: 0; pointer-events: none; transition: opacity 120ms ease, background-color 120ms ease; }
|
|
19
|
+
[data-popmelt-taste] [data-taste-tile]:is(:hover, :focus-within) [data-taste-add] { opacity: 1; }
|
|
20
|
+
[data-popmelt-taste] [data-taste-thumbnail]:hover [data-taste-add] { background: ${m.actionHover}; }
|
|
21
|
+
[data-popmelt-taste] button:focus-visible { outline: 2px solid ${m.primary}; outline-offset: 2px; }
|
|
22
|
+
[data-popmelt-taste] button[data-taste-close]:hover { background: ${m.hoverSurface} !important; color: ${m.primary} !important; }
|
|
23
|
+
[data-taste-refresh-icon] { opacity: 0; transform: translateX(-4px); transition: opacity 120ms ease, transform 160ms ease; }
|
|
24
|
+
[data-taste-refresh]:not(:disabled):is(:hover, :focus-visible) [data-taste-refresh-icon] { opacity: 1; transform: translateX(0); }
|
|
25
|
+
@media (hover: none) { [data-taste-refresh]:not(:disabled) [data-taste-refresh-icon] { opacity: 1; transform: none; } }
|
|
26
|
+
@media (prefers-reduced-motion: reduce) { [data-taste-refresh-icon] { transition: none; transform: none; } }
|
|
27
|
+
@media (hover: none) { [data-popmelt-taste] [data-taste-add] { opacity: 1; } }
|
|
28
|
+
@media (hover: none) { [data-popmelt-taste] [data-taste-detail-chevron] { width: 15px; opacity: 1; transform: none; } }
|
|
29
|
+
@media (prefers-reduced-motion: reduce) { [data-popmelt-taste] :is([data-taste-name], [data-taste-metadata], [data-taste-add], [data-taste-detail-chevron]) { transition: none; } }
|
|
30
|
+
`}),h("div",{"data-taste-collection-header":!0,style:{display:"flex",alignItems:"center",gap:4,flexShrink:0},children:[h("button",{type:"button","data-taste-refresh":!0,"aria-label":"Refresh taste collection",onClick:()=>{G(_.current?.offsetHeight),o?.()},disabled:!o||n||s,style:{display:"inline-flex",alignItems:"center",gap:4,padding:0,border:0,borderRadius:4,background:"transparent",font:"inherit",cursor:o&&!n?"pointer":"default",color:m.primary,fontSize:14,fontWeight:600,letterSpacing:"-.14px"},children:[t(Qe,{size:16,"aria-hidden":"true",style:{transform:"scaleY(-1)"}}),"Taste",t(ha,{"data-taste-refresh-icon":!0,size:12,"aria-hidden":"true",style:{marginLeft:2}})]}),t("button",{type:"button","data-taste-close":!0,"aria-label":"Back to settings",onClick:i,style:{marginLeft:"auto",border:0,padding:0,width:20,height:20,display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:4,background:"transparent",color:m.muted,cursor:"pointer"},children:t(Fe,{size:16})})]}),h("div",{"data-taste-scroll":!0,onScroll:M=>v(M.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:k?"linear-gradient(to bottom, transparent, #000 16px)":void 0,WebkitMaskImage:k?"linear-gradient(to bottom, transparent, #000 16px)":void 0,overscrollBehavior:"contain"},children:[h("div",{"data-taste-content":!0,ref:A,style:{display:"flex",flexDirection:"column",gap:ue&&x?.phase!=="collapse"?24:0,transition:x?`gap ${Ne}ms ease-in-out`:void 0},children:[ue&&h("section",{ref:y,"aria-label":"Active taste","data-taste-removal-phase":x?.phase,"aria-hidden":!!x,inert:!!x,style:{display:"flex",flexDirection:"column",gap:8,flexShrink:0,minHeight:0,height:x?x.phase==="collapse"?0:x.activeHeight:void 0,opacity:x?0:1,overflow:x||ye?"hidden":void 0,pointerEvents:x?"none":void 0,transition:x?`opacity ${vt}ms ease-out, height ${Ne}ms ease-in-out`:void 0},children:[t("h3",{style:{margin:0,font:"inherit",fontWeight:500,lineHeight:"14px",color:m.secondary},children:"Active"}),t("ul",{style:{listStyle:"none",padding:0,margin:0},children:t(Dt,{entry:ue,active:!0,featured:!0,previewBackground:m.control,onRemove:ye?void 0:_e,onOpenDetails:g,onPrefetchDetails:w})})]}),h("div",{"data-taste-collections":!0,style:{display:"flex",flexDirection:"column",gap:ue&&x?.phase!=="collapse"?16:0,transition:x?`gap ${Ne}ms ease-in-out`:void 0},children:[ue&&t("h3",{ref:d,"data-taste-collections-heading":!0,style:{margin:0,font:"inherit",fontWeight:600,lineHeight:"12px",color:e==="light"?"#555555":"#aaaaaa",flexShrink:0,height:x?x.phase==="collapse"?0:x.headingHeight:void 0,opacity:x?.phase==="collapse"?0:1,overflow:x||ye?"hidden":void 0,transition:x?`height ${Ne}ms ease-in-out, opacity ${vt}ms ease-out`:void 0},children:"Collections"}),t("div",{"data-taste-catalogs":!0,ref:N,style:{display:"flex",flexDirection:"column",gap:24},children:[{label:"Private",entries:ve},{label:"Public",entries:E}].map(({label:M,entries:U})=>h("section",{"aria-label":`${M} tastes`,style:{display:"flex",flexDirection:"column",gap:8},children:[h("h3",{style:{margin:0,font:"inherit",fontWeight:500,lineHeight:"14px"},children:[t("span",{children:M})," ",t("span",{"data-taste-count":!0,style:{color:m.muted},children:U.length})]}),U.length?t("ul",{style:{listStyle:"none",padding:0,margin:0,display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:8},children:U.map(Z=>t(Dt,{entry:Z,onAdd:x||!l?void 0:q,onRemove:c,active:!1,hasActiveTaste:!!ae&&!pe,onOpenDetails:g,onPrefetchDetails:w},Z.id))}):t("span",{style:{color:m.muted},children:M==="Private"&&S?S:`No ${M.toLowerCase()} results found.`})]},M))})]})]}),P&&t("span",{role:"status",children:P}),I]})]})}function Ia({entry:e,theme:a,active:r,onBack:i,onToggle:o,notice:n,style:s,facts:l,summaryNotice:c,drilldown:p,onOpenFact:f}){let g=He[a],[w,P]=$(!1),I=z(null),S=oa(p)?p.key:null;return X(()=>{I.current&&(I.current.scrollTop=0),P(!1)},[e.id,S]),h("div",{role:"region","aria-label":`${e.name} taste details`,"data-taste-detail":!0,"data-popmelt-font":"sans","data-popmelt-theme":a,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:ht,fontSize:12,lineHeight:1.3,boxSizing:"border-box",overflow:"hidden",...s},children:[t("style",{children:`
|
|
31
|
+
[data-taste-detail] > div { flex-shrink: 0; }
|
|
32
|
+
[data-taste-detail] [data-taste-detail-body] { flex-shrink: 1; }
|
|
33
|
+
[data-taste-detail-body] > * { flex-shrink: 0; }
|
|
34
|
+
[data-taste-detail] button:focus-visible { outline: 2px solid ${g.primary}; outline-offset: 3px; }
|
|
35
|
+
[data-taste-detail] [data-detail-back]:hover { color: ${g.primary} !important; }
|
|
36
|
+
[data-taste-detail] [data-detail-cta]:enabled:hover { background: ${g.actionHover} !important; }
|
|
37
|
+
[data-taste-fact]:hover dt, [data-taste-fact]:focus-within dt { color: ${g.primary} !important; }
|
|
38
|
+
[data-taste-fact]:hover button, [data-taste-fact] button:focus-visible { background: ${g.control} !important; }
|
|
39
|
+
[data-taste-fact] button::after { content: ''; position: absolute; inset: 0; }
|
|
40
|
+
[data-taste-fact] button svg { opacity: 0; width: 0; transition: opacity 120ms, width 120ms; }
|
|
41
|
+
[data-taste-fact]:hover button svg, [data-taste-fact] button:focus-visible svg { opacity: 1; width: 14px; }
|
|
42
|
+
`}),h("div",{"data-taste-detail-header":!0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[h("button",{type:"button","data-detail-back":!0,"aria-label":"Back to taste collection",onClick:i,style:{display:"flex",alignItems:"center",gap:2,alignSelf:"flex-start",padding:0,border:0,background:"transparent",color:g.secondary,font:"inherit",fontWeight:600,cursor:"pointer"},children:[t(At,{size:16,color:g.primary}),t(Qe,{size:14,style:{transform:"scaleY(-1)"}}),e.name]}),t("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",fontWeight:600,opacity:o?1:.5,cursor:o?"pointer":"default"},children:r?h(be,{children:["Remove",t(Fe,{size:12})]}):h(be,{children:[t(mt,{size:12}),"Add"]})})]}),t("div",{"data-taste-detail-body":!0,ref:I,onScroll:T=>P(T.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:w?"linear-gradient(to bottom, transparent, #000 16px)":void 0,WebkitMaskImage:w?"linear-gradient(to bottom, transparent, #000 16px)":void 0},children:p??h(be,{children:[t("div",{style:{display:"flex",flexDirection:"column",gap:8},children:t(qt,{preview:e.preview,thumbnailUrl:e.thumbnailUrl,background:g.control},e.id)}),t("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}]:[],...(l??[]).filter(T=>T.key!=="version")].map(({key:T,label:m,value:k})=>h("div",{"data-taste-fact":!0,style:{position:"relative",display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,padding:"4px 0"},children:[t("dt",{style:{color:g.secondary},children:m}),t("dd",{"aria-label":`${m}: ${k}`,style:{margin:0,fontSize:14,fontWeight:500,fontVariantNumeric:"tabular-nums"},children:f?h("button",{type:"button","aria-label":`View ${m}`,onClick:()=>f(T),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:[k,t(et,{size:14})]}):k})]},T))}),c&&t("div",{role:"status",style:{color:g.secondary,padding:"0 4px"},children:c}),n&&t("div",{role:"status",style:{color:g.secondary,padding:"0 4px"},children:n})]})})]})}function za(e,a){return a==="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 Ft=e=>{let a=e.replace(/([a-z])([A-Z])/g,"$1 $2");return a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()};function Pa(e,a,r=!1,i=!1,o=!1){let n=new Map;for(let l of e){let c=l.path.slice(1).filter(S=>S!=="$value");i&&(c=c.slice(1).filter(S=>S!=="$children")),a&&c[0]==="copy"&&(c=c.slice(1)),a&&c[0]==="slots"&&(c=c.slice(1));let p=c.length-1;if(r&&(p=Math.min(1,p)),a){let S=c.findIndex(T=>["budget","rules","template"].includes(T));S>=0&&(p=S)}let f=c.slice(0,p),g=c.slice(p);a&&g[0]==="budget"&&g.shift();let w=g.map(S=>/^\d+$/.test(S)?String(Number(S)+1):Ft(S)).join(" \xB7 "),P=JSON.stringify(f),I=n.get(P)??{heading:f.map(S=>a||r?Ft(S):S).join(" \u2192 "),rows:[]};I.rows.push({...l,label:w}),n.set(P,I)}let s=[...n.values()];if(i){let l=["default","hover","active","disabled"],c=new Map,p=g=>{let w=g.split(" \u2192 "),P=w.pop()??"",I=w.join(" \u2192 ");c.has(I)||c.set(I,c.size);let S=l.indexOf(P);return[c.get(I),S<0?l.length:S]},f=new Map(s.map(g=>[g,p(g.heading)]));s.sort((g,w)=>{let[P=0,I=0]=f.get(g),[S=0,T=0]=f.get(w);return P-S||I-T})}return s.map(l=>l.rows.length>1||(i||o)&&l.heading?l:{heading:"",rows:l.rows.map(c=>({...c,label:[l.heading,c.label].filter(Boolean).join(" \xB7 ")}))})}function Ot(e,a){let r=new Set;for(let i=0;i<32;i+=1){if(r.has(e))return;if(r.add(e),e&&typeof e=="object"){let s=e;e=s.$value??s.ref;continue}if(typeof e!="string")return;let o=e.trim(),n=o.replace(/^\{(.+)\}$/,"$1").replace(/^var\(--([^,)]+)\)$/,"$1").replace(/^var\(principles\.([^,)]+)\)$/,"$1").replace(/^principles\./,"");if(Object.hasOwn(a,n)){e=a[n];continue}if(/\b(currentcolor|inherit|initial|unset|revert|var|env|light-dark)\b/i.test(o))return;if(typeof CSS<"u"&&CSS.supports)return CSS.supports("color",o)?o:void 0;if(typeof document<"u"){let s=document.createElement("span").style;return s.color=o,s.color?o:void 0}return}}var Aa=["Palette","Semantic colors","Typography","Spacing & layout","Radii & borders","Shadows & effects","Motion","Other"],Nt=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{},tt=(e,a)=>e.localeCompare(a,"en",{numeric:!0,sensitivity:"base"}),Ma=new Map([["none",0],["xs",1],["sm",2],["base",3],["md",4],["lg",5],["xl",6]]),Ta=new Map([["xs",0],["sm",1],["base",2],["lg",3],["xl",4]]);function Wt(e){return/^(text|space|spacing|radius|radii|shadow)(?:-|$)/i.exec(e)?.[1]?.toLowerCase()??null}function Bt(e,a){let r=e.toLowerCase().slice(a.length).replace(/^-/,"");if(a==="space"||a==="spacing")return r==="px"?.25:/^\d+(?:\.\d+)?$/.test(r)?Number(r):null;if(r==="full"&&(a==="radius"||a==="radii"))return 100;if(!r)return a==="text"?null:3;let i=/^(\d+)xs$/.exec(r),o=/^(\d+)xl$/.exec(r)??/^(x{2,})l$/.exec(r);return a==="text"?i?1-Number(i[1]):r==="xxs"?-1:o?3+(/^x/.test(o[1])?o[1].length:Number(o[1])):Ta.get(r)??null:i?2-Number(i[1]):r==="xxs"?0:o?5+(/^x/.test(o[1])?o[1].length:Number(o[1])):Ma.get(r)??null}function Ea(e,a){let r=Wt(e),i=Wt(a);if(!r||r!==i)return tt(e,a);let o=Bt(e,r),n=Bt(a,i);return o!==null&&n!==null?o-n||tt(e,a):o!==null?-1:n!==null?1:tt(e,a)}function qa(e,a,r){let i=Nt(a),o=String(i.$type??"").toLowerCase(),n=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),s=i.$value??a,l=Nt(s),c=/^(?:background|foreground|primary|secondary|accent|muted|card|popover|sidebar|input|ring|border|destructive|success|warning|info|surface|text|chart)(?:-|$)/.test(n);return o==="color"||Ot(s,r)?c?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(n)||"fontFamily"in l||"fontSize"in l?2:/^(space|spacing|gap|padding|margin|layout|container|width|height|size|breakpoint)(?:-|$)/.test(n)||"maxWidth"in l?3:/^(radius|radii|border|stroke)(?:-|$)/.test(n)?4:/^(shadow|elevation|blur|opacity|gradient|filter)(?:-|$)/.test(n)?5:/^(transition|duration|easing|animation|motion)(?:-|$)/.test(n)?6:7}function ja(e,a){let r=["fontFamily","fontSize","fontWeight","lineHeight","letterSpacing","color"],i=o=>{let n=r.indexOf(o.at(-1)??"");return n<0?r.length:n};return i(e)-i(a)||tt(e.join("."),a.join("."))}function La({taste:e,style:a,onClick:r,children:i}){let o=Ve(e?.states?.button,!0,320);return t("button",{type:"button",...o.handlers,onClick:r,style:{...Oe(Ue(a)),...Q(e?.detail?.button,320),...o.style},children:i})}var Da={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"},Fa=["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 Ht(e){let a=e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=Da[a]??a;return Fa.includes(r)?r:void 0}var $e=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{};function at(e,a){let r=(n,s=0)=>{if(s>12)return;if(n&&typeof n=="object")return r($e(n).$value??$e(n).ref,s+1);if(typeof n!="string")return n;let l=n.trim();return Object.hasOwn(a,l)?r(a[l],s+1):l.replace(/var\(\s*(?:--|principles\.)([\w-]+)\s*\)|\{(?:principles\.)?([\w-]+)\}/g,(c,p,f)=>String(r(a[p??f],s+1)??""))},i=Object.fromEntries(Object.entries($e(e)).slice(0,80).map(([n,s])=>[n,r(s)])),o=Q(bt({card:i})?.card,320);return["flex","inline-flex","grid","block","inline-block"].includes(String(i.display))&&(o.display=i.display),["row","column","row-reverse","column-reverse"].includes(String(i.flexDirection))&&(o.flexDirection=i.flexDirection),o}function Oa({kind:e,style:a,handlers:r,definition:i,tokens:o,taste:n}){let s=la(),[l,c]=$(0),[p,f]=$(!1),[g,w]=$(!0),[P,I]=$(60),[S,T]=$(""),m=$e($e(i).$value),k=$e(m.$children??$e(i).$children),v=(y,d)=>{let R=$e(k[y]),G=$e(R.$value??R);return{...at(G.default,o),...at(d?G[d]:void 0,o)}},_=y=>y?at(m.checked??m.selected??m.active,o):{},A={boxSizing:"border-box",maxWidth:"86%",font:"inherit",...Q(n?.detail?.body,320),...a},N={padding:"5cqw",...A,width:"82%"},D={font:"inherit",color:"inherit",background:"transparent",borderWidth:0,borderStyle:"none",borderRadius:0,boxShadow:"none",padding:"1.5cqw 3cqw",cursor:"pointer"},W={display:"flex",flexDirection:"column",gap:"3cqw"},H={size:"1em","aria-hidden":!0},J=(y,d,R={})=>t(La,{taste:n,onClick:d,style:{...D,...R},children:y},y),F=t("strong",{style:{...Q(n?.detail?.heading,320),...v("title")},children:"A little space"}),de=t("span",{style:{fontSize:"0.85em",...Q(n?.detail?.body,320),...v("description")},children:"Make something your own."}),C={...r,"data-specimen-kind":e};switch(e){case"button":return t("button",{...C,type:"button",style:{...A,cursor:"pointer"},children:"Button"});case"input":return t("input",{...C,"aria-label":"Preview input",defaultValue:"A fresh start",style:{...A,width:"76%",outline:"none"}});case"textarea":return t("textarea",{...C,"aria-label":"Preview textarea",defaultValue:"A little space for your ideas.",rows:3,style:{...A,width:"76%",resize:"none",outline:"none"}});case"card":return h("div",{...C,style:{...N,...W},children:[F,de,J("Get started",()=>w(!g),v("button"))]});case"badge":return t("span",{...C,style:A,children:"New"});case"avatar":return t("div",{...C,"aria-label":"Preview avatar",style:{...A,width:"18cqw",height:"18cqw",display:"grid",placeItems:"center"},children:t(va,{...H})});case"label":return t("label",{...C,style:A,children:"Project name"});case"separator":return t("div",{...C,role:"separator",style:{...A,width:"76%",padding:0,...v("separator")}});case"checkbox":return h("label",{...C,style:{...A,display:"flex",gap:"3cqw",alignItems:"center"},children:[t("input",{type:"checkbox",checked:g,onChange:y=>w(y.target.checked),style:{width:"5cqw",height:"5cqw",...v("indicator",g?"checked":void 0)}}),"Stay inspired"]});case"radio":return t("div",{...C,role:"radiogroup","aria-label":"Preview options",style:{...A,...W},children:["Personal","Team"].map((y,d)=>h("label",{style:{display:"flex",gap:"3cqw",...v("item",l===d?"checked":void 0)},children:[t("input",{name:s,type:"radio",checked:l===d,onChange:()=>c(d)}),y]},y))});case"switch":return t("button",{...C,type:"button",role:"switch","aria-label":"Preview switch","aria-checked":g,onClick:()=>w(!g),style:{...A,width:"18cqw",padding:"1.5cqw",cursor:"pointer",..._(g)},children:t("span",{style:{display:"block",width:"6cqw",height:"6cqw",marginLeft:g?"auto":0,...v("thumb",g?"checked":void 0)}})});case"toggle":return h("button",{...C,type:"button","aria-pressed":g,onClick:()=>w(!g),style:{...A,cursor:"pointer",..._(g)},children:["Bold ",g&&t(ya,{...H})]});case"slider":return t("input",{...C,type:"range","aria-label":"Preview slider",value:P,onChange:y=>I(Number(y.target.value)),style:{...A,width:"76%"}});case"progress":return t("div",{...C,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:t("div",{style:{width:"60%",height:"100%",...v("indicator")}})});case"skeleton":return t("div",{...C,"aria-label":"Preview loading placeholder",style:{...A,width:"76%",height:"22cqw"}});case"tabs":return h("div",{...C,style:N,children:[t("div",{role:"tablist","aria-label":"Preview tabs",style:{display:"flex",gap:"2cqw",...v("list")},children:["Overview","Activity"].map((y,d)=>t("button",{type:"button",role:"tab","aria-selected":l===d,onClick:()=>c(d),onKeyDown:R=>{(R.key==="ArrowLeft"||R.key==="ArrowRight")&&(R.preventDefault(),c(1-l))},style:{...D,...v("trigger",l===d?"active":void 0)},children:y},y))}),t("div",{role:"tabpanel",style:{paddingTop:"4cqw",...v("content")},children:l===0?"Your next big idea starts here.":"All caught up."})]});case"accordion":return t("div",{...C,style:N,children:["What is included?","Can I make it mine?"].map((y,d)=>h("div",{style:v("item"),children:[h("button",{type:"button","aria-expanded":p&&l===d,onClick:()=>{c(d),f(!(p&&l===d))},style:{...D,width:"100%",display:"flex",justifyContent:"space-between",...Q(n?.detail?.heading,320),...v("trigger")},children:[y,t(ba,{...H})]}),p&&l===d&&t("div",{style:{padding:"3cqw",...Q(n?.detail?.body,320),...v("content")},children:"Everything you need to get started."})]},y))});case"select":return t("select",{...C,"aria-label":"Preview select",value:l,onChange:y=>c(Number(y.target.value)),style:A,children:["Choose a project","Personal","Team"].map((y,d)=>t("option",{value:d,children:y},y))});case"combobox":case"command":return h("div",{...C,style:{...N,...W},children:[h("label",{style:{display:"flex",alignItems:"center",gap:"2cqw"},children:[t(gt,{...H}),t("input",{"aria-label":"Search preview options",value:S,onChange:y=>T(y.target.value),placeholder:"Search projects\u2026",style:{...D,minWidth:0,width:"100%",...v("input")}})]}),["Personal","Team","Archive"].filter(y=>y.toLowerCase().includes(S.toLowerCase())).map(y=>J(y,()=>T(y),v("item"))),!["Personal","Team","Archive"].some(y=>y.toLowerCase().includes(S.toLowerCase()))&&t("span",{children:"No results"})]});case"dropdown-menu":case"menubar":return h("div",{...C,style:{...N,...W},children:[J("Options \u25BE",()=>f(!p),v("trigger")),p&&t("div",{style:{...W,...v("content")},children:["New project","Duplicate","Archive"].map((y,d)=>J(`${l===d?"\u2713 ":""}${y}`,()=>{c(d),f(!1)},v("item")))})]});case"dialog":case"sheet":return t("div",{...C,style:{...N,...W,...e==="sheet"?{marginLeft:"auto",maxWidth:"65%",minHeight:"42cqw"}:{},...v("content")},children:p?h(be,{children:[F,de,J("Done",()=>f(!1),v("button"))]}):h(be,{children:[F,de,J("Open preview",()=>f(!0),v("trigger"))]})});case"popover":case"tooltip":return h("div",{...C,style:{...A,...W},children:[t("button",{type:"button",onClick:()=>f(!p),onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onFocus:()=>f(!0),onBlur:()=>f(!1),style:{...D,...v("trigger")},children:"Learn more"}),p&&t("span",{role:"tooltip",style:v("content"),children:"A little room for your ideas."})]});case"alert":case"toast":return h("div",{...C,role:"status",style:{...N,display:"flex",gap:"3cqw",alignItems:"center"},children:[t(ma,{...H}),h("div",{style:W,children:[t("strong",{style:v("title"),children:g?"Changes saved":"Ready when you are"}),t("span",{style:v("description"),children:"Your project is up to date."})]}),e==="toast"&&t("button",{type:"button","aria-label":"Dismiss preview toast",onClick:()=>w(!g),style:D,children:t(Fe,{...H})})]});case"table":return t("div",{...C,style:{...N,padding:0,overflow:"hidden",textAlign:"left"},children:h("table",{style:{width:"100%",borderCollapse:"separate",borderSpacing:0,font:"inherit",color:"inherit"},children:[t("thead",{style:v("header"),children:t("tr",{children:["Project","Status"].map(y=>t("th",{style:{padding:"2cqw",...v("head")},children:y},y))})}),t("tbody",{children:["Personal","Team"].map(y=>h("tr",{style:v("row"),children:[t("td",{style:{padding:"2cqw",...v("cell")},children:y}),t("td",{style:{padding:"2cqw",...v("cell")},children:"Active"})]},y))})]})});case"breadcrumb":return h("nav",{...C,"aria-label":"Preview breadcrumb",style:{...A,display:"flex",gap:"2cqw",alignItems:"center"},children:[J("Home",()=>c(0),v("link")),t(et,{...H}),t("span",{"aria-current":"page",style:v("page"),children:l?"Settings":"Projects"})]});case"pagination":return t("nav",{...C,"aria-label":"Preview pagination",style:{...A,display:"flex",gap:"2cqw"},children:[0,1,2].map(y=>t("button",{type:"button","aria-current":l===y?"page":void 0,onClick:()=>c(y),style:{...D,...v("item",l===y?"active":void 0)},children:y+1},y))});case"calendar":return h("div",{...C,style:{...N,padding:"2cqw",fontSize:"3.5cqw"},children:[t("div",{style:{textAlign:"center",...v("caption")},children:"September 2026"}),h("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:"0.5cqw"},children:[["M","T","W","T","F","S","S"].map((y,d)=>t("span",{style:{textAlign:"center",...v("head")},children:y},d)),t("span",{"aria-hidden":"true"}),Array.from({length:30},(y,d)=>t("button",{type:"button","aria-label":`September ${d+1}`,"aria-pressed":l===d,onClick:()=>c(d),style:{...D,border:0,padding:0,...v("day",l===d?"selected":void 0)},children:d+1},d))]})]});case"form":return h("form",{...C,onSubmit:y=>{y.preventDefault(),f(!0)},style:{...N,...W},children:[t("label",{htmlFor:s,style:v("label"),children:"Project name"}),t("input",{id:s,required:!0,placeholder:"A fresh start",style:{...D,...v("input")}}),t("button",{type:"submit",style:{...D,...v("button")},children:"Create project"}),p&&t("span",{role:"status",children:"Project created (preview)"})]});case"otp":return t("div",{...C,style:{...A,display:"flex",gap:"1cqw"},children:[0,1,2,3].map(y=>t("input",{"aria-label":`Preview digit ${y+1}`,inputMode:"numeric",maxLength:1,pattern:"[0-9]",style:{...D,width:"8cqw",padding:"2cqw 0",textAlign:"center",...v("slot")}},y))});case"scroll":return t("div",{...C,tabIndex:0,"aria-label":"Preview scroll area",style:{...N,maxHeight:"35cqw",overflow:"auto",overscrollBehavior:"contain"},children:Array.from({length:12},(y,d)=>h("div",{style:{padding:"2cqw",...v("item")},children:["Project ",d+1]},d))});case"chart":return h("figure",{...C,"aria-label":"Preview project activity chart",style:{...N,margin:0},children:[t("figcaption",{style:v("title"),children:"Activity"}),t("div",{style:{display:"flex",alignItems:"end",gap:"3cqw",height:"25cqw"},children:[35,60,45,85,70].map((y,d)=>t("div",{title:`${y} projects`,style:{flex:1,height:`${y}%`,...v("bar")}},d))})]});default:return null}}var Se=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{};function Ut(e,a,r){return!!r&&!!Ht(e)&&!!Object.keys(Se(Se(Se(a).$value).default)).length}function Vt(e,a,r=[]){if(a.length>12||r.length>=500)return r;if(a.includes("$value")&&["string","number","boolean"].includes(typeof e))r.push({path:a,value:e});else if(e&&typeof e=="object")for(let[i,o]of Object.entries(e))["__proto__","constructor","prototype","$type"].includes(i)||Vt(o,[...a,i],r);return r}function Na({bridgeUrl:e,id:a,collection:r,section:i,theme:o,onPreview:n,onReconnect:s,cache:l,query:c=""}){let p=He[o],[f,g]=$(),[w,P]=$(""),[I,S]=$(!1),[T,m]=$(!1),[k,v]=$(null),_=z(null),A=`${e??""}/cloud-taste/definition?id=${encodeURIComponent(a)}&collection=${encodeURIComponent(r)}`;X(()=>{let d=new AbortController;return _.current=d,g(void 0),P(""),S(!1),v(null),(l?l.read(A):me(A,{signal:d.signal})).then(async R=>{if(!R.ok){let x=await R.json().catch(()=>null),O=za(R.status,x?.error);d.signal.aborted||(P(O.message),S(O.reconnect));return}let G=await R.json();if(!G.sections||!Array.isArray(G.overrides))throw new Error("Invalid taste definition");if(!d.signal.aborted){g(G);let x=Ae(G.preview);x&&n(x)}}).catch(R=>{d.signal.aborted||P(R 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.")}),()=>d.abort()},[A,n,l]);async function N(d,R,G=!1){if(!f||T)return;let x=_.current;if(!(!x||x.signal.aborted)){m(!0),P("");try{let O=await me(A,{signal:x.signal,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:d,value:R,reset:G,sourceHash:f.hash,expectedRevision:f.revision})});if(!O.ok)throw new Error("Save failed. Your remote taste is unchanged. Reopen this section to reload before trying again.");let B=await O.json();if(x.signal.aborted)return;l?.put(A,B),g(B);let ge=Ae(B.preview);ge&&n(ge)}catch(O){l?.invalidate(A),x.signal.aborted||P(O.message)}finally{x.signal.aborted||m(!1)}}}let D=i==="tokens"||i==="principles"?"principles":i==="visual-directions"?"assets":i==="copy-guidance"?"content":i,W=c.trim().toLocaleLowerCase(),H=d=>!W||String(d).toLocaleLowerCase().includes(W),J=Object.entries(Se(f?.sections[D])),F=D==="principles",de=new Map(J.map(([d,R])=>[d,F?qa(d,R,Se(f?.sections.principles)):7]));if(F&&J.sort(([d],[R])=>de.get(d)-de.get(R)||Ea(d,R)),D==="components"){let d=(R,G)=>Ut(R,G,Ae(f?.componentPreviews?.[R]));J.sort(([R,G],[x,O])=>Number(d(x,O))-Number(d(R,G))||R.localeCompare(x,void 0,{sensitivity:"base",numeric:!0}))}let C=J.filter(([d,R])=>H(d)||H(JSON.stringify(R))),y=f?.versions?.filter(d=>H(`${d.version} ${d.saved_at??"Not recorded"} ${d.saved_at?new Date(d.saved_at).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):""}`));return i==="version"?t("div",{"data-taste-versions":!0,children:w?h("div",{role:"alert",children:[w,I&&t("div",{style:{marginTop:8},children:t("button",{type:"button",onClick:s,children:"Reconnect"})})]}):f?r==="public"?t("div",{children:"Public version history is not available yet."}):f.versions?h("dl",{style:{margin:0},children:[y?.map(d=>h("div",{style:{display:"flex",justifyContent:"space-between",gap:16,padding:"8px 4px"},children:[t("dt",{children:d.version}),t("dd",{style:{margin:0,color:p.secondary},children:d.saved_at?t("time",{dateTime:d.saved_at,title:new Date(d.saved_at).toLocaleString(),children:new Date(d.saved_at).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}):"Not recorded"})]},d.version)),!f.versions.length&&t("div",{children:"No version history recorded."}),!!f.versions.length&&!y?.length&&t("div",{role:"status",children:"No matching versions."})]}):t("div",{role:"status",children:"Version history is currently unavailable."}):t("div",{role:"status",children:"Loading versions\u2026"})}):h("div",{"data-taste-drilldown":!0,style:{display:"flex",flexDirection:"column",gap:0},children:[t("style",{children:`
|
|
43
|
+
[data-preview-zoom] + [data-taste-component-header] { margin-top: -4px; }
|
|
44
|
+
[data-taste-component-header]:hover:not(:disabled), [data-taste-component-header]:focus-visible { color: ${p.primary} !important; }
|
|
45
|
+
[data-taste-component-header]:hover:not(:disabled) svg { background: ${p.control}; }
|
|
46
|
+
[data-taste-value-row]:hover, [data-taste-value-row]:focus-within { color: ${p.primary} !important; }
|
|
47
|
+
[data-taste-token-group]:has(> [data-taste-token-child] [data-taste-value-row]:hover) > [data-taste-token-parent],
|
|
48
|
+
[data-taste-token-parent]:hover,
|
|
49
|
+
[data-taste-token-parent]:hover ~ [data-taste-token-child] [data-taste-value-row] > label { color: ${p.primary} !important; }
|
|
50
|
+
[data-taste-value-row]:hover input, [data-taste-value-row] input:focus { background: ${p.control} !important; }
|
|
51
|
+
[data-taste-value-row]:hover input, [data-taste-value-row]:focus-within input { color: ${p.primary} !important; }
|
|
52
|
+
[data-taste-value-row] input:focus-visible { outline: 1px solid ${p.secondary}; }
|
|
53
|
+
[data-taste-value-row] input { cursor: inherit; }
|
|
54
|
+
[data-taste-value-row] input:not([type="checkbox"]):focus { cursor: text; text-overflow: clip !important; }
|
|
55
|
+
`}),!f&&!w&&t("div",{role:"status",children:"Loading definitions\u2026"}),w&&h("div",{role:"alert",style:{color:p.secondary},children:[w,!f&&I&&t("button",{type:"button",onClick:s,style:{display:"block",marginTop:8},children:"Reconnect"})]}),!!f?.conflicts.length&&t("div",{role:"status",children:"Some source values changed remotely. Conflicting overrides are not applied; reset or edit them to resolve."}),f&&!C.length&&t("div",{role:"status",children:W&&J.length?"No matching definitions.":"No definitions in this section."}),C.map(([d,R],G)=>{let x=Vt(R,[D,d]).filter(B=>H(d)||H(B.path.join(" "))||H(JSON.stringify(B.value))),O=D==="components";return F&&x.sort((B,ge)=>ja(B.path,ge.path)),h("div",{"data-taste-group-path":JSON.stringify([D,d]),style:{display:"flex",flexDirection:"column",gap:O?8:0,marginBottom:O?8:0},children:[F&&(G===0||de.get(C[G-1][0])!==de.get(d))&&t("h2",{"data-taste-token-section":!0,style:{font:"inherit",fontWeight:500,color:p.primary,margin:G===0?"0 4px 8px":"16px 4px 8px"},children:Aa[de.get(d)]}),O&&t(Wa,{name:d,definition:R,taste:Ae(f?.preview),tokens:Se(f?.sections.principles),recipe:Ae(f?.componentPreviews?.[d])}),O&&h("button",{type:"button","data-taste-component-header":!0,disabled:!x.length,onClick:()=>v(k===d?null:d),"aria-expanded":x.length?k===d||!!W:void 0,style:{display:"flex",justifyContent:"space-between",alignItems:"center",border:0,padding:"6px 4px",font:"inherit",background:"transparent",borderRadius:8,color:p.secondary,cursor:x.length?"pointer":"default"},children:[t("span",{children:d}),!!x.length&&t(et,{size:14,style:{boxSizing:"content-box",padding:"2px 4px",borderRadius:8,transform:k===d||W?"rotate(90deg)":void 0,transition:"transform 120ms"}})]}),(!O||k===d||!!W)&&Pa(x,i==="copy-guidance",i==="visual-directions",O,F).map((B,ge,ue)=>h("div",{"data-taste-state-group":O?"":void 0,"data-taste-token-group":F&&B.heading?"":void 0,style:{position:"relative",display:"flex",flexDirection:"column",gap:0,paddingLeft:O?12:0},children:[O&&B.heading&&ge<ue.length-1&&t("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, ${p.secondary} 40%, ${p.surface})`}}),B.heading&&h("h3",{"data-taste-token-parent":F?"":void 0,style:{position:"relative",margin:F?0:O?"2px 4px 0":"12px 4px 0",font:"inherit",fontWeight:F?"inherit":500,fontSize:F?12:void 0,color:F?p.secondary:p.primary,display:F?"flex":void 0,alignItems:F?"center":void 0,padding:F?"4px 4px":void 0},children:[O&&t("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, ${p.secondary} 40%, ${p.surface})`}}),B.heading,F&&t("span",{"aria-hidden":"true",style:{visibility:"hidden",fontSize:14,padding:"2px 0"},children:"\xA0"})]}),B.rows.map((ae,ye)=>{let pe=JSON.stringify(ae.path),E=f.overrides.some(q=>JSON.stringify(q.path)===pe),ve=t(Ba,{path:ae.path,label:ae.label,value:ae.value,disabled:T,overridden:E,colors:p,componentValue:O,colorTokens:D==="principles"||D==="components"?Se(f?.sections.principles):void 0,onSave:q=>{N(ae.path,q)},onReset:()=>{N(ae.path,ae.value,!0)}},pe);return F&&B.heading?h("div",{"data-taste-token-child":!0,style:{position:"relative",paddingLeft:12},children:[h("span",{"aria-hidden":"true",style:{position:"absolute",left:4,top:0,bottom:0,pointerEvents:"none",color:`color-mix(in srgb, ${p.secondary} 40%, ${p.surface})`},children:[ye<B.rows.length-1&&t("span",{style:{position:"absolute",top:0,bottom:0,borderLeft:"1px solid currentColor"}}),t("span",{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"}})]}),ve]},pe):ve})]},ge)),!O&&!x.length&&h("div",{style:{color:p.secondary,padding:"0 4px",overflowWrap:"anywhere"},children:[d,": ",JSON.stringify(R)]})]},d)})]})}function Wa({name:e,definition:a,recipe:r,tokens:i,taste:o}){let n=Ht(e),s=/button/i.test(e)?"button":/input|text.?field|textarea/i.test(e)?"input":"card",l=Ve(r?.states?.[s],!0,320);if(!r||!n||!Ut(e,a,r))return null;let c={backgroundColor:"transparent",backgroundImage:"none",borderWidth:0,borderStyle:"none",borderRadius:0,boxShadow:"none",padding:s==="button"?"3cqw 5cqw":16,fontSize:"4.6cqw",lineHeight:s==="button"?1.2:void 0,color:r.foreground,...Q(o?.detail?.body,320),...at(Se(Se(a).$value).default,i),...l.style};return t(Et,{children:t("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:t(Oa,{kind:n,style:c,handlers:l.handlers,definition:a,tokens:i,accent:r.accent,taste:o})})})}function Ba({path:e,label:a,value:r,disabled:i,overridden:o,colors:n,onSave:s,onReset:l,colorTokens:c,componentValue:p=!1}){let f=p&&typeof r=="string"?/^var\(principles\.([^,)]+)\)$/.exec(r.trim())?.[1]:void 0,g=f&&c&&Object.hasOwn(c,f)?f:String(r),[w,P]=$(g),I=z(null),S=z(!1),T=c&&typeof r=="string"?Ot(w,c):void 0;X(()=>P(g),[g]);function m(){let k=typeof r=="number"?Number(w):p&&c&&Object.hasOwn(c,w.trim())?`var(principles.${w.trim()})`:w;if(typeof k=="number"&&(!w.trim()||!Number.isFinite(k))||k===r||w===g){P(g);return}s(k)}return h("div",{"data-taste-value-row":!0,"data-taste-path":JSON.stringify(e),onClick:k=>{i||k.target instanceof Element&&k.target.closest("input, button")||(I.current?.focus({preventScroll:!0}),typeof r=="boolean"&&I.current?.click())},style:{display:"flex",alignItems:"center",gap:8,color:n.secondary,padding:"4px 4px",cursor:i?"default":"pointer"},children:[t("label",{style:{flex:1,minWidth:0,overflowWrap:"anywhere",fontSize:12},children:a}),typeof r=="boolean"?t("input",{ref:I,"aria-label":a,type:"checkbox",checked:r,disabled:i,onChange:k=>s(k.target.checked)}):h("span",{"data-taste-value-field":!0,style:{position:"relative",display:"inline-grid",maxWidth:"52%",marginRight:T?0:-8,minWidth:0},children:[t("span",{"aria-hidden":"true",style:{visibility:"hidden",whiteSpace:"pre",overflow:"hidden",font:"inherit",fontSize:14,padding:"2px 8px"},children:w||" "}),t("input",{ref:I,"data-taste-value-input":!0,"aria-label":a,value:w,title:w,disabled:i,onChange:k=>P(k.target.value),onBlur:()=>{if(S.current){S.current=!1;return}m()},onKeyDown:k=>{k.key==="Enter"&&k.currentTarget.blur(),k.key==="Escape"&&(S.current=!0,P(g),k.preventDefault(),k.stopPropagation(),k.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, ${n.primary} 50%, ${n.secondary})`,font:"inherit",fontSize:14}})]}),T&&t("span",{"data-taste-color-swatch":!0,title:T,"aria-label":`Color preview: ${T}`,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 ${n.border}`},children:t("span",{style:{display:"block",width:"100%",height:"100%",backgroundColor:T}})}),o&&t("button",{type:"button",disabled:i,onClick:l,"aria-label":`Reset ${a}`,style:{border:0,background:"transparent",color:n.secondary,padding:0},children:t(fa,{size:12})})]})}var Ha=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,a){this.invalidate(e),this.entries.set(e,{response:new Response(JSON.stringify(a)),expires:Date.now()+6e4,abort:new AbortController})}async read(e){let a=this.entries.get(e);if(a?.response&&a.expires>Date.now())return a.response.clone();if(a?.pending)return(await a.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=me(e,{signal:r.abort.signal}).then(async i=>{if(i.ok){let o=await i.clone().json();if(!o.sections||!Array.isArray(o.overrides))throw new Error("Invalid taste definition");this.entries.get(e)===r&&(r.response=i.clone(),r.expires=Date.now()+6e4)}else this.entries.get(e)===r&&this.entries.delete(e);return i}).catch(i=>{throw this.entries.get(e)===r&&this.entries.delete(e),i}).finally(()=>{r.pending=void 0}),(await r.pending).clone()}},Ua={principles:"tokens",components:"components",assets:"visual-directions",content:"copy-guidance"};function Va(e,a,r){if(a.kind==="search")return e.querySelector(r.searchOpen?"[data-taste-search] input":"[data-taste-search-trigger]");let i=`${a.collection}:${a.id}`;if(!r.showingDetail)return[...e.querySelectorAll("[data-taste-entry-id]")].find(o=>o.getAttribute("data-taste-entry-id")===i)??null;if(r.detailEntryId!==i)return null;if(a.kind==="path"&&r.drilldownVisible&&Ua[a.path[0]??""]===r.drilldown){let o=e.querySelector('[data-taste-layer="drilldown"]'),n=[...o?.querySelectorAll("[data-taste-path]")??[]].find(s=>s.getAttribute("data-taste-path")===JSON.stringify(a.path));if(n)return n;if(a.path.length>=2){let s=[...o?.querySelectorAll("[data-taste-group-path]")??[]].find(l=>l.getAttribute("data-taste-group-path")===JSON.stringify(a.path.slice(0,2)));if(s)return s}}return e.querySelector("[data-taste-nav-title]")}var _t=e=>typeof e=="string"&&e.length>0&&e.length<=200&&!["__proto__","prototype","constructor"].includes(e);function _a(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid Taste looking target");let a=e;if(a.kind==="search"&&typeof a.query=="string"&&a.query.length<=200)return{kind:"search",query:a.query};if((a.kind==="taste"||a.kind==="path")&&(a.collection==="public"||a.collection==="private")&&_t(a.id)){let r={collection:a.collection,id:a.id};if(a.kind==="taste")return{kind:"taste",...r};if(Array.isArray(a.path)&&a.path.length>=1&&a.path.length<=12&&a.path.every(_t)&&["principles","components","assets","content"].includes(a.path[0]??""))return{kind:"path",...r,path:[...a.path]}}throw new Error("Invalid Taste looking target")}var Xt=(e,a)=>`${e}:${a}`;function Xa(e){let a=z(e.onDirectionChange);a.current=e.onDirectionChange;let[r,i]=$([]),o=z(null),n=z(null),[s,l]=$(0),[c,p]=$(!1),[f,g]=$(null),[w,P]=$(!1),[I,S]=$(!1),T=z(null),[m,k]=$(null),[v,_]=$(null),[A,N]=$(),D=()=>{let u=T.current?.offsetHeight;u&&N(u),S(!0)},[W,H]=$(!1),J=z(null),F=z(null),de=z(!1);X(()=>{I?J.current?.focus({preventScroll:!0}):de.current&&F.current?.focus({preventScroll:!0}),de.current=I},[I]);let C=()=>{S(!1),d("")},[y,d]=$(""),R=z(void 0);X(()=>()=>clearTimeout(R.current),[]);let[G,x]=$(),[O,B]=$(!1),[ge,ue]=$(null),ae=z(void 0),ye=u=>{clearTimeout(ae.current),ue(e.visible===!1?null:u),ae.current=setTimeout(()=>ue(null),200)};X(()=>{e.visible===!1&&(clearTimeout(ae.current),ue(null))},[e.visible]),X(()=>()=>clearTimeout(ae.current),[]);let pe=z(void 0);X(()=>()=>clearTimeout(pe.current),[]);let[E,ve]=$(null),q=!!E&&c,[_e,M]=$(!1),[U,Z]=$(null),[ce,oe]=$(),ee=ce!==void 0?ce:U?.direction,Y=ee?Xt(ee.sourceCollection,ee.sourceModelId):null,[he,le]=$(!1),[rt,Xe]=$(!1),Ce=z(null);X(()=>()=>Ce.current?.abort(),[]);let[Re,Ee]=$(!1),[Jt,it]=$(!0),[xt,ke]=$("Loading collection\u2026"),[qe,kt]=$(0),[Yt,Kt]=$(0),Je=z(0),nt=z(!1),$t=z(""),je=z([]),We=z(void 0),ot=z(void 0),Me=z(!1),lt=z(0),we=z(0),K=e.bridgeUrl;X(()=>{if(!K||e.visible===!1){k(null);return}let u=!0,b=!1,j=async()=>{if(!b){b=!0;try{let te=await me(`${K}/cloud-taste/agent-look`,{cache:"no-store"}),se=await te.json();u&&k(te.ok&&se.status==="looking"&&se.expiresAt>Date.now()?_a(se.target):null)}catch{u&&k(null)}finally{b=!1}}};j();let L=setInterval(()=>{j()},750);return()=>{u=!1,clearInterval(L)}},[K,e.visible]);let Ie=Pt(()=>({bridgeUrl:K,revision:qe,cache:new Ha}),[K,qe]).cache;X(()=>{let u=T.current;if(!u||!m||e.visible===!1){_(null);return}let b=()=>{let L=Va(u,m,{searchOpen:I,showingDetail:q,detailEntryId:E?.id??null,drilldown:f,drilldownVisible:w});_(te=>te===L?te:L)};b();let j=new MutationObserver(b);return j.observe(u,{childList:!0,subtree:!0}),()=>j.disconnect()},[m,E,f,w,e.visible,I,q]),X(()=>()=>Ie.clear(),[Ie]);let[,Gt]=$(0),V=Pt(()=>({bridgeUrl:K,revision:qe,requests:new Map}),[K,qe]).requests;X(()=>()=>{for(let u of V.values())u.abort.abort();V.clear()},[V]);let Le=na(u=>{let b=V.get(u.id);if(b&&(b.fetchedAt===void 0||Date.now()-b.fetchedAt<3e4))return b.promise;let j=new AbortController,[L="",te=""]=u.id.split(":"),se={preview:b?.preview,facts:b?.facts,abort:j,promise:Promise.resolve([])};return se.promise=(async()=>{if(!K)throw Error("Connection unavailable.");let Be=await me(`${K}/cloud-taste/summary?${new URLSearchParams({id:te,collection:L})}`,{signal:j.signal,cache:"no-store"});if(!Be.ok)throw Error("Summary unavailable.");let xe=await Be.json();if(!Array.isArray(xe.facts))throw Error("Summary unavailable.");if(!j.signal.aborted){se.facts=xe.facts,se.fetchedAt=Date.now();let ie=Ae(xe.preview),Pe=je.current.find(De=>De.id===u.id)?.preview;se.preview=Pe&&Pe!==u.preview||Pe&&(Pe.recipeRevision??0)>(ie?.recipeRevision??0)?Pe:ie,Gt(De=>De+1)}return xe.facts})(),V.set(u.id,se),se.promise.catch(()=>{V.get(u.id)===se&&(b?.preview||b?.facts?V.set(u.id,b):V.delete(u.id))}),se.promise},[K,V]),[st,dt]=$(null);X(()=>{let u=r.find(j=>j.id===Y),b=[...u?[u]:[],...["private","public"].flatMap(j=>r.filter(L=>L.sourceCollection===j&&L.id!==Y))].slice(0,20);for(let j of b)j.preview||Le(j).catch(()=>{})},[Y,r,Le]),X(()=>{if(!E||!K)return;let u=!0;return dt({id:E.id,cache:V,notice:"Loading details\u2026"}),(async()=>{try{let b=await Le(E);u&&dt({id:E.id,cache:V,facts:b})}catch{u&&dt({id:E.id,cache:V,notice:"Summary unavailable. Reopen this taste to retry."})}})(),()=>{u=!1}},[E,K,Le,V]),X(()=>{let u=()=>{Je.current>0&&!nt.current&&!Me.current&&Date.now()-Je.current>=3e4&&Kt(j=>j+1)};if(u(),e.visible===!1)return;let b=setInterval(u,3e4);return window.addEventListener("focus",u),()=>{clearInterval(b),window.removeEventListener("focus",u)}},[e.visible,e.prefetchSignal]),X(()=>{let u=++we.current,b=lt.current,j=new AbortController,L;nt.current=!0;let te=`${K}:${qe}`,se=$t.current===te&&je.current.length>0;$t.current=te,se||(it(!0),Z(null),oe(void 0),le(!1),M(!1),i([]),je.current=[]);async function Be(){try{if(!K)throw Error("Connection unavailable.");let xe=await me(`${K}/cloud-taste/status`,{signal:j.signal,cache:"no-store"});if(!xe.ok)throw Error("Connection unavailable.");let ie=await xe.json();if(u!==we.current)return;if(ie.pending){ke("Complete sign-in in the browser."),L=setTimeout(Be,1e3);return}if(ie.state!=="signed_in"){a.current?.(null),Ie.clear(),i([]),je.current=[],ve(null);for(let re of V.values())re.abort.abort();throw V.clear(),Error("Sign in to activate a taste.")}if(We.current!==void 0&&(We.current!==ie.accountId||ot.current!==ie.environment)){Ie.clear(),Ce.current?.abort(),x(void 0);for(let re of V.values())re.abort.abort();V.clear(),je.current=[],i([]),ve(null)}We.current=ie.accountId,ot.current=ie.environment,ie.canInspect||Ie.clear();let[Pe,De,Ge]=await Promise.all([me(`${K}/cloud-taste/catalog`,{signal:j.signal,cache:"no-store"}),me(`${K}/cloud-taste/direction`,{signal:j.signal,cache:"no-store"}),ie.canBrowsePrivate===!0?me(`${K}/cloud-taste/private-catalog`,{signal:j.signal,cache:"no-store"}):null]);if(!Pe.ok||!De.ok||Ge&&!Ge.ok)throw Error("Could not load tastes. Please retry or reconnect in Settings.");let ta=await Pe.json(),aa=Ge?await Ge.json():{items:[]},pt=await De.json();if(u!==we.current)return;let Ze=["private","public"].flatMap(re=>(re==="private"?aa.items:ta.items).map(ne=>({id:Xt(re,ne.id),sourceModelId:ne.id,sourceCollection:re,thumbnailUrl:ne.thumbnailUrl,preview:Ae(ne.preview),name:ne.name,...ne.version?{metadata:{value:ne.version,label:`Version ${ne.version}`}}:{}}))).sort((re,ne)=>re.name.localeCompare(ne.name));for(let re of Ze){let ne=V.get(re.id);ne&&re.preview&&(ne.preview?.recipeRevision!==re.preview.recipeRevision||ne.preview?.contentRevision!==re.preview.contentRevision)&&(ne.abort.abort(),V.delete(re.id))}je.current=Ze,i(Ze),se&&ve(re=>re?Ze.find(ne=>ne.id===re.id)??null:null),Je.current=Date.now(),b===lt.current&&(Z(pt),typeof ie.accountId=="string"&&a.current?.({accountId:ie.accountId,environment:ie.environment,name:pt.direction?.name??null,generation:pt.generation})),le(ie.canWrite===!0),Xe(ie.canInspect===!0),M(ie.canBrowsePrivate===!0),ke(null)}catch(xe){u===we.current&&ke(xe instanceof Error?xe.message:"Connection unavailable.")}finally{u===we.current&&(it(!1),nt.current=!1,Je.current=Date.now())}}return Be(),()=>{we.current=u+1,j.abort(),clearTimeout(L)}},[K,qe,Yt,V,Ie]);async function Ye(u){if(!K||!U||!he||Me.current)return;let b=u?r.find(L=>L.id===u.id):void 0;if(u&&!b){ke("Reload the collection before choosing this taste.");return}Me.current=!0,lt.current+=1,oe(b?{sourceModelId:b.sourceModelId,sourceCollection:b.sourceCollection,name:b.name,sourceVersion:b.metadata?.value??null}:null),b&&!b.preview&&!V.get(b.id)?.preview&&Le(b).catch(()=>{}),Ee(!0),ke("Saving taste\u2026");let j=we.current;try{let L=await me(`${K}/cloud-taste/direction`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedGeneration:U.generation,...b?{sourceModelId:b.sourceModelId,sourceCollection:b.sourceCollection}:{}})});if(!L.ok)throw Error("The change could not be confirmed. Reload the collection before trying again.");let te=await L.json();if(j!==we.current)return;Z(te),oe(void 0),typeof We.current=="string"&&a.current?.({accountId:We.current,environment:ot.current,name:te.direction?.name??null,generation:te.generation}),ke(null)}catch(L){j===we.current&&(Z(null),oe(void 0),a.current?.(null),ke(L instanceof Error?L.message:"Could not save taste. Reload to check its state."))}finally{Me.current=!1,j===we.current&&Ee(!1)}}async function St(){if(!K||Me.current)return;let u=window.open("about:blank","_blank");if(!u){ke("Allow popups, then try again.");return}u.opener=null,Me.current=!0,Ee(!0);try{let b=await me(`${K}/cloud-taste/enable-activation`,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"});if(!b.ok)throw Error("Could not start sign-in. Retry in Settings.");let j=await b.json(),L=ia(j.authorizationUrl);u.location.replace(L.href),kt(te=>te+1)}catch(b){u.close(),ke(b instanceof Error?b.message:"Could not start sign-in.")}finally{Me.current=!1,Ee(!1)}}let Ke=r.find(u=>u.id===Y),Zt=ee&&Y?Ke?{...Ke,preview:V.get(Ke.id)?.preview??Ke.preview}:{id:Y,name:ee.name,sourceModelId:ee.sourceModelId,sourceCollection:ee.sourceCollection,...ee.sourceVersion?{metadata:{value:ee.sourceVersion,label:`Version ${ee.sourceVersion}`}}:{}}:null,Ct=u=>r.filter(b=>b.sourceCollection===u).map(b=>({...b,preview:V.get(b.id)?.preview??b.preview})),Qt=!!U&&(!he||!_e),Rt=E?V.get(E.id)?.facts:void 0,It=st?.id===E?.id&&st?.cache===V?st:null,fe=He[e.theme],ct=!q||w,ze=I&&ct,zt=w&&f?f==="components"?sa:f==="copy-guidance"?da:f==="version"?ca:f==="visual-directions"?ua:pa:Qe;X(()=>{q&&n.current?.focus({preventScroll:!0})},[q]);let ut=()=>{if(H(!1),clearTimeout(ae.current),ue(null),S(!1),d(""),w){P(!1),clearTimeout(R.current),R.current=setTimeout(()=>g(null),220);return}p(!1),clearTimeout(pe.current),pe.current=setTimeout(()=>ve(null),220)},ea=()=>{it(!0),kt(u=>u+1)};return X(()=>{if(e.visible===!1)return;let u=b=>{if(b.key==="Tab"&&H(!0),b.defaultPrevented||b.isComposing||b.metaKey||b.ctrlKey||b.altKey)return;let j=b.composedPath().some(L=>L instanceof HTMLElement&&(L.matches('input, textarea, select, [role="textbox"], [role="combobox"]')||L.isContentEditable));if(!(b.key==="Escape"&&b.composedPath().some(L=>L instanceof HTMLElement&&L.matches("[data-taste-value-input]")))){if(b.key===" "&&ct&&!j)H(!1),b.preventDefault(),b.stopImmediatePropagation(),b.repeat||D();else if(b.key==="Escape"){if(H(!1),b.preventDefault(),b.stopImmediatePropagation(),b.repeat)return;ze?C():q?ut():e.onClose()}}};return document.addEventListener("keydown",u,!0),()=>document.removeEventListener("keydown",u,!0)}),h("div",{"data-popmelt-font":"sans",ref:T,"data-taste-keyboard-focus":W,onPointerDownCapture:()=>H(!1),"data-taste-navigation":q?"detail":"collection","data-taste-animated":O||void 0,"data-taste-entering":e.visible===!1?void 0:ge??void 0,"data-taste-depth":w?"drilldown":"overview",style:{position:"relative",height:ze?A:e.style?.height,maxHeight:e.style?.maxHeight,overflow:"hidden",borderRadius:20,background:fe.surface,fontFamily:ht},children:[t("style",{children:`
|
|
56
|
+
[data-taste-navigation] { user-select: none; -webkit-user-select: none; }
|
|
57
|
+
[data-taste-navigation] input, [data-taste-navigation] textarea, [data-taste-navigation] [contenteditable="true"] { user-select: text; -webkit-user-select: text; }
|
|
58
|
+
[data-taste-keyboard-focus="false"] [data-taste-navigation-header] :focus { outline: none !important; box-shadow: none !important; }
|
|
59
|
+
[data-taste-navigation] [data-taste-collection-header], [data-taste-navigation] [data-taste-detail-header] { display: none !important; }
|
|
60
|
+
[data-taste-navigation] [data-popmelt-taste], [data-taste-navigation] [data-taste-detail] { padding-top: 60px !important; }
|
|
61
|
+
[data-taste-navigation] [data-taste-detail] { position: absolute; inset: 0; z-index: 1; background: transparent !important; overflow: hidden !important; }
|
|
62
|
+
[data-taste-navigation] [data-taste-detail-body] { min-height: 0; overflow-y: auto; flex-shrink: 1; }
|
|
63
|
+
[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; }
|
|
64
|
+
[data-taste-navigation="detail"] [data-taste-scroll] { transform: translateX(-100%); opacity: 0; }
|
|
65
|
+
[data-taste-navigation="collection"] [data-taste-detail-body] { transform: translateX(100%); opacity: 0; }
|
|
66
|
+
[data-taste-entering="overview"] [data-taste-layer="overview"] [data-taste-detail-body],
|
|
67
|
+
[data-taste-entering="drilldown"] [data-taste-layer="drilldown"] [data-taste-detail-body] { animation: taste-detail-enter 200ms cubic-bezier(.2,.8,.2,1); }
|
|
68
|
+
[data-taste-depth="drilldown"] [data-taste-layer="overview"] [data-taste-detail-body] { transform: translateX(-100%); opacity: 0; }
|
|
69
|
+
[data-taste-depth="overview"] [data-taste-layer="drilldown"] [data-taste-detail-body] { transform: translateX(100%); opacity: 0; }
|
|
70
|
+
@keyframes taste-detail-enter { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
|
|
71
|
+
[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; }
|
|
72
|
+
[data-taste-navigation] [data-taste-nav-title]:hover [data-taste-refresh-icon] { opacity: 1; transform: none; }
|
|
73
|
+
[data-taste-navigation] [data-taste-nav-action]:enabled:hover { background: ${fe.actionHover} !important; }
|
|
74
|
+
[data-taste-navigation] [data-taste-search-trigger]:hover, [data-taste-navigation] [data-taste-search-trigger]:focus-visible { color: ${fe.primary} !important; }
|
|
75
|
+
[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; }
|
|
76
|
+
[data-taste-navigation-header] > [data-taste-search] { opacity: 0; transform: translateX(12px); visibility: hidden; pointer-events: none; }
|
|
77
|
+
[data-taste-navigation-header][data-search-open="true"] > [data-taste-search] { opacity: 1; transform: none; visibility: visible; pointer-events: auto; transition-delay: 0s; }
|
|
78
|
+
[data-taste-navigation-header] > [data-taste-header-default] { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }
|
|
79
|
+
[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; }
|
|
80
|
+
@media (prefers-reduced-motion: reduce) { [data-taste-navigation] *, [data-taste-navigation] [data-taste-detail-body] { animation: none !important; transition: none !important; } }
|
|
81
|
+
`}),h("div",{"data-taste-navigation-header":!0,"data-search-open":ze,style:{position:"absolute",top:16,left:16,right:16,height:28,zIndex:2,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[h("div",{"data-taste-search":!0,inert:!ze,"aria-hidden":!ze,style:{position:"absolute",inset:0,display:"flex",alignItems:"center",gap:8,width:"100%",color:fe.secondary},children:[t(gt,{size:16}),t("input",{ref:J,"aria-label":q?"Search taste definitions":"Search tastes",placeholder:q?"Search keys and values\u2026":"Search tastes\u2026",value:y,onChange:u=>d(u.target.value),onKeyDown:u=>{u.stopPropagation(),u.key==="Escape"&&C()},style:{flex:1,minWidth:0,border:0,outline:"none",background:"transparent",color:fe.primary,font:"inherit",fontSize:12}}),t("button",{type:"button","aria-label":"Close search",onClick:C,style:{border:0,padding:4,background:"transparent",color:fe.secondary,cursor:"pointer"},children:t(Fe,{size:16})})]}),h("div",{"data-taste-header-default":!0,inert:ze,"aria-hidden":ze,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,width:"100%"},children:[h("button",{ref:n,type:"button","data-taste-nav-title":!0,"aria-label":q?w?"Back to taste details":"Back to taste collection":"Back to settings",onClick:q?ut:e.onClose,style:{display:"flex",alignItems:"center",gap:3,padding:0,border:0,background:"transparent",color:q?fe.secondary:fe.primary,fontFamily:"inherit",fontSize:q?12:14,fontWeight:600,letterSpacing:q?"-.12px":"-.14px",minWidth:0,cursor:"pointer"},children:[t(At,{size:16,style:{width:16,color:fe.primary}}),t(zt,{"data-taste-nav-icon":!0,style:{width:q?14:16,height:q?14:16,transform:zt===Qe?"scaleY(-1)":void 0,transitionProperty:"color, width, height, opacity"}}),t("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:q?E.name:void 0,children:q?f&&w?{version:"Versions",tokens:"Tokens",components:"Components","visual-directions":"Visual directions","copy-guidance":"Copy guidance"}[f]??f:E.name:"Taste"})]}),t("div",{style:{position:"relative",height:28,width:80,flexShrink:0},children:ct?t("button",{type:"button","aria-label":q?"Search definitions":"Search tastes",ref:F,"data-taste-search-trigger":!0,onClick:()=>{H(!1),D()},style:{position:"absolute",right:0,border:0,padding:6,background:"transparent",color:fe.muted,transition:"color 160ms ease",cursor:"pointer"},children:t(gt,{size:16})}):t(be,{children:t("button",{type:"button","data-taste-nav-action":!0,"aria-label":`${E?.id===Y?"Remove":"Add"} ${E?.name??"taste"}`,"aria-pressed":!!E&&E.id===Y,inert:!q,disabled:!he||!U||Re,onClick:()=>{E&&Ye(E.id===Y?void 0:E)},style:{position:"absolute",right:0,top:0,display:"flex",alignItems:"center",gap:3,padding:E?.id===Y?"4px 7px 4px 8px":"4px 8px",border:0,borderRadius:8,background:fe.actionSurface,color:fe.actionForeground,font:"inherit",fontSize:12,fontWeight:600,cursor:"pointer",opacity:q?1:0,transform:q?"translateX(0)":"translateX(5px)",pointerEvents:q?"auto":"none"},children:E?.id===Y?h(be,{children:["Remove",t(Fe,{size:12})]}):h(be,{children:[t(mt,{size:12}),"Add"]})})})})]})]}),E&&(f?["overview","drilldown"]:["overview"]).map(u=>t("div",{"data-taste-layer":u,inert:!q||u==="drilldown"!==w,"aria-hidden":!q||u==="drilldown"!==w,children:t(Ia,{theme:e.theme,style:{...e.style,...s>0?{minHeight:`min(${s}px, ${typeof e.style?.maxHeight=="number"?`${e.style.maxHeight}px`:e.style?.maxHeight??"calc(100dvh - 64px)"})`}:{}},entry:{...E,preview:G??V.get(E.id)?.preview??E.preview},facts:Rt??It?.facts,onOpenFact:b=>{H(!1),ye("drilldown"),clearTimeout(R.current),S(!1),d(""),g(b),P(!0)},drilldown:u==="drilldown"&&f?t(Na,{cache:Ie,bridgeUrl:e.bridgeUrl,id:E.sourceModelId,collection:E.sourceCollection,section:f,query:y,theme:e.theme,onPreview:x,onReconnect:()=>{St()}},`${E.id}:${f}`):void 0,summaryNotice:Rt?void 0:It?.notice??"Loading details\u2026",active:E.id===Y,onBack:ut,onToggle:he&&U&&!Re?()=>{Ye(E.id===Y?void 0:E)}:void 0,notice:xt},E.id)},u)),t("div",{ref:o,inert:q,"aria-hidden":q,style:{display:"contents"},children:t(Ra,{...e,style:{...e.style,...ze&&A?{height:"100%"}:{}},publicEntries:Ct("public").filter(u=>q||`${u.name} ${u.metadata?.value??""}`.toLowerCase().includes(y.trim().toLowerCase())),privateEntries:Ct("private").filter(u=>q||`${u.name} ${u.metadata?.value??""}`.toLowerCase().includes(y.trim().toLowerCase())),activeEntryId:Y,activeEntry:Zt,onRefresh:ea,refreshing:Jt,refreshDisabled:Re,onAdd:he&&U&&!Re?u=>{Ye(u)}:void 0,onRemove:he&&U&&!Re?()=>Ye():void 0,onOpenDetails:u=>{if(H(!1),ye("overview"),clearTimeout(pe.current),B(!0),l(o.current?.firstElementChild?.offsetHeight??0),ve(u),g(null),P(!1),S(!1),d(""),x(void 0),Ce.current?.abort(),rt&&e.bridgeUrl){let b=new AbortController;Ce.current=b,Ie.read(`${e.bridgeUrl}/cloud-taste/definition?id=${encodeURIComponent(u.sourceModelId)}&collection=${u.sourceCollection}`).then(async j=>{if(!j.ok)return;let L=await j.json(),te=Ae(L.preview);!b.signal.aborted&&te&&x(te)}).catch(()=>{})}p(!0)},onPrefetchDetails:u=>{Le(u).catch(()=>{})},privateEmptyMessage:_e?"No private results found.":"Reconnect to browse your private tastes.",notice:xt,action:Qt?t("button",{type:"button",disabled:Re,onClick:()=>{St()},style:{border:0,borderRadius:8,padding:"6px 10px",cursor:"pointer",font:"inherit"},children:"Reconnect account"}):null})}),t(ra,{element:v,label:"AI is looking at this Taste",inverse:!0})]})}export{Xa as PopmeltTasteConnectedPane};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{b as c}from"./chunk-FRHGK5ZV.mjs";import"./chunk-NXMPY7RX.mjs";import"./chunk-ZJPPZLXU.mjs";import{useRef as i,useEffect as s}from"react";function f({config:r,adapters:e}){let n=i(e);n.current=e;let t=i(new Set);return s(()=>{c({sourceId:r.projectId,revision:r.revision},{get:()=>n.current,subscribe:u=>(t.current.add(u),()=>{t.current.delete(u)})});let o=window.__POPMELT_CODE_PREVIEW__;return()=>o?.dispose()},[r]),s(()=>{for(let o of t.current)o()},[e]),null}export{f as default};
|