@popmelt.com/core 0.33.0 → 0.33.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.
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/dist/ExploreAttachment-VKCCEIM7.mjs +1 -0
- package/dist/ParticipantRuntime-YS5SIZUQ.mjs +1 -0
- package/dist/PopmeltTasteConnectedPane-FKIJM3C7.mjs +1 -215
- package/dist/PreviewRuntime-LFPK56NW.mjs +1 -2
- package/dist/QueuedReplies-ZYUDSTS2.mjs +1 -46
- package/dist/SuppliedContext-RWN6UR3K.mjs +1 -2
- package/dist/ThreadErrorCard-7J62GD5W.mjs +1 -2
- package/dist/ThreadPanel-KVNM67WO.mjs +1 -0
- package/dist/adapter-react-three-fiber.mjs +1 -2
- package/dist/bridge-entry.mjs +1 -1
- package/dist/bridge-recovery-3IQN3U6D.mjs +1 -2
- package/dist/bridgeSSEStream-NEYI73TC.mjs +1 -4
- package/dist/bridgeWebSocketStream-H3DCP4T3.mjs +1 -2
- package/dist/browser-runtime-AP35S5MK.mjs +1 -0
- package/dist/browser.mjs +1 -2
- package/dist/canvas-chat-note-NHYL3T6J.mjs +1 -2
- package/dist/checkFixture-MWBOYIM2.mjs +1 -0
- package/dist/chunk-27ADDVGC.mjs +1 -3
- package/dist/chunk-2IASPT6L.mjs +1 -2
- package/dist/chunk-2P2NUZW7.mjs +1 -2
- package/dist/chunk-2VCHBI7Y.mjs +1 -11
- package/dist/chunk-2ZJ4FBTG.mjs +1 -2
- package/dist/chunk-4LHTPRFY.mjs +1 -2
- package/dist/chunk-5K7SACPW.mjs +1 -2
- package/dist/chunk-6V2VCKPG.mjs +1 -53
- package/dist/chunk-6VXFTT5U.mjs +1 -2
- package/dist/chunk-75PQGTKX.mjs +1 -2
- package/dist/chunk-BVTLSUQT.mjs +1 -2
- package/dist/chunk-CPOYMGYY.mjs +1 -2
- package/dist/chunk-DNOKP3JS.mjs +1 -2
- package/dist/chunk-EAV2VV2V.mjs +1 -2
- package/dist/chunk-EX63NVDN.mjs +1 -2
- package/dist/chunk-F5XSNRGT.mjs +1 -2
- package/dist/chunk-GASEZICN.mjs +1 -2
- package/dist/chunk-H7XMDLGU.mjs +30 -0
- package/dist/{chunk-C5WXW6VL.mjs → chunk-HVD5ZG6W.mjs} +1 -1
- package/dist/chunk-J3UIBBU2.mjs +1 -2
- package/dist/chunk-J4WDYITA.mjs +1 -2
- package/dist/chunk-JMMP5JSP.mjs +1 -2
- package/dist/chunk-LVEMYZOA.mjs +1 -2
- package/dist/chunk-N2QUNHV6.mjs +1 -0
- package/dist/chunk-N2ZEZCHO.mjs +1 -2
- package/dist/{chunk-HNCV37XO.mjs → chunk-N6JTX4PD.mjs} +1 -1
- package/dist/chunk-O4HZP3RP.mjs +1 -2
- package/dist/chunk-ODIGT4YJ.mjs +1 -17
- package/dist/chunk-PQT5FYN5.mjs +1 -2
- package/dist/chunk-PSSHCTJ2.mjs +1 -8
- package/dist/chunk-RESPUCV7.mjs +1 -0
- package/dist/chunk-SHAIHRV2.mjs +1 -0
- package/dist/chunk-V2I7PSJW.mjs +1 -2
- package/dist/{chunk-H2UYAUX3.mjs → chunk-VPPVURBR.mjs} +1 -1
- package/dist/chunk-W5NIRROD.mjs +1 -7
- package/dist/chunk-WHJEKDNP.mjs +1 -2
- package/dist/chunk-XKD2ABCO.mjs +1 -7
- package/dist/chunk-XTOCFTVW.mjs +1 -2
- package/dist/chunk-YLKEDOII.mjs +31 -0
- package/dist/chunk-ZHJZPC7U.mjs +1 -2
- package/dist/cli.mjs +1 -1
- package/dist/codex-note-context-4JYQ437H.mjs +2 -0
- package/dist/{codex-project-7VYHYTWO.mjs → codex-project-FA4EK6VR.mjs} +1 -1
- package/dist/focus-inspection-VBS5656D.mjs +1 -2
- package/dist/index.mjs +1 -2
- package/dist/media.mjs +1 -2
- package/dist/{peer-client-MTWZG2FB.mjs → peer-client-KJCPXT76.mjs} +1 -1
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-nuxt.mjs +1 -1
- package/dist/plugin-vite.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/taste-proposal-session-XU4N7RUV.mjs +1 -2
- package/dist/workspace-snapshot-RTTXNNUX.mjs +1 -2
- package/package.json +1 -1
- package/dist/ExploreAttachment-CLFSAWKM.mjs +0 -260
- package/dist/ParticipantRuntime-HW3MOZI5.mjs +0 -139
- package/dist/ThreadPanel-RJIHV3P6.mjs +0 -197
- package/dist/browser-runtime-JJHSKIKD.mjs +0 -2
- package/dist/checkFixture-TJDFGPQI.mjs +0 -2
- package/dist/chunk-7IJGE5AK.mjs +0 -31
- package/dist/chunk-I63OQTCF.mjs +0 -347
- package/dist/chunk-J5SC3R5L.mjs +0 -2
- package/dist/chunk-PHKDIU3X.mjs +0 -30
- package/dist/chunk-XMKYGH62.mjs +0 -142
- package/dist/codex-note-context-YHKPQ4WP.mjs +0 -2
- /package/dist/{chunk-DMWB3IRD.mjs → chunk-QOJCTLQW.mjs} +0 -0
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{b}from"./chunk-LVEMYZOA.mjs";import{v as k,d as S,o as $}from"./chunk-WHJEKDNP.mjs";function v(r,n){let l=r.filter(e=>(!n.kind||e.kind===n.kind)&&(!n.entryId||e.id===n.entryId)&&(!n.pathname||e.pathname===n.pathname)),t=Number.isInteger(n.limit)?Math.min(50,Math.max(1,n.limit)):20,o=Number.isInteger(n.offset)?Math.max(0,n.offset):0;return{entries:l.slice(o,o+t).map(({details:e,...d})=>n.entryId?{...d,details:e}:d),total:l.length,nextOffset:o+t<l.length?o+t:null}}function I(r,n,l,t=!1){if(!r||!n)return null;let o=i=>{let s=S(i),h=b(i),u=a=>a.width>0&&a.height>0&&a.bottom>0&&a.right>0&&a.top<innerHeight&&a.left<innerWidth;return i.isConnected&&s.width>0&&s.height>0&&(t||u(s)||!!h&&u(h))&&!$(i,'[data-popmelt-private], [aria-hidden="true"]')},e=i=>{try{let s=i?document.querySelectorAll(i):[];return s.length===1?s[0]:null}catch{return null}};if(n.startsWith("thread:")){let i=n.slice(7),s=[...document.querySelectorAll("[data-popmelt-thread-id]")].filter(a=>a.getAttribute("data-popmelt-thread-id")===i&&o(a));if(s.length===1)return s[0].querySelector("[data-popmelt-thread-header]");let h=r.annotations.filter(a=>a.threadId===i&&(!a.pathname||a.pathname===location.pathname)),u=new Set(h.map(a=>a.target?l.resolve(a.target)?.element??null:k(a.linkedSelector,a.elements?.[0])).filter(a=>!!a&&o(a)));return u.size===1?[...u][0]:null}let d=y(r,{entryId:n});if(!("entries"in d)||d.entries.length!==1)return null;let c=d.entries[0];if(c.pathname&&c.pathname!==location.pathname)return null;let m=r.annotations.find(i=>`draft:${i.id}`===n);if(m?.target){let i=l.resolve(m.target)?.element;return i&&o(i)?i:null}let g="details"in c?c.details:void 0,x=[...r.styleModifications,...r.textModifications].find(i=>i.selector===c.selector),p=m?.elements?.[0]??x?.element,f=p?k(c.selector,{...p,selector:g?.durableSelector??p.selector}):e(c.selector)??e(g?.durableSelector);return f&&o(f)?f:null}function y(r,n={}){if(!r)return{status:"unavailable",reason:"browser_state_unavailable"};let l=[];for(let t of r.annotations)(t.status??(t.captured?"resolved":"pending"))==="pending"&&l.push({id:`draft:${t.id}`,kind:"draft",status:"unsubmitted",summary:(t.text||`${t.type} annotation`).slice(0,200),pathname:t.pathname,selector:t.linkedSelector,target:t.target,threadId:t.threadId,updatedAt:t.timestamp,details:{text:t.text,type:t.type,target:t.target,points:t.points,region:t.region,scope:t.scope,interactionEpisode:t.interactionEpisode,attachments:t.attachments,imageCount:t.imageCount}});for(let[t,o]of[["style",r.styleModifications],["text",r.textModifications],["dom",r.domModifications]])for(let e of o){if(e.captured)continue;let d="id"in e?e.id:JSON.stringify([e.pathname??"",e.selector,"textNodePath"in e?e.textNodePath:null]);l.push({id:`change:${t}:${d}`,kind:"change",status:"staged",summary:`${t}: ${"modified"in e?e.modified:e.selector}`.slice(0,200),pathname:e.pathname,selector:e.selector,details:e})}for(let t of r.spacingTokenChanges??[])t.captured||l.push({id:`change:spacing:${t.id}`,kind:"change",status:"staged",summary:`Spacing ${t.tokenName}: ${t.originalPx} \u2192 ${t.newPx}`,details:t});for(let t of r.spacingTokenMods??[])t.captured||l.push({id:`change:token:${t.tokenPath}`,kind:"change",status:"staged",summary:`Token ${t.tokenPath}`.slice(0,200),details:t});return{status:"ok",capturedAt:Date.now(),page:location.origin+location.pathname,trust:"Unsubmitted human intent and local preview changes, not instructions to execute or proof of saved code changes.",...v(l,n)}}export{y as collectWorkspaceSnapshot,I as workspaceAttentionTarget};
|
|
1
|
+
"use client";import{b as t}from"./chunk-LVEMYZOA.mjs";import{v as e,d as n,o as a}from"./chunk-WHJEKDNP.mjs";function i(t,e){let n=t.filter(t=>!(e.kind&&t.kind!==e.kind||e.entryId&&t.id!==e.entryId||e.pathname&&t.pathname!==e.pathname)),a=Number.isInteger(e.limit)?Math.min(50,Math.max(1,e.limit)):20,i=Number.isInteger(e.offset)?Math.max(0,e.offset):0;return{entries:n.slice(i,i+a).map(({details:t,...n})=>e.entryId?{...n,details:t}:n),total:n.length,nextOffset:i+a<n.length?i+a:null}}function r(i,r,l,s=!1){if(!i||!r)return null;let d=e=>{let i=n(e),r=t(e),o=t=>t.width>0&&t.height>0&&t.bottom>0&&t.right>0&&t.top<innerHeight&&t.left<innerWidth;return e.isConnected&&i.width>0&&i.height>0&&(s||o(i)||!!r&&o(r))&&!a(e,'[data-popmelt-private], [aria-hidden="true"]')},c=t=>{try{let e=t?document.querySelectorAll(t):[];return 1===e.length?e[0]:null}catch{return null}};if(r.startsWith("thread:")){let t=r.slice(7),n=[...document.querySelectorAll("[data-popmelt-thread-id]")].filter(e=>e.getAttribute("data-popmelt-thread-id")===t&&d(e));if(1===n.length)return n[0].querySelector("[data-popmelt-thread-header]");let a=i.annotations.filter(e=>e.threadId===t&&(!e.pathname||e.pathname===location.pathname)),o=new Set(a.map(t=>t.target?l.resolve(t.target)?.element??null:e(t.linkedSelector,t.elements?.[0])).filter(t=>!!t&&d(t)));return 1===o.size?[...o][0]:null}let u=o(i,{entryId:r});if(!("entries"in u)||1!==u.entries.length)return null;let h=u.entries[0];if(h.pathname&&h.pathname!==location.pathname)return null;let m=i.annotations.find(t=>`draft:${t.id}`===r);if(m?.target){let t=l.resolve(m.target)?.element;return t&&d(t)?t:null}let p="details"in h?h.details:void 0,f=[...i.styleModifications,...i.textModifications].find(t=>t.selector===h.selector),g=m?.elements?.[0]??f?.element,k=g?e(h.selector,{...g,selector:p?.durableSelector??g.selector}):c(h.selector)??c(p?.durableSelector);return k&&d(k)?k:null}function o(t,e={}){if(!t)return{status:"unavailable",reason:"browser_state_unavailable"};let n=[];for(let e of t.annotations)"pending"===(e.status??(e.captured?"resolved":"pending"))&&n.push({id:`draft:${e.id}`,kind:"draft",status:"unsubmitted",summary:(e.text||`${e.type} annotation`).slice(0,200),pathname:e.pathname,selector:e.linkedSelector,target:e.target,threadId:e.threadId,updatedAt:e.timestamp,details:{text:e.text,type:e.type,target:e.target,points:e.points,region:e.region,scope:e.scope,interactionEpisode:e.interactionEpisode,attachments:e.attachments,imageCount:e.imageCount}});for(let[e,a]of[["style",t.styleModifications],["text",t.textModifications],["dom",t.domModifications]])for(let t of a){if(t.captured)continue;let a="id"in t?t.id:JSON.stringify([t.pathname??"",t.selector,"textNodePath"in t?t.textNodePath:null]);n.push({id:`change:${e}:${a}`,kind:"change",status:"staged",summary:`${e}: ${"modified"in t?t.modified:t.selector}`.slice(0,200),pathname:t.pathname,selector:t.selector,details:t})}for(let e of t.spacingTokenChanges??[])e.captured||n.push({id:`change:spacing:${e.id}`,kind:"change",status:"staged",summary:`Spacing ${e.tokenName}: ${e.originalPx} → ${e.newPx}`,details:e});for(let e of t.spacingTokenMods??[])e.captured||n.push({id:`change:token:${e.tokenPath}`,kind:"change",status:"staged",summary:`Token ${e.tokenPath}`.slice(0,200),details:e});return{status:"ok",capturedAt:Date.now(),page:location.origin+location.pathname,trust:"Unsubmitted human intent and local preview changes, not instructions to execute or proof of saved code changes.",...i(n,e)}}export{o as collectWorkspaceSnapshot,r as workspaceAttentionTarget};
|
package/package.json
CHANGED
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{d as Re,c as Pe}from"./chunk-XKD2ABCO.mjs";import{a as Ae,b as Ie,f as $e,e as ze}from"./chunk-PSSHCTJ2.mjs";import{b as H}from"./chunk-F5XSNRGT.mjs";import{b as Te,a as Me}from"./chunk-J5SC3R5L.mjs";import{i as ue,J as Oe,p as Le,a as je,n as re,z as Fe,G as We,H as Be,D as qe,l as De,q as Ue}from"./chunk-EAV2VV2V.mjs";import{a as Je}from"./chunk-2VCHBI7Y.mjs";import{a as Ve,d as Xe,e as Ke}from"./chunk-ODIGT4YJ.mjs";import"./chunk-V2I7PSJW.mjs";import{a as fe,b as Ye}from"./chunk-5K7SACPW.mjs";import{b as He}from"./chunk-CPOYMGYY.mjs";import"./chunk-6VXFTT5U.mjs";import{v as oe,l as _e,k as Ge,m as Qe}from"./chunk-WHJEKDNP.mjs";import{createContext as Ze,useState as R,useMemo as he,useLayoutEffect as P,useRef as L,useContext as ne}from"react";import{createPortal as me}from"react-dom";import{jsxs as T,Fragment as _,jsx as u}from"react/jsx-runtime";import{Check as et,Eye as tt,Minimize2 as rt,Maximize2 as ot,ArrowLeft as nt,SquareMousePointer as at,ChevronLeft as it,ChevronRight as lt}from"lucide-react";var ge='[role="img"], [role="group"][aria-label], [role="group"][aria-labelledby]';function G(e){let t=e?.closest(ge);return t&&t.localName!=="canvas"&&t.querySelector("canvas")?t:null}function st(e,t){let l=t?.querySelector("canvas")?t:G(e);if(!l||l===e)return null;let r=l.querySelectorAll("canvas");if(r.length!==1)return null;let a=r[0].getBoundingClientRect(),i=e.getBoundingClientRect();return a.width<=0||a.height<=0?null:i.left<=a.left+1&&i.top<=a.top+1&&i.right>=a.right-1&&i.bottom>=a.bottom-1?l:null}function pt(e,t=oe(e.selector,e.element)){let l=e.element;if(l?.tagName!=="canvas"&&l?.tagName!=="svg"&&!t?.closest("svg,canvas"))return t;let r=G(t);if(r)return r;if(t)return t;let a=l?.selector,i=a?.lastIndexOf(" > ")??-1;if(a&&i>=0)try{let n=G(_e(a.slice(0,i)));if(n&&(!l?.reactComponent||fe(n)?.name===l.reactComponent))return n}catch{}if(!l?.reactComponent||l.frameContext?.length||a?.includes(" >>> "))return null;let o=Ge().flatMap(n=>Array.from(n.querySelectorAll(ge)).filter(s=>s.querySelector("canvas")&&fe(s)?.name===l.reactComponent));return o.length===1?o[0]:null}function ct(e,t){let l=Ye(e).findLast(i=>i.name===t)?.fiber;if(!l?.child)return null;let r=[l.child],a=null;for(;r.length;){let i=r.pop();if(i.tag===4)return null;i.sibling&&r.push(i.sibling);let o=i.stateNode;if((o?.nodeType===1||o?.nodeType===3)&&(!a&&o.nodeType===1&&(a=o),!a?.contains(o)))return null;i.child&&r.push(i.child)}return a?.contains(e)?a:null}function be(e){let t=oe(e.selector,e.element),l=pt(e,t),r=e.element?.reactComponent,a=t&&(r?ct(t,r):G(t));return{element:t,component:a,legacy:l,legacyScene:t&&st(t,a)}}function dt(e,t,l){let r=t==="component"?e.component:t==="element"?e.element:l&&e.legacyScene||e.legacy;return r?.isConnected&&r.parentElement&&!r.matches("body,html")&&!r.closest("[data-devtools]")?r:null}var ae=Ze({visible:!0,toggle:()=>{}}),ye=["font-family","font-size","font-weight","font-style","font-stretch","font-variation-settings","font-feature-settings","line-height","letter-spacing","white-space","overflow-wrap","word-break","flex-wrap","color"];function ve(e){return e.trim().replace(/^(['"])(.*)\1$/,"$2").toLowerCase()}function ut(e,t){let l=e.ownerDocument,r=[];function a(n){if(!n||n.disabled)return;let s;try{s=n.cssRules}catch{return}i(s,n.href??l.baseURI)}function i(n,s){for(let p of n)if(p.type===CSSRule.FONT_FACE_RULE){let{style:f}=p;if(!t.has(ve(f.getPropertyValue("font-family"))))continue;let g=p.cssText.replace(/url\("([^"]*)"\)|url\('([^']*)'\)|url\(([^)]*)\)/gi,(h,d,b,w)=>{try{return"url("+JSON.stringify(new URL(d??b??w.trim(),s).href)+")"}catch{return h}});r.push(g)}else p.type===CSSRule.IMPORT_RULE?a(p.styleSheet):"cssRules"in p&&i(p.cssRules,s)}let o=[l];for(let n=e.getRootNode();"host"in n;n=n.host.getRootNode())o.push(n);for(let n of o)for(let s of[...n.styleSheets,...n.adoptedStyleSheets])a(s);return r}async function ft(e,t){let l=new Set(Array.from(getComputedStyle(e).fontFamily.matchAll(/\s*("[^"]*"|'[^']*'|[^,]+)\s*(?:,|$)/g),o=>ve(o[1]))),r=ut(e,l).join(`
|
|
3
|
-
`),a=new Set(Array.from(r.matchAll(/url\("([^"]+)"\)/g),o=>o[1])),i=r;return await Promise.all([...a].map(async o=>{if(!o.startsWith("data:"))try{let n=await fetch(o,{signal:t,credentials:"same-origin"});if(!n.ok)return;let s=await n.blob(),p=await new Promise((f,g)=>{let h=new FileReader;h.onload=()=>f(String(h.result)),h.onerror=g,h.readAsDataURL(s)});i=i.replaceAll(JSON.stringify(o),JSON.stringify(p))}catch{}})),i}function xe(e,t,l){let r=e.closest(".sp-card");if(!r)return;let a=Array.from(r.querySelectorAll(".sp-zoom-actions, .sp-actions, .tag-option, .pager")),i=()=>{let n=e.getBoundingClientRect();if(!n.width||!n.height)return;let s=e.clientWidth/n.width,p=e.clientHeight/n.height;t({compact:!r.closest(".sp-workspace"),bounds:a.map(f=>{let g=f.getBoundingClientRect();return{left:(g.left-n.left)*s,right:(g.right-n.left)*s,top:(g.top-n.top)*p,bottom:(g.bottom-n.top)*p}})})},o=new ResizeObserver(i);o.observe(e),o.observe(r);for(let n of a)o.observe(n),n.addEventListener("pointermove",l,{passive:!0});return i(),()=>{o.disconnect();for(let n of a)n.removeEventListener("pointermove",l)}}function ie(e,t){return e.computedStyleMap?.().get(t)?.toString()??(t==="max-width"?getComputedStyle(e).maxWidth:Je(e,t))}function we(e,t){if(e){if(/^[\d.]+px$/.test(e))return parseFloat(e);if(/^[\d.]+%$/.test(e))return t*parseFloat(e)/100}}function ht(e){let t=[];for(let r=e;r;r=Qe(r))t.unshift(r);function l(){let r=e.ownerDocument.documentElement.clientWidth;for(let a of t){let i=getComputedStyle(a);if(i.display==="inline"||i.display==="contents")continue;let o=(parseFloat(i.paddingLeft)||0)+(parseFloat(i.paddingRight)||0)+(parseFloat(i.borderLeftWidth)||0)+(parseFloat(i.borderRightWidth)||0),n=i.boxSizing==="border-box",s=we(ie(a,"width"),r),p=we(ie(a,"max-width"),r),f=s===void 0?r-o:s-(n?o:0);r=Math.max(0,Math.min(f,p===void 0?1/0:p-(n?o:0)))}return r}return{boxes:t,measure:l}}var le=/^(?:@[a-zA-Z][\w-]{0,63}|~?(?:0|[1-9]\d{0,3})(?:\.(?:0|[1-9]\d{0,3})){0,31}|)$/;function ke(e,t){let l=new Map;for(let r of[...e,...t]){let a=r.part+":"+r.property,i=l.get(a)?.from??r.from;i===r.to?l.delete(a):(l.delete(a),l.set(a,{...r,from:i}))}return[...l.values()]}function se(e){let t=Object.create(null);for(let{batchId:l,option:r,part:a,property:i,to:o}of e){let n=t[l]??(t[l]=Object.create(null)),s=n[r]??(n[r]=Object.create(null)),p=s[a]??(s[a]=Object.create(null));p[i]=o}return t}function Se(e){if(!e||typeof e!="object")throw new Error("Invalid Steer edit.");let{batchId:t,option:l,part:r,property:a,from:i,to:o,sticker:n}=e;if(typeof t!="string"||typeof l!="number"||!Number.isInteger(l)||typeof r!="string"||typeof a!="string"||typeof i!="string"||typeof o!="string"||a==="text"&&n!==void 0)throw new Error("Invalid Steer edit.");a!=="text"&&pe({[a]:o});let s={batchId:t,option:l,part:r,property:a,from:i,to:o};if(n===void 0)return s;let{family:p,subproperty:f,step:g,axisSteps:h}=n;if(!ue.includes(p)||Ue(p,f)!==f||!re(p,f).includes(g))throw new Error("Invalid Steer dimension.");let d={family:p,subproperty:f,step:g};if(h===void 0)return{...s,sticker:d};let b=re("transform","translate");if(p!=="transform"||f!=="translate"||!b.includes(h.x)||!b.includes(h.y))throw new Error("Invalid Steer translation.");return{...s,sticker:{...d,axisSteps:{x:h.x,y:h.y}}}}var ee=new Map;function Q(e,t){ee.has(e)||ee.set(e,new Set),ee.get(e).add(t)}for(let e of ue){let t=Oe(e);t&&Q("display",t);for(let l of Le(e))for(let r of l==="color"?je:[l]){let a=re(e,r);for(let i of a){let o=Fe(e,r);Q(o,We(e,i,r));for(let n of Be(e,r,i))Q(n.property,n.value);if(e==="border"&&o.endsWith("width")&&Q(qe(r),"solid"),o==="translate")for(let n of a)Q(o,Number(i)*4+"px "+Number(n)*4+"px")}}}function Y(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid Steer draft.");return Object.entries(e)}function pe(e){return Object.fromEntries(Y(e).map(([t,l])=>{if(typeof l!="string"||!ee.get(t)?.has(l))throw new Error("Unsupported Steer declaration: "+t);return[t,l]}))}function Ce(e,t){if(t===void 0)return e;let l=structuredClone(e);for(let[r,a]of Y(t)){let i=l.messages.find(o=>o.batch?.id===r)?.batch;if(!i)throw new Error("Steer draft refers to an unknown batch.");for(let[o,n]of Y(a)){let s=/^[0-5]$/.test(o)&&i.options[Number(o)];if(!s)throw new Error("Steer draft refers to an unknown option.");for(let[p,f]of Y(n)){if("fixture"in s){if(!le.test(p))throw new Error("Invalid fixture part.");let{text:k,...M}=Object.fromEntries(Y(f));if(k!==void 0&&typeof k!="string")throw new Error("Invalid fixture text.");pe(M);continue}if(!/^(?:[0-7](?:\.[0-7]){0,3})?(?:\/label)?$/.test(p))throw new Error("Invalid specimen path.");let[g,h]=p.split("/"),d=s.root;for(let k of g?g.split("."):[])d=d?.children?.[Number(k)];if(!d||h&&(!d.label||d.kind==="text"))throw new Error("Steered element no longer exists.");let{text:b,...w}=Object.fromEntries(Y(f));if(b!==void 0){if(typeof b!="string"||!h&&d.kind!=="text")throw new Error("Invalid specimen text.");d.label=b}if(Object.keys(w).length){let k=h?"labelStyle":"style";d[k]={...d[k],...pe(w)}}}}}return l}function mt(e,t,l){let r={},a=e&&getComputedStyle(e);if(a)for(let n of ye)r[n]=a.getPropertyValue(n);let i=$e(),o=n=>{let{raisedSurface:s,primary:p}=Ke[n];return a&&i&&ze(i(a.color,s),i(s,s))>=4.5?a.color:p};return{style:r,width:t,fonts:l,lightInk:o("light"),darkInk:o("dark")}}function gt(e,t){let l=t.flatMap(i=>"fixture"in i?[i.fixture.bundle]:[]).join(","),[r,a]=R({});return P(()=>{let i=new AbortController,o=new Set(l.split(",").filter(Boolean));a({});for(let n of o)/^[a-f0-9]{64}$/.test(n)&&He(e+"/files/explore-"+n+".json",{signal:i.signal}).then(async s=>{if(s.status===409)return"The saved recipe could not reproduce the original preview with this checkout.";if(!s.ok)throw Error("This fixture bundle could not be loaded.");let p=await s.json();if(typeof p.script!="string"||typeof p.css!="string")throw Error("Invalid fixture bundle.");return p}).catch(()=>"This fixture bundle could not be loaded.").then(s=>{i.signal.aborted||a(p=>({...p,[n]:s}))});return()=>i.abort()},[e,l]),r}function bt({frameKey:e,bundle:t,...l}){let[r,a]=R(null);if(typeof t=="string")return u("div",{className:"sp-steer-frame",role:"alert",children:t});let i=r&&r.key!==e?r:null,o=[];return i&&o.push(u(ce,{...i.props,presentation:"retiring"},i.key)),t&&o.push(u(ce,{...l,bundle:t,presentation:r?.key===e?"current":"pending",onReady:()=>a({key:e,props:{...l,bundle:t}})},e)),o.length?u(_,{children:o}):u("div",{className:"sp-steer-frame",role:"status",children:"Loading preview\u2026"})}function ce(e){let t=L(null),l=L(null),r=L(e);r.current=e;let{toggle:a}=ne(ae),i=L(a);i.current=a;let[o,n]=R(0),[s,p]=R(""),f=he(()=>location.pathname===e.target.pathname?oe(e.target.selector,e.target.element):null,[e.target.pathname,e.target.selector,e.target.element]),{bundle:g,mirror:h,fillScene:d,framing:b}=e;return P(()=>{t.current&&(t.current.inert=e.presentation==="retiring"||e.presentation==="pending")},[e.presentation]),P(()=>{let w=t.current;if(!o||!w?.contentWindow)return;let{port1:k,port2:M}=new MessageChannel;l.current=k;let A=r.current.initial,q=f&&ht(f),C="",v=()=>mt(f,q?.measure()??document.documentElement.clientWidth,C),z=c=>k.postMessage(c),K=()=>z({type:"reference",reference:v(),theme:r.current.theme}),D=new ResizeObserver(K);for(let c of q?.boxes??[])D.observe(c);let J=!1,W=new AbortController;f&&ft(f,W.signal).then(c=>{!J&&c&&(C=c,K())}).catch(()=>{});let U=h?void 0:xe(w,c=>z({type:"controls",bounds:c}),()=>z({type:"controlEnter"})),j=w.closest(".sp-workspace"),N=["wheel","gesturestart","gesturechange","gestureend"],V=c=>{if(!b||r.current.presentation==="retiring")return;let x=c;if(x.type==="wheel"&&!x.ctrlKey&&b.getScale()===1)return;c.preventDefault(),c.stopPropagation();let I=w.getBoundingClientRect();z({type:"framingGesture",event:x.type,clientX:x.clientX-I.left,clientY:x.clientY-I.top,deltaX:x.deltaX,deltaY:x.deltaY,deltaMode:x.deltaMode,ctrlKey:x.ctrlKey,scale:x.scale??1})};for(let c of N)j?.addEventListener(c,V,{capture:!0,passive:!1});let E=JSON.stringify(A),B=!1,O=b?.subscribe(()=>{B||z({type:"framing",view:b.snapshot()})});return k.onmessage=({data:c})=>{if(!(J||r.current.presentation==="retiring"||!c||typeof c!="object"))switch(c.type){case"edits":{if(h||!Array.isArray(c.edits)||c.edits.length>512)return;try{let x=ke(A,c.edits.map(F=>{if(!le.test(F.part))throw Error();return Se({...F,batchId:"",option:0}),F})),I=JSON.stringify(x);E!==I&&(E=I,r.current.onChange?.(x))}catch{}break}case"framing":{let{view:x,fit:I}=c;if(!b||!Number.isFinite(I)||I<=0||I>1||!x||!(x.pageScale===null||Number.isFinite(x.pageScale)&&x.pageScale>0&&x.pageScale<=4)||!Number.isFinite(x.focusX)||!Number.isFinite(x.focusY))return;B=!0,b.setFitScale(I),b.restore(x),B=!1;break}case"tag":typeof c.part=="string"&&le.test(c.part)&&r.current.onTag?.(c.part,typeof c.label=="string"?c.label.slice(0,80):void 0);break;case"preview":r.current.onPreview?.(c.parts);break;case"escape":r.current.onEscape?.();break;case"toggle":h||i.current();break;case"canvas":typeof c.present=="boolean"&&r.current.onCanvas?.(c.present);break;case"ready":r.current.onReady?.(),z({type:"interaction",selected:r.current.selected}),h&&z({type:"styles",parts:r.current.parts??{}});break;case"size":h&&!d&&Number.isFinite(c.width)&&Number.isFinite(c.height)&&(w.style.height=Math.min(16384,Math.max(1,c.height))+"px",c.inline&&(w.style.width=Math.min(16384,Math.max(1,c.width))+"px"));break;case"error":r.current.onReady?.(),p(String(c.message).slice(0,300));break}},w.contentWindow.postMessage({bundle:g,initial:A,reference:v(),theme:r.current.theme,accent:r.current.accent,framing:b?.snapshot()??{pageScale:null,focusX:0,focusY:0},mirror:!!h,fillScene:d},"*",[M]),()=>{for(let c of N)j?.removeEventListener(c,V,!0);J=!0,U?.(),D.disconnect(),W.abort(),O?.(),l.current=null,k.close(),r.current.onPreview?.(null)}},[o,g,f,h,d,b]),P(()=>{l.current?.postMessage({type:"interaction",selected:e.selected})},[e.selected]),P(()=>{l.current?.postMessage({type:"styles",parts:e.parts??{}})},[e.parts]),P(()=>{l.current?.postMessage({type:"theme",theme:e.theme})},[e.theme]),T(_,{children:[u("iframe",{ref:t,title:h?"Explore page preview":"Edit or interact with this option",sandbox:"allow-scripts","aria-hidden":e.presentation==="retiring"||void 0,referrerPolicy:"no-referrer",srcDoc:Te,className:h?void 0:"sp-steer-frame",style:h?{border:0,display:"block",width:"100%",maxWidth:"100%",height:d?"100%":1}:{gridArea:"1 / 1",opacity:e.presentation==="pending"?0:1},onLoad:()=>n(w=>w+1)}),s&&u("span",{role:"alert",children:s})]})}var yt=`
|
|
4
|
-
.sp-card button { border: 0; cursor: pointer; font: inherit; }
|
|
5
|
-
.sp-card {
|
|
6
|
-
--sp-control-bg: light-dark(var(--popmelt-thread-soft, #f2f2f2), #363636);
|
|
7
|
-
position: relative;
|
|
8
|
-
align-self: stretch;
|
|
9
|
-
min-width: 0;
|
|
10
|
-
width: 100%;
|
|
11
|
-
margin-top: 6px;
|
|
12
|
-
border-radius: 12px;
|
|
13
|
-
overflow: hidden;
|
|
14
|
-
color: var(--popmelt-thread-primary, #222);
|
|
15
|
-
font:
|
|
16
|
-
13px/1.38 'Popmelt Geist',
|
|
17
|
-
system-ui,
|
|
18
|
-
sans-serif;
|
|
19
|
-
}
|
|
20
|
-
.sp-card, .sp-workspace {
|
|
21
|
-
color-scheme: light dark;
|
|
22
|
-
background-color: var(--popmelt-thread-raised, light-dark(#fff, #181818));
|
|
23
|
-
background-image: radial-gradient(circle, light-dark(#c8c8c8, #2a2a2a) 1px, transparent 1.25px);
|
|
24
|
-
background-size: 11px 11px;
|
|
25
|
-
}
|
|
26
|
-
:is(.sp-workspace[data-popmelt-theme='dark'], [data-popmelt-theme='dark'] .sp-card) {
|
|
27
|
-
color-scheme: dark;
|
|
28
|
-
}
|
|
29
|
-
:is(.sp-workspace[data-popmelt-theme='light'], [data-popmelt-theme='light'] .sp-card) {
|
|
30
|
-
color-scheme: light;
|
|
31
|
-
}
|
|
32
|
-
.sp-stage {
|
|
33
|
-
position: relative;
|
|
34
|
-
min-height: 185px;
|
|
35
|
-
display: grid;
|
|
36
|
-
place-items: center;
|
|
37
|
-
padding: 0;
|
|
38
|
-
}
|
|
39
|
-
.sp-actions,
|
|
40
|
-
.sp-zoom-actions {
|
|
41
|
-
position: absolute;
|
|
42
|
-
z-index: 2;
|
|
43
|
-
top: 6px;
|
|
44
|
-
display: flex;
|
|
45
|
-
gap: 3px;
|
|
46
|
-
opacity: 0;
|
|
47
|
-
pointer-events: none;
|
|
48
|
-
transition: opacity 120ms ease-out;
|
|
49
|
-
}
|
|
50
|
-
.sp-actions {
|
|
51
|
-
right: 6px;
|
|
52
|
-
}
|
|
53
|
-
.sp-zoom-actions {
|
|
54
|
-
left: 6px;
|
|
55
|
-
}
|
|
56
|
-
.sp-card:is(:hover, :has(:focus-visible)) :is(.sp-actions, .sp-zoom-actions) {
|
|
57
|
-
opacity: 1;
|
|
58
|
-
pointer-events: auto;
|
|
59
|
-
}
|
|
60
|
-
.sp-zoom-actions [role='group'] {
|
|
61
|
-
display: flex;
|
|
62
|
-
gap: 2px;
|
|
63
|
-
}
|
|
64
|
-
.sp-card :is(.sp-actions, .sp-zoom-actions) button {
|
|
65
|
-
color: var(--popmelt-thread-primary, #383838);
|
|
66
|
-
background: var(--sp-control-bg);
|
|
67
|
-
border-radius: 8px;
|
|
68
|
-
width: 28px;
|
|
69
|
-
height: 26px;
|
|
70
|
-
display: grid;
|
|
71
|
-
place-items: center;
|
|
72
|
-
}
|
|
73
|
-
.sp-card .sp-zoom-actions button {
|
|
74
|
-
width: 26px;
|
|
75
|
-
}
|
|
76
|
-
.sp-card .sp-zoom-actions button:disabled {
|
|
77
|
-
color: #aaa;
|
|
78
|
-
cursor: default;
|
|
79
|
-
}
|
|
80
|
-
.sp-card .sp-actions button[aria-pressed='true'] {
|
|
81
|
-
background: #ed1014;
|
|
82
|
-
color: white;
|
|
83
|
-
}
|
|
84
|
-
.sp-card button:focus-visible {
|
|
85
|
-
outline: 2px solid #ed1014;
|
|
86
|
-
outline-offset: 2px;
|
|
87
|
-
}
|
|
88
|
-
.sp-card svg {
|
|
89
|
-
width: 14px;
|
|
90
|
-
height: 14px;
|
|
91
|
-
}
|
|
92
|
-
.sp-card footer {
|
|
93
|
-
font: 14px/1.5 ${Ve};
|
|
94
|
-
display: flex;
|
|
95
|
-
align-items: center;
|
|
96
|
-
justify-content: space-between;
|
|
97
|
-
gap: 3px;
|
|
98
|
-
position: absolute;
|
|
99
|
-
inset: auto 0 0;
|
|
100
|
-
z-index: 2;
|
|
101
|
-
padding: 6px;
|
|
102
|
-
pointer-events: none;
|
|
103
|
-
}
|
|
104
|
-
.sp-card .tag-option,
|
|
105
|
-
.sp-card .pager button {
|
|
106
|
-
padding: 3px;
|
|
107
|
-
background: none;
|
|
108
|
-
color: inherit;
|
|
109
|
-
}
|
|
110
|
-
.sp-card .tag-option {
|
|
111
|
-
display: inline-flex;
|
|
112
|
-
align-items: center;
|
|
113
|
-
gap: 4px;
|
|
114
|
-
min-width: 0;
|
|
115
|
-
text-align: left;
|
|
116
|
-
}
|
|
117
|
-
.sp-card .tag-option > span {
|
|
118
|
-
overflow: hidden;
|
|
119
|
-
text-overflow: ellipsis;
|
|
120
|
-
white-space: nowrap;
|
|
121
|
-
}
|
|
122
|
-
.sp-card .tag-option > svg {
|
|
123
|
-
flex: none;
|
|
124
|
-
transform: rotate(180deg) scaleX(-1);
|
|
125
|
-
opacity: 0;
|
|
126
|
-
transition: opacity 120ms ease-out;
|
|
127
|
-
}
|
|
128
|
-
.sp-workspace .tag-option > svg {
|
|
129
|
-
transform: scaleX(-1);
|
|
130
|
-
}
|
|
131
|
-
.sp-card .tag-option:is(:hover, :focus-visible) > svg {
|
|
132
|
-
opacity: 1;
|
|
133
|
-
}
|
|
134
|
-
@media (hover: none) {
|
|
135
|
-
.sp-card .tag-option > svg {
|
|
136
|
-
opacity: 1;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
@media (prefers-reduced-motion: reduce) {
|
|
140
|
-
.sp-card .tag-option > svg {
|
|
141
|
-
transition: none;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
.sp-card .pager {
|
|
145
|
-
display: flex;
|
|
146
|
-
align-items: center;
|
|
147
|
-
gap: 3px;
|
|
148
|
-
color: var(--popmelt-thread-primary, #383838);
|
|
149
|
-
white-space: nowrap;
|
|
150
|
-
}
|
|
151
|
-
.sp-card .pager-number {
|
|
152
|
-
font-variant-numeric: tabular-nums;
|
|
153
|
-
}
|
|
154
|
-
.sp-card .pager button {
|
|
155
|
-
width: 22px;
|
|
156
|
-
height: 22px;
|
|
157
|
-
display: grid;
|
|
158
|
-
place-items: center;
|
|
159
|
-
}
|
|
160
|
-
.sp-card footer :is(.tag-option, .pager) {
|
|
161
|
-
pointer-events: auto;
|
|
162
|
-
touch-action: manipulation;
|
|
163
|
-
}
|
|
164
|
-
.sp-card footer .tag-option {
|
|
165
|
-
padding: 0;
|
|
166
|
-
}
|
|
167
|
-
.sp-card .tag-option > span,
|
|
168
|
-
.sp-card .pager {
|
|
169
|
-
box-sizing: border-box;
|
|
170
|
-
min-height: 26px;
|
|
171
|
-
padding: 2px 8px;
|
|
172
|
-
border-radius: 8px;
|
|
173
|
-
background: var(--sp-control-bg);
|
|
174
|
-
}
|
|
175
|
-
.sp-card .tag-option > span {
|
|
176
|
-
align-content: center;
|
|
177
|
-
}
|
|
178
|
-
.sp-card .pager { padding-inline: 2px; }
|
|
179
|
-
@media (prefers-reduced-motion: reduce) {
|
|
180
|
-
.sp-actions,
|
|
181
|
-
.sp-zoom-actions {
|
|
182
|
-
transition: none;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
@media (hover: none) {
|
|
186
|
-
.sp-actions,
|
|
187
|
-
.sp-zoom-actions {
|
|
188
|
-
pointer-events: auto;
|
|
189
|
-
opacity: 1;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
.sp-expanded-placeholder, .sp-steer-frame { height: 260px; }
|
|
194
|
-
.sp-steer-frame {
|
|
195
|
-
border: 0;
|
|
196
|
-
display: block;
|
|
197
|
-
width: 100%;
|
|
198
|
-
border-radius: inherit;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/* An expanded card covers the annotation canvas. Its editor takes the free side of the thread. */
|
|
202
|
-
/* Group the toolbar and its popovers above the editor, alongside the thread. */
|
|
203
|
-
:is(body, [data-popmelt-root]):has(> .sp-workspace:not([hidden])) [data-popmelt-toolbar-layer] {
|
|
204
|
-
position: relative;
|
|
205
|
-
z-index: 10005;
|
|
206
|
-
}
|
|
207
|
-
.sp-workspace {
|
|
208
|
-
position: fixed;
|
|
209
|
-
inset: 8px;
|
|
210
|
-
overflow: clip;
|
|
211
|
-
box-shadow: 0 0 0 100vmax light-dark(rgb(255 255 255 / 50%), rgb(0 0 0 / 50%));
|
|
212
|
-
}
|
|
213
|
-
.sp-workspace .sp-card {
|
|
214
|
-
position: absolute;
|
|
215
|
-
inset: 0 var(--sp-work-right, 0px) 0 var(--sp-work-left, 0px);
|
|
216
|
-
width: auto;
|
|
217
|
-
display: flex;
|
|
218
|
-
flex-direction: column;
|
|
219
|
-
margin: 0;
|
|
220
|
-
border-radius: 0;
|
|
221
|
-
background: transparent;
|
|
222
|
-
}
|
|
223
|
-
.sp-workspace .sp-stage {
|
|
224
|
-
flex: 1;
|
|
225
|
-
min-height: 0;
|
|
226
|
-
}
|
|
227
|
-
.sp-workspace .sp-steer-frame {
|
|
228
|
-
position: absolute;
|
|
229
|
-
inset: 0;
|
|
230
|
-
height: 100%;
|
|
231
|
-
}
|
|
232
|
-
.sp-workspace :is(.sp-actions, .sp-zoom-actions) {
|
|
233
|
-
top: 12px;
|
|
234
|
-
opacity: 1;
|
|
235
|
-
pointer-events: auto;
|
|
236
|
-
}
|
|
237
|
-
.sp-workspace .sp-actions { right: 12px; }
|
|
238
|
-
.sp-workspace .sp-zoom-actions { left: 12px; }
|
|
239
|
-
.sp-workspace .sp-card footer { padding: 12px; }
|
|
240
|
-
.sp-card .sp-expanded-badge {
|
|
241
|
-
display: inline-flex;
|
|
242
|
-
align-items: center;
|
|
243
|
-
gap: 5px;
|
|
244
|
-
border-radius: 8px;
|
|
245
|
-
min-height: 26px;
|
|
246
|
-
padding: 2px 8px;
|
|
247
|
-
background: var(--sp-control-bg);
|
|
248
|
-
color: inherit;
|
|
249
|
-
}
|
|
250
|
-
@media (max-width: 767px) {
|
|
251
|
-
/* Keep chat usable below the editor when a side-by-side layout is too tight. */
|
|
252
|
-
:is(body, [data-popmelt-root]):has(> .sp-workspace:not([hidden])) [data-devtools="thread-panel"] {
|
|
253
|
-
top: 54% !important;
|
|
254
|
-
/* Reserve the compact toolbar row plus the standard panel gap. */
|
|
255
|
-
bottom: calc(max(8px, env(safe-area-inset-bottom)) + 40px + 8px) !important;
|
|
256
|
-
max-height: none !important;
|
|
257
|
-
}
|
|
258
|
-
.sp-workspace .sp-card { inset: 0 0 var(--sp-work-bottom); }
|
|
259
|
-
}
|
|
260
|
-
`;function vt({anchor:e,children:t}){let{visible:l}=ne(ae),r=L(null),[a,i]=R(null);return P(()=>{i(e.current?.closest("[data-popmelt-root]")??document.body)},[e]),P(()=>{if(!l||!a)return;let o=a.ownerDocument,n=o.createElement("style");return n.textContent=":root, body { overflow: hidden !important; }",o.head.append(n),()=>n.remove()},[a,l]),P(()=>{let o=r.current,n=e.current?.closest('[data-devtools="thread-panel"]');if(!o||!n)return;let s=()=>{let g=n.getBoundingClientRect(),h=o.getBoundingClientRect(),d=g.left-h.left>=h.right-g.right;o.style.setProperty("--sp-work-left",d?"0px":`${Math.max(0,g.right-h.left)}px`),o.style.setProperty("--sp-work-right",d?`${Math.max(0,h.right-g.left)}px`:"0px"),o.style.setProperty("--sp-work-bottom",`${Math.max(0,h.bottom-g.top)}px`),o.style.borderRadius=getComputedStyle(n).borderRadius,o.dataset.popmeltTheme=n.dataset.popmeltTheme;for(let b of Array.from(n.style))b.startsWith("--popmelt-thread-")&&o.style.setProperty(b,n.style.getPropertyValue(b))};s();let p=new ResizeObserver(s);p.observe(n);let f=new MutationObserver(s);return f.observe(n,{attributes:!0,attributeFilter:["style","data-popmelt-theme"]}),window.addEventListener("resize",s),()=>{p.disconnect(),f.disconnect(),window.removeEventListener("resize",s)}},[e,a]),a?me(u("div",{hidden:!l,ref:r,className:"sp-workspace","data-popmelt-font":"sans",style:{zIndex:10003},children:t}),a):null}function xt({frameUrl:e,theme:t,...l}){let[r,a]=R(null);return P(()=>{r&&t&&(r.documentElement.style.colorScheme=t)},[r,t]),T(_,{children:[u("iframe",{className:"sp-steer-frame","aria-label":"Edit or comment on this option",src:e,srcDoc:e?void 0:Me,onLoad:i=>{let o=i.currentTarget.contentDocument;o&&Xe(o),a(o)}}),r&&u(wt,{doc:r,...l},l.editorKey)]})}function wt({doc:e,...t}){let{toggle:l}=ne(ae),r=L(t),a=L(t);a.current=t;let i=L(void 0);P(()=>{let g=e.defaultView;if(!g)return;let{node:h,initial:d,target:b,accentColor:w,framing:k}=r.current,M=!0,A=d;i.current=g.startScratchSteer?.(h,b,w,k,C=>{if(!M)return;let v=ke(d,C);JSON.stringify(v)!==JSON.stringify(A)&&(A=v,a.current.onChange(v))},C=>{M&&a.current.onTag(C)},C=>{M&&a.current.onPreview(C)},l);let q=C=>{C.key!=="Escape"||!a.current.onEscapeWorkspace||C.target?.closest?.('input, textarea, [contenteditable="true"]')||(C.preventDefault(),C.stopImmediatePropagation(),a.current.onEscapeWorkspace())};return g.addEventListener("keydown",q,!0),()=>{M=!1,i.current=void 0,a.current.onPreview(null),g.removeEventListener("keydown",q,!0)}},[e,l]);let[o,n]=R();P(()=>{let g=e.defaultView?.frameElement;if(g instanceof HTMLIFrameElement)return xe(g,n,()=>{e.documentElement.setAttribute("data-preview-control-hovered","")})},[e]);let{selectedPart:s,hoveredPart:p,focusRequest:f}=t;return P(()=>{i.current?.({selectedPart:s,hoveredPart:p,focusRequest:f,controlBounds:o})},[e,l,s,p,f,o]),null}function kt({batch:e,frameUrl:t,bundles:l,canApply:r=!0,theme:a,accentColor:i,selection:o,preview:n,setTag:s,onTogglePreview:p,onBrowse:f,edits:g,revisions:h,index:d,hoveredTarget:b,focusRequest:w,onPreviewStyle:k,onFixtureCanvas:M,onSteer:A,onApply:q,busy:C,expanded:v,onExpand:z}){let[K,D]=R(""),[J,W]=R(!1),U=L(null),j=L(null),N=L(v);P(()=>{v!==N.current&&(N.current=v,(v?j.current:U.current)?.querySelector("[data-expand-option]")?.focus({preventScroll:!0}))},[v]),P(()=>{if(w?.batchId!==e.id||w.option!==d)return;let m=v?j.current:U.current,$=m?.closest('[data-devtools="thread-panel-messages"]');if(!m||!$)return;let X=m.getBoundingClientRect(),te=$.getBoundingClientRect();X.top>=te.top&&X.bottom<=te.bottom||$.scrollBy({top:X.top-te.top-Math.max(0,($.clientHeight-X.height)/2),behavior:window.matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth"})},[e.id,d,w,v]);let V=e.id+":"+d+":"+(h?.[d]??0),[E]=R(()=>Ae(null)),B=e.options.length,O=e.options[d],c={batchId:e.id,option:d,path:[]},x=n?.showVariant&&n.target.batchId===e.id&&n.target.option===d;function I(m){let $=(d+m+B)%B;D(""),f({...c,option:$})}let F="fixture"in O?l?.[O.fixture.bundle]:void 0,y=T("div",{className:"sp-stage",style:{cursor:De(i)},children:[u("div",{className:"sp-zoom-actions",children:u(Ie,{framing:E})}),T("div",{className:"sp-actions",children:[x&&r&&u(H,{type:"button","aria-label":"Apply this option in code",disabled:C||J,onClick:async()=>{D(""),W(!0);try{await q(c)}catch(m){D(m instanceof Error?m.message:"Could not apply this option.")}finally{W(!1)}},children:u(et,{})}),u(H,{type:"button","aria-pressed":v?void 0:!!n,hint:!v&&n?"Turn off page preview":"Preview on page","aria-label":"Preview on page",disabled:"fixture"in O&&(!F||typeof F=="string"),onClick:()=>p(c),children:u(tt,{})}),u(H,{type:"button",autoFocus:v,"data-expand-option":"","aria-label":v?"Collapse preview":"Expand preview","aria-expanded":v,onClick:()=>z(!v),children:v?u(rt,{}):u(ot,{})})]}),"fixture"in O?u(bt,{frameKey:V,bundle:F,target:e.target,framing:E,theme:a,accent:i,initial:g.filter(m=>m.batchId===e.id&&m.option===d),onCanvas:m=>M?.(O.fixture.bundle,m),onEscape:v?()=>z(!1):void 0,selected:o?.batchId===e.id&&o.option===d?o.fixturePart:void 0,onTag:(m,$)=>s({...c,fixturePart:m,fixturePartLabel:$}),onChange:m=>A(d,m),onPreview:m=>k(d,m)}):u(xt,{editorKey:V,framing:E,onEscapeWorkspace:v?()=>z(!1):void 0,frameUrl:t,target:e.target,node:O.root,theme:a,accentColor:i,initial:g.filter(m=>m.batchId===e.id&&m.option===d),onPreview:m=>k(d,m),hoveredPart:b?.batchId===e.id&&b.option===d?b.part:void 0,focusRequest:w?.batchId===e.id&&w.option===d?w:void 0,selectedPart:o?.batchId===e.id&&o.option===d?o.path.join(".")+(o.field?"/label":""):void 0,onChange:m=>A(d,m),onTag:m=>{let[$,X]=m.split("/");s({...c,path:$?$.split(".").map(Number):[],field:X==="label"?"label":void 0})}}),K&&u("span",{role:"alert",children:K})]}),S=u(St,{title:O.title,index:d,optionCount:B,accentColor:i,canTag:r,onTag:()=>s(c),browseBy:I});return T(_,{children:[T("section",{ref:U,"aria-label":"Explore options",className:"sp-card","data-popmelt-tooltip-group":"",children:[u("style",{children:yt}),v?u("div",{className:"sp-stage sp-expanded-placeholder",children:T(H,{type:"button",className:"sp-expanded-badge",hint:"Collapse preview","aria-label":"Preview expanded. Collapse preview","aria-expanded":!0,onClick:()=>z(!1),children:[u(nt,{"aria-hidden":"true"}),"Preview expanded"]})}):y,S]}),v&&u(vt,{anchor:U,children:T("section",{ref:j,"aria-label":"Expanded explore options",className:"sp-card","data-popmelt-tooltip-group":"","data-popmelt-tooltip-boundary":!0,children:[y,S]})})]})}function St({title:e,index:t,optionCount:l,accentColor:r,onTag:a,canTag:i,browseBy:o}){let n=L(null);return T("footer",{children:[T(H,{above:!0,className:"tag-option",disabled:!i,hint:"Add to chat",anchorRef:n,"aria-label":`Add ${e} to chat`,onClick:a,children:[u("span",{children:e}),u(at,{ref:n,"aria-hidden":"true",color:r})]}),l>1&&T("div",{className:"pager",children:[u("button",{type:"button","aria-label":"Previous option",onClick:()=>o(-1),children:u(it,{})}),T("span",{"aria-live":"polite",children:[u("span",{className:"pager-number",children:t+1})," of"," ",u("span",{className:"pager-number",children:l})]}),u("button",{type:"button","aria-label":"Next option",onClick:()=>o(1),children:u(lt,{})})]})]})}function Ee(e,t,l){return`popmelt-explore-draft:${e}:${t}:${l}`}function Ct(e,t){return t.options.flatMap((l,r)=>{try{let a=window.localStorage.getItem(Ee(e,t.id,r));if(!a)return[];let i=JSON.parse(a);if(!Array.isArray(i))return[];let o=i.map(Se);return o.some(n=>n.batchId!==t.id||n.option!==r)?[]:(Ce({messages:[{batch:t}]},se(o)),o)}catch{return[]}})}function Et(e,t,l,r){try{let a=Ee(e,t,l);r.length?window.localStorage.setItem(a,JSON.stringify(r)):window.localStorage.removeItem(a)}catch{}}function de(e,t){let l=e.label?.trim().replace(/\s*[→↓]$/,"").slice(0,52),r=l?l[0].toUpperCase()+l.slice(1)+" "+e.kind:e.kind[0].toUpperCase()+e.kind.slice(1),a=e.name||r;return t==="label"?a+" label":a}function Z(e){return Object.fromEntries(Object.entries(e??{}).map(([t,l])=>[t.replace(/-([a-z])/g,(r,a)=>a.toUpperCase()),l]))}function Ne({node:e,picker:t,path:l=[],live:r}){let a=e.kind==="row"||e.kind==="column",i=l.join("."),o={display:"inline-flex",flexDirection:e.kind==="column"?"column":"row",alignItems:a&&e.kind==="column"?"flex-start":"center",gap:e.space??0,flexWrap:a&&e.kind==="row"?"inherit":void 0,maxWidth:"100%",boxSizing:"border-box",color:e.ink,background:e.fill,border:e.stroke?"1px solid "+e.stroke:void 0,borderRadius:e.radius,padding:e.px||e.py?String(e.py??0)+"px "+String(e.px??0)+"px":void 0,fontSize:e.size?e.size+"px":void 0,fontWeight:e.weight,...Z(e.style),...Z(r?.[i])},n=i+"/label",s=!a&&e.kind!=="text";return T("span",{style:o,className:[t&&"sp-piece"].filter(Boolean).join(" ")||void 0,"data-sp-fill":t&&(e.fill||o.backgroundColor)?"":void 0,"data-sp-ink":t&&o.color?"":void 0,"data-scratch-text":e.kind==="text"||void 0,"data-popmelt-label":de(e),"data-scratch-part":i,tabIndex:t?-1:void 0,"data-badge-hover":t?.hovered===i||void 0,"data-tagged":t?.selected===i||void 0,children:[t&&u("button",{type:"button",className:"sp-piece-hit",onClick:()=>t.tag(i),"aria-label":`Tag ${e.kind}${e.label?": "+e.label:""}`,"aria-pressed":t.selected===i}),a?e.children?.map((p,f)=>u(Ne,{live:r,node:p,path:[...l,f],picker:t},f)):t&&s?u("button",{type:"button",className:"sp-label-hit","data-popmelt-label":de(e,"label"),"data-sp-fill":e.labelStyle?.["background-color"]?"":void 0,"data-sp-ink":e.labelStyle?.color?"":void 0,"data-scratch-text":"",style:Z(e.labelStyle),"data-scratch-part":n,"data-badge-hover":t.hovered===n||void 0,"data-tagged":t.selected===n||void 0,onClick:()=>t.tag(n),"aria-label":"Tag text: "+e.label,"aria-pressed":t.selected===n,children:r?.[n]?.text??e.label}):s?u("span",{"data-popmelt-label":de(e,"label"),"data-scratch-part":n,style:{display:"inline-block",...Z(e.labelStyle),...Z(r?.[n])},children:r?.[n]?.text??e.label}):r?.[i]?.text??e.label]})}function Nt({element:e,scene:t,children:l}){let[r,a]=R(null);return P(()=>{let i=e.ownerDocument,o=i.createElement("span");if(o.dataset.popmeltExplorePreview="",o.setAttribute("inert",""),t){let p=i.createElement("style");return p.textContent="[data-popmelt-explore-scene] > :not([data-popmelt-explore-preview]) { opacity: 0 !important; pointer-events: none !important; } [data-popmelt-explore-scene-position] { position: relative !important; }",getComputedStyle(e).position==="static"&&e.setAttribute("data-popmelt-explore-scene-position",""),e.setAttribute("data-popmelt-explore-scene",""),o.style.cssText="position:absolute;inset:0;display:block;overflow:hidden",o.append(p),e.append(o),a(o),()=>{e.removeAttribute("data-popmelt-explore-scene"),e.removeAttribute("data-popmelt-explore-scene-position"),o.remove()}}let n=getComputedStyle(e);if(o.style.display=n.display.startsWith("inline")?"inline-flex":"block",n.position==="absolute"||n.position==="fixed")for(let p of["position","top","right","bottom","left","z-index","transform","transform-origin"])o.style.setProperty(p,n.getPropertyValue(p));if(n.display!=="inline")for(let p of["width","max-width"]){let f=ie(e,p);f&&o.style.setProperty(p,f)}for(let p of[...ye,"align-self","grid-area","margin"])o.style.setProperty(p,n.getPropertyValue(p));let s=i.createElement("style");return s.textContent="[data-popmelt-explore-original] { display: none !important; }",e.before(s,o),e.setAttribute("data-popmelt-explore-original",""),a(o),()=>{e.removeAttribute("data-popmelt-explore-original"),o.remove(),s.remove()}},[e,t]),r&&me(l,r)}function Rt({batch:e,draftScope:t,bridgeUrl:l,theme:r,accentColor:a,active:i,hidden:o,activate:n,expanded:s,onExpand:p,canReply:f,busy:g,submit:h,selection:d,onAttach:b}){let w=gt(l,e.options),[k,M]=R(0),[A,q]=R(()=>Ct(t,e)),[C,v]=R(null),[z,K]=R({}),[D,J]=R(""),[W,U]=R(null),j=he(()=>Ce({messages:[{batch:e}]},se(A)).messages[0].batch,[e,A]),N=j.options[k],V=y=>"fixture"in N?dt(y,N.previewScope,!!z[N.fixture.bundle]):y.element,E=C&&V(C),B="fixture"in N&&N.previewScope==="component"?"Core could not locate a single root for this component on the page. You can still review the option here.":"Open the annotated page with its target visible to preview this option.";P(()=>{if(!i||!E)return;let y=()=>{E.isConnected||v(be(e.target))},S=new MutationObserver(y);return S.observe(E.getRootNode(),{subtree:!0,childList:!0}),y(),()=>S.disconnect()},[i,E,e.target]);let O=!!E&&"fixture"in N&&(G(E)===E||(E===C?.component||E===C?.legacyScene)&&!!E.querySelector("canvas")),c="fixture"in N?w[N.fixture.bundle]:void 0,x=se(A)[e.id]?.[k]??{},I={...x};if(W?.option===k)for(let[y,S]of Object.entries(W.parts))I[y]={...x[y],...S};let F=i&&!o&&E&&("root"in N||c&&typeof c!="string")?{target:{batchId:e.id,option:k,path:[]},showVariant:!0}:null;return T(_,{children:[u(kt,{batch:j,bundles:w,index:k,edits:A,theme:r,accentColor:a,selection:d,preview:F,expanded:s&&!o,onExpand:p,revisions:void 0,focusRequest:null,hoveredTarget:null,busy:g,canApply:f,onTogglePreview:()=>{if(J(""),F&&!s){n(!1);return}let y=be(e.target),S=location.pathname===e.target.pathname&&V(y);if(!S||!S.parentElement||S.matches("body,html")||S.closest("[data-devtools]")){J(B);return}v(y),p(!1),n(!0)},onBrowse:y=>{M(y.option),U(null)},onFixtureCanvas:(y,S)=>K(m=>m[y]===S?m:{...m,[y]:S}),onPreviewStyle:(y,S)=>U(m=>S?{option:y,parts:S}:m?.option===y?null:m),onSteer:(y,S)=>{let m=S.map($=>({...$,batchId:e.id,option:y}));Et(t,e.id,y,m),q($=>[...$.filter(X=>X.option!==y),...m])},setTag:y=>{f&&b(Pe(j,y,A))},onApply:async()=>{let{text:y,meta:S}=Re(j,k,A);if(!await h(y,S))throw Error("This thread cannot send the apply request.");n(!1),p(!1)}}),(D||i&&!o&&C&&!E)&&u("span",{role:"alert",children:D||B}),F&&E&&u(Nt,{element:E,scene:O,children:"fixture"in N?c&&typeof c!="string"&&u(ce,{mirror:!0,fillScene:O,bundle:c,target:e.target,theme:r,accent:a,initial:[],parts:I},k):u(Ne,{node:N.root,live:W?.option===k?W.parts:void 0})})]})}export{Rt as ExploreAttachment};
|