@popmelt.com/core 0.34.0 → 0.36.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 +24 -868
- package/THIRD_PARTY_NOTICES.md +72 -0
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/dist/ExploreAttachment-H5WPEAZB.mjs +1 -0
- package/dist/PagePreviewLayer-WCYOBKAS.mjs +1 -0
- package/dist/ParticipantRuntime-HEC26AER.mjs +1 -0
- package/dist/PhoneHostGate-Q2AXVOSH.mjs +1 -0
- package/dist/PopmeltTasteConnectedPane-B7DHQKRQ.mjs +1 -0
- package/dist/{PreviewRuntime-EYKB7MG5.mjs → PreviewRuntime-H2UOLP6T.mjs} +1 -1
- package/dist/QueuedReplies-ESIFFRKS.mjs +1 -0
- package/dist/SuppliedContext-7ASO6GAW.mjs +1 -0
- package/dist/ThreadErrorCard-6R7W3RGZ.mjs +1 -0
- package/dist/ThreadPanel-3IS7GUYS.mjs +1 -0
- package/dist/adapter-react-three-fiber.d.mts +1 -1
- package/dist/bridge-entry.mjs +1 -1
- package/dist/browser-runtime-ILNTJLZ5.mjs +1 -0
- package/dist/browser.d.mts +4 -4
- package/dist/browser.mjs +1 -1
- package/dist/{checkFixture-AMLLLJNS.mjs → checkFixture-YE2ROOLL.mjs} +1 -1
- package/dist/chunk-26P7UUHT.mjs +1 -0
- package/dist/chunk-3SEXH3AZ.mjs +1 -0
- package/dist/chunk-3XJEC6LS.mjs +1 -0
- package/dist/chunk-7CGKO4IU.mjs +30 -0
- package/dist/{chunk-YXPRWW6B.mjs → chunk-AH6LZOQC.mjs} +1 -1
- package/dist/chunk-APP5IYTE.mjs +1 -0
- package/dist/chunk-DC47WNPG.mjs +1 -0
- package/dist/chunk-DJTGR3RO.mjs +1 -0
- package/dist/{chunk-QQB5G3VB.mjs → chunk-DLUNNAZC.mjs} +1 -1
- package/dist/chunk-EXIUW3JX.mjs +1 -0
- package/dist/chunk-FLTHWLRC.mjs +1 -0
- package/dist/chunk-GBVPRXA3.mjs +1 -0
- package/dist/chunk-HU2XWUJC.mjs +1 -0
- package/dist/chunk-L7QONR4K.mjs +1 -0
- package/dist/chunk-MSWXKP77.mjs +1 -0
- package/dist/{chunk-YTUQYKLM.mjs → chunk-NDGM4DAP.mjs} +1 -1
- package/dist/chunk-NWE5PYKM.mjs +1 -0
- package/dist/{chunk-GSEMSZDB.mjs → chunk-OAHYSDJ4.mjs} +1 -1
- package/dist/{chunk-Y6WD56SO.mjs → chunk-OZBMHEOD.mjs} +1 -1
- package/dist/chunk-PNTM77NT.mjs +1 -0
- package/dist/chunk-PYGRFSUU.mjs +1 -0
- package/dist/{chunk-H2RLTCUJ.mjs → chunk-R3AJWOID.mjs} +1 -1
- package/dist/chunk-TLREGQQB.mjs +1 -0
- package/dist/chunk-TUXBMJQZ.mjs +1 -0
- package/dist/chunk-WDAXARLI.mjs +1 -0
- package/dist/chunk-X2Q3H6X7.mjs +1 -0
- package/dist/chunk-XJQJQ5V5.mjs +1 -0
- package/dist/chunk-YHYFWNN6.mjs +1 -0
- package/dist/{chunk-MJ2PFKF3.mjs → chunk-ZDXQ7WNW.mjs} +1 -1
- package/dist/chunk-ZSL57PQ7.mjs +1 -0
- package/dist/cli.mjs +1 -1
- package/dist/codex-note-context-YFURG7VL.mjs +1 -0
- package/dist/codex-project-3NSU5OWL.mjs +1 -0
- package/dist/focus-inspection-SZJ5KP23.mjs +1 -0
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +1 -1
- package/dist/media.d.mts +3 -3
- package/dist/memory-store.d.mts +1 -1
- package/dist/{participantBootstrap-ClKpD2qC.d.mts → participantBootstrap-DFJlcKRI.d.mts} +2 -2
- package/dist/peer-client-56EAHIGF.mjs +1 -0
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-nuxt.mjs +1 -1
- package/dist/plugin-vite.d.mts +17 -0
- package/dist/plugin-vite.mjs +1 -1
- package/dist/server.d.mts +6 -6
- package/dist/server.mjs +1 -1
- package/dist/{steerStyles-VKQD57KC.mjs → steerStyles-E76E44PI.mjs} +1 -1
- package/dist/{subjects-EWAR5-0S.d.mts → subjects-DdavjSTL.d.mts} +12 -0
- package/dist/{types-C8tjyhiF.d.mts → types-g9YCBx4Z.d.mts} +2 -1
- package/dist/{video-adapter-BUMpNTCP.d.mts → video-adapter-DB6Hex1f.d.mts} +1 -1
- package/package.json +2 -3
- package/dist/ExploreAttachment-BG7ZOQSA.mjs +0 -1
- package/dist/PagePreviewLayer-CBDGPMJQ.mjs +0 -1
- package/dist/ParticipantRuntime-FSZX2PUQ.mjs +0 -1
- package/dist/PhoneHostGate-OM7FLOJ2.mjs +0 -1
- package/dist/PopmeltTasteConnectedPane-KJSBPJQR.mjs +0 -1
- package/dist/QueuedReplies-ZYUDSTS2.mjs +0 -1
- package/dist/SuppliedContext-7THB2WZY.mjs +0 -1
- package/dist/ThreadErrorCard-J2VTA5JW.mjs +0 -1
- package/dist/ThreadPanel-PNVMIIYJ.mjs +0 -1
- package/dist/browser-runtime-FFT5NH66.mjs +0 -1
- package/dist/chunk-2ETPREWQ.mjs +0 -1
- package/dist/chunk-3WSTAV5B.mjs +0 -1
- package/dist/chunk-67OWRNU3.mjs +0 -30
- package/dist/chunk-BFVLMSG5.mjs +0 -1
- package/dist/chunk-BJ25TGJN.mjs +0 -1
- package/dist/chunk-E5WNW4WE.mjs +0 -1
- package/dist/chunk-F5XSNRGT.mjs +0 -1
- package/dist/chunk-FMI4VQDZ.mjs +0 -1
- package/dist/chunk-GRPDZGPP.mjs +0 -1
- package/dist/chunk-JRP5XFYN.mjs +0 -1
- package/dist/chunk-LD3532UC.mjs +0 -1
- package/dist/chunk-MP6ZV2DN.mjs +0 -1
- package/dist/chunk-N66ZZG3L.mjs +0 -1
- package/dist/chunk-P4KM3K5M.mjs +0 -1
- package/dist/chunk-PQT5FYN5.mjs +0 -1
- package/dist/chunk-R3FPXDQS.mjs +0 -1
- package/dist/chunk-RSUMSUAW.mjs +0 -1
- package/dist/chunk-TRHC7WBO.mjs +0 -1
- package/dist/chunk-XSMCZUDR.mjs +0 -1
- package/dist/chunk-YC5CUNRU.mjs +0 -1
- package/dist/codex-note-context-NUKGR2WT.mjs +0 -1
- package/dist/codex-project-KE7ZZ6YX.mjs +0 -1
- package/dist/focus-inspection-BPPRCMNN.mjs +0 -1
- package/dist/peer-client-UQDASAO7.mjs +0 -1
- /package/dist/{chunk-3GXLNBXU.mjs → chunk-YD3PDEFX.mjs} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as t}from"./chunk-
|
|
1
|
+
import{c as t}from"./chunk-NWE5PYKM.mjs";import{f as r}from"./chunk-DLUNNAZC.mjs";import{s as e}from"./chunk-7CGKO4IU.mjs";import{e as a}from"./chunk-HV7HRQ2S.mjs";async function o(o,s){let i=await a(o);if(!i||!s)return[];let n=await e(o,s);return n.length?(await Promise.all([i,...i.mountedStores].map(async e=>{try{let a=await t(e,o);if(!a)return[];let{endpoint:s,request:i}=a,m=[];for(let t of n){let a=await r(s,"/participants/read-canvas-receipt",{...i,method:"POST",body:JSON.stringify({receiptId:t})});a.response.ok&&m.push({storeId:e.storeId,receipt:a.body})}return m}catch{return[]}}))).flat():[]}export{o as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";function r(r){if(r.length>256e3)throw Error("Paragraph draft is too large.");let t=JSON.parse(r);if(!Array.isArray(t)||!t.length||t.length>4096||t.some(r=>!(r&&Array.isArray(r.path)&&r.path.length&&!(r.path.length>128)&&r.path.every(r=>"number"==typeof r&&Number.isSafeInteger(r)&&r>=0)&&Array.isArray(r.parts)&&r.parts.length&&r.parts.every(r=>"string"==typeof r)))||t.reduce((r,t)=>r+t.parts.length-1,0)>512)throw Error("Invalid paragraph draft.");return t}function t(r){let t=[""];for(let{parts:e}of r)t[t.length-1]=t[t.length-1]+e[0],t.push(...e.slice(1));return t}export{r as a,t as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{a as e}from"./chunk-APP5IYTE.mjs";import{i as t,J as r,p as n,a as l,n as o,z as i,G as a,H as s,D as f,q as c}from"./chunk-HAE5LUJX.mjs";import{a as u,b as p}from"./chunk-5K7SACPW.mjs";import{v as d,l as m,k as h}from"./chunk-WHJEKDNP.mjs";var g='[role="img"], [role="group"][aria-label], [role="group"][aria-labelledby]';function y(e){let t=e?.closest(g);return t&&"canvas"!==t.localName&&t.querySelector("canvas")?t:null}function b(e,t){let r=t?.querySelector("canvas")?t:y(e);if(!r||r===e)return null;let n=r.querySelectorAll("canvas");if(1!==n.length)return null;let l=n[0].getBoundingClientRect(),o=e.getBoundingClientRect();return l.width<=0||l.height<=0?null:o.left<=l.left+1&&o.top<=l.top+1&&o.right>=l.right-1&&o.bottom>=l.bottom-1?r:null}function w(e){let t=d(e.selector,e.element),r=function(e,t=d(e.selector,e.element)){let r=e.element;if("canvas"!==r?.tagName&&"svg"!==r?.tagName&&!t?.closest("svg,canvas"))return t;let n=y(t);if(n)return n;if(t)return t;let l=r?.selector,o=l?.lastIndexOf(" > ")??-1;if(l&&o>=0)try{let e=y(m(l.slice(0,o)));if(e&&(!r?.reactComponent||u(e)?.name===r.reactComponent))return e}catch{}if(!r?.reactComponent||r.frameContext?.length||l?.includes(" >>> "))return null;let i=h().flatMap(e=>Array.from(e.querySelectorAll(g)).filter(e=>e.querySelector("canvas")&&u(e)?.name===r.reactComponent));return 1===i.length?i[0]:null}(e,t),n=e.element?.reactComponent,l=t&&(n?function(e,t){let r=p(e).findLast(e=>e.name===t)?.fiber;if(!r?.child)return null;let n=[r.child],l=null;for(;n.length;){let e=n.pop();if(4===e.tag)return null;e.sibling&&n.push(e.sibling);let t=e.stateNode;if((1===t?.nodeType||3===t?.nodeType)&&(!l&&1===t.nodeType&&(l=t),!l?.contains(t)))return null;e.child&&n.push(e.child)}return l?.contains(e)?l:null}(t,n):y(t));return{element:t,component:l,legacy:r,legacyScene:t&&b(t,l)}}function S(e,t,r){let n="component"===t?e.component:"element"===t?e.element:r&&e.legacyScene||e.legacy;return n?.isConnected&&n.parentElement&&!n.matches("body,html")&&!n.closest("[data-devtools]")?n:null}var E=["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 x(e){return e.trim().replace(/^(['"])(.*)\1$/,"$2").toLowerCase()}function*v(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,{acceptNode(e){if(e.nodeType===Node.TEXT_NODE)return e.textContent?.trim()?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP;let t=e;return t.matches("script,style,noscript,template,[hidden],[data-devtools],[data-popmelt-root]")?NodeFilter.FILTER_REJECT:t.matches("input,textarea,select")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}}),r=new Set;for(let e=t.nextNode();e;e=t.nextNode()){let t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;!t||r.has(t)||(r.add(t),yield[t,e.nodeType===Node.TEXT_NODE?e.textContent.trim():""])}}function N(e){let t=[],r=new Set;for(let[n,l]of v(e)){let o=getComputedStyle(n),i=n.closest("button,a,label"),a=(i&&e.contains(i)?i:n).localName,{fontFamily:s,fontWeight:f,fontSize:c}=o,u=JSON.stringify([a,s,f,c]);if(s&&!r.has(u)&&(r.add(u),t.push({tag:a,text:l.slice(0,64),family:s,weight:f,size:c}),12===t.length))break}return t}function C(e,t){let r=e.ownerDocument,n=[];function l(e){if(!e||e.disabled)return;let t;try{t=e.cssRules}catch{return}o(t,e.href??r.baseURI)}function o(e,r){for(let i of e)if(i.type===CSSRule.FONT_FACE_RULE){let{style:e}=i;if(!t.has(x(e.getPropertyValue("font-family"))))continue;let l=i.cssText.replace(/url\("([^"]*)"\)|url\('([^']*)'\)|url\(([^)]*)\)/gi,(e,t,n,l)=>{try{return"url("+JSON.stringify(new URL(t??n??l.trim(),r).href)+")"}catch{return e}});n.push(l)}else i.type===CSSRule.IMPORT_RULE?l(i.styleSheet):"cssRules"in i&&o(i.cssRules,r)}let i=[r];for(let t=e.getRootNode();"host"in t;t=t.host.getRootNode())i.push(t);for(let e of i)for(let t of[...e.styleSheets,...e.adoptedStyleSheets??[]])l(t);return n}async function k(e,t){let r=function(e,t){let r=new Set([t]);for(let[t]of v(e))t!==e&&r.add(getComputedStyle(t).fontFamily);let n=new Set;for(let e of r)for(let t of e.matchAll(/\s*("[^"]*"|'[^']*'|[^,]+)\s*(?:,|$)/g))n.add(x(t[1]));return n}(e,getComputedStyle(e).fontFamily),n=C(e,r).join("\n"),l=new Set(Array.from(n.matchAll(/url\("([^"]+)"\)/g),e=>e[1])),o=n;return await Promise.all([...l].map(async e=>{if(!e.startsWith("data:"))try{let r=await fetch(e,{signal:t,credentials:"same-origin"});if(!r.ok)return;let n=await r.blob(),l=await new Promise((e,t)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=t,r.readAsDataURL(n)});o=o.replaceAll(JSON.stringify(e),JSON.stringify(l))}catch{}})),o}var T={explore:"/explore"};function I(e){let t=[];for(let r of e.matchAll(/(?<!\S)\/\S*/g)){let e=r[0],n=e.toLowerCase(),l=Object.values(T).filter(e=>e.startsWith(n));if(!l.length)continue;let o=e.length>1&&1===l.length?l[0].slice(e.length):"";t.push({start:r.index,token:e,suffix:o})}return t}function A(e){return I(e).find(({token:e})=>e.toLowerCase()===T.explore)}function O(e){let t=I(e)[0];if(!t)return;let r=e.slice(0,t.start);if(r.trim())return;let n=e.slice(t.start+t.token.length);return!n||Object.values(T).some(e=>e===t.token.toLowerCase())?{...t,leading:r,body:n}:void 0}var R=/^(?:@[a-zA-Z][\w-]{0,63}|~?(?:0|[1-9]\d{0,3})(?:\.(?:0|[1-9]\d{0,3})){0,31}|)$/;function j(e,t){let r="text"===t?e.replace(/\/text\/(?:0|[1-9]\d{0,3})$/,""):e;return R.test(r)}function F(e){if(e.matches('svg, img, [role="img"]'))return!0;if(e.childElementCount||"http://www.w3.org/1999/xhtml"!==e.namespaceURI)return!1;let t=e.ownerDocument.defaultView?.getComputedStyle(e).maskImage;return!!t&&"none"!==t}function L(e){let t=e.getAttribute("data-popmelt-subject-label")||e.getAttribute("data-explore-part");if(t)return t.slice(0,80);let r=e.closest('button, a[href], [role="button"], [role="link"]');if(r===e)return e.matches('a[href], [role="link"]')?"link":"button";let n=e.getAttribute("aria-label");if(F(e)){let t=n||e.getAttribute("alt")||e.querySelector(":scope > title")?.textContent;if(t)return t.slice(0,80);if(r){let t=Array.from(r.querySelectorAll("*")).filter(F);if(t.length>1)return"icon "+(t.indexOf(e)+1)}return"icon"}let l=Array.from(e.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.textContent).join(" ").trim();return r&&l?"label":(n||l||e.localName).slice(0,80)}function _(e,t){let r=new Map;for(let n of[...e,...t]){let e=n.part+":"+n.property,t=r.get(e)?.from??n.from;t===n.to?r.delete(e):(r.delete(e),r.set(e,{...n,from:t}))}return[...r.values()]}function P(e){let t=Object.create(null);for(let{batchId:r,option:n,part:l,property:o,to:i}of e){let e=t[r]??(t[r]=Object.create(null)),a=e[n]??(e[n]=Object.create(null));(a[l]??(a[l]=Object.create(null)))[o]=i}return t}function U(r){if(!r||"object"!=typeof r)throw new Error("Invalid Steer edit.");let{batchId:n,option:l,part:i,property:a,from:s,to:f,sticker:u}=r;if("string"!=typeof n||"number"!=typeof l||!Number.isInteger(l)||"string"!=typeof i||"string"!=typeof a||"string"!=typeof s||"string"!=typeof f||("text"===a||"paragraphs"===a)&&void 0!==u)throw new Error("Invalid Steer edit.");"paragraphs"===a?(e(s),e(f)):"text"!==a&&W({[a]:f});let p={batchId:n,option:l,part:i,property:a,from:s,to:f};if(void 0===u)return p;let{family:d,subproperty:m,step:h,axisSteps:g}=u;if(!t.includes(d)||c(d,m)!==m||!o(d,m).includes(h))throw new Error("Invalid Steer dimension.");let y={family:d,subproperty:m,step:h};if(void 0===g)return{...p,sticker:y};let b=o("transform","translate");if("transform"!==d||"translate"!==m||!b.includes(g.x)||!b.includes(g.y))throw new Error("Invalid Steer translation.");return{...p,sticker:{...y,axisSteps:{x:g.x,y:g.y}}}}var $=new Map;function q(e,t){$.has(e)||$.set(e,new Set),$.get(e).add(t)}for(let e of t){let t=r(e);t&&q("display",t);for(let t of n(e))for(let r of"color"===t?l:[t]){let t=o(e,r);for(let n of t){let l=i(e,r);q(l,a(e,n,r));for(let t of s(e,r,n))q(t.property,t.value);if("border"===e&&l.endsWith("width")&&q(f(r),"solid"),"translate"===l)for(let e of t)q(l,4*Number(n)+"px "+4*Number(e)+"px")}}}function D(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Invalid Steer draft.");return Object.entries(e)}function W(e){return Object.fromEntries(D(e).map(([e,t])=>{if("string"!=typeof t||!$.get(e)?.has(t))throw new Error("Unsupported Steer declaration: "+e);return[e,t]}))}function J(t,r){if(void 0===r)return t;let n=structuredClone(t);for(let[t,l]of D(r)){let r=n.messages.find(e=>e.batch?.id===t)?.batch;if(!r)throw new Error("Steer draft refers to an unknown batch.");for(let[t,n]of D(l)){let l=/^[0-5]$/.test(t)&&r.options[Number(t)];if(!l)throw new Error("Steer draft refers to an unknown option.");for(let[t,r]of D(n)){if("fixture"in l){if(!D(r).every(([e])=>j(t,e)))throw new Error("Invalid fixture part.");let{text:n,paragraphs:l,...o}=Object.fromEntries(D(r));if(void 0!==n&&"string"!=typeof n)throw new Error("Invalid fixture text.");if(void 0!==l){if("string"!=typeof l)throw Error("Invalid paragraph draft.");e(l)}W(o);continue}if(!/^(?:[0-7](?:\.[0-7]){0,3})?(?:\/label)?$/.test(t))throw new Error("Invalid specimen path.");let[n,o]=t.split("/"),i=l.root;for(let e of n?n.split("."):[])i=i?.children?.[Number(e)];if(!i||o&&(!i.label||"text"===i.kind))throw new Error("Steered element no longer exists.");let{text:a,...s}=Object.fromEntries(D(r));if(void 0!==a){if("string"!=typeof a||!o&&"text"!==i.kind)throw new Error("Invalid specimen text.");i.label=a}if(Object.keys(s).length){let e=o?"labelStyle":"style";i[e]={...i[e],...W(s)}}}}}return n}function X(e){return[...e.original?.runnable?[e.original.runnable]:[],...e.options]}function z(e,t){if(!e||e.target)return;let r=e.elements?.find(t=>t.selector===e.linkedSelector)??e.elements?.[0],n=e.linkedSelector??r?.selector;return n?{selector:n,element:r,pathname:e.pathname??t}:void 0}var H=new RegExp(`^${T.explore}(?=\\s|$)`,"i");function M(e){let t=H.exec(e.trimStart());return!!t&&!!e.trimStart().slice(t[0].length).trim()}function K(e,t){let r=e.label?.trim().replace(/\s*[→↓]$/,"").slice(0,52),n=r?r[0].toUpperCase()+r.slice(1)+" "+e.kind:e.kind[0].toUpperCase()+e.kind.slice(1),l=e.name||n;return"label"===t?l+" label":l}export{y as a,w as b,S as c,E as d,N as e,k as f,I as g,A as h,O as i,R as j,j as k,L as l,_ as m,P as n,U as o,J as p,X as q,z as r,M as s,K as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{f as e}from"./chunk-J4WDYITA.mjs";import{l as t,d as n}from"./chunk-WHJEKDNP.mjs";import{destroyContext as o,createContext as r,domToCanvas as i}from"modern-screenshot";function a(){return performance.now()+5e3}async function l(e,t){let n,o=e-performance.now(),r=()=>new Error("Visual capture timed out");if(o<=0)throw r();try{return await Promise.race([new Promise((e,t)=>{n=setTimeout(()=>t(r()),o)}),t()])}finally{clearTimeout(n)}}var s="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",c=24e6,d=["position","inset","top","right","bottom","left","z-index","display","visibility","opacity","overflow","overflow-x","overflow-y","box-sizing","box-decoration-break","float","clear","width","min-width","max-width","height","min-height","max-height","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","border","border-width","border-style","border-color","border-top","border-right","border-bottom","border-left","border-radius","outline","outline-offset","box-shadow","background","background-color","background-image","background-size","background-position","background-repeat","background-clip","background-origin","color","font","font-family","font-size","font-style","font-weight","font-stretch","font-variant","line-height","letter-spacing","text-align","text-decoration","text-indent","text-overflow","text-shadow","text-transform","white-space","word-break","overflow-wrap","vertical-align","direction","writing-mode","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","align-content","align-items","align-self","justify-content","justify-items","justify-self","gap","row-gap","column-gap","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-row","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","order","columns","column-count","column-fill","column-rule","column-span","column-width","list-style","list-style-image","list-style-position","list-style-type","object-fit","object-position","aspect-ratio","transform","transform-box","transform-origin","transform-style","perspective","perspective-origin","backface-visibility","clip","clip-path","filter","backdrop-filter","mix-blend-mode","isolation","mask","mask-image","mask-position","mask-repeat","mask-size","content","quotes","counter-increment","counter-reset","appearance","accent-color","caret-color","cursor","pointer-events","fill","fill-opacity","fill-rule","stroke","stroke-width","stroke-opacity"];async function m(e,t){try{let t=await e();if(t)return t}catch{}return t()}var h=new Map,u=new WeakMap,g=1;function f(){return typeof performance<"u"?performance.now():Date.now()}function p(e){if(void 0!==e?.debug)return e.debug;if(typeof window>"u")return!1;try{return"true"===window.localStorage.getItem("popmelt:screenshot-debug")}catch{return!1}}function w(e,t){let n=null;return async o=>{if(!b(o))return!1;n??(n=Date.now()+e);let r=n-Date.now();if(r<=0)return t(),s;let i=new AbortController,a=setTimeout(()=>i.abort(),r);try{let e=await fetch(o,{cache:"force-cache",mode:"cors",signal:i.signal});if(!e.ok)throw new Error(`Asset returned ${e.status}`);return await function(e){return new Promise((t,n)=>{let o=new FileReader;o.onload=()=>t(String(o.result)),o.onerror=()=>n(o.error??new Error("Asset could not be read")),o.readAsDataURL(e)})}(await e.blob())}catch{return t(),s}finally{clearTimeout(a)}}}function y(e,t,n){let o=Math.min(t,n);return{top:Math.max(0,Math.min(e,n-o)),height:o,annotations:[]}}function b(e){if(typeof window>"u")return!1;try{let t=new URL(e,window.location.href);return("http:"===t.protocol||"https:"===t.protocol)&&t.origin!==window.location.origin}catch{return!1}}function x(e){let t=document.createElement("canvas").getContext("2d");return t?(t.fillStyle=e,t.fillStyle):"#888888"}function M(e,t=[],n,o,r=[],i=[],a){let l=new Map,s=[];for(let t of e)if(t.groupId){let e=l.get(t.groupId)||[];e.push(t),l.set(t.groupId,e)}else s.push(t);let c=[];for(let[e,t]of l){let e=t.find(e=>"text"!==e.type),n=t.find(e=>"text"===e.type);if(e){let t=e.linkedSelector||n?.linkedSelector,o=n?.imageCount||e.imageCount,r=n?.attachments||e.attachments,i=n?.interactionEpisode||e.interactionEpisode,a=e.pathname||n?.pathname;c.push({id:e.id,type:e.type,instruction:n?.text,...t?{linkedSelector:t}:{},...e.target||n?.target?{target:e.target??n?.target}:{},...a?{pathname:a}:{},elements:e.elements||[],...o?{imageCount:o}:{},...r?.length?{attachments:r}:{},...i?{interactionEpisode:i}:{}})}}for(let e of s)c.push({id:e.id,type:e.type,instruction:"text"===e.type?e.text:void 0,...e.linkedSelector?{linkedSelector:e.linkedSelector}:{},...e.target?{target:e.target}:{},...e.pathname?{pathname:e.pathname}:{},elements:e.elements||[],...e.region?{region:e.region}:{},...e.imageCount?{imageCount:e.imageCount}:{},...e.attachments?.length?{attachments:e.attachments}:{},...e.interactionEpisode?{interactionEpisode:e.interactionEpisode}:{}});return{timestamp:(new Date).toISOString(),url:window.location.href,viewport:{width:window.innerWidth,height:window.innerHeight},scrollPosition:{x:window.scrollX,y:window.scrollY},annotations:c,styleModifications:t,...r.length>0?{textModifications:r}:{},...i.length>0?{domModifications:i}:{},...n?{inspectedElement:n}:{},...o&&o.length>0?{spacingTokenChanges:o}:{},...a?{meta:a}:{}}}function v(e){if(!e.points||0===e.points.length)return null;let t=[...e.points,...e.region?.points??[]],n=t.map(e=>e.x),o=t.map(e=>e.y);return{minX:Math.min(...n),minY:Math.min(...o),maxX:Math.max(...n),maxY:Math.max(...o)}}function k(e){let o=new Map;for(let r of e)if(r.linkedSelector)try{let e=t(r.linkedSelector);if(e){let t=n(e);o.set(r.id,{x:t.left+window.scrollX,y:t.top+window.scrollY,width:t.width,height:t.height})}}catch{}return o}function A(t,n,o,r,i){if(t.save(),t.scale(r,r),i)for(let e of n){let n=i.get(e.id);if(!n)continue;let r=n.y-o;t.fillStyle=e.color,t.globalAlpha=.05,t.fillRect(n.x,r,n.width,n.height),t.globalAlpha=1,t.strokeStyle=e.color,t.lineWidth=1,t.setLineDash([2,4]),t.strokeRect(n.x,r,n.width,n.height),t.setLineDash([])}for(let r of n){let n=r.points.map(e=>({x:e.x,y:e.y-o}));switch(t.strokeStyle=r.color,t.fillStyle=r.color,t.lineWidth=r.strokeWidth,t.lineCap="round",t.lineJoin="round",r.region&&e(t,r.region.points.map(e=>({x:e.x,y:e.y-o})),r.color),r.type){case"freehand":if(n.length<2)break;t.beginPath(),t.moveTo(n[0].x,n[0].y);for(let e=1;e<n.length;e++)t.lineTo(n[e].x,n[e].y);t.stroke();break;case"line":if(n.length<2)break;t.beginPath(),t.moveTo(n[0].x,n[0].y),t.lineTo(n[n.length-1].x,n[n.length-1].y),t.stroke();break;case"rectangle":{if(n.length<2)break;let e=n[0],o=n[n.length-1],r=Math.min(e.x,o.x),i=Math.min(e.y,o.y),a=Math.abs(o.x-e.x),l=Math.abs(o.y-e.y);t.strokeRect(r,i,a,l);break}case"circle":{if(n.length<2)break;let e=n[0],o=n[n.length-1],r=(e.x+o.x)/2,i=(e.y+o.y)/2,a=Math.abs(o.x-e.x)/2,l=Math.abs(o.y-e.y)/2;t.beginPath(),t.ellipse(r,i,a,l,0,0,2*Math.PI),t.stroke();break}case"text":{if(!r.text||n.length<1)break;let e=n[0],o=r.fontSize||16;t.font=`${o}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=r.color;let i=(r.imageCount&&r.imageCount>0?`[${r.imageCount} image${r.imageCount>1?"s":""}] ${r.text}`:r.text).split("\n"),a=1.2*o,l=4,s=0;for(let e of i)s=Math.max(s,t.measureText(e).width);t.fillRect(e.x-l,e.y-l,s+2*l,i.length*a+2*l),t.fillStyle="#ffffff",i.forEach((n,r)=>{t.fillText(n,e.x,e.y+o+r*a)});break}}}t.restore()}async function S(e,t,n=[],i){let m=function(e,t,n){let o=u.get(e);o||(o=g++,u.set(e,o));let r=t.filter(e=>"pending"===(e.status??"pending")).map(e=>{let t=e.points[0],n=e.points[e.points.length-1];return`${e.id}:${e.points.length}:${t?.x??""}:${t?.y??""}:${n?.x??""}:${n?.y??""}`}).join("|");return[o,window.location.href,window.innerWidth,window.innerHeight,n?.dpr??window.devicePixelRatio??1,n?.viewportOnly?window.scrollY:"",r].join("::")}(e,n,i),x=h.get(m);if(x)return p(i)&&console.debug("[Screenshot] Reusing in-flight capture",m),x;let M=async function(e,t,n){let i=a(),m=f(),h=n?.dpr??(window.devicePixelRatio||1),u=window.innerWidth,g=window.innerHeight,x=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight),M=Math.max(250,n?.mediaTimeoutMs??1500),A=p(n),S=t.filter(e=>"pending"===(e.status??"pending")),L=k(S),U=n?.viewportOnly?[y(window.scrollY,g,x)]:function(e,t,n,o){return 0===e.length?[{top:Math.max(0,Math.min(o,Math.max(0,n-t))),height:Math.min(t,n||t),annotations:[]}]:e.map(e=>{let o=Math.min(t,n||t);return{top:Math.max(0,Math.min(e.top,Math.max(0,n-o))),height:o,annotations:e.annotations}})}(function(e,t){if(0===e.length)return[];let n=e.map(e=>({annotation:e,bounds:v(e)})).filter(e=>null!==e.bounds);if(0===n.length)return[];n.sort((e,t)=>e.bounds.minY-t.bounds.minY);let o=Math.min(...n.map(e=>e.bounds.minY)),r=Math.max(...n.map(e=>e.bounds.maxY));if(r-o<=t){let n=(o+r)/2,i=Math.max(0,n-t/2);return[{top:i,bottom:i+t,annotations:e}]}let i=[],a=Math.max(0,o-50),l=[],s=a;for(let{annotation:e,bounds:o}of n){let n=o.maxY+50;if(n-a<=t)l.push(e),s=Math.max(s,n);else{if(l.length>0){let e=(a+s)/2,n=Math.max(0,e-t/2);i.push({top:n,bottom:n+t,annotations:l})}a=Math.max(0,o.minY-50),l=[e],s=o.maxY+50}}if(l.length>0){let e=(a+s)/2,n=Math.max(0,e-t/2);i.push({top:n,bottom:n+t,annotations:l})}return i}(S,g),g,x,window.scrollY),j=function(e){let t=0,n=0;for(let o of e.querySelectorAll("img[src]"))b(o.currentSrc||o.src)&&(t++,(!o.complete||0===o.naturalWidth)&&n++);return{remoteImages:t,unresolvedRemoteImages:n}}(e),O={startedAt:m,mode:"dom",mediaTimeoutMs:M,ranges:U.length,...j,remoteAssetFallbacks:0,nativeMs:0,contextMs:0,renderMs:0,compositeMs:0,encodeMs:0};console.log("[Screenshot] Starting capture with",S.length,"active annotations (filtered",t.length-S.length,"captured);",`${U.length} range(s), ${j.remoteImages} remote image(s), ${j.unresolvedRemoteImages} unresolved`);let $=null,D=null,T=function(e,t,n){if(0===e.length)return null;let o=Math.min(...e.map(e=>e.top)),r=Math.max(...e.map(e=>e.top+e.height))-o,i=t*r*n*n;return r>16e3||i>c?null:{top:o,height:r}}(U,u,h),Y=T??U[0],B=async()=>{if(!$){let t=f();$=l(i,()=>async function(e,t,n,o,i,a,l,c){let m=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)>4*window.innerHeight||e.querySelectorAll("*").length>2500,h=c?await c():[];return I(h,()=>r(e,{autoDestruct:!1,filter:C,features:{restoreScrollPosition:!0},onCloneNode:t=>{e===document.body&&(t.style.margin=getComputedStyle(e).margin)},onCloneEachNode:e=>{if(1===e.nodeType&&"html"===e.localName&&e.ownerDocument!==document){let t=e.style;t.overflow="hidden",t.display="inline-block",t.clipPath=`inset(0 round ${t.borderRadius||"0px"})`}},scale:o,backgroundColor:R(),width:n,height:t.height,style:{transform:`translate(${-window.scrollX}px, ${-t.top}px)`,transformOrigin:"top left"},timeout:i,debug:a,includeStyleProperties:m?[...d]:null,fetchFn:w(i,()=>{l.remoteAssetFallbacks++}),fetch:{requestInit:{cache:"force-cache"},placeholderImage:s}}))}(e,Y,u,h,M,A,O,n?.captureSurfaces)).then(e=>(D=e,O.contextMs+=f()-t,e))}return $};try{let e,t=f();if(T){let t=await l(i,()=>E(T,u,h,n,B,O));e=U.map(e=>P(t,T.top,e,u,h,L))}else{e=[];for(let t of U){let o=await l(i,()=>E(t,u,h,n,B,O));e.push(P(o,t.top,t,u,h,L))}}let o=function(e){if(1===e.length)return e[0];let t=document.createElement("canvas");t.width=e[0]?.width??0,t.height=e.reduce((e,t)=>e+t.height,0);let n=t.getContext("2d");if(!n)throw new Error("Canvas context unavailable");let o=0;for(let t of e)n.drawImage(t,0,o),o+=t.height;return t}(e);O.compositeMs+=f()-t-O.renderMs-O.nativeMs-O.contextMs;let r=f(),a=await l(i,()=>function(e,t="image/webp",n=.8){return new Promise(o=>e.toBlob(o,t,n))}(o));O.encodeMs=f()-r;let s=f()-O.startedAt,c={mode:O.mode,totalMs:Math.round(s),mediaTimeoutMs:O.mediaTimeoutMs,ranges:O.ranges,remoteImages:O.remoteImages,unresolvedRemoteImages:O.unresolvedRemoteImages,remoteAssetFallbacks:O.remoteAssetFallbacks,nativeMs:Math.round(O.nativeMs),contextMs:Math.round(O.contextMs),renderMs:Math.round(O.renderMs),compositeMs:Math.max(0,Math.round(O.compositeMs)),encodeMs:Math.round(O.encodeMs),overBudget:performance.now()>i};return console.log("[Screenshot] Capture complete",JSON.stringify(c)),a?[a]:[]}catch(e){return console.error("[Screenshot] Capture failed:",e),[]}finally{D&&o(D)}}(e,n,i).finally(()=>h.delete(m));return h.set(m,M),M}function R(){let e=getComputedStyle(document.documentElement).backgroundColor;return e&&"rgba(0, 0, 0, 0)"!==e&&"transparent"!==e?e:"#ffffff"}function C(e){return!(e instanceof HTMLElement)||"devtools-canvas"!==e.id&&"devtools-toolbar"!==e.id&&"devtools-scrim"!==e.id&&void 0===e.dataset.devtools}async function I(e,t){let n=[];for(let t of e){let e=Object.getOwnPropertyDescriptor(t.element,"toDataURL");try{Object.defineProperty(t.element,"toDataURL",{configurable:!0,value:()=>t.dataUrl}),n.push(()=>{e?Object.defineProperty(t.element,"toDataURL",e):Reflect.deleteProperty(t.element,"toDataURL")})}catch{}}try{return await t()}finally{for(let e of n.reverse())e()}}async function E(e,t,n,o,r,a){if(o?.nativeCapture){let r=f();try{let i=await o.nativeCapture({url:window.location.href,clip:{x:window.scrollX,y:e.top,width:t,height:e.height},scale:n});if(a.nativeMs+=f()-r,i)return a.mode=a.renderMs>0||a.contextMs>0?"mixed":"native",async function(e,t,n){let o=document.createElement("canvas");o.width=t,o.height=n;let r=o.getContext("2d");if(!r)throw new Error("Canvas context unavailable");if("function"==typeof createImageBitmap){let i=await createImageBitmap(e);return r.drawImage(i,0,0,t,n),i.close(),o}let i=new Image,a=URL.createObjectURL(e);try{return await new Promise((e,t)=>{i.onload=()=>e(),i.onerror=()=>t(new Error("Native screenshot could not be decoded")),i.src=a}),r.drawImage(i,0,0,t,n),o}finally{URL.revokeObjectURL(a)}}(i,Math.round(t*n),Math.round(e.height*n))}catch(e){a.nativeMs+=f()-r,p(o)&&console.debug("[Screenshot] Native capture unavailable; using DOM fallback",e)}}let l=await r(),s=f(),c=await async function(e,t,n){return e.width=n,e.height=t.height,e.style={transform:`translate(${-window.scrollX}px, ${-t.top}px)`,transformOrigin:"top left"},i(e)}(l,e,t);return a.renderMs+=f()-s,a.mode="native"===a.mode?"mixed":"dom",c}function P(e,t,n,o,r,i){let a=document.createElement("canvas");a.width=Math.round(o*r),a.height=Math.round(n.height*r);let l=a.getContext("2d");if(!l)throw new Error("Canvas context unavailable");let s=Math.round((n.top-t)*r);return l.drawImage(e,0,s,a.width,a.height,0,0,a.width,a.height),A(l,n.annotations,n.top,r,i),a}async function L(e){if(0===e.length)return null;if(1===e.length)return e[0];let t=await Promise.all(e.map(e=>new Promise((t,n)=>{let o=new Image;o.onload=()=>t(o),o.onerror=n,o.src=URL.createObjectURL(e)}))),n=t[0].width,o=t.reduce((e,t)=>e+t.height,0),r=document.createElement("canvas");r.width=n,r.height=o;let i=r.getContext("2d");if(!i)return null;let a=0;for(let e of t)i.drawImage(e,0,a),a+=e.height,URL.revokeObjectURL(e.src);return new Promise(e=>{r.toBlob(t=>e(t),"image/webp",.8)})}async function U(e,t,n,o,r){try{let i=Array.isArray(e)?e:[e];if(0===i.length)return!1;let a=await L(i);if(!a)return!1;let l=a;if("image/png"!==a.type){let e=new Image,t=URL.createObjectURL(a);await new Promise(n=>{e.onload=()=>n(),e.src=t}),URL.revokeObjectURL(t);let n=document.createElement("canvas");n.width=e.naturalWidth,n.height=e.naturalHeight,n.getContext("2d").drawImage(e,0,0),l=await new Promise(e=>n.toBlob(t=>e(t),"image/png"))}let s={"image/png":l},c=t&&t.length>0,d=n&&n.length>0,m=o&&o.length>0,h=r&&r.length>0;if(c||d||m||h){let e=t?t.filter(e=>"pending"===(e.status??"pending")):[];if(e.length>0||d||m||h){let t=M(e,n||[],void 0,void 0,o||[],r||[]),i=new Blob([JSON.stringify(t,null,2)],{type:"text/plain"});s["text/plain"]=i}}return await navigator.clipboard.write([new ClipboardItem(s)]),!0}catch(e){return console.warn("Clipboard write failed:",e),!1}}export{a,l as b,m as c,x as d,M as e,A as f,S as g,I as h,L as i,U as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e}from"./chunk-
|
|
1
|
+
import{d as e}from"./chunk-FLTHWLRC.mjs";import{G as t,H as a,i as r,p as o}from"./chunk-7CGKO4IU.mjs";import{readFile as s,readdir as n,realpath as i,stat as c}from"fs/promises";import{dirname as p,join as l,parse as m,relative as u,resolve as d,sep as f}from"path";async function w(e){return c(e).then(()=>!0,()=>!1)}async function y(e){try{let t=JSON.parse(await s(e,"utf8"));return"@popmelt.com/core"===t.name||["dependencies","devDependencies","peerDependencies"].some(e=>{let a=t[e];return!(!a||"object"!=typeof a||!Object.prototype.hasOwnProperty.call(a,"@popmelt.com/core"))})}catch{return!1}}async function h(e){return i(e).catch(()=>d(e))}async function j(e){let t=new Set;try{let a=await s(l(e,"pnpm-workspace.yaml"),"utf8");for(let r of a.matchAll(/^\s*-\s*['"]?([^'"\r\n]+)['"]?\s*$/gm)){let a=r[1].trim().split(/[*{[]/,1)[0].replace(/\/$/,"");a&&t.add(d(e,a))}}catch{}try{let a=JSON.parse(await s(l(e,"package.json"),"utf8")),r=Array.isArray(a.workspaces)?a.workspaces:a.workspaces?.packages??[];for(let a of r){let r=a.split(/[*{[]/,1)[0].replace(/\/$/,"");r&&t.add(d(e,r))}}catch{}return[...t]}var k=new Set([".git",".next",".turbo","build","coverage","dist","node_modules","vendor"]);async function g(e,t=5){let a=[],r=async(e,o)=>{if(o>t)return;let s;try{s=await n(e,{withFileTypes:!0})}catch{return}s.some(e=>e.isDirectory()&&".popmelt"===e.name)&&a.push(e),await Promise.all(s.flatMap(t=>!t.isDirectory()||".popmelt"===t.name||k.has(t.name)?[]:[r(l(e,t.name),o+1)]))};return await r(e,0),a}function I(e,t){let a=u(e,t);return a?a.split(f).filter(Boolean).length:0}async function O(e=process.cwd()){let a=await h(e),o=a,s=m(o).root,n=new Map,i=(e,t)=>{let a=n.get(e)??new Set;a.add(t),n.set(e,a)},c=[];for(;await w(l(o,".popmelt"))&&i(o,"store"),await w(l(o,".popmelt","ambient.json"))&&i(o,"marker"),await y(l(o,"package.json"))&&i(o,"package"),await y(l(o,"packages","popmelt","package.json"))&&i(o,"workspace_package"),(await j(o)).length&&c.push(o),o!==s;)o=p(o);for(let e of c){let t=await j(e),a=await Promise.all(t.map(e=>g(e)));for(let e of a.flat())i(await h(e),"store")}return(await Promise.all([...n].map(async([e,a])=>{let o=await h(e),s=await t(o),n=[...a].sort();return{root:o,storeId:s.storeId,projectId:r(o),reason:n[0],reasons:n,initialized:a.has("store")}}))).sort((e,t)=>e.initialized!==t.initialized?e.initialized?-1:1:I(a,e.root)-I(a,t.root)||e.root.localeCompare(t.root))}async function P(e=process.cwd()){return(await O(e))[0]??null}function b(){return process.env.POPMELT_EXECUTION_OWNER}function v(){return b()===o}async function C(t){let r=await a(t.root);return{...await e({projectRoot:t.root,detached:!0,manageLease:!1}),storeId:r.storeId}}async function S(e,t,a={}){let r=await fetch(`http://127.0.0.1:${e.port}${t}`,{...a,headers:{"Content-Type":"application/json","X-Popmelt-Project-Id":e.projectId,...a.headers}}),o=await r.json().catch(()=>null);return{response:r,body:o}}export{O as a,P as b,b as c,v as d,C as e,S as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{b as e}from"./chunk-TUXBMJQZ.mjs";import{b as t}from"./chunk-RK6UROPO.mjs";import{ba as i,na as r,aa as n}from"./chunk-MSWXKP77.mjs";import{a as o}from"./chunk-57FM7XQV.mjs";import{useSyncExternalStore as a,useState as l,useRef as c,useLayoutEffect as s}from"react";import{jsxs as u,jsx as d,Fragment as h}from"react/jsx-runtime";var m=[1,1.5,2.25,3.375,4];function p(e=1){let t=e,i=null,r=0,n=0,o=()=>null===i?1:i/(t??1),a=e=>Math.max(Math.min(1,o()),Math.min(4/(t??1),e)),l=new Set,c=(e,t)=>t<=1?(1-t)/2:Math.max(1-t,Math.min(0,e));function s(e,o,a){let c=1===e?null:e*(t??1);if(i!==c||r!==o||n!==a){i=c,r=o,n=a;for(let e of l)e()}}return{clampScale:a,snapshot:()=>({pageScale:i,focusX:r,focusY:n}),restore(e){if(e.pageScale!==i||e.focusX!==r||e.focusY!==n){({pageScale:i,focusX:r,focusY:n}=e);for(let e of l)e()}},getFitScale:()=>t,setFitScale(e){if(t!==e){t=e;for(let e of l)e()}},getScale:o,setScale(e){let t=a(e);s(t,1===t?0:r,1===t?0:n)},getView(e,a){let l=o(),s=(1-l)/2,u=i??t??1;return{scale:l,x:c(e>0?s-r*u/e:s,l),y:c(a>0?s-n*u/a:s,l)}},setView(e,i,r,n,o){if(!n||!o)return;let l=a(e),u=(1-l)/2,d=l*(t??1);s(l,(u-c(i,l))*n/d,(u-c(r,l))*o/d)},subscribe:e=>(l.add(e),()=>{l.delete(e)})}}function f({framing:t}){let n=a(t.subscribe,t.getScale,t.getScale),o=a(t.subscribe,t.getFitScale,t.getFitScale),l=null===o?[]:m.map(e=>e/o),c=l.find(e=>e>n)??n,s=l.filter(e=>e<n).pop()??Math.min(1,n);function h(e,t){if(null===o)return`Zoom ${e}`;let i=Math.round(o*t*100)+"%";return t===n?"out"===e?`Fit (${i})`:`Maximum zoom (${i})`:`Zoom ${e} to ${i}`}return u("div",{"data-preview-zoom-controls":"",role:"group","aria-label":"Preview framing","data-popmelt-canvas-block":"",children:[d(e,{type:"button","aria-label":"Zoom out",hint:h("out",s),disabled:s===n,onClick:()=>t.setScale(s),children:d(i,{size:14})}),d(e,{type:"button","aria-label":"Zoom in",hint:h("in",c),disabled:c===n,onClick:()=>t.setScale(c),children:d(r,{size:14})})]})}function g({children:e,overlay:i,interactive:r=!1,framing:a,parentGestureSurface:m}){let g=o.dark,[v]=l(p),w=a??v,b=c(null),[y,x]=l(),[z,M]=l({scale:1,x:0,y:0}),S=c(z);return s(()=>{let e=b.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect(),i=w.getView(t.width,t.height);S.current=i,M(i)},i=()=>{x({width:e.clientWidth,height:e.clientHeight}),t()},n=w.subscribe(t);i();let o=typeof ResizeObserver<"u"?new ResizeObserver(i):void 0;o?.observe(e);let a=()=>window.matchMedia("(any-hover: hover) and (any-pointer: fine)").matches,l=t=>(m&&t.currentTarget===m?e.ownerDocument.defaultView?.frameElement:e)?.getBoundingClientRect()??e.getBoundingClientRect(),c=(t,i,r,n=e.getBoundingClientRect())=>{if(!n.width||!n.height)return;let o=S.current,a=w.clampScale(t),l=Math.max(0,Math.min(1,(i-n.left)/n.width)),c=Math.max(0,Math.min(1,(r-n.top)/n.height));w.setView(a,l-(l-o.x)*a/o.scale,c-(c-o.y)*a/o.scale,n.width,n.height)},s=null,u=t=>{if(!r&&!a()||!t.ctrlKey&&1===S.current.scale)return;t.preventDefault(),t.stopPropagation();let i=l(t),n=1===t.deltaMode?16:2===t.deltaMode?e.clientHeight:1;t.ctrlKey?null===s&&c(S.current.scale*Math.exp(-t.deltaY*n*.01),t.clientX,t.clientY,i):i.width&&i.height&&w.setView(S.current.scale,S.current.x-t.deltaX*n/i.width,S.current.y-t.deltaY*n/i.height,i.width,i.height)},d=e=>{if(!r&&!a())return;e.preventDefault(),e.stopPropagation();let t=e;if("gesturestart"===e.type)s=S.current.scale;else if("gestureend"===e.type)s=null;else if(null!==s&&Number.isFinite(t.scale)){let i=l(e);c(s*t.scale,Number.isFinite(t.clientX)?t.clientX:i.left+i.width/2,Number.isFinite(t.clientY)?t.clientY:i.top+i.height/2,i)}},h=null,p=e=>{if(2!==e.touches.length)return void(h=null);let[t,i]=[e.touches[0],e.touches[1]],r=(t.clientX+i.clientX)/2,n=(t.clientY+i.clientY)/2,o=Math.hypot(t.clientX-i.clientX,t.clientY-i.clientY);if(e.preventDefault(),"touchmove"===e.type&&null===s&&h&&h.distance>0){let t=l(e);c(S.current.scale*o/h.distance,h.x,h.y,t);let i=S.current;t.width&&t.height&&w.setView(i.scale,i.x+(r-h.x)/t.width,i.y+(n-h.y)/t.height,t.width,t.height)}h={x:r,y:n,distance:o}},f=t=>{if(S.current.scale<=1||!(t.target instanceof Element)||!t.target.closest("[data-preview-zoom-content]"))return;let i=t.target.getBoundingClientRect(),r=e.getBoundingClientRect();(i.left<r.left||i.top<r.top||i.right>r.right||i.bottom>r.bottom)&&w.setScale(1)},g=["touchstart","touchmove","touchend","touchcancel"],v=m?[e,m]:[e],y=["gesturestart","gesturechange","gestureend"];for(let e of v){if(r)for(let t of g)e.addEventListener(t,p,{passive:!1,capture:!0});e.addEventListener("wheel",u,{passive:!1,capture:r});for(let t of y)e.addEventListener(t,d,{passive:!1,capture:r})}return r&&e.addEventListener("focusin",f),()=>{for(let e of v){if(r)for(let t of g)e.removeEventListener(t,p,!0);e.removeEventListener("wheel",u,r);for(let t of y)e.removeEventListener(t,d,r)}e.removeEventListener("focusin",f),n(),o?.disconnect()}},[r,w,m]),s(()=>{r&&b.current&&t(b.current)},[r,z,y]),u("div",{ref:b,"data-preview-zoom":!0,style:{position:"relative",width:"100%",aspectRatio:r?void 0:"16 / 9",height:r?"100%":void 0,touchAction:r?"none":void 0,overflow:"hidden",borderRadius:8},children:[d("div",{"data-preview-zoom-content":!0,style:{width:y?.width||"100%",height:y?.height||"100%",zoom:z.scale,transformOrigin:"0 0",transform:`translate(${100*z.x/z.scale}%, ${100*z.y/z.scale}%)`},children:e}),i,r&&!a&&d(f,{framing:w}),!r&&z.scale>1&&u(h,{children:[d("style",{children:`\n [data-preview-zoom-reset] span { color: ${g.primary}; }\n [data-preview-zoom-reset] svg { color: ${g.secondary}; }\n [data-preview-zoom-reset]:hover span, [data-preview-zoom-reset]:focus-visible span { color: ${g.secondary}; }\n [data-preview-zoom-reset]:hover svg, [data-preview-zoom-reset]:focus-visible svg { color: ${g.primary}; }\n [data-preview-zoom-reset] span, [data-preview-zoom-reset] svg { transition: color 120ms ease; }\n `}),u("button",{"data-popmelt-canvas-block":"","data-preview-zoom-reset":!0,type:"button","aria-label":"Reset preview zoom",onClick:()=>w.setScale(1),style:{position:"absolute",right:8,bottom:8,display:"inline-flex",alignItems:"center",gap:6,border:0,borderRadius:8,padding:"4px 6px 4px 10px",background:g.control,color:g.primary,fontSize:12,cursor:"pointer"},children:[u("span",{children:[Math.round(100*z.scale),"%"]}),d(n,{size:14,"aria-hidden":"true"})]})]})]})}export{p as a,f as b,g as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as e,F as t,H as r,I as o,J as a,K as i,L as n,a as s,b as p,i as l,x as c}from"./chunk-7CGKO4IU.mjs";import{a as d,b as m}from"./chunk-NOHXTT24.mjs";import{spawn as w}from"child_process";import{closeSync as u,openSync as f}from"fs";import{appendFile as h,mkdir as g,readFile as _,realpath as E}from"fs/promises";import{dirname as P,join as T}from"path";import{fileURLToPath as y}from"url";import{spawn as O}from"child_process";import{mkdtemp as v,readFile as I,rm as R}from"fs/promises";import{tmpdir as S}from"os";import{join as C}from"path";import M from"ws";async function b(e,t){let r=Date.now()+25e3;for(;Date.now()<r;){let t=await e();if(t)return t;await new Promise(e=>setTimeout(e,100))}throw new Error(`Timed out waiting for ${t}`)}function L(e){let t=new URL(e);if("http:"!==t.protocol||!["localhost","127.0.0.1"].includes(t.hostname)||t.username||t.password||t.hash||t.search)throw new Error("Managed participants require an explicit local app URL");return async e=>{let r,o,a=await v(C(S(),"popmelt-participant-")),i=O(process.env.CHROME_PATH??("darwin"===process.platform?"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome":"google-chrome"),["--headless=new","--no-first-run","--no-default-browser-check","--remote-debugging-address=127.0.0.1","--remote-debugging-port=0","--window-size=1440,1000",`--user-data-dir=${a}`,"about:blank"],{stdio:["ignore","ignore","pipe"]}),n="",s=!1,p=0,l=new Map;i.on("error",e=>{r=e}),i.stderr.on("data",e=>{n=(n+e).slice(-4e3)});let c=()=>{for(let e of l.values())clearTimeout(e.timer),e.reject(new Error("Participant browser disconnected"));l.clear()},d=async()=>{if(!s){if(s=!0,c(),o?.close(),i.pid&&null===i.exitCode&&null===i.signalCode){let e=new Promise(e=>i.once("exit",()=>e()));i.kill("SIGTERM");let t=setTimeout(()=>i.kill("SIGKILL"),3e3);await e,clearTimeout(t)}await R(a,{recursive:!0,force:!0})}};try{let m=await b(async()=>{if(r)throw r;if(null!==i.exitCode||null!==i.signalCode)throw new Error(`Participant browser exited: ${n}`);return I(C(a,"DevToolsActivePort"),"utf8").then(e=>e.split("\n")[0]).catch(()=>null)},"participant browser startup"),w=(await(await fetch(`http://127.0.0.1:${m}/json/list`,{signal:AbortSignal.timeout(3e3)})).json()).find(e=>"page"===e.type);if(!w)throw new Error("Participant browser has no page");o=new M(w.webSocketDebuggerUrl,{handshakeTimeout:5e3}),await new Promise((e,t)=>{o.once("open",e),o.once("error",t)}),o.on("close",c),o.on("error",c),o.on("message",e=>{let t=JSON.parse(e.toString()),r=l.get(t.id);r&&(l.delete(t.id),clearTimeout(r.timer),t.error?r.reject(new Error(t.error.message??"Participant browser request failed")):r.resolve(t.result))});let u=(e,t={})=>new Promise((r,a)=>{if(s||o?.readyState!==M.OPEN)return void a(new Error("Participant browser is closed"));let i=++p,n=setTimeout(()=>{l.delete(i),a(new Error(`Participant browser timed out: ${e}. Action was not retried.`))},35e3);l.set(i,{resolve:r,reject:a,timer:n}),o.send(JSON.stringify({id:i,method:e,params:t}))}),f=async(e,t=!1)=>{let r=await u("Runtime.evaluate",{expression:e,userGesture:t,awaitPromise:!0,returnByValue:!0});if(r.exceptionDetails)throw new Error("Participant action failed: "+JSON.stringify(r.exceptionDetails));return r.result?.value};await u("Page.enable"),await u("Runtime.enable");let h=(await u("Page.getFrameTree")).frameTree.frame.id,g=new Set,_=!1;await u("Runtime.addBinding",{name:"__popmeltCapture"}),o.on("message",e=>{let r=JSON.parse(e.toString());if("Runtime.executionContextCreated"===r.method){let e=r.params.context;e.auxData?.isDefault&&e.auxData.frameId===h&&g.add(e.id)}if("Runtime.executionContextDestroyed"===r.method&&g.delete(r.params.executionContextId),"Runtime.executionContextsCleared"===r.method&&g.clear(),"Runtime.bindingCalled"!==r.method||"__popmeltCapture"!==r.params.name||!g.has(r.params.executionContextId))return;let o,a=r.params.executionContextId,i=r.params.payload;if(i.length>22e4)return;try{o=JSON.parse(i)}catch{return}if(!Number.isSafeInteger(o.id)||!Array.isArray(o.selectors)||o.selectors.length>200||o.selectors.some(e=>"string"!=typeof e||e.length>1024))return;let n=e=>u("Runtime.evaluate",{contextId:a,expression:`window.__POPMELT_CAPTURE_DELIVER__?.(${o.id},${JSON.stringify(e)})`}).catch(()=>{});_?n(null):(_=!0,(async()=>{try{if(!await f(`location.origin + location.pathname === ${JSON.stringify(t.href)}`))return null;let e=await f(`window.__POPMELT_AGENT_VIEW__.geometry(${JSON.stringify(o.selectors)})`),r=e.clip;if(![r.x,r.y,r.width,r.height].every(Number.isFinite)||r.x<0||r.y<0||r.width<=0||r.height<=0||r.width>4096||r.height>4096)return null;await f("window.__POPMELT_CAPTURE_CHROME__ = [...document.querySelectorAll('[data-popmelt-top-layer-host]')].map(element => [element, element.style.opacity]); window.__POPMELT_CAPTURE_CHROME__.forEach(([element]) => element.style.opacity = '0');");try{let t=await u("Page.captureScreenshot",{format:"jpeg",quality:80,captureBeyondViewport:!0,clip:{...r,scale:Math.min(1,1280/Math.max(r.width,r.height))}});return"string"!=typeof t.data||t.data.length>5e5?null:{image:"data:image/jpeg;base64,"+t.data,targets:e.targets}}finally{await f("window.__POPMELT_CAPTURE_CHROME__?.forEach(([element, opacity]) => element.style.opacity = opacity); delete window.__POPMELT_CAPTURE_CHROME__;").catch(()=>{})}}catch{return null}})().then(n).finally(()=>{_=!1}))}),await u("Page.addScriptToEvaluateOnNewDocument",{source:`if (location.origin + location.pathname === ${JSON.stringify(t.href)}) {\n window.__POPMELT_AGENT_CREDENTIAL__ = ${JSON.stringify(e)};\n const waiting = new Map(); let id = 0;\n window.__POPMELT_CAPTURE_DELIVER__ = (id, frame) => { const pending = waiting.get(id); if (!pending) return; waiting.delete(id); clearTimeout(pending.timer); pending.resolve(frame); };\n window.__POPMELT_MANAGED_CAPTURE__ = () => { let stopped = false; const owned = new Set(); return {\n frame: selectors => stopped ? Promise.resolve(null) : new Promise(resolve => { const key = ++id; owned.add(key); const timer = setTimeout(() => window.__POPMELT_CAPTURE_DELIVER__(key, null), 5000); waiting.set(key, {resolve: frame => { owned.delete(key); resolve(frame); }, timer}); window.__popmeltCapture(JSON.stringify({id: key, selectors})); }),\n stop: () => { stopped = true; for (const key of owned) window.__POPMELT_CAPTURE_DELIVER__(key, null); }\n }; };\n }`});let E=()=>b(()=>f(`location.origin + location.pathname === ${JSON.stringify(t.href)} && Boolean(window.__POPMELT_AGENT_VIEW__)`),"native participant canvas");o.on("message",e=>{"Page.loadEventFired"===JSON.parse(e.toString()).method&&E().then(()=>f("window.__POPMELT_AGENT_VIEW__.share()",!0)).catch(()=>{})}),await u("Page.navigate",{url:t.href}),await E(),await f("window.__POPMELT_AGENT_VIEW__.share()",!0);let P=Promise.resolve();return{act(e){let t=P.then(async()=>(await E(),f(`window.__POPMELT_AGENT_VIEW__.act(${JSON.stringify(e)})`)));return P=t.catch(()=>{}),t},close:d}}catch(e){throw await d(),e}}}import{randomBytes as N,timingSafeEqual as j}from"crypto";import{readFile as x,writeFile as $,mkdir as A}from"fs/promises";import{join as k}from"path";var D=(e,t)=>"string"==typeof e&&Buffer.byteLength(e)===Buffer.byteLength(t)&&j(Buffer.from(e),Buffer.from(t));async function J(e){let t=k(e.projectRoot,".popmelt");await A(t,{recursive:!0});let r,o=k(t,"participant-host-recovery.json");try{if(r=JSON.parse(await x(o,"utf8")).token,"string"!=typeof r||!/^[\w-]{43}$/.test(r))throw new Error("Invalid host recovery capability")}catch(e){if("ENOENT"!==e.code)throw e;r=N(32).toString("base64url"),await $(o,JSON.stringify({token:r}),{mode:384,flag:"wx"})}let a=N(32).toString("base64url"),i=`popmelt-host-${e.projectId}`;return{handler:async(t,o)=>{if(o.setHeader("Cache-Control","no-store"),"POST"!==t.method||t.headers.origin!==e.origin||"application/json"!==t.headers["content-type"])return o.statusCode=403,void o.end();try{let n="";for await(let e of t)if(n+=e,n.length>2048)throw new Error("Invalid host proof");let s,p=JSON.parse(n),l=t.headers.cookie?.split(";").map(e=>e.trim()).find(e=>e.startsWith(`${i}=`))?.slice(i.length+1);if(a&&D(p.token,a))a="";else if(!D(l,r)){if(!p.credential)throw new Error("Host proof required");if(s=await e.host(),p.credential.participantId!==s.participantId||!D(p.credential.token,s.token))throw new Error("Invalid host proof")}s??=await e.host(),o.setHeader("Set-Cookie",`${i}=${r}; Path=/__popmelt/host; HttpOnly; SameSite=Strict; Max-Age=31536000`),o.setHeader("Content-Type","application/json"),o.end(JSON.stringify(s))}catch{o.statusCode=403,o.end()}},claimUrl:`${e.origin}/#popmelt-host=${a}`}}import{chmod as G,mkdir as H,writeFile as B}from"fs/promises";import{join as U}from"path";async function V(e){let{bridge:t}=e;if(!t.participantHost)throw new Error("The bridge does not support participant sessions");let r=await J({projectRoot:e.projectRoot,projectId:t.projectId,origin:e.origin,host:t.participantHost}),o=U(e.projectRoot,".popmelt");await H(o,{recursive:!0}),await B(U(o,"participant-bridge.json"),JSON.stringify({port:t.port,projectId:t.projectId}),{mode:384});let a=U(o,"participant-host-link.json");return await B(a,JSON.stringify({url:r.claimUrl}),{mode:384}),await G(a,384),{hostEntry:r.handler,read:async()=>({version:1,url:`http://127.0.0.1:${t.port}`,projectId:t.projectId,revision:await(e.sourceRevision?.())??"unversioned"})}}async function F(e,t){let r=(await _(t,"utf8").catch(()=>"")).slice(-8e3).trim();return new Error(r?`${e}\nBridge log (${t}):\n${r}`:e)}async function q(_){if("production"===process.env.NODE_ENV&&!_?.force)throw new Error("[Bridge] Refusing to start in production. Pass { force: true } to override.");if((_={..._,experimentalEventTransport:c(_?.experimentalEventTransport)}).detached){let n=_.projectRoot??process.cwd(),c=await s(T(n,".popmelt","bridge-start.lock"),()=>async function(n){let s,c=n.port??1111,d=await async function(e){return E(e).catch(()=>e)}(n.projectRoot??process.cwd()),m=l(d),_=await r(d);for await(let{port:r,status:o}of a(d,c))if(o.projectId===m){if(o.version&&o.version!==e&&"detached"===o.restartMode){s??={port:r,status:o};continue}if("detached"===o.restartMode&&o.version===e&&(o.eventTransport??"sse")!==n.experimentalEventTransport)throw new Error(`[Bridge] Transport conflict on port ${r}: the project is using ${o.eventTransport??"sse"}, but this client requested ${n.experimentalEventTransport}. Use the running transport or stop the bridge before switching.`);if(!t(o,{projectId:m,version:e,restartMode:"detached",eventTransport:n.experimentalEventTransport}))continue;let a=n.devOrigin;if(a&&o.devOrigin!==a)try{await fetch(`http://127.0.0.1:${r}/config`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({devOrigin:a})})}catch{}return process.env.POPMELT_BRIDGE_PORT=String(r),process.env.POPMELT_PROJECT_ID=m,{port:r,projectId:m,storeId:_.storeId,close:async()=>{}}}s&&await i(s.port,m,s.status);let O=T(P(y(import.meta.url)),"bridge-entry.mjs"),v=T(d,".popmelt"),I=T(v,"bridge.log");await g(v,{recursive:!0}),await h(I,`\n[${(new Date).toISOString()}] Starting detached bridge\n`);let R,S=f(I,"a");try{R=w(process.execPath,[O],{detached:!0,stdio:["ignore","ignore",S],env:{...process.env,POPMELT_PORT:String(c),POPMELT_PROJECT_ROOT:d,POPMELT_DEV_ORIGIN:n.devOrigin??"",POPMELT_OPENCODE_PATH:n.opencodePath??"",POPMELT_COPILOT_PATH:n.copilotPath??"",POPMELT_EXPERIMENTAL_EVENT_TRANSPORT:n.experimentalEventTransport}})}finally{u(S)}let C=null;R.once("error",e=>{C=`spawn error: ${e.message}`}),R.once("exit",(e,t)=>{C=`child exited before becoming healthy (${t?`signal ${t}`:`code ${e??"unknown"}`})`}),R.unref();let M=Date.now()+3e4;for(;Date.now()<M;){if(await new Promise(e=>setTimeout(e,100)),C)throw await F(`[Bridge] Detached bridge ${C}`,I);let r=await p(d);if(r&&r.pid===R.pid){let a=await o(r.port);if(t(a,{projectId:m,version:e,restartMode:"detached",eventTransport:n.experimentalEventTransport}))return process.env.POPMELT_BRIDGE_PORT=String(r.port),process.env.POPMELT_PROJECT_ID=m,{port:r.port,projectId:m,storeId:_.storeId,close:async()=>{}}}}throw R.kill("SIGTERM"),await F(`[Bridge] Detached bridge failed to start within 30s (port ${c})`,I)}(_),4e4);if(!1===_.manageLease)return c;let O=await d({port:c.port,projectId:c.projectId});if(!O)return console.warn("[popmelt] detached bridge started without a process lease"),c;let v=m(O);return{...c,close:async()=>{v(),await O.release()}}}let O=await n(_);return process.env.POPMELT_BRIDGE_PORT=String(O.port),process.env.POPMELT_PROJECT_ID=O.projectId,O}export{L as a,J as b,V as c,q as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useRef as e,useId as t,useLayoutEffect as r}from"react";import{jsxs as n,Fragment as i,jsx as o}from"react/jsx-runtime";var a=Array.from({length:16},(e,t)=>{let r=16-t,n=19*r/16;return{dash:`0 ${100-n} ${n} 0`,opacity:1/(r+1)}}),l=Array.from({length:16},(e,t)=>{let r=2.75+5*t;return`M${r} 0L${r-40} 40`}).join(" "),s="M20.25 8.00293H20.249C21.5098 8.0286 22.7219 8.25094 23.8584 8.63672L23.8604 8.63574C23.8961 8.64787 23.9312 8.66145 23.9668 8.67383C24.0611 8.70686 24.1548 8.74106 24.248 8.77637C24.2915 8.79273 24.3357 8.80727 24.3789 8.82422L24.376 8.82617C27.6145 10.0955 30.1646 12.7301 31.3213 16.0234L31.3232 16.0225C31.3327 16.0493 31.3404 16.0766 31.3496 16.1035C31.7691 17.3256 32 18.6356 32 20C32 20.8726 31.9366 21.6706 31.7598 22.4902L31.7197 22.6328C31.6412 23.0066 31.5136 23.6108 31.3408 24.2217L31.3398 24.2246C31.2967 24.377 31.251 24.5299 31.2021 24.6797C30.9215 25.5403 30.5473 26.2998 30.0879 26.2998C29.7613 26.2996 29.5995 25.9674 29.4316 25.6221C29.2501 25.2487 29.0614 24.8605 28.6484 24.8604C27.8532 24.8604 27.2081 25.5046 27.208 26.2998V27.0771C27.2079 27.6079 26.9661 28.112 26.5205 28.4004C25.9146 28.7925 25.2357 28.6462 24.7959 28.2061L24.7949 28.208C24.7897 28.2028 24.7854 28.1967 24.7803 28.1914C24.7654 28.1761 24.7507 28.1606 24.7363 28.1445C24.7105 28.1156 24.6858 28.0857 24.6621 28.0547C24.6461 28.0339 24.6302 28.013 24.6152 27.9912C24.5931 27.9591 24.5726 27.9257 24.5527 27.8916C24.5392 27.8685 24.5261 27.8452 24.5137 27.8213C24.5093 27.8128 24.5043 27.8045 24.5 27.7959L24.501 27.7939C24.3932 27.5763 24.3282 27.3276 24.3281 27.0576V26.2998C24.328 25.5993 23.8278 25.0158 23.165 24.8867V24.8877C23.0752 24.8702 22.9826 24.8604 22.8877 24.8604C22.8446 24.8604 22.8019 24.8624 22.7598 24.8662C22.0247 24.9312 21.4483 25.5479 21.4482 26.2998C21.4482 26.9127 21.4608 27.5305 21.4736 28.1494L21.4951 29.3135C21.5 29.7013 21.5015 30.089 21.4971 30.4756C21.4874 31.3103 20.8426 32 20.0078 32C19.1732 31.9998 18.5292 31.3102 18.5195 30.4756C18.5159 30.1613 18.5176 29.8464 18.5205 29.5312V29.5322C18.5212 29.4593 18.5206 29.3864 18.5215 29.3135L18.5303 28.8154V28.8145C18.5343 28.5927 18.5384 28.371 18.543 28.1494C18.5558 27.5305 18.5684 28.1129 18.5684 27.5C18.5684 26.7047 17.9232 26.0596 17.1279 26.0596C16.907 26.0596 16.6978 26.1103 16.5107 26.1992C16.2161 26.3393 15.9767 26.5769 15.834 26.8701C15.8269 26.8846 15.8201 26.8993 15.8135 26.9141C15.7821 26.9845 15.7562 27.0579 15.7363 27.1338C15.7243 27.1798 15.7155 27.2267 15.708 27.2744C15.7012 27.3175 15.6953 27.361 15.6924 27.4053C15.6903 27.4366 15.6885 27.4681 15.6885 27.5V28.7383C15.6883 29.9234 14.4911 30.7248 13.4961 30.0811C13.0505 29.7926 12.8086 29.2886 12.8086 28.7578V26.2998C12.8086 25.9737 12.6984 25.674 12.5156 25.4326C12.4437 25.3381 12.3612 25.2521 12.2686 25.1777V25.1768C12.0219 24.9788 11.709 24.8604 11.3682 24.8604C10.9892 24.8604 10.8622 24.8872 10.7295 25.2295C10.5837 25.6055 10.4302 26 9.92773 26C9.33081 25.9996 8.95963 25.2403 8.71484 24.3799C8.5591 23.8325 8.45907 23.571 8.3623 23.0107C8.3501 22.9401 8.33284 22.8403 8.31738 22.7529C8.12812 21.9466 8.02043 21.1089 8.00293 20.249V20.25L8 20C8 19.8617 8.00317 19.724 8.00781 19.5869C8.00837 19.5703 8.00816 19.5537 8.00879 19.5371L8.00977 19.5352C8.0998 17.1716 8.87444 14.9844 10.1396 13.1631C10.1488 13.1499 10.1587 13.1372 10.168 13.124C12.255 10.1453 15.6582 8.15745 19.5352 8.00977L19.5371 8.00879C19.5537 8.00816 19.5703 8.00837 19.5869 8.00781C19.724 8.00317 19.8617 8 20 8L20.25 8.00293Z";function c({active:c,interactive:h=!1,hatched:d=!1,tracing:u,onSettlingChange:p,...m}){let C=e(null),g=e(null),f=e(null),y=t(),M=y+"-trace",v=y+"-perimeter",x=e(0),L=e(!1),b=e(null);return r(()=>{c&&(g.current?.setAttribute("fill",m.fill??"currentColor"),g.current?.setAttribute("stroke","none"))},[c,m.fill]),r(()=>{let e=C.current;if(!e)return;e.style.removeProperty("fill"),e.style.removeProperty("stroke");let t=window.matchMedia("(prefers-reduced-motion: reduce)"),r=0,n=null,i=0,o=!1,a=x.current,l=Math.ceil(a),d=!c&&l-a>1e-9,m=!1,y=0,M=null,v=e,k=v.style.cursor,A=v.style.touchAction,P=e=>{g.current?.setAttribute("d",e),f.current?.setAttribute("d",e)},I=()=>{b.current??(b.current=function(){let e=[],t=0,r=0;for(let[,n,i]of s.matchAll(/([A-Z])([^A-Z]*)/g)){let o=(i.match(/-?\d*\.?\d+/g)??[]).map(Number),a=t,l=r;if("Z"!==n)if("H"===n?t=o[0]:"V"===n?r=o[0]:(t=o[o.length-2],r=o[o.length-1]),"C"===n)for(let n=1;n<=24;n++){let i=n/24,s=1-i;e.push({x:s**3*a+3*s**2*i*o[0]+3*s*i**2*o[2]+i**3*t,y:s**3*l+3*s**2*i*o[1]+3*s*i**2*o[3]+i**3*r})}else e.push({x:t,y:r})}let n=24,i=e.findIndex(e=>e.y>=n),o=i;for(;o+1<e.length&&e[o+1].y>=n;)o++;let a=(e,t)=>({x:e.x+(t.x-e.x)*(n-e.y)/(t.y-e.y),y:n}),l=a(e[i-1],e[i]),c=a(e[o],e[o+1]),h=(l.x+c.x)/2,d=(l.x-c.x)/2,u=[l,...e.slice(i,o+1),c].map(e=>{let t=Math.asin(Math.max(-1,Math.min(1,(e.x-h)/d))),r=Math.cos(t);return{longitude:t,height:r>1e-5?(e.y-n)/r:0}}),p=[],m=[8,6.2,8.6,6.5,8],C=[0,1.4,.8,1.8,1.1,0],g=(e,t,r,n)=>{for(let i=0;i<=24;i++){let o=i/24,a=1-o;p.push({longitude:a**3*e[0]+3*a**2*o*t[0]+3*a*o**2*r[0]+o**3*n[0],height:a**3*e[1]+3*a**2*o*t[1]+3*a*o**2*r[1]+o**3*n[1]})}};for(let[e,t]of m.entries()){let r=Math.PI/2+e/m.length*Math.PI,n=r+Math.PI/m.length,i=(r+n)/2,o=.145,a=C[e],l=C[e+1];g([r,a],[i-o,a],[i-o,a+.7],[i-o,t-1.4]);for(let e=0;e<=32;e++){let r=Math.PI*(1-e/32);p.push({longitude:i+o*Math.cos(r),height:t-1.4+1.4*Math.sin(r)})}g([i+o,t-1.4],[i+o,l+.7],[i+o,l],[n,l])}let f=[...u,...p],y=e=>`L${e.x} ${e.y}`,M=`M${e[0].x} ${e[0].y}`+e.slice(1,i).map(y).join("")+y(l),v=y(c)+e.slice(o+1).map(y).join("")+"Z";return e=>{let t=Math.atan2(Math.sin(e),Math.cos(e));if(Math.abs(t)<1e-9)return s;let r=f.map(e=>({longitude:Math.atan2(Math.sin(e.longitude+t),Math.cos(e.longitude+t)),height:e.height})).filter(e=>Math.abs(e.longitude)<Math.PI/2).sort((e,t)=>t.longitude-e.longitude).map(e=>`L${h+d*Math.sin(e.longitude)} ${n+e.height*Math.cos(e.longitude)}`).join("");return M+r+v}}()),P(b.current(-x.current*Math.PI*2))},$=()=>{o=!0,x.current=0,P(s),g.current?.removeAttribute("fill"),g.current?.removeAttribute("stroke"),p?.(!1)},V=e=>{let t=null===n?0:e-n;if(n=e,m){let e=Math.min(t/1e3,.05),r=c?1/15:0,n=Math.exp(-1.8*e);x.current+=r*e+(y-r)*(1-n)/1.8,y=r+(y-r)*n,Math.abs(y-r)<.005&&(m=!1,a=x.current,l=Math.round(a),i=0)}else if(c)x.current+=t/15e3;else{i+=t;let e=Math.min(1,i/250);if(1===e)return void $();let r=1-(1-e)**3;x.current=a+(l-a)*r}I(),r=requestAnimationFrame(V)},w=()=>{cancelAnimationFrame(r),n=null,!M&&!o&&(c||!t.matches&&L.current&&!document.hidden?t.matches?(x.current=0,P(s)):L.current&&!document.hidden&&(r=requestAnimationFrame(V)):$())},j=e=>{M||!e.isPrimary||0!==e.button||(v.setPointerCapture(e.pointerId),M={id:e.pointerId,startX:e.clientX,x:e.clientX,time:e.timeStamp,moved:!1},y=0,cancelAnimationFrame(r),v.style.cursor="grabbing")},E=e=>{if(!M||M.id!==e.pointerId||!M.moved&&Math.abs(e.clientX-M.startX)<3)return;M.moved=!0;let t=-(e.clientX-M.x)/160,r=Math.max((e.timeStamp-M.time)/1e3,.001),n=24/(2*Math.PI);y+=(Math.max(-n,Math.min(n,t/r))-y)*(1-Math.exp(-r/.035)),x.current+=t,M.x=e.clientX,M.time=e.timeStamp,I()},X=e=>{!M||M.id!==e.pointerId||(M.moved&&(y*=Math.exp(-Math.max(0,e.timeStamp-M.time-40)/60),m="pointerup"===e.type&&!t.matches,o=!1,a=x.current,l=Math.round(a),i=0),M=null,v.style.cursor="grab",v.hasPointerCapture(e.pointerId)&&v.releasePointerCapture(e.pointerId),w())};if((u||!c&&!d)&&($(),!h))return;let S=e=>{for(let[t,r]of Object.entries({pointerdown:j,pointermove:E,pointerup:X,pointercancel:X,lostpointercapture:X}))v[e](t,r)};h&&(v.style.cursor="grab",v.style.touchAction="pan-y",S("addEventListener")),p?.(d);let Z=new IntersectionObserver(([e])=>{L.current=e?.isIntersecting??!1,w()});return Z.observe(e),t.addEventListener("change",w),document.addEventListener("visibilitychange",w),w(),()=>{cancelAnimationFrame(r),Z.disconnect(),h&&(S("removeEventListener"),v.style.cursor=k,v.style.touchAction=A,M&&v.hasPointerCapture(M.id)&&v.releasePointerCapture(M.id)),t.removeEventListener("change",w),document.removeEventListener("visibilitychange",w)}},[c,h,p,u]),n("svg",{...m,ref:C,children:[d&&n(i,{children:[o("defs",{children:n("mask",{id:y,x:"0",y:"0",width:"40",height:"40",maskUnits:"userSpaceOnUse",style:{maskType:"luminance"},children:[o("rect",{width:"40",height:"40",fill:"white"}),o("path",{ref:f,d:s,fill:"black",stroke:"black",strokeWidth:"5",strokeLinejoin:"round"})]})}),o("path",{d:l,fill:"none",stroke:"currentColor",strokeWidth:"0.65",mask:`url(#${y})`})]}),void 0!==u&&o("style",{children:'\n @keyframes popmelt-logo-trace { to { stroke-dashoffset: -100; } }\n @media (prefers-reduced-motion: no-preference) {\n [data-popmelt-logo-fill] { transition: fill-opacity 360ms ease-in-out; }\n [data-popmelt-logo-outline] { transition: opacity 360ms ease-in-out; }\n [data-popmelt-logo-outline][opacity="0"] [data-popmelt-logo-sweep] { animation-play-state: paused; }\n [data-popmelt-logo-sweep] { animation: popmelt-logo-trace 1.5s linear infinite; }\n [data-popmelt-logo-tail] { display: inline; }\n [data-popmelt-logo-trace] { stroke-dasharray: 19 81; }\n }\n '}),o("path",{ref:g,d:s,"data-popmelt-logo-fill":void 0!==u||void 0,fillOpacity:void 0===u?void 0:u?0:1}),void 0!==u&&n(i,{children:[o("defs",{children:o("clipPath",{id:M,children:o("path",{clipRule:"evenodd",d:`M0 0H40V40H0Z ${s}`})})}),n("g",{"data-popmelt-logo-outline":!0,opacity:u?1:0,pointerEvents:"none",clipPath:`url(#${M})`,fill:"none",stroke:"currentColor",strokeWidth:"2.7",strokeLinecap:"round",children:[o("g",{opacity:".3",children:o("path",{id:v,d:s,pathLength:"100"})}),n("g",{"data-popmelt-logo-sweep":!0,children:[o("g",{"data-popmelt-logo-tail":!0,display:"none",strokeLinecap:"butt",children:a.map(({dash:e,opacity:t})=>o("use",{href:`#${v}`,strokeDasharray:e,strokeOpacity:t},e))}),o("path",{"data-popmelt-logo-trace":!0,d:s,pathLength:"100"})]})]})]})]})}export{c as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{c as e,g as t}from"./chunk-XT6PHPPG.mjs";import{a as n}from"./chunk-V2I7PSJW.mjs";import{f as r,d as o,c as a,e as l,g as i}from"./chunk-WHJEKDNP.mjs";var s={isAnnotating:!1,activeTool:"inspector",activeColor:"oklch(0.628 0.258 29)",strokeWidth:3,annotations:[],undoStack:[],redoStack:[],selectedAnnotationIds:[],lastSelectedId:null,styleModifications:[],textModifications:[],domModifications:[],spacingTokenChanges:[],spacingTokenMods:[]};function f(e){return e.left+e.width}function u(e){return e.top+e.height}function d(e,t){if(0===e.length)return t;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top));return{left:n,top:r,width:Math.max(...e.map(f))-n,height:Math.max(...e.map(u))-r}}function p(e){let t=[...e].sort((e,t)=>e.top-t.top||e.left-t.left),n=[];for(let e of t){let t=e.top+e.height/2,r=n.find(n=>{let r=n.top+n.height/2;return Math.abs(t-r)<=.4*Math.max(n.height,e.height)});if(!r){n.push({...e});continue}let o=Math.min(r.left,e.left),a=Math.min(r.top,e.top),l=Math.max(f(r),f(e)),i=Math.max(u(r),u(e));r.left=o,r.top=a,r.width=l-o,r.height=i-a}return n.sort((e,t)=>e.top-t.top||e.left-t.left)}function c(e){return!!e&&!!e.closest("#devtools-toolbar, #devtools-scrim, #devtools-text-input, [data-devtools], [data-popmelt-panel], [data-popmelt-shadow-host]")}function h(e,t,n){let r=e.caretPositionFromPoint?.(t,n);if(r?.offsetNode.nodeType===Node.TEXT_NODE)return{node:r.offsetNode,offset:r.offset};let o=e.caretRangeFromPoint?.(t,n);return o?.startContainer.nodeType===Node.TEXT_NODE?{node:o.startContainer,offset:o.startOffset}:null}function g(e,n,o,a=!1){return function(e,t){if(!e)return t();let n=e.style.pointerEvents;e.style.pointerEvents="none";try{return t()}finally{e.style.pointerEvents=n}}(o,()=>{let o=t(e,n);if(!o||c(o))return null;let s=o?.ownerDocument??document,f=l(e,n,s),u=h(s,f.x,f.y)?.node??null;if(u&&!o.contains(u)&&(u=null),!u){let e=o;e&&!c(e)&&(u=function(e,t,n){let r=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:e=>e.textContent?.trim()?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}),o=r.nextNode();for(;o;){let a=o,l=e.ownerDocument.createRange();l.selectNodeContents(a);let i=Array.from(l.getClientRects());if(l.detach?.(),i.some(e=>t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom))return a;o=r.nextNode()}return null}(e,f.x,f.y))}if(!u&&o?.closest("p")?.querySelector("[data-popmelt-empty-paragraph]"))return m(o.closest("p"));if(!u||!i(u.parentElement))return null;let d=u.parentElement;if(c(d))return null;for(;!a&&d.parentElement&&d!==s.body;){let e=r(d).getComputedStyle(d).display,t="inline-block"===e&&1===d.childNodes.length&&d.firstChild?.nodeType===Node.ELEMENT_NODE;if("inline"!==e&&"contents"!==e&&!t)break;let n=d.parentElement;if(c(n))break;if(Array.from(n.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&!!e.nodeValue?.trim())){d=n;continue}let o=r(n).getComputedStyle(n).display,a="inline-block"===o&&1===n.childNodes.length&&n.firstChild?.nodeType===Node.ELEMENT_NODE;if("inline"!==o&&"contents"!==o&&!a)break;d=n}let p=u.parentElement?.closest("p"),g=u.parentElement?.closest('button, input, textarea, select, [role="button"]');if(p&&(!g||!p.contains(g)))return m(p,u);let N=d.tagName.toLowerCase();if("script"===N||"style"===N||"textarea"===N||"input"===N)return null;let b=x(d).filter(e=>!a||e.textNode===u),T=b.map(e=>e.originalText).join("");if(!T.trim())return null;let E=y(d,u);if(!E)return null;let S=r(d).getComputedStyle(d),v=w(b,d,S,a),{textRect:C,boundaryRect:M,boundaryRects:R,flowRect:P,firstLineIndent:D}=v;if(C.width<=0||C.height<=0)return null;let k=parseFloat(S.fontSize)||12,A="nowrap"!==S.whiteSpace&&"pre"!==S.whiteSpace&&(a?R.length>1:function(e){let t=e.ownerDocument.createRange();t.selectNodeContents(e);let n=Array.from(t.getClientRects()).filter(e=>e.width>0&&e.height>0).length;return t.detach?.(),n>1}(u)||"inline"!==S.display);return{textNode:u,targetElement:d,textNodePath:E,segments:b,originalText:T,rect:C,boundaryRect:M,boundaryRects:R,flowRect:P,firstLineIndent:D,styles:S,fontSize:k,wrapsText:A,singleTextNode:a}})}function m(e,t){let n=x(e),o=n.find(e=>e.textNode===t)??n[0];if(!o)return null;let a=r(e).getComputedStyle(e),{textRect:l,...i}=w(n,e,a);return{...o,targetElement:e,segments:n,originalText:n.map(e=>e.originalText).join(""),styles:a,rect:l,...i,fontSize:parseFloat(a.fontSize)||12,wrapsText:"nowrap"!==a.whiteSpace&&"pre"!==a.whiteSpace}}function y(e,t){let n=[],r=t;for(;r&&r!==e;){let e=r.parentNode;if(!e)return null;n.unshift(Array.prototype.indexOf.call(e.childNodes,r)),r=e}return r===e?n:null}function x(e){let t=[],n=r=>{if(r.nodeType===Node.TEXT_NODE){let n=r,o=y(e,n);return void(o&&t.push({textNode:n,textNodePath:o,originalText:n.nodeValue??""}))}if(r.nodeType!==Node.ELEMENT_NODE&&r!==e)return;let o=r.tagName?.toLowerCase();"script"===o||"style"===o||r.childNodes.forEach(n)};return e.childNodes.forEach(n),t}function N(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function b(e){let t=e.getBoundingClientRect(),n=r(e).getComputedStyle(e),o=(parseFloat(n.borderLeftWidth)||0)+(parseFloat(n.paddingLeft)||0),l=(parseFloat(n.borderRightWidth)||0)+(parseFloat(n.paddingRight)||0),i=(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.paddingTop)||0),s=(parseFloat(n.borderBottomWidth)||0)+(parseFloat(n.paddingBottom)||0);return a({left:t.left+o,top:t.top+i,width:Math.max(0,t.width-o-l),height:Math.max(0,t.height-i-s)},e.ownerDocument)}function w(e,t,n,r=!1){let l=N(o(t)),i=function(e){let t=[];for(let n of e){if(!n.textNode.isConnected||!n.originalText.trim())continue;let e=n.textNode.ownerDocument.createRange();e.selectNodeContents(n.textNode),t.push(...Array.from(e.getClientRects()).filter(e=>e.width>0&&e.height>0).map(e=>N(a(e,n.textNode.ownerDocument)))),e.detach?.()}return p(t)}(e),s=e[0]?.textNode?function(e,t){let n=e.ownerDocument.createRange();n.selectNodeContents(e);let r=a(n.getBoundingClientRect(),e.ownerDocument);if(n.detach?.(),r.width>0&&r.height>0)return{left:r.left,top:r.top,width:r.width,height:r.height};let l=o(t);return{left:l.left,top:l.top,width:l.width,height:l.height}}(e[0].textNode,t):l,f=i.length>0?i:[s];return function({display:e,singleTextNode:t=!1,fragmentRects:n,elementRect:r,parentContentRect:o}){let a=p(n),l=d(a,r);if(!("inline"===e&&a.length>1&&o&&o.width>0))return{textRect:l,boundaryRect:t?l:r,boundaryRects:t?a:[r],firstLineIndent:0};let i=a[0],s={left:o.left,top:i.top,width:o.width,height:Math.max(l.height,u(l)-i.top)},f=Math.max(0,Math.min(s.width,i.left-s.left));return{textRect:l,boundaryRect:d(a,r),boundaryRects:a,flowRect:s,firstLineIndent:f}}({display:n.display,singleTextNode:r,fragmentRects:f,elementRect:l,parentContentRect:t.parentElement?b(t.parentElement):void 0})}function T(e,t,n){if(t===n||0===e.length)return[];let r=0;for(;r<t.length&&r<n.length&&t[r]===n[r];)r+=1;let o=0;for(;o<t.length-r&&o<n.length-r&&t[t.length-1-o]===n[n.length-1-o];)o+=1;let a=r,l=t.length-o,i=n.slice(r,n.length-o),s=0,f=!1;return e.flatMap((t,n)=>{let r=s,o=r+t.originalText.length;s=o;let u=a===l;if(!(u&&(a>=r&&a<o||n===e.length-1&&a===o))&&!(!u&&o>a&&r<l))return[];let d=Math.max(0,Math.min(t.originalText.length,a-r)),p=Math.max(0,Math.min(t.originalText.length,l-r)),c=t.originalText.slice(0,d);return f||(c+=i,f=!0),c+=t.originalText.slice(p),c===t.originalText?[]:[{segment:t,modifiedText:c}]})}function E(e,t){return Math.abs(e.left-t.left)<.5&&Math.abs(e.top-t.top)<.5&&Math.abs(e.width-t.width)<.5&&Math.abs(e.height-t.height)<.5}function S(e,t){return e&&t?E(e,t):e===t}function v(e,t){return e.length===t.length&&e.every((e,n)=>E(e,t[n]))}var C=new WeakMap;function M(e){let t=e.closest("p");return t?C.get(t):void 0}function R(e){let t=x(e);return{root:e,rows:[e],runs:t.map(e=>[e.textNode]),paths:t.map(e=>e.textNodePath),undo:[]}}function P(e){let t=C.get(e)??R(e),n=t.runs.map((e,n)=>({path:t.paths[n],parts:e.map(e=>e.data)}));return{group:t,layout:n}}function D(e,t,n){let r=t.splitText(n),o=r,a=t.parentElement;for(;;){let t=a,n=a.cloneNode(!1);for(n.removeAttribute("id"),n.removeAttribute("data-pm");o.nextSibling;)n.appendChild(o.nextSibling);if(n.insertBefore(o,n.firstChild),t.after(n),e.undo.push(()=>{for(;n.firstChild;)t.appendChild(n.firstChild);n.remove()}),"P"===a.tagName){n.dataset.popmeltParagraphContinuation="",e.rows.splice(e.rows.indexOf(t)+1,0,n),C.set(n,e);break}o=n,a=t.parentElement}return r}function k(e){let t=C.get(e);if(t&&t.root===e){for(let e of t.rows)e.querySelector("br[data-popmelt-empty-paragraph]")?.remove(),C.delete(e);for(let e of t.undo.reverse())e()}}function A(e,t){if("P"!==e.tagName)return;let n=C.get(e);if((!n||n.root===e)&&(n&&!n.runs.every((e,n)=>e.length===t[n]?.parts.length)&&(k(e),n=void 0),n??(n=R(e)),n.paths.length===t.length&&t.every((e,t)=>e.parts.length&&e.path.join(".")===n.paths[t].join(".")))){if(!C.has(e)){C.set(e,n);for(let e=0;e<t.length;e++){let r=n.runs[e],o=r[0],a=o.data;n.undo.push(()=>{o.data=a;for(let e of r.slice(1))e.remove()});let l=t[e].parts;for(let e=1;e<l.length;e++){let t=r[e-1];r.push(D(n,t,t.length))}}}n.runs.forEach((e,n)=>e.forEach((e,r)=>{let o=t[n].parts[r];e.data!==o&&(e.data=o)}));for(let e of n.rows){let t=e.querySelector("br[data-popmelt-empty-paragraph]");if(e.textContent||t||e.querySelector("br,img,svg,input"))e.textContent&&t&&t.remove();else{let t=e.ownerDocument.createElement("br");t.dataset.popmeltEmptyParagraph="",e.appendChild(t)}}return n}}var F=new WeakMap,O=new WeakMap;function L(e,t){if(n(t))for(let[n,r]of O.get(e)??[])r.value?t.style.setProperty(n,r.value,r.priority):t.style.removeProperty(n)}function I(e,t){F.set(e,new Set(t))}function W(e){F.delete(e)}function _(e,t){return n(e)&&(F.get(e)?.has(t)??!1)}function V(e){let t=e.sticker;return t?"padding"===t.family||"margin"===t.family?"all"===t.subproperty?10:"x"===t.subproperty||"y"===t.subproperty?20:30:"radius"===t.family||"border"===t.family?"all"===t.subproperty?10:20:10:0}function j(e){return e.changes.map((e,t)=>({change:e,index:t})).sort((e,t)=>V(e.change)-V(t.change)||e.index-t.index).map(({change:e})=>e)}function X(e,t,r){if(n(e)){let n=O.get(e);n||(n=new Map,O.set(e,n)),n.has(t)||n.set(t,{value:e.style.getPropertyValue(t),priority:e.style.getPropertyPriority(t)}),e.style.setProperty(t,r,"important")}}function q(e,t,r,o=!1){if(n(e)){let n=o?O.get(e)?.get(t):void 0;n?.value?e.style.setProperty(t,n.value,n.priority):e.style.removeProperty(t),O.get(e)?.delete(t)}}function B(t){let n=e(t.selector);if(!n&&t.durableSelector&&(n=e(t.durableSelector),n)){let e=t.selector.match(/\[data-pm="([^"]+)"\]/)?.[1];e&&n.setAttribute("data-pm",e)}return n}function z(e){for(let t of e){let e=B(t);if(e)for(let n of j(t))_(e,n.property)||X(e,n.property,n.modified)}}function J(t,n=!1){for(let r of t){let t=e(r.selector);if(t)for(let e of r.changes)_(t,e.property)||q(t,e.property,e.original,n)}}function H(t){let n=e(t.selector);if(!n&&t.durableSelector&&(n=e(t.durableSelector),n)){let e=t.selector.match(/\[data-pm="([^"]+)"\]/)?.[1];e&&n.setAttribute("data-pm",e)}return n}function G(e,t){let n=e;for(let e of t)n=n?.childNodes[e]??null;return n?.nodeType===Node.TEXT_NODE?n:null}function K(e){for(let t of e){if(t.captured)continue;let e=H(t);if(!e)continue;if(t.paragraphs&&"P"===e.tagName){let n=e;if(!M(n)&&JSON.stringify(P(n).layout)!==JSON.stringify(t.paragraphs.before))continue;A(n,t.paragraphs.after);continue}let n=G(e,t.textNodePath);n&&n.nodeValue===t.original&&n.nodeValue!==t.modified&&(n.nodeValue=t.modified)}}function Q(e){for(let t of[...e].reverse()){if(t.captured)continue;let e=H(t);if(!e)continue;if(t.paragraphs&&"P"===e.tagName){k(e),t.paragraphs.before.some(e=>e.parts.length>1)&&A(e,t.paragraphs.before);continue}let n=G(e,t.textNodePath);n&&n.nodeValue===t.modified&&n.nodeValue!==t.original&&(n.nodeValue=t.original)}}function U(e,t){let n=new Set(t);Q(e.filter(e=>!(n.has(e)||e.paragraphs&&t.some(t=>t.paragraphs&&t.selector===e.selector&&!t.captured)))),K(t)}function Y(t,n){if(!t)return null;let r=e(t);if(!r&&n&&(r=e(n),r)){let e=t.match(/\[data-pm="([^"]+)"\]/)?.[1];e&&r.setAttribute("data-pm",e)}return r}function Z(e){e.removeAttribute("data-pm"),e.querySelectorAll("[data-pm]").forEach(e=>e.removeAttribute("data-pm"))}function $(e,t){let n=t.match(/\[data-pm="([^"]+)"\]/)?.[1];n&&e.setAttribute("data-pm",n)}function ee(e,t,n){let r=Array.from(e.children).filter(e=>e!==t),o=Math.max(0,Math.min(n,r.length));e.insertBefore(t,r[o]??null)}function te(e){for(let t of e){let e=Y(t.targetParentSelector,t.targetParentDurableSelector);if(!e)continue;if("move"===t.operation){let n=Y(t.selector,t.durableSelector);if(!n||n===e||n.contains(e))continue;ee(e,n,t.targetIndex);continue}if(Y(t.selector,t.durableSelector))continue;let n=Y(t.sourceSelector,t.sourceDurableSelector);if(!n)continue;let r=n.cloneNode(!0);r instanceof Element&&(Z(r),$(r,t.selector),ee(e,r,t.targetIndex))}}function ne(e){for(let t of[...e].reverse()){if("copy"===t.operation){Y(t.selector,t.durableSelector)?.remove();continue}let e=Y(t.selector,t.durableSelector),n=Y(t.originalParentSelector,t.originalParentDurableSelector);!e||!n||e===n||e.contains(n)||ee(n,e,t.originalIndex??n.children.length)}}export{ne as A,s as a,d as b,p as c,c as d,h as e,g as f,m as g,w as h,T as i,E as j,S as k,v as l,M as m,P as n,A as o,L as p,I as q,W as r,X as s,B as t,z as u,J as v,K as w,Q as x,U as y,te as z};
|