@popmelt.com/core 0.31.1 → 0.31.3

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 (51) hide show
  1. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  2. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  3. package/dist/{ParticipantRuntime-HU2P2PJ6.mjs → ParticipantRuntime-X2ZI2GJF.mjs} +1 -1
  4. package/dist/{PopmeltTasteConnectedPane-ALR3RTSC.mjs → PopmeltTasteConnectedPane-7YIHIFPE.mjs} +1 -1
  5. package/dist/{PreviewRuntime-YAUBP6HA.mjs → PreviewRuntime-QDA4OF67.mjs} +1 -1
  6. package/dist/ThreadErrorCard-6QN2ECBT.mjs +2 -0
  7. package/dist/bridge-entry.mjs +1 -1
  8. package/dist/{browser-runtime-LTQBOXZW.mjs → browser-runtime-6N65USFN.mjs} +1 -1
  9. package/dist/browser.mjs +1 -1
  10. package/dist/canvas-chat-note-NHYL3T6J.mjs +2 -0
  11. package/dist/{chunk-EG6SRS7N.mjs → chunk-6C4FAOTC.mjs} +1 -1
  12. package/dist/chunk-EXDOFFFJ.mjs +2 -0
  13. package/dist/{chunk-OLLUQ45J.mjs → chunk-F6AMPRUB.mjs} +1 -1
  14. package/dist/{chunk-253MCKJJ.mjs → chunk-GNZ73T3H.mjs} +1 -1
  15. package/dist/chunk-IKCHOC3U.mjs +3 -0
  16. package/dist/{chunk-GQ6CPJG6.mjs → chunk-IPR652AZ.mjs} +1 -1
  17. package/dist/chunk-JGNVTID4.mjs +2 -0
  18. package/dist/{chunk-RXRZTZPN.mjs → chunk-JU7D4I76.mjs} +1 -1
  19. package/dist/{chunk-CXQWNKZ4.mjs → chunk-M6LCEEFH.mjs} +4 -19
  20. package/dist/{chunk-JQHZFDY5.mjs → chunk-MTQ5IWIK.mjs} +1 -1
  21. package/dist/{chunk-4ZZTJRHL.mjs → chunk-QTGE5KAA.mjs} +1 -1
  22. package/dist/chunk-RCVAPQ7X.mjs +2 -0
  23. package/dist/{chunk-LSPIP2IX.mjs → chunk-SKOSDB5K.mjs} +87 -87
  24. package/dist/{chunk-E3ZTB2VR.mjs → chunk-UJ5PA3SZ.mjs} +84 -84
  25. package/dist/chunk-X3UK5M3S.mjs +2 -0
  26. package/dist/{chunk-IRFL32GJ.mjs → chunk-ZGERZLB4.mjs} +3 -3
  27. package/dist/cli.mjs +8 -8
  28. package/dist/codex-note-context-KSRJRH3F.mjs +2 -0
  29. package/dist/codex-project-JYNETLSG.mjs +2 -0
  30. package/dist/codex-session-registry-SPRWY2WW.mjs +2 -0
  31. package/dist/{focus-inspection-GJKMI6OE.mjs → focus-inspection-WPHGCN6Y.mjs} +1 -1
  32. package/dist/index.mjs +1 -1
  33. package/dist/peer-client-STR2FWR4.mjs +2 -0
  34. package/dist/plugin-astro.mjs +1 -1
  35. package/dist/plugin-nuxt.mjs +1 -1
  36. package/dist/plugin-vite.mjs +1 -1
  37. package/dist/server.mjs +1 -1
  38. package/dist/{workspace-snapshot-LKQWBDNS.mjs → workspace-snapshot-O34KMJ2V.mjs} +1 -1
  39. package/package.json +32 -22
  40. package/dist/ThreadErrorCard-5ADUBZKJ.mjs +0 -2
  41. package/dist/canvas-chat-note-7HSL7MH6.mjs +0 -2
  42. package/dist/chunk-4V7SK3M6.mjs +0 -3
  43. package/dist/chunk-CECQ4VMR.mjs +0 -2
  44. package/dist/chunk-HGW2U6PD.mjs +0 -2
  45. package/dist/chunk-WIQ3RY6R.mjs +0 -2
  46. package/dist/chunk-XOGBFVWI.mjs +0 -2
  47. package/dist/codex-note-context-NVDO3PVT.mjs +0 -2
  48. package/dist/codex-project-IE6ZJFGB.mjs +0 -2
  49. package/dist/codex-session-registry-25DAA2KO.mjs +0 -2
  50. package/dist/peer-client-2THOHRGA.mjs +0 -2
  51. /package/dist/{chunk-V6VQACC2.mjs → chunk-WMHM647D.mjs} +0 -0
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{k as y,a as g,i as S}from"./chunk-XOGBFVWI.mjs";function h(e){return Array.from(e,t=>{if(t==='"'||t==="\\")return`\\${t}`;let r=t.codePointAt(0);return r<32||r===127?`\\${r.toString(16)} `:t}).join("")}function f(e){return`[data-popmelt-subject-adapter="${h(e.adapter)}"][data-popmelt-subject-key="${h(e.key)}"]`}function k(e){let t=e?.getAttribute("data-popmelt-subject-adapter"),r=e?.getAttribute("data-popmelt-subject-key");return t&&r?{adapter:t,key:r}:void 0}function d(e,t){let r=!1;e.dataset.popmeltSubjectLabel!==t.label&&(e.dataset.popmeltSubjectLabel=t.label,r=!0);let{left:a,top:i,width:n,height:s}=t.bounds,u=l=>`${Math.round(l*2)/2}px`,b={left:u(a),top:u(i),width:u(Math.max(0,n)),height:u(Math.max(0,s))};for(let[l,c]of Object.entries(b)){let m=l;e.style[m]!==c&&(e.style[m]=c,r=!0)}let o=t.surfaceBounds,j={popmeltSubjectSurfaceLeft:o?String(o.left):void 0,popmeltSubjectSurfaceTop:o?String(o.top):void 0,popmeltSubjectSurfaceWidth:o?String(o.width):void 0,popmeltSubjectSurfaceHeight:o?String(o.height):void 0};for(let[l,c]of Object.entries(j))c===void 0?l in e.dataset&&(delete e.dataset[l],r=!0):e.dataset[l]!==c&&(e.dataset[l]=c,r=!0);let p=t.outline?.map(l=>`${l.x},${l.y}`).join(" ");return p?e.dataset.popmeltSubjectOutline!==p&&(e.dataset.popmeltSubjectOutline=p,r=!0):e.dataset.popmeltSubjectOutline!==void 0&&(delete e.dataset.popmeltSubjectOutline,r=!0),r}var v=class{constructor(e){this.adapters=e,this.projections=new Map,this.frameListeners=new Set,this.frame=null,this.lastProjectionFrameTime=0,this.adapterUnsubscribes=e.flatMap(t=>{let r=t.subscribe?.(()=>{for(let a of this.frameListeners)a()});return r?[r]:[]})}async whenReady(){await Promise.all(this.adapters.map(e=>e.whenReady?.()))}hitTest(e){return this.hitTestAll(e)[0]??null}hitTestAll(e){let t=new Map;for(let r=this.adapters.length-1;r>=0;r-=1){let a=this.adapters[r];if(!a)continue;let i=(a.hitTestAll?.(e)??[a.hitTest(e)]).filter(n=>!!n).filter(n=>{let s=n.sourceElement;return s?(t.has(s)||t.set(s,y(s,e.x,e.y)),t.get(s)):!0}).map(n=>this.project(a,n));if(i.length>0)return i}return[]}resolve(e){let t=this.adapters.find(a=>a.id===e.adapter);if(!t)return null;let r=t.resolve(e.key);return r?this.project(t,r):null}restore(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.restoreSubject?.(e.key,t);return r&&a?this.project(r,a):null}async captureFeedback(e){let t=this.resolve(e);if(!t)return null;let{adapter:r,subject:a}=t,i={...t.elementInfo};if(a.sourceElement&&(i.sourceElement={...S(a.sourceElement),selector:g(a.sourceElement)}),!r.captureSubject)return{elementInfo:i};try{let n=await r.captureSubject(e.key);return n?{elementInfo:i,crop:n}:{elementInfo:i,warning:"Object crop unavailable; use the page screenshot and image coordinates."}}catch{return{elementInfo:i,warning:"Object crop unavailable (the image may block canvas access via CORS); use the page screenshot and image coordinates."}}}beginCreate(e){for(let t=this.adapters.length-1;t>=0;t-=1){let r=this.adapters[t],a=r?.beginCreate?.(e);if(r&&a)return{adapter:r,session:a}}return null}rename(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.renameSubject?.(e.key,t);return r&&a?this.project(r,a):null}updateBounds(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.updateSubjectBounds?.(e.key,t);return r&&a?this.project(r,a):null}updateTrackingAnchors(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.updateSubjectTrackingAnchors?.(e.key,t);return r&&a?this.project(r,a):null}promote(e){let t=this.adapters.find(a=>a.id===e.adapter),r=t?.promoteSubject?.(e.key);return t&&r?this.project(t,r):null}remove(e){this.adapters.find(t=>t.id===e.adapter)?.removeSubject?.(e.key)}async captureSurfaces(){return(await Promise.all(this.adapters.map(async e=>e.captureSurfaces?.()??[]))).flat()}subscribeFrame(e){return this.frameListeners.add(e),()=>this.frameListeners.delete(e)}destroy(){this.frame!==null&&cancelAnimationFrame(this.frame),this.frame=null;for(let e of this.projections.values())e.element.remove();this.projections.clear();for(let e of this.adapterUnsubscribes)e();this.frameListeners.clear()}project(e,t){let r={adapter:e.id,key:t.key},a=`${e.id}\0${t.key}`,i=this.projections.get(a);if(i)return i.subject=t,i.elementInfo=this.elementInfo(e,t,i.selector),d(i.element,t),i;let n=f(r),s=document.createElement("div");s.dataset.popmeltSubjectAdapter=e.id,s.dataset.popmeltSubjectKey=t.key,s.dataset.popmeltSubjectLabel=t.label,s.dataset.popmeltSubjectProjection="true",s.setAttribute("aria-hidden","true"),Object.assign(s.style,{position:"fixed",pointerEvents:"none",opacity:"0",zIndex:"-1"}),d(s,t),document.body.appendChild(s);let u={adapter:e,subject:t,target:r,element:s,selector:n,elementInfo:this.elementInfo(e,t,n)};return this.projections.set(a,u),this.ensureFrame(),u}elementInfo(e,t,r){return{selector:r,tagName:e.id,subjectLabel:t.label,textContent:t.label,context:t.context,...t.imageObject?{imageObject:t.imageObject}:{},...t.videoObject?{videoObject:t.videoObject}:{},dataAttributes:{adapter:e.id,key:t.key,...t.data??{}}}}ensureFrame(){if(this.frame!==null||this.projections.size===0)return;let e=t=>{if(this.frame=null,this.lastProjectionFrameTime>0&&t-this.lastProjectionFrameTime<32){this.ensureFrame();return}this.lastProjectionFrameTime=t;let r=!1;for(let[a,i]of this.projections){let n=i.adapter.resolve(i.target.key);if(!n){i.element.remove(),this.projections.delete(a),r=!0;continue}i.subject=n,r=d(i.element,n)||r}if(r)for(let a of this.frameListeners)a();this.projections.size>0&&this.ensureFrame()};this.frame=requestAnimationFrame(e)}};export{f as a,k as b,v as c};
2
+ import{k as y,a as g,i as S}from"./chunk-EXDOFFFJ.mjs";function h(e){return Array.from(e,t=>{if(t==='"'||t==="\\")return`\\${t}`;let r=t.codePointAt(0);return r<32||r===127?`\\${r.toString(16)} `:t}).join("")}function f(e){return`[data-popmelt-subject-adapter="${h(e.adapter)}"][data-popmelt-subject-key="${h(e.key)}"]`}function k(e){let t=e?.getAttribute("data-popmelt-subject-adapter"),r=e?.getAttribute("data-popmelt-subject-key");return t&&r?{adapter:t,key:r}:void 0}function d(e,t){let r=!1;e.dataset.popmeltSubjectLabel!==t.label&&(e.dataset.popmeltSubjectLabel=t.label,r=!0);let{left:a,top:i,width:n,height:s}=t.bounds,u=l=>`${Math.round(l*2)/2}px`,b={left:u(a),top:u(i),width:u(Math.max(0,n)),height:u(Math.max(0,s))};for(let[l,c]of Object.entries(b)){let m=l;e.style[m]!==c&&(e.style[m]=c,r=!0)}let o=t.surfaceBounds,j={popmeltSubjectSurfaceLeft:o?String(o.left):void 0,popmeltSubjectSurfaceTop:o?String(o.top):void 0,popmeltSubjectSurfaceWidth:o?String(o.width):void 0,popmeltSubjectSurfaceHeight:o?String(o.height):void 0};for(let[l,c]of Object.entries(j))c===void 0?l in e.dataset&&(delete e.dataset[l],r=!0):e.dataset[l]!==c&&(e.dataset[l]=c,r=!0);let p=t.outline?.map(l=>`${l.x},${l.y}`).join(" ");return p?e.dataset.popmeltSubjectOutline!==p&&(e.dataset.popmeltSubjectOutline=p,r=!0):e.dataset.popmeltSubjectOutline!==void 0&&(delete e.dataset.popmeltSubjectOutline,r=!0),r}var v=class{constructor(e){this.adapters=e,this.projections=new Map,this.frameListeners=new Set,this.frame=null,this.lastProjectionFrameTime=0,this.adapterUnsubscribes=e.flatMap(t=>{let r=t.subscribe?.(()=>{for(let a of this.frameListeners)a()});return r?[r]:[]})}async whenReady(){await Promise.all(this.adapters.map(e=>e.whenReady?.()))}hitTest(e){return this.hitTestAll(e)[0]??null}hitTestAll(e){let t=new Map;for(let r=this.adapters.length-1;r>=0;r-=1){let a=this.adapters[r];if(!a)continue;let i=(a.hitTestAll?.(e)??[a.hitTest(e)]).filter(n=>!!n).filter(n=>{let s=n.sourceElement;return s?(t.has(s)||t.set(s,y(s,e.x,e.y)),t.get(s)):!0}).map(n=>this.project(a,n));if(i.length>0)return i}return[]}resolve(e){let t=this.adapters.find(a=>a.id===e.adapter);if(!t)return null;let r=t.resolve(e.key);return r?this.project(t,r):null}restore(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.restoreSubject?.(e.key,t);return r&&a?this.project(r,a):null}async captureFeedback(e){let t=this.resolve(e);if(!t)return null;let{adapter:r,subject:a}=t,i={...t.elementInfo};if(a.sourceElement&&(i.sourceElement={...S(a.sourceElement),selector:g(a.sourceElement)}),!r.captureSubject)return{elementInfo:i};try{let n=await r.captureSubject(e.key);return n?{elementInfo:i,crop:n}:{elementInfo:i,warning:"Object crop unavailable; use the page screenshot and image coordinates."}}catch{return{elementInfo:i,warning:"Object crop unavailable (the image may block canvas access via CORS); use the page screenshot and image coordinates."}}}beginCreate(e){for(let t=this.adapters.length-1;t>=0;t-=1){let r=this.adapters[t],a=r?.beginCreate?.(e);if(r&&a)return{adapter:r,session:a}}return null}rename(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.renameSubject?.(e.key,t);return r&&a?this.project(r,a):null}updateBounds(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.updateSubjectBounds?.(e.key,t);return r&&a?this.project(r,a):null}updateTrackingAnchors(e,t){let r=this.adapters.find(i=>i.id===e.adapter),a=r?.updateSubjectTrackingAnchors?.(e.key,t);return r&&a?this.project(r,a):null}promote(e){let t=this.adapters.find(a=>a.id===e.adapter),r=t?.promoteSubject?.(e.key);return t&&r?this.project(t,r):null}remove(e){this.adapters.find(t=>t.id===e.adapter)?.removeSubject?.(e.key)}async captureSurfaces(){return(await Promise.all(this.adapters.map(async e=>e.captureSurfaces?.()??[]))).flat()}subscribeFrame(e){return this.frameListeners.add(e),()=>this.frameListeners.delete(e)}destroy(){this.frame!==null&&cancelAnimationFrame(this.frame),this.frame=null;for(let e of this.projections.values())e.element.remove();this.projections.clear();for(let e of this.adapterUnsubscribes)e();this.frameListeners.clear()}project(e,t){let r={adapter:e.id,key:t.key},a=`${e.id}\0${t.key}`,i=this.projections.get(a);if(i)return i.subject=t,i.elementInfo=this.elementInfo(e,t,i.selector),d(i.element,t),i;let n=f(r),s=document.createElement("div");s.dataset.popmeltSubjectAdapter=e.id,s.dataset.popmeltSubjectKey=t.key,s.dataset.popmeltSubjectLabel=t.label,s.dataset.popmeltSubjectProjection="true",s.setAttribute("aria-hidden","true"),Object.assign(s.style,{position:"fixed",pointerEvents:"none",opacity:"0",zIndex:"-1"}),d(s,t),document.body.appendChild(s);let u={adapter:e,subject:t,target:r,element:s,selector:n,elementInfo:this.elementInfo(e,t,n)};return this.projections.set(a,u),this.ensureFrame(),u}elementInfo(e,t,r){return{selector:r,tagName:e.id,subjectLabel:t.label,textContent:t.label,context:t.context,...t.imageObject?{imageObject:t.imageObject}:{},...t.videoObject?{videoObject:t.videoObject}:{},dataAttributes:{adapter:e.id,key:t.key,...t.data??{}}}}ensureFrame(){if(this.frame!==null||this.projections.size===0)return;let e=t=>{if(this.frame=null,this.lastProjectionFrameTime>0&&t-this.lastProjectionFrameTime<32){this.ensureFrame();return}this.lastProjectionFrameTime=t;let r=!1;for(let[a,i]of this.projections){let n=i.adapter.resolve(i.target.key);if(!n){i.element.remove(),this.projections.delete(a),r=!0;continue}i.subject=n,r=d(i.element,n)||r}if(r)for(let a of this.frameListeners)a();this.projections.size>0&&this.ensureFrame()};this.frame=requestAnimationFrame(e)}};export{f as a,k as b,v as c};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{c as v}from"./chunk-JQHZFDY5.mjs";import{a as P,l as R,h as $,j as x,k as g,i as b,m as y}from"./chunk-OLLUQ45J.mjs";import{v as A}from"./chunk-HGW2U6PD.mjs";var O="__popmelt_code_preview";function C(a,n){let t=new URL(a,n);if(t.origin!==new URL(n).origin||!/^https?:$/.test(t.protocol))throw new Error("Code previews must use the same application origin");return t.hash="",t.searchParams.delete("popmelt"),t.searchParams.set(O,"1"),t.href}function T(a,n){if(!new URL(location.href).searchParams.has(O))return!1;if(parent===window)return!0;window.__POPMELT_CODE_PREVIEW__?.dispose();let t=P,w="",s=!1,u=0,d=new Map,h=()=>{for(let[e,i]of d)i===null?e.removeAttribute("data-pm"):e.setAttribute("data-pm",i);d.clear()},r=new v(n?.get()??[]),m=()=>{for(let e of t.annotations)e.target&&r.resolve(e.target)},_=()=>{R(t.domModifications),$(t.styleModifications),x(t.textModifications),m();for(let e of t.annotations){let i=e.linkedSelector?.match(/^\[data-pm="([^"]+)"\]$/)?.[1];if(!i)continue;let o=A(e.linkedSelector,e.elements?.[0]);o&&(d.has(o)||d.set(o,o.getAttribute("data-pm")),o.setAttribute("data-pm",i))}},c=new MutationObserver(e=>{e.some(i=>i.addedNodes.length)&&(cancelAnimationFrame(u),u=requestAnimationFrame(()=>{c.disconnect(),_(),p()}))}),p=()=>c.observe(document.body,{childList:!0,subtree:!0}),E=()=>{let e=r;e.whenReady().then(()=>{!s&&r===e&&(m(),document.dispatchEvent(new Event("popmelt-subjects-ready")))})},L=n?.subscribe(()=>{r.destroy(),r=new v(n.get()),m(),E()});E();let f={dispose(){s||(s=!0,c.disconnect(),L?.(),r.destroy(),cancelAnimationFrame(u),window.removeEventListener("pagehide",f.dispose),window.__POPMELT_CODE_PREVIEW__===f&&delete window.__POPMELT_CODE_PREVIEW__,g(t.textModifications),b(t.styleModifications,!0),y(t.domModifications),h())},source:a,getSubjects:()=>r,update(e){if(s)throw new Error("Preview runtime closed");if(e.draft.source&&e.draft.source.sourceId!==a.sourceId)throw new Error("This draft belongs to a different source");let i=JSON.stringify([e.planeId,e.draft.revision,e.draft.source?.sourceId,e.draft.source?.revision]);if(w===i)return;let o=structuredClone(e.draft.state??P),l=M=>!M.pathname||M.pathname===location.pathname,I={...o,annotations:o.annotations.filter(l),styleModifications:o.styleModifications.filter(l),textModifications:o.textModifications.filter(l),domModifications:o.domModifications.filter(l)};c.disconnect(),g(t.textModifications),b(t.styleModifications,!0),y(t.domModifications),h(),t=I,_(),p(),w=i}};return window.__POPMELT_CODE_PREVIEW__=f,p(),window.addEventListener("pagehide",f.dispose,{once:!0}),!0}export{C as a,T as b};
2
+ import{c as v}from"./chunk-MTQ5IWIK.mjs";import{a as P,l as R,h as $,j as x,k as g,i as b,m as y}from"./chunk-F6AMPRUB.mjs";import{v as A}from"./chunk-RCVAPQ7X.mjs";var O="__popmelt_code_preview";function C(a,n){let t=new URL(a,n);if(t.origin!==new URL(n).origin||!/^https?:$/.test(t.protocol))throw new Error("Code previews must use the same application origin");return t.hash="",t.searchParams.delete("popmelt"),t.searchParams.set(O,"1"),t.href}function T(a,n){if(!new URL(location.href).searchParams.has(O))return!1;if(parent===window)return!0;window.__POPMELT_CODE_PREVIEW__?.dispose();let t=P,w="",s=!1,u=0,d=new Map,h=()=>{for(let[e,i]of d)i===null?e.removeAttribute("data-pm"):e.setAttribute("data-pm",i);d.clear()},r=new v(n?.get()??[]),m=()=>{for(let e of t.annotations)e.target&&r.resolve(e.target)},_=()=>{R(t.domModifications),$(t.styleModifications),x(t.textModifications),m();for(let e of t.annotations){let i=e.linkedSelector?.match(/^\[data-pm="([^"]+)"\]$/)?.[1];if(!i)continue;let o=A(e.linkedSelector,e.elements?.[0]);o&&(d.has(o)||d.set(o,o.getAttribute("data-pm")),o.setAttribute("data-pm",i))}},c=new MutationObserver(e=>{e.some(i=>i.addedNodes.length)&&(cancelAnimationFrame(u),u=requestAnimationFrame(()=>{c.disconnect(),_(),p()}))}),p=()=>c.observe(document.body,{childList:!0,subtree:!0}),E=()=>{let e=r;e.whenReady().then(()=>{!s&&r===e&&(m(),document.dispatchEvent(new Event("popmelt-subjects-ready")))})},L=n?.subscribe(()=>{r.destroy(),r=new v(n.get()),m(),E()});E();let f={dispose(){s||(s=!0,c.disconnect(),L?.(),r.destroy(),cancelAnimationFrame(u),window.removeEventListener("pagehide",f.dispose),window.__POPMELT_CODE_PREVIEW__===f&&delete window.__POPMELT_CODE_PREVIEW__,g(t.textModifications),b(t.styleModifications,!0),y(t.domModifications),h())},source:a,getSubjects:()=>r,update(e){if(s)throw new Error("Preview runtime closed");if(e.draft.source&&e.draft.source.sourceId!==a.sourceId)throw new Error("This draft belongs to a different source");let i=JSON.stringify([e.planeId,e.draft.revision,e.draft.source?.sourceId,e.draft.source?.revision]);if(w===i)return;let o=structuredClone(e.draft.state??P),l=M=>!M.pathname||M.pathname===location.pathname,I={...o,annotations:o.annotations.filter(l),styleModifications:o.styleModifications.filter(l),textModifications:o.textModifications.filter(l),domModifications:o.domModifications.filter(l)};c.disconnect(),g(t.textModifications),b(t.styleModifications,!0),y(t.domModifications),h(),t=I,_(),p(),w=i}};return window.__POPMELT_CODE_PREVIEW__=f,p(),window.addEventListener("pagehide",f.dispose,{once:!0}),!0}export{C as a,T as b};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ function m(t){try{let e=t.defaultView?.frameElement;return e?.localName==="iframe"?e:null}catch{return null}}function w(t){if(t.localName!=="iframe"||t.closest("[data-devtools],[data-popmelt-peer-surface]"))return null;try{let e=t.contentDocument;return e?.documentElement?e:null}catch{return null}}function D(t){let e=t.getBoundingClientRect(),r=t.offsetWidth?e.width/t.offsetWidth:1,u=t.offsetHeight?e.height/t.offsetHeight:1;return{x:e.left+t.clientLeft*r,y:e.top+t.clientTop*u,sx:r,sy:u}}function v(t,e){let{left:r,top:u,width:o,height:n}=t,l=m(e);for(;l;){let a=D(l);r=a.x+r*a.sx,u=a.y+u*a.sy,o*=a.sx,n*=a.sy,l=m(l.ownerDocument)}return new DOMRect(r,u,o,n)}function V(t){return v(t.getBoundingClientRect(),t.ownerDocument)}function M(t,e,r){let u=[],o=m(r);for(;o;)u.unshift(o),o=m(o.ownerDocument);for(let n of u){let l=D(n);t=(t-l.x)/l.sx,e=(e-l.y)/l.sy}return{x:t,y:e}}function k(t){return t.ownerDocument.defaultView??window}function z(t){return!!(t&&t.namespaceURI==="http://www.w3.org/1999/xhtml")}function A(t,e=document){if(t===e)return!0;let r=m(t);return!!(r?.isConnected&&r.contentDocument===t&&A(r.ownerDocument,e))}function B(t,e){if(!A(e))return new DOMRect(0,0,0,0);let r=t.left,u=t.top,o=t.right,n=t.bottom;for(let l=m(e);l;l=m(l.ownerDocument)){let a=v({left:0,top:0,width:l.clientWidth,height:l.clientHeight},l.contentDocument);r=Math.max(r,a.left),u=Math.max(u,a.top),o=Math.min(o,a.right),n=Math.min(n,a.bottom)}return new DOMRect(r,u,Math.max(0,o-r),Math.max(0,n-u))}var g="@frame(";function I(t,e){return`${g}${encodeURIComponent(JSON.stringify({selector:t,url:e.URL}))}) `}function O(t){if(!t.startsWith(g))return null;let e=t.indexOf(") ");if(e<0)return null;try{let r=JSON.parse(decodeURIComponent(t.slice(g.length,e)));return typeof r.selector!="string"||typeof r.url!="string"?null:{...r,rest:t.slice(e+2)}}catch{return null}}var b=" >>> ";function N(t){return Array.from(t.querySelectorAll("*")).flatMap(e=>e.shadowRoot?[e.shadowRoot]:[])}function S(t=document){let e=[t];for(let r of e)e.push(...N(r));return e}function p(t,e=document){if(t.startsWith(g)){let o=O(t);if(!o)return null;let n=o.selector.startsWith(g)||o.selector.includes(b)?[p(o.selector,e)].filter(s=>!!s):S(e).flatMap(s=>Array.from(s.querySelectorAll(o.selector))),l=n.length===1?n[0]:null,a=l&&w(l);return!a||a.URL!==o.url?null:p(o.rest,a)}let r=t.split(b);if(r.length>1){let o=e,n=null;for(let l=0;l<r.length;l+=1){if(n=o.querySelector(r[l]),!n)return null;if(l<r.length-1){if(!n.shadowRoot)return null;o=n.shadowRoot}}return n}let u=[e];for(let o of u){let n=o.querySelector(t);if(n)return n;u.push(...N(o))}return null}function R(t){if(t.parentElement)return t.parentElement;let e=t.getRootNode();return"host"in e?e.host:null}function _(t,e){return e.startsWith(g)||e.includes(b)?p(e)===t:t.matches(e)}function $(t,e){let r=t;for(;r;){if(r.matches(e))return r;r=R(r)}return null}function H(t,e){let r=e;for(;r;){if(r===t)return!0;r=R(r)}return!1}var W=new WeakMap;function E(t){let e=t.getAttribute("style");return t.style.setProperty("pointer-events","auto","important"),()=>{e===null?t.removeAttribute("style"):t.setAttribute("style",e)}}function J(t){let e=t.nodeType===9?t:t.ownerDocument,r="* { pointer-events: auto !important; }",u=[];try{let o=e.defaultView?.CSSStyleSheet;if(o?.prototype.replaceSync&&"adoptedStyleSheets"in t){let n=W.get(e);n||(n=new o,n.replaceSync(r),W.set(e,n));let l=[...t.adoptedStyleSheets];t.adoptedStyleSheets=[...l,n],u.push(()=>{t.adoptedStyleSheets=l})}else{let n=e.createElement("style");n.textContent=r,(t.nodeType===9?e.head??e.documentElement:t).appendChild(n),u.push(()=>n.remove())}for(let n of t.querySelectorAll('[style*="pointer-events"]'))n.style.getPropertyValue("pointer-events")!=="none"||n.style.getPropertyPriority("pointer-events")!=="important"||u.push(E(n))}catch(o){throw u.reverse().forEach(n=>n()),o}return()=>u.reverse().forEach(o=>o())}function G(t,e,r,u=n=>[n],o){let n=[];for(let l of t.querySelectorAll("iframe")){if(!w(l))continue;let a=l.getBoundingClientRect();e<a.left||e>a.right||r<a.top||r>a.bottom||l.ownerDocument.defaultView?.getComputedStyle(l).pointerEvents==="none"&&n.push(E(l))}try{let l=()=>{let c=typeof t.elementsFromPoint=="function"?t.elementsFromPoint(e,r):[],i=t.elementFromPoint?.(e,r)??null;return(i&&!c.includes(i)?[i,...c]:c).filter(f=>t.nodeType===9||f.getRootNode()===t)},a=l(),s=a;if(o){let c=J(t);try{s=l()}finally{c()}s=s.filter(i=>a.includes(i)||o(i))}return s.flatMap(u)}finally{n.forEach(l=>l())}}function q(t,e,r=document,u){let o=[],n=new Set,l=r.nodeType===9?r:r.ownerDocument,a=M(t,e,l);for(let s of S(r).reverse())for(let c of G(s,a.x,a.y,i=>{let f=w(i);return f?[...q(t,e,f,u),i]:[i]},u))n.has(c)||(n.add(c),o.push(c));return o}function K(){return b}var Q=["id","data-testid","data-test","data-cy","data-popmelt-media-id","aria-label","name","href"],j=t=>t.replace(/\s+/g," ").trim();function y(t){return t==="id"||t==="data-popmelt-media-id"||/^data-(?:testid|test|cy)(?:-[a-z0-9_-]+)?$/.test(t)}function F(t,e){return!!(e&&e.length<=200&&!(t==="id"&&/^(radix-|:|_r_)/.test(e)))}function P(t){let e={},r=new Set([...Q,...t.getAttributeNames().filter(y)]);for(let n of r){let l=t.getAttribute(n);l&&F(n,l)&&(e[n]=l)}let u=j(t.querySelector("h1,h2,h3,h4,h5,h6")?.textContent??""),o=j(Array.from(t.childNodes).filter(n=>n.nodeType===3).map(n=>n.textContent).join(" "));return{tag:t.tagName.toLowerCase(),...Object.keys(e).length?{attributes:e}:{},...u&&u.length<=200?{heading:u}:{},...o&&o.length<=200?{text:o}:{}}}function L(t,e,r=document){let u=S(r),o=i=>{try{return u.flatMap(f=>Array.from(f.querySelectorAll(i)))}catch{return[]}},n=!!(e&&(e.heading||e.text||Object.keys(e.attributes??{}).length)),l=i=>{if(!e||!n)return!0;let f=P(i);return f.tag===e.tag&&(!e.heading||f.heading===e.heading)&&(!e.text||f.text===e.text)&&Object.entries(e.attributes??{}).every(([h,d])=>i.getAttribute(h)===d)};for(let i of t){if(i.includes(" >>> ")||i.startsWith("@frame(")){try{let h=p(i,r),d=O(i),C=Object.entries(e?.attributes??{}).filter(([x])=>y(x)),T=d&&h&&(d.rest.startsWith("[data-pm=")||C.length>0&&h.tagName.toLowerCase()===e?.tag&&C.every(([x,U])=>h.getAttribute(x)===U));if(h&&(T||l(h)))return{status:"matched",element:h}}catch{}continue}let f=o(i);if(f.length===1&&(/^\[data-pm=/.test(i)||!n))return{status:"matched",element:f[0]}}if(!n||t.some(i=>i.includes(" >>> ")||i.startsWith("@frame("))||!/^[a-z][a-z0-9-]*$/.test(e.tag))return{status:"missing"};let a=o(e.tag);if(a.length>500)return{status:"ambiguous"};let s=Object.entries(e.attributes??{}).filter(([i])=>y(i));if(s.length){let i=a.filter(f=>s.every(([h,d])=>f.getAttribute(h)===d));return i.length===1?{status:"matched",element:i[0]}:{status:i.length?"ambiguous":"missing"}}let c=a.filter(l);return c.length===1?{status:"matched",element:c[0]}:{status:c.length?"ambiguous":"missing"}}function X(t,e,r=document){let u={};if(e)for(let[a,s]of Object.entries({...e.dataAttributes,...e.id?{id:e.id}:{}}))y(a)&&F(a,s)&&(u[a]=s);let o=e?.targetFingerprint?.tag??e?.tagName?.toLowerCase(),n=e&&o?{...e.targetFingerprint,tag:o,attributes:{...u,...e.targetFingerprint?.attributes}}:e?.targetFingerprint,l=L([t,e?.selector].filter(a=>!!a),n,r);return l.status==="matched"?l.element:null}export{m as a,w as b,v as c,V as d,M as e,k as f,z as g,A as h,B as i,I as j,S as k,p as l,R as m,_ as n,$ as o,H as p,q,K as r,y as s,P as t,L as u,X as v};