@popmelt.com/core 0.24.2 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +34 -2
  2. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  3. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  4. package/dist/ParticipantRuntime-5WM2XJT7.mjs +139 -0
  5. package/dist/PopmeltTasteConnectedPane-IXJ2KAPX.mjs +81 -0
  6. package/dist/PreviewRuntime-ATSECGMB.mjs +2 -0
  7. package/dist/bridge-entry.mjs +84 -71
  8. package/dist/browser-runtime-O5GITMZB.mjs +2 -0
  9. package/dist/browser.mjs +1 -1
  10. package/dist/{chunk-NV55QGKG.mjs → chunk-7IVK4FEU.mjs} +1 -1
  11. package/dist/chunk-CWVRJOGB.mjs +370 -0
  12. package/dist/chunk-EH5Y2F4E.mjs +77 -0
  13. package/dist/chunk-FRHGK5ZV.mjs +2 -0
  14. package/dist/chunk-J2OX47QB.mjs +345 -0
  15. package/dist/{chunk-TJVWZRAF.mjs → chunk-MGIH5NQE.mjs} +1 -1
  16. package/dist/chunk-NXMPY7RX.mjs +2 -0
  17. package/dist/chunk-ZJPPZLXU.mjs +2 -0
  18. package/dist/cli.mjs +109 -96
  19. package/dist/index.mjs +1 -1
  20. package/dist/plugin-astro.mjs +1 -1
  21. package/dist/plugin-next.d.mts +6 -2
  22. package/dist/plugin-next.mjs +1 -1
  23. package/dist/plugin-nuxt.mjs +1 -1
  24. package/dist/plugin-vite.mjs +1 -1
  25. package/dist/server-QHSVIUQW.mjs +241 -0
  26. package/dist/server.d.mts +7 -0
  27. package/dist/server.mjs +87 -74
  28. package/package.json +4 -1
  29. package/dist/ParticipantRuntime-6QPULJPO.mjs +0 -139
  30. package/dist/PreviewRuntime-NGTLOEX3.mjs +0 -2
  31. package/dist/browser-runtime-3UZPA2SA.mjs +0 -2
  32. package/dist/chunk-3XSTOVWX.mjs +0 -2
  33. package/dist/chunk-D4ZJC7OV.mjs +0 -301
  34. package/dist/chunk-ENERPQJN.mjs +0 -2
  35. package/dist/chunk-ZL4X7KBW.mjs +0 -413
  36. package/dist/server-M6OXW7FE.mjs +0 -228
@@ -1,2 +0,0 @@
1
- "use client";
2
- var P=" >>> ";function $(t){return Array.from(t.querySelectorAll("*")).flatMap(e=>e.shadowRoot?[e.shadowRoot]:[])}function x(t=document){let e=[t];for(let r of e)e.push(...$(r));return e}function A(t,e=document){let r=t.split(P);if(r.length>1){let o=e,n=null;for(let i=0;i<r.length;i+=1){if(n=o.querySelector(r[i]),!n)return null;if(i<r.length-1){if(!n.shadowRoot)return null;o=n.shadowRoot}}return n}let a=[e];for(let o of a){let n=o.querySelector(t);if(n)return n;a.push(...$(o))}return null}function h(t){if(t.parentElement)return t.parentElement;let e=t.getRootNode();return e instanceof ShadowRoot?e.host:null}function k(t,e){let r=t;for(;r;){if(r.matches(e))return r;r=h(r)}return null}function te(t,e){let r=e;for(;r;){if(r===t)return!0;r=h(r)}return!1}function re(t,e,r){let a=typeof t.elementsFromPoint=="function"?t.elementsFromPoint(e,r):[],o=t.elementFromPoint?.(e,r)??null;return o&&!a.includes(o)?[o,...a]:a}function W(t,e){let r=[],a=new Set;for(let o of x().reverse())for(let n of re(o,t,e))a.has(n)||(a.add(n),r.push(n));return r}function w(){return P}var ae=["data-popmelt-media-id","data-testid","data-test","data-cy"];function oe(t){let e=t.getRootNode();if(!(e instanceof Document||e instanceof ShadowRoot))return null;for(let r of ae){let a=t.getAttribute(r);if(!a)continue;let o=`[${r}="${CSS.escape(a)}"]`;if(e.querySelectorAll(o).length===1)return o}return null}function ne(t){if(t.id)return`#${t.id}`;let e=t.tagName.toLowerCase(),r=Array.from(t.classList).slice(0,3).join(".");return r?`${e}.${r}`:e}function y(t){if(t.getRootNode()instanceof Document&&t.id&&!t.id.startsWith("radix-")&&!t.id.startsWith(":"))return`#${CSS.escape(t.id)}`;let e=[],r=t;for(;r&&r!==document.documentElement;){let a=r.tagName.toLowerCase(),o=oe(r);if(o?a=o:r.id&&!r.id.startsWith("radix-")&&!r.id.startsWith(":")&&(a=`#${CSS.escape(r.id)}`),!o&&!a.startsWith("#")){let l=Array.from(r.classList).filter(f=>!f.startsWith("_")&&f.length<30).slice(0,2);l.length>0&&(a+="."+l.map(f=>CSS.escape(f)).join("."))}let n=r.parentElement;if(n&&!o&&!a.startsWith("#")){let l=Array.from(n.children).filter(f=>f.tagName===r.tagName);if(l.length>1){let f=l.indexOf(r)+1;a+=`:nth-of-type(${f})`}}if(e.unshift(a),o||a.startsWith("#")){let l=r.getRootNode();if(l instanceof Document)break;if(l instanceof ShadowRoot){e.unshift(w().trim()),r=l.host;continue}}if(n){r=n;continue}let i=r.getRootNode();if(!(i instanceof ShadowRoot))break;e.unshift(w().trim()),r=i.host}return e.join(" > ").replace(/ > >>> > /g,w())}function p(t){try{return A(t)}catch{return null}}var I=["id","data-testid","data-test","data-cy","data-popmelt-media-id","aria-label","name","href"],R=t=>t.replace(/\s+/g," ").trim();function M(t){let e={};for(let o of I){let n=t.getAttribute(o);n&&n.length<=200&&!(o==="id"&&/^(radix-|:|_r_)/.test(n))&&(e[o]=n)}let r=R(t.querySelector("h1,h2,h3,h4,h5,h6")?.textContent??""),a=R(Array.from(t.childNodes).filter(o=>o.nodeType===3).map(o=>o.textContent).join(" "));return{tag:t.tagName.toLowerCase(),...Object.keys(e).length?{attributes:e}:{},...r&&r.length<=200?{heading:r}:{},...a&&a.length<=200?{text:a}:{}}}function _(t,e,r=document){let a=x(r),o=s=>{try{return a.flatMap(c=>Array.from(c.querySelectorAll(s)))}catch{return[]}},n=!!(e&&(e.heading||e.text||Object.keys(e.attributes??{}).length)),i=s=>{if(!e||!n)return!0;let c=M(s);return c.tag===e.tag&&(!e.heading||c.heading===e.heading)&&(!e.text||c.text===e.text)&&Object.entries(e.attributes??{}).every(([u,m])=>s.getAttribute(u)===m)};for(let s of t){if(s.includes(" >>> ")){try{let u=A(s,r);if(u&&i(u))return{status:"matched",element:u}}catch{}continue}let c=o(s);if(c.length===1&&(/^\[data-pm=/.test(s)||!n))return{status:"matched",element:c[0]}}if(!n||t.some(s=>s.includes(" >>> "))||!/^[a-z][a-z0-9-]*$/.test(e.tag))return{status:"missing"};let l=o(e.tag);if(l.length>500)return{status:"ambiguous"};let f=Object.entries(e.attributes??{}).filter(([s])=>I.slice(0,5).includes(s));if(f.length){let s=l.filter(c=>f.every(([u,m])=>c.getAttribute(u)===m));return s.length===1?{status:"matched",element:s[0]}:{status:s.length?"ambiguous":"missing"}}let d=l.filter(i);return d.length===1?{status:"matched",element:d[0]}:{status:d.length?"ambiguous":"missing"}}function ie(t,e,r=document){let a=_([t,e?.selector].filter(o=>!!o),e?.targetFingerprint,r);return a.status==="matched"?a.element:null}var le=900,N=80;function g(t){if(!t)return null;try{return A(t)}catch{return null}}function S(t){return(t??"").replace(/\s+/g," ").trim()}function D(t){let e=S(t.getAttribute("aria-label"));if(e)return e.slice(0,N);let r=S(t.getAttribute("aria-labelledby"));if(r){let o=r.split(/\s+/).map(n=>S(document.getElementById(n)?.textContent)).filter(Boolean).join(" ");if(o)return o.slice(0,N)}let a=S(t.getAttribute("title"));return a?a.slice(0,N):S(t.textContent).slice(0,N)}function se(t){return t.id?Array.from(document.querySelectorAll("[aria-controls]")).find(e=>e.getAttribute("aria-controls")===t.id)??null:null}function ue(t){if(t instanceof HTMLDetailsElement){let a=Array.from(t.children).find(n=>n.tagName.toLowerCase()==="summary");if(!a)return null;let o=D(a);return o?{triggerSelector:y(a),targetSelector:y(t),label:o}:null}let e=se(t);if(!e)return null;let r=D(e);return r?{triggerSelector:y(e),targetSelector:y(t),label:r}:null}function C(t){let e=[],r=new Set,a=h(t);for(;a&&a!==document.body&&a!==document.documentElement;){let n=ue(a);n&&!r.has(n.triggerSelector)&&(r.add(n.triggerSelector),e.push(n)),a=h(a)}if(e.length===0)return;let o=e.reverse();return{steps:o,location:o.map(n=>n.label)}}function q(t){let e=t?.[0]?.revealRecipe;if(e?.steps.length)return e;let r=g(t?.[0]?.selector);return r?C(r):void 0}function ce(t){let e=q(t)?.location.filter(Boolean);return e?.length?`Inside: ${e.join(" \u203A ")}`:null}function T(t){if(!t?.isConnected)return!1;let e=t.getBoundingClientRect();if(e.width<=0||e.height<=0||t.getClientRects().length===0)return!1;let r=t;for(;r;){let a=window.getComputedStyle(r);if(a.display==="none"||a.visibility==="hidden"||a.visibility==="collapse"||Number.parseFloat(a.opacity||"1")<=0)return!1;r=r.parentElement}return!0}function fe(t,e,r){return e.getAttribute("aria-expanded")==="true"||e.getAttribute("data-state")==="open"?!0:r instanceof HTMLDetailsElement?r.open:T(r)}function B(t,e=le){return t?new Promise(r=>{let a=performance.now(),o=()=>{let n=g(t);if(T(n)){r(n);return}if(performance.now()-a>=e){r(null);return}requestAnimationFrame(o)};o()}):Promise.resolve(null)}function de(t,e){return g(t)??g(e?.[0]?.selector)}async function me(t,e){let r=de(t,e);if(T(r))return r;let a=q(e)??(r?C(r):void 0);if(!a)return null;for(let n of a.steps){let i=g(n.triggerSelector);if(!(i instanceof HTMLElement))return null;let l=g(n.targetSelector);if(!fe(n,i,l)&&(i.click(),!await B(n.targetSelector)))return null}let o=t&&g(t)?t:e?.[0]?.selector;return B(o)}function H(t){let e=Object.keys(t).find(n=>n.startsWith("__reactFiber$")||n.startsWith("__reactInternalInstance$"));if(!e)return null;let r=t[e],a=[],o=r?._debugSource;for(;r;){let n=r.type,i=n?.displayName||n?.name;i&&typeof i=="string"&&/^[A-Z]/.test(i)&&!i.startsWith("_")&&i!=="Fragment"&&a.unshift(i),r=r.return}return a.length>0?{name:a[a.length-1],path:a,...o?.fileName&&Number.isFinite(o.lineNumber)?{source:o}:{}}:null}function pe(t){let e=Object.keys(t).find(o=>o.startsWith("__reactFiber$")||o.startsWith("__reactInternalInstance$"));if(!e)return[];let r=t[e],a=[];for(;r;){let o=r.type,n=typeof o=="function"||typeof o=="object"?o?.displayName||o?.name:null;n&&typeof n=="string"&&/^[A-Z]/.test(n)&&!n.startsWith("_")&&n!=="Fragment"&&a.push({name:n,fiber:r}),r=r.return}return a.reverse(),a}function he(t){let e=t,r=new Set;for(;e&&!r.has(e);){if(r.add(e),e.stateNode instanceof Element)return e.stateNode;e.child?e=e.child:e=null}return null}function z(t){let e={targetFingerprint:M(t),selector:ne(t),tagName:t.tagName.toLowerCase()};t.id&&(e.id=t.id),t.classList.length>0&&(e.className=Array.from(t.classList).join(" "));let r=ge(t)||t.matches('button, a, [role="button"], [role="tab"]')&&(t.getAttribute("aria-label")||t.getAttribute("title")||t.textContent?.trim())||"";r&&r.length>0&&r.length<200&&(e.textContent=r);let a={};for(let l of t.attributes)l.name.startsWith("data-")&&(a[l.name]=l.value);Object.keys(a).length>0&&(e.dataAttributes=a);let o=H(t);o&&(e.reactComponent=o.name,e.reactComponentPath=o.path,o.source&&(e.reactSource=o.source));let n=ke(t);n&&(e.context=n);let i=C(t);return i&&(e.revealRecipe=i),e}function ge(t){let e="";for(let r of t.childNodes)r.nodeType===Node.TEXT_NODE&&(e+=r.textContent||"");return e.trim()}function be(t,e){return G(t,e)[0]??null}var ye="[data-popmelt-canvas-block]";function V(t,e){let r=W(t,e).find(a=>a.id!=="devtools-canvas"&&a.id!=="devtools-scrim");return!!(r&&k(r,ye))}function Se(t){return t instanceof SVGElement?t.closest("svg")??t:t}function G(t,e){if(V(t,e))return[];let r=new Set;return W(t,e).map(Se).filter(a=>r.has(a)||(r.add(a),a.id==="devtools-canvas"||a.id==="devtools-toolbar"||a.id==="devtools-scrim")||k(a,"#devtools-toolbar")||a.hasAttribute("data-devtools")||k(a,"[data-devtools]")?!1:!["html","body"].includes(a.tagName.toLowerCase()))}function je(t,e,r){for(let a of t.childNodes){if(a.nodeType!==Node.TEXT_NODE||!a.textContent?.trim())continue;let o=document.createRange();o.selectNodeContents(a);let n=o.getClientRects?.();if(n&&Array.from(n).some(i=>e>=i.left&&e<=i.right&&r>=i.top&&r<=i.bottom))return!0}return!1}function ve(t,e,r){if(je(t,e,r)||["button","canvas","embed","iframe","img","input","object","select","svg","textarea","video"].includes(t.tagName.toLowerCase()))return!0;let a=getComputedStyle(t);if(a.backgroundImage&&a.backgroundImage!=="none")return!0;let o=a.backgroundColor.trim();if(o&&o!=="transparent"&&!/rgba?\([^)]*,\s*0(?:\.0+)?\s*\)$/.test(o))return!0;let n=t.getBoundingClientRect(),i={top:Number.parseFloat(a.borderTopWidth)||0,right:Number.parseFloat(a.borderRightWidth)||0,bottom:Number.parseFloat(a.borderBottomWidth)||0,left:Number.parseFloat(a.borderLeftWidth)||0};return i.top>0&&r<=n.top+i.top||i.right>0&&e>=n.right-i.right||i.bottom>0&&r>=n.bottom-i.bottom||i.left>0&&e<=n.left+i.left}function Ae(t,e){let r=G(t,e);return r.find(a=>ve(a,t,e))??r.at(-1)??null}function ke(t){let e=h(t),r=["section","article","nav","aside","header","footer","main"];for(;e&&e!==document.body;){let a=e.tagName.toLowerCase();if(r.includes(a)&&e.id)return`${a}#${e.id}`;if(e.id&&!e.id.startsWith("radix-")&&!e.id.startsWith(":"))return`${a}#${e.id}`;e=h(e)}return null}function X(t){return Array.from(t,e=>{if(e==='"'||e==="\\")return`\\${e}`;let r=e.codePointAt(0);return r<32||r===127?`\\${r.toString(16)} `:e}).join("")}function U(t){return`[data-popmelt-subject-adapter="${X(t.adapter)}"][data-popmelt-subject-key="${X(t.key)}"]`}function we(t){let e=t?.getAttribute("data-popmelt-subject-adapter"),r=t?.getAttribute("data-popmelt-subject-key");return e&&r?{adapter:e,key:r}:void 0}function E(t,e){let r=!1;t.dataset.popmeltSubjectLabel!==e.label&&(t.dataset.popmeltSubjectLabel=e.label,r=!0);let{left:a,top:o,width:n,height:i}=e.bounds,l=u=>`${Math.round(u*2)/2}px`,f={left:l(a),top:l(o),width:l(Math.max(0,n)),height:l(Math.max(0,i))};for(let[u,m]of Object.entries(f)){let O=u;t.style[O]!==m&&(t.style[O]=m,r=!0)}let d=e.surfaceBounds,s={popmeltSubjectSurfaceLeft:d?String(d.left):void 0,popmeltSubjectSurfaceTop:d?String(d.top):void 0,popmeltSubjectSurfaceWidth:d?String(d.width):void 0,popmeltSubjectSurfaceHeight:d?String(d.height):void 0};for(let[u,m]of Object.entries(s))m===void 0?u in t.dataset&&(delete t.dataset[u],r=!0):t.dataset[u]!==m&&(t.dataset[u]=m,r=!0);let c=e.outline?.map(u=>`${u.x},${u.y}`).join(" ");return c?t.dataset.popmeltSubjectOutline!==c&&(t.dataset.popmeltSubjectOutline=c,r=!0):t.dataset.popmeltSubjectOutline!==void 0&&(delete t.dataset.popmeltSubjectOutline,r=!0),r}var Ne=class{constructor(t){this.adapters=t,this.projections=new Map,this.frameListeners=new Set,this.frame=null,this.lastProjectionFrameTime=0,this.adapterUnsubscribes=t.flatMap(e=>{let r=e.subscribe?.(()=>{for(let a of this.frameListeners)a()});return r?[r]:[]})}async whenReady(){await Promise.all(this.adapters.map(t=>t.whenReady?.()))}hitTest(t){return this.hitTestAll(t)[0]??null}hitTestAll(t){for(let e=this.adapters.length-1;e>=0;e-=1){let r=this.adapters[e];if(!r)continue;let a=(r.hitTestAll?.(t)??[r.hitTest(t)]).filter(o=>!!o).map(o=>this.project(r,o));if(a.length>0)return a}return[]}resolve(t){let e=this.adapters.find(a=>a.id===t.adapter);if(!e)return null;let r=e.resolve(t.key);return r?this.project(e,r):null}restore(t,e){let r=this.adapters.find(o=>o.id===t.adapter),a=r?.restoreSubject?.(t.key,e);return r&&a?this.project(r,a):null}async captureFeedback(t){let e=this.resolve(t);if(!e)return null;let{adapter:r,subject:a}=e,o={...e.elementInfo};if(a.sourceElement&&(o.sourceElement={...z(a.sourceElement),selector:y(a.sourceElement)}),!r.captureSubject)return{elementInfo:o};try{let n=await r.captureSubject(t.key);return n?{elementInfo:o,crop:n}:{elementInfo:o,warning:"Object crop unavailable; use the page screenshot and image coordinates."}}catch{return{elementInfo:o,warning:"Object crop unavailable (the image may block canvas access via CORS); use the page screenshot and image coordinates."}}}beginCreate(t){for(let e=this.adapters.length-1;e>=0;e-=1){let r=this.adapters[e],a=r?.beginCreate?.(t);if(r&&a)return{adapter:r,session:a}}return null}rename(t,e){let r=this.adapters.find(o=>o.id===t.adapter),a=r?.renameSubject?.(t.key,e);return r&&a?this.project(r,a):null}updateBounds(t,e){let r=this.adapters.find(o=>o.id===t.adapter),a=r?.updateSubjectBounds?.(t.key,e);return r&&a?this.project(r,a):null}updateTrackingAnchors(t,e){let r=this.adapters.find(o=>o.id===t.adapter),a=r?.updateSubjectTrackingAnchors?.(t.key,e);return r&&a?this.project(r,a):null}promote(t){let e=this.adapters.find(a=>a.id===t.adapter),r=e?.promoteSubject?.(t.key);return e&&r?this.project(e,r):null}remove(t){this.adapters.find(e=>e.id===t.adapter)?.removeSubject?.(t.key)}async captureSurfaces(){return(await Promise.all(this.adapters.map(async t=>t.captureSurfaces?.()??[]))).flat()}subscribeFrame(t){return this.frameListeners.add(t),()=>this.frameListeners.delete(t)}destroy(){this.frame!==null&&cancelAnimationFrame(this.frame),this.frame=null;for(let t of this.projections.values())t.element.remove();this.projections.clear();for(let t of this.adapterUnsubscribes)t();this.frameListeners.clear()}project(t,e){let r={adapter:t.id,key:e.key},a=`${t.id}\0${e.key}`,o=this.projections.get(a);if(o)return o.subject=e,o.elementInfo=this.elementInfo(t,e,o.selector),E(o.element,e),o;let n=U(r),i=document.createElement("div");i.dataset.popmeltSubjectAdapter=t.id,i.dataset.popmeltSubjectKey=e.key,i.dataset.popmeltSubjectLabel=e.label,i.dataset.popmeltSubjectProjection="true",i.setAttribute("aria-hidden","true"),Object.assign(i.style,{position:"fixed",pointerEvents:"none",opacity:"0",zIndex:"-1"}),E(i,e),document.body.appendChild(i);let l={adapter:t,subject:e,target:r,element:i,selector:n,elementInfo:this.elementInfo(t,e,n)};return this.projections.set(a,l),this.ensureFrame(),l}elementInfo(t,e,r){return{selector:r,tagName:t.id,subjectLabel:e.label,textContent:e.label,context:e.context,...e.imageObject?{imageObject:e.imageObject}:{},...e.videoObject?{videoObject:e.videoObject}:{},dataAttributes:{adapter:t.id,key:e.key,...e.data??{}}}}ensureFrame(){if(this.frame!==null||this.projections.size===0)return;let t=e=>{if(this.frame=null,this.lastProjectionFrameTime>0&&e-this.lastProjectionFrameTime<32){this.ensureFrame();return}this.lastProjectionFrameTime=e;let r=!1;for(let[a,o]of this.projections){let n=o.adapter.resolve(o.target.key);if(!n){o.element.remove(),this.projections.delete(a),r=!0;continue}o.subject=n,r=E(o.element,n)||r}if(r)for(let a of this.frameListeners)a();this.projections.size>0&&this.ensureFrame()};this.frame=requestAnimationFrame(t)}},xe={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 j(t){return t instanceof HTMLElement||t instanceof SVGElement}var F=new WeakMap,v=new WeakMap;function Ce(t,e){if(j(e))for(let[r,a]of v.get(t)??[])a.value?e.style.setProperty(r,a.value,a.priority):e.style.removeProperty(r)}function Te(t,e){F.set(t,new Set(e))}function Ee(t){F.delete(t)}function Z(t,e){return j(t)&&(F.get(t)?.has(e)??!1)}function J(t){let e=t.sticker;return e?e.family==="padding"||e.family==="margin"?e.subproperty==="all"?10:e.subproperty==="x"||e.subproperty==="y"?20:30:e.family==="radius"||e.family==="border"?e.subproperty==="all"?10:20:10:0}function Fe(t){return t.changes.map((e,r)=>({change:e,index:r})).sort((e,r)=>J(e.change)-J(r.change)||e.index-r.index).map(({change:e})=>e)}function K(t,e,r){if(j(t)){let a=v.get(t);a||(a=new Map,v.set(t,a)),a.has(e)||a.set(e,{value:t.style.getPropertyValue(e),priority:t.style.getPropertyPriority(e)}),t.style.setProperty(e,r,"important")}}function Le(t,e,r,a=!1){if(j(t)){let o=a?v.get(t)?.get(e):void 0;o?.value?t.style.setProperty(e,o.value,o.priority):t.style.removeProperty(e),v.get(t)?.delete(e)}}function Q(t){let e=p(t.selector);if(!e&&t.durableSelector&&(e=p(t.durableSelector),e)){let r=t.selector.match(/\[data-pm="([^"]+)"\]/)?.[1];r&&e.setAttribute("data-pm",r)}return e}function Oe(t){for(let e of t){let r=Q(e);if(r)for(let a of Fe(e))Z(r,a.property)||K(r,a.property,a.modified)}}function Pe(t,e=!1){for(let r of t){let a=p(r.selector);if(a)for(let o of r.changes)Z(a,o.property)||Le(a,o.property,o.original,e)}}function Y(t){let e=p(t.selector);if(!e&&t.durableSelector&&(e=p(t.durableSelector),e)){let r=t.selector.match(/\[data-pm="([^"]+)"\]/)?.[1];r&&e.setAttribute("data-pm",r)}return e}function ee(t,e){let r=t;for(let a of e)r=r?.childNodes[a]??null;return r?.nodeType===Node.TEXT_NODE?r:null}function $e(t){for(let e of t){let r=Y(e);if(!r)continue;let a=ee(r,e.textNodePath);a&&(a.nodeValue=e.modified)}}function We(t){for(let e of t){let r=Y(e);if(!r)continue;let a=ee(r,e.textNodePath);a&&(a.nodeValue=e.original)}}function b(t,e){if(!t)return null;let r=p(t);if(!r&&e&&(r=p(e),r)){let a=t.match(/\[data-pm="([^"]+)"\]/)?.[1];a&&r.setAttribute("data-pm",a)}return r}function Ie(t){t.removeAttribute("data-pm"),t.querySelectorAll("[data-pm]").forEach(e=>e.removeAttribute("data-pm"))}function Re(t,e){let r=e.match(/\[data-pm="([^"]+)"\]/)?.[1];r&&t.setAttribute("data-pm",r)}function L(t,e,r){let a=Array.from(t.children).filter(n=>n!==e),o=Math.max(0,Math.min(r,a.length));t.insertBefore(e,a[o]??null)}function Me(t){for(let e of t){let r=b(e.targetParentSelector,e.targetParentDurableSelector);if(!r)continue;if(e.operation==="move"){let n=b(e.selector,e.durableSelector);if(!n||n===r||n.contains(r))continue;L(r,n,e.targetIndex);continue}if(b(e.selector,e.durableSelector))continue;let a=b(e.sourceSelector,e.sourceDurableSelector);if(!a)continue;let o=a.cloneNode(!0);o instanceof Element&&(Ie(o),Re(o,e.selector),L(r,o,e.targetIndex))}}function _e(t){for(let e of[...t].reverse()){if(e.operation==="copy"){b(e.selector,e.durableSelector)?.remove();continue}let r=b(e.selector,e.durableSelector),a=b(e.originalParentSelector,e.originalParentDurableSelector);!r||!a||r===a||r.contains(a)||L(a,r,e.originalIndex??a.children.length)}}export{Ee as A,K as B,Q as C,Oe as D,Pe as E,$e as F,We as G,Me as H,_e as I,x as a,A as b,h as c,k as d,te as e,w as f,y as g,p as h,ce as i,me as j,H as k,pe as l,he as m,_ as n,ie as o,z as p,be as q,V as r,Ae as s,U as t,we as u,Ne as v,xe as w,j as x,Ce as y,Te as z};