@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,5 +1,5 @@
1
1
  "use client";
2
- import{c as He,b as En}from"./chunk-4LHTPRFY.mjs";import{a as Cn}from"./chunk-OLLUQ45J.mjs";import{j as St,a as Q,f as An,i as We,g as Rn,h as It}from"./chunk-XOGBFVWI.mjs";import{b as je,g as Ye,e as qe}from"./chunk-V44RIEET.mjs";import{a as Nn,b as Ln}from"./chunk-LVEMYZOA.mjs";import{a as Mt,d as Ee,v as On,h as Dn,i as Tt,c as Ce,f as Ae,b as kt,e as $n,g as _n}from"./chunk-HGW2U6PD.mjs";import{Clock as Et,OctagonAlert as Fn,MessageCircleQuestionMark as Pn,TriangleAlert as zn,Reply as Bn,Eye as Hn,SendHorizontal as Re,CornerDownLeft as Wn}from"lucide-react";import{createContext as Ke,useContext as de,useState as re,useEffect as V,useLayoutEffect as Ct,useId as jn,useRef as le,useMemo as Yn,useCallback as qn,useReducer as Kn,useSyncExternalStore as Un}from"react";import{jsxs as R,jsx as x,Fragment as W}from"react/jsx-runtime";var Ne=new Set,Le;function Ue(e){if(Ne.add(e),!Le){let t=new Map,n=new Map,i="",o=!0,r=!0,a=!1,l=!0,d=0,s=()=>{let h=new Set,u=new Map,f=y=>{if(h.add(y),!t.has(y)){let m=new MutationObserver(k=>{let w=k.filter(v=>!(v.target.nodeType===1?v.target:v.target.parentElement)?.closest("[data-devtools]"));w.length&&(o=!0),w.some(v=>v.type==="childList")&&(r=!0)});m.observe(y,{subtree:!0,childList:!0,characterData:!0,attributes:!0});let g=()=>{o=!0};y.addEventListener("scroll",g,!0),y.addEventListener("load",g,!0),t.set(y,()=>{m.disconnect(),y.removeEventListener("scroll",g,!0),y.removeEventListener("load",g,!0)})}for(let m of y.querySelectorAll("*")){if(m.shadowRoot&&!m.closest("[data-devtools]")&&f(m.shadowRoot),m.localName!=="iframe"||m.closest("[data-devtools],[data-popmelt-peer-surface]"))continue;let g=kt(m);u.set(m,g),g&&f(g)}};f(document);for(let[y,m]of t)h.has(y)||(m(),t.delete(y));n=u,r=!1,o=!0},c=()=>{if(!l)return;(r||[...n].some(([f,y])=>kt(f)!==y))&&s();let h=[];for(let[f,y]of n){let m=f.getBoundingClientRect();h.push(y?.URL,m.x,m.y,m.width,m.height,y?.defaultView?.scrollX,y?.defaultView?.scrollY)}let u=JSON.stringify(h);if((o||u!==i)&&(o=!1,i=u,a))for(let f of Ne)f();a=!0,l&&(d=requestAnimationFrame(c))};c(),Le=()=>{l=!1,cancelAnimationFrame(d);for(let h of t.values())h()}}return()=>{Ne.delete(e),Ne.size||(Le?.(),Le=void 0)}}var xe=Ke(!0);function Xe(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);if(n)return`oklch(${n[1]} / ${t})`;let i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(i){let o=parseInt(i[1],16),r=parseInt(i[2],16),a=parseInt(i[3],16);return`rgba(${o}, ${r}, ${a}, ${t})`}return`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function At(e,t){let n=Rn(e),i=t.toLowerCase(),o=-1;for(let r=n.length-1;r>=0;r--){let a=n[r].name;if(a===t){let l=It(n[r].fiber)??e;return{name:t,path:n.map(d=>d.name),depthIndex:r,rootElement:l}}if(o===-1){let l=a.toLowerCase();(l.length>=4&&i.includes(l)||i.length>=4&&l.includes(i))&&(o=r)}}if(o>=0){let r=It(n[o].fiber)??e;return{name:t,path:n.map(a=>a.name),depthIndex:o,rootElement:r}}return null}function Xn(e){let t=Oe(),n=[],i=new Set,o=t.currentNode;for(;o=t.nextNode();){let r=At(o,e);r&&!i.has(r.rootElement)&&(i.add(r.rootElement),n.push(r))}return n}function Qn(e){let t=new Map;if(e.size===0)return t;let n=new Set(e),i=Oe(),o=new Set,r=i.currentNode;for(;(r=i.nextNode())&&n.size>0;)for(let a of n){let l=At(r,a);if(!l||o.has(l.rootElement))continue;o.add(l.rootElement);let d=l.rootElement.getBoundingClientRect();t.set(a,d.top+window.scrollY),n.delete(a);break}for(let a of n)t.set(a,1/0);return t}function Oe(){return document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return e.closest("#devtools-toolbar, #devtools-canvas, #devtools-scrim, [data-popmelt-panel]")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function q(e,t){return e.style.getPropertyValue(t)!==""}function Vn(e,t=30){if(e<=0)return[];let n=[],i=Oe(),o=.5,r=i.currentNode;for(;(r=i.nextNode())&&n.length<t;){let a=r,l=a.getBoundingClientRect();if(l.bottom<-50||l.top>window.innerHeight+50||l.right<-50||l.left>window.innerWidth+50||l.width<1||l.height<1)continue;let d=getComputedStyle(a);!q(a,"padding-top")&&Math.abs((parseFloat(d.paddingTop)||0)-e)<o&&n.push({element:a,property:"padding-top"}),!q(a,"padding-bottom")&&Math.abs((parseFloat(d.paddingBottom)||0)-e)<o&&n.length<t&&n.push({element:a,property:"padding-bottom"}),!q(a,"padding-left")&&Math.abs((parseFloat(d.paddingLeft)||0)-e)<o&&n.length<t&&n.push({element:a,property:"padding-left"}),!q(a,"padding-right")&&Math.abs((parseFloat(d.paddingRight)||0)-e)<o&&n.length<t&&n.push({element:a,property:"padding-right"}),!q(a,"margin-top")&&Math.abs((parseFloat(d.marginTop)||0)-e)<o&&n.length<t&&n.push({element:a,property:"margin-top"}),!q(a,"margin-bottom")&&Math.abs((parseFloat(d.marginBottom)||0)-e)<o&&n.length<t&&n.push({element:a,property:"margin-bottom"}),!q(a,"margin-left")&&Math.abs((parseFloat(d.marginLeft)||0)-e)<o&&n.length<t&&n.push({element:a,property:"margin-left"}),!q(a,"margin-right")&&Math.abs((parseFloat(d.marginRight)||0)-e)<o&&n.length<t&&n.push({element:a,property:"margin-right"});let s=d.display;if((s.includes("flex")||s.includes("grid"))&&n.length<t){let c=q(a,"gap"),h=parseFloat(d.gap)||0,u=parseFloat(d.rowGap)||0,f=parseFloat(d.columnGap)||0;!c&&Math.abs(h-e)<o?n.push({element:a,property:"gap"}):!q(a,"row-gap")&&Math.abs(u-e)<o?n.push({element:a,property:"row-gap"}):!q(a,"column-gap")&&Math.abs(f-e)<o&&n.push({element:a,property:"column-gap"})}}return n}function Gn(e){return typeof e=="string"?{value:e}:e}var Rt={gap:["gap","row-gap","column-gap"],padding:["padding-top","padding-bottom","padding-left","padding-right"],margin:["margin-top","margin-bottom","margin-left","margin-right"]};function Nt(e,t){let n=Rt[t];return n?n.includes(e):!1}function Jn(e,t){let n=e.split(/\s+/);for(let i of n){if(i===t)return!0;let o=i.lastIndexOf(":");if(o>=0&&i.slice(o+1)===t)return!0}return!1}function Zn(e){let t=e.lastIndexOf(":"),n=t>=0?e.slice(t+1):e,i=n.indexOf("-");if(i<0)return null;let o=n.slice(0,i),r={gap:"gap","gap-x":"column-gap","gap-y":"row-gap",p:"padding",pt:"padding-top",pb:"padding-bottom",pl:"padding-left",pr:"padding-right",px:"padding-left",py:"padding-top",m:"margin",mt:"margin-top",mb:"margin-bottom",ml:"margin-left",mr:"margin-right",mx:"margin-left",my:"margin-top"},a=n.slice(0,n.indexOf("-",i+1)>0?n.indexOf("-",i+1):i);return r[a]??r[o]??null}function eo(e,t=30){let n=parseFloat(e.value);if(isNaN(n)||n<=0)return[];if(e.bindings&&e.bindings.length>0){let o=[],r=Oe(),a=r.currentNode;for(;(a=r.nextNode())&&o.length<t;){let l=a,d=l.getBoundingClientRect();if(d.bottom<-50||d.top>window.innerHeight+50||d.right<-50||d.left>window.innerWidth+50||d.width<1||d.height<1)continue;let s=l.className;if(typeof s=="string")for(let c of e.bindings){if(!Jn(s,c))continue;let h=Zn(c);if(h&&!(e.property&&!Nt(h,e.property))){o.push({element:l,property:h});break}}}return o}let i=Vn(n,t*2);return e.property?i.filter(o=>Nt(o.property,e.property)).slice(0,t):i.slice(0,t)}function to(e,t){let n=new Set,i=we(t);for(let o of e){let r=Lt[o.property];if(!r)continue;let a=o.element.className;if(typeof a=="string")for(let l of r){let d=`${l}-${i}`;for(let s of a.split(/\s+/)){let c=s.lastIndexOf(":"),h=c>=0?s.slice(c+1):s;if(h===d){n.add(h);break}}}}return[...n]}function no(e){let t=new Set;for(let n of e)for(let[i,o]of Object.entries(Rt))if(o.includes(n.property)){t.add(i);break}if(t.size===1)return[...t][0]}function oo(e,t,n){if(t===n)return e;let i=we(t),o=we(n);return e.map(r=>{let a=r.lastIndexOf("-");if(a<0)return r;let l=r.slice(0,a),d=r.slice(a+1);return d===i||d===`[${t}px]`?`${l}-${o}`:r})}var io={0:"0",1:"px",2:"0.5",4:"1",6:"1.5",8:"2",12:"3",16:"4",20:"5",24:"6",28:"7",32:"8",40:"10",48:"12",64:"16",80:"20",96:"24"};function we(e){return io[e]??`[${e}px]`}var Lt={"padding-top":["pt","py","p"],"padding-bottom":["pb","py","p"],"padding-left":["pl","px","p"],"padding-right":["pr","px","p"],"margin-top":["mt","my","m"],"margin-bottom":["mb","my","m"],"margin-left":["ml","mx","m"],"margin-right":["mr","mx","m"],gap:["gap"],"row-gap":["gap-y","gap"],"column-gap":["gap-x","gap"]};function ao(e,t,n,i){let o=Lt[t];if(!o)return null;let r=we(n);for(let a of o){let l=new RegExp("(?:^|\\s)((?:[\\w-]+:)*"+a+"-(?:"+ro(r)+"|\\["+n+"px\\]))(?:\\s|$)"),d=e.match(l);if(d?.[1]){let s=we(i),c=d[1].lastIndexOf(":"),h=c>=0?d[1].slice(0,c+1):"";return{matched:d[1],suggested:`${h}${a}-${s}`}}}return null}function ro(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lo(e,t,n){let i=new Set,o=[];for(let r of e){let a=Q(r.element),l=`${a}::${r.property}`;if(i.has(l))continue;i.add(l);let d=An(r.element),s=r.element.className||"",c=ao(s,r.property,t,n);o.push({selector:a,reactComponent:d?.name,className:s,property:r.property,matchedClass:c?.matched,suggestedClass:c?.suggested})}return o}function so(e){let t=window.getComputedStyle(e).display;return t==="flex"||t==="inline-flex"||t==="grid"||t==="inline-grid"}function po(e){let t=window.getComputedStyle(e);return{row:parseFloat(t.rowGap)||0,column:parseFloat(t.columnGap)||0}}function co(e){let t=[];for(let n of e){let i=t.find(o=>o.axis!==n.axis?!1:n.axis==="row"?Math.abs(o.y-n.y)<2&&Math.abs(o.h-n.h)<2:Math.abs(o.x-n.x)<2&&Math.abs(o.w-n.w)<2);if(i)if(n.axis==="row"){let o=Math.min(i.x,n.x),r=Math.max(i.x+i.w,n.x+n.w);i.x=o,i.w=r-o}else{let o=Math.min(i.y,n.y),r=Math.max(i.y+i.h,n.y+n.h);i.y=o,i.h=r-o}else t.push({...n})}return t}function uo(e){let t=Array.from(e.children).filter(l=>{if(!(l instanceof HTMLElement))return!1;let d=window.getComputedStyle(l);return d.display!=="none"&&d.position!=="absolute"&&d.position!=="fixed"});if(t.length<2)return[];let n=[],i=e.getBoundingClientRect(),o=window.getComputedStyle(e).flexDirection,r=o==="column"||o==="column-reverse",a=6;for(let l=0;l<t.length-1;l++){let d=t[l].getBoundingClientRect(),s=t[l+1].getBoundingClientRect();if(s.left>d.right+.5&&n.push({axis:"column",x:d.right,y:i.top,w:s.left-d.right,h:i.height}),s.top>d.bottom+.5&&n.push({axis:"row",x:i.left,y:d.bottom,w:i.width,h:s.top-d.bottom}),!(s.left>d.right+.5)&&!(s.top>d.bottom+.5))if(r){let c=(d.bottom+s.top)/2;n.push({axis:"row",x:i.left,y:c-a/2,w:i.width,h:a})}else{let c=(d.right+s.left)/2;n.push({axis:"column",x:c-a/2,y:i.top,w:a,h:i.height})}}return co(n)}function fo(e,t){let n=window.getComputedStyle(e),i=n.display;if(i!=="flex"&&i!=="inline-flex")return!1;let o=n.justifyContent;if(o!=="space-between"&&o!=="space-around"&&o!=="space-evenly"&&o!=="stretch")return!1;let r=n.flexDirection;return!(t!==(r==="column"||r==="column-reverse"?"row":"column")||parseFloat(t==="row"?n.rowGap:n.columnGap)>0)}function ho(e){let t=window.getComputedStyle(e);return{top:parseFloat(t.paddingTop)||0,right:parseFloat(t.paddingRight)||0,bottom:parseFloat(t.paddingBottom)||0,left:parseFloat(t.paddingLeft)||0}}function go(e){let t=window.getComputedStyle(e);return{top:parseFloat(t.marginTop)||0,right:parseFloat(t.marginRight)||0,bottom:parseFloat(t.marginBottom)||0,left:parseFloat(t.marginLeft)||0}}function Ot(e){let t=window.getComputedStyle(e);return{topLeft:t.borderTopLeftRadius,topRight:t.borderTopRightRadius,bottomRight:t.borderBottomRightRadius,bottomLeft:t.borderBottomLeftRadius}}function Dt(e){let t=window.getComputedStyle(e);return{"top-left":parseFloat(t.borderTopLeftRadius)||0,"top-right":parseFloat(t.borderTopRightRadius)||0,"bottom-right":parseFloat(t.borderBottomRightRadius)||0,"bottom-left":parseFloat(t.borderBottomLeftRadius)||0}}function mo(e){for(let t of e.childNodes)if(t.nodeType===Node.TEXT_NODE&&(t.textContent||"").trim().length>0)return!0;return!1}function yo(e){let t=document.createRange(),n=!1;for(let c of e.childNodes)c.nodeType===Node.TEXT_NODE&&(c.textContent||"").trim().length>0&&(n||(t.setStart(c,0),n=!0),t.setEnd(c,c.textContent?.length??0));if(!n)return null;let i=t.getBoundingClientRect(),o=window.getComputedStyle(e),r=parseFloat(o.fontSize)||16,a=parseFloat(o.lineHeight);isNaN(a)&&(a=r*1.2);let l=Math.max(1,t.getClientRects().length),d=Math.max(i.height,l*a),s=(d-i.height)/2;return new DOMRect(i.x,i.y-s,i.width,d)}function xo(e){let t=window.getComputedStyle(e),n=parseFloat(t.fontSize)||16,i=parseFloat(t.lineHeight);return isNaN(i)&&(i=n*1.2),{fontSize:n,lineHeight:i}}function wo(e){let t=e.startsWith("top-");return{top:t?4:12,right:4,bottom:t?12:4,left:4}}function vo({hasCommentEntry:e,stagedChangeCount:t}){return e&&t===0?2:6}function bo({annotationNumber:e,stickerCount:t,interactionEpisodeStepCount:n,hasStatus:i,hasSend:o,controlGap:r}){let a=16+Math.max(1,e===void 0?0:String(e).length)*7.2,l=t*28-Math.max(0,t-1)*2,d=n>0?32+String(n).length*7.2:0,s=28,c=t>0?l+(d>0?d-2:0)+(o?s-2:0):0,h=[t>0?c:0,t===0?d:0,t===0&&o?s:0,i?s:0].filter(u=>u>0);return a+h.reduce((u,f)=>u+f,0)+h.length*r}function So(e,t,n){let i=e.horizontalAlignment==="right"?e.left-t:e.left;return{left:i,top:e.top,right:i+t,bottom:e.top+n}}function Io(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}function Mo(e,t,n){let i=Math.max(0,e.left+t-n);return Math.max(0,t-e.right)<i?"right":"left"}function $t(e,t,n,i,o=0,r=Number.POSITIVE_INFINITY){if(e.height>=i)return{anchor:"top-left",horizontalAlignment:"left",left:e.left+8,top:e.top+8};let a=Mo(e,o,r);return e.top>=t+n?{anchor:a==="right"?"top-right":"top-left",horizontalAlignment:a,left:a==="right"?e.right:e.left,top:e.top-t-n}:{anchor:a==="right"?"bottom-right":"bottom-left",horizontalAlignment:a,left:a==="right"?e.right:e.left,top:e.bottom+n}}function Qe(e){return e.left+e.width}function De(e){return e.top+e.height}function Ve(e,t){if(e.length===0)return t;let n=Math.min(...e.map(a=>a.left)),i=Math.min(...e.map(a=>a.top)),o=Math.max(...e.map(Qe)),r=Math.max(...e.map(De));return{left:n,top:i,width:o-n,height:r-i}}function Ge(e){let t=[...e].sort((i,o)=>i.top-o.top||i.left-o.left),n=[];for(let i of t){let o=i.top+i.height/2,r=n.find(c=>{let h=c.top+c.height/2;return Math.abs(o-h)<=Math.max(c.height,i.height)*.4});if(!r){n.push({...i});continue}let a=Math.min(r.left,i.left),l=Math.min(r.top,i.top),d=Math.max(Qe(r),Qe(i)),s=Math.max(De(r),De(i));r.left=a,r.top=l,r.width=d-a,r.height=s-l}return n.sort((i,o)=>i.top-o.top||i.left-o.left)}function To({display:e,fragmentRects:t,elementRect:n,parentContentRect:i}){let o=Ge(t),r=Ve(o,n);if(!(e==="inline"&&o.length>1&&i&&i.width>0))return{textRect:r,boundaryRect:n,boundaryRects:[n],firstLineIndent:0};let a=o[0],l={left:i.left,top:a.top,width:i.width,height:Math.max(r.height,De(r)-a.top)},d=Math.max(0,Math.min(l.width,a.left-l.left));return{textRect:r,boundaryRect:Ve(o,n),boundaryRects:o,flowRect:l,firstLineIndent:d}}var Je=new WeakMap;function ko(e){let t={listeners:new Set,rafId:null,schedule:()=>{t.rafId===null&&(t.rafId=e.requestAnimationFrame(()=>{t.rafId=null;for(let n of t.listeners)n()}))}};return Je.set(e,t),e.addEventListener("scroll",t.schedule,{passive:!0,capture:!0}),e.addEventListener("resize",t.schedule),t}function _t(e,t=window){let n=Je.get(t)??ko(t);return n.listeners.add(e),()=>{n.listeners.delete(e)&&(n.listeners.size>0||(t.removeEventListener("scroll",n.schedule,!0),t.removeEventListener("resize",n.schedule),n.rafId!==null&&t.cancelAnimationFrame(n.rafId),Je.delete(t)))}}var se={topLeft:"0px",topRight:"0px",bottomRight:"0px",bottomLeft:"0px"};function Ft(e,t){return e.radii.topLeft!==t.radii.topLeft||e.radii.topRight!==t.radii.topRight||e.radii.bottomRight!==t.radii.bottomRight||e.radii.bottomLeft!==t.radii.bottomLeft||e.outline!==t.outline||e.fragments.length!==t.fragments.length?!1:e.fragments.every((n,i)=>{let o=t.fragments[i];return!!o&&n.left===o.left&&n.top===o.top&&n.width===o.width&&n.height===o.height})}function Pt(e){if(!e.isConnected||!Dn(e.ownerDocument))return{fragments:[],radii:se};let t=Tt(Ee(e),e.ownerDocument);if(Mt(e.ownerDocument)&&(!t.width||!t.height))return{fragments:[],radii:se};if(e.getAttribute("data-popmelt-subject-projection")==="true")return{fragments:[{left:t.left,top:t.top,width:t.width,height:t.height}],radii:se,outline:e.getAttribute("data-popmelt-subject-outline")??void 0};let n=Array.from(e.getClientRects()).map(i=>Tt(Ce(i,e.ownerDocument),e.ownerDocument)).filter(i=>i.width>0&&i.height>0).map(i=>({left:i.left,top:i.top,width:i.width,height:i.height}));return{fragments:Ge(n.length>0?n:[{left:t.left,top:t.top,width:t.width,height:t.height}]),radii:Ot(e)}}function zt({element:e,projectedRect:t,isSelected:n=!1,elementInfo:i,color:o="#3b82f6",annotationNumber:r,changeCount:a,hideTooltip:l=!1,hideOutline:d=!1,hideFill:s=!1,fillOpacity:c=.05,subjectRegistry:h,railGap:u=2,railHeight:f=22,railWidth:y=0,renderRail:m,refreshKey:g,outlineZIndex:k=9996,onActivate:w,onRemove:v}){let I=de(xe),[b,C]=re({fragments:[],radii:se});V(()=>{if(!I)return;if(!e){C({fragments:[],radii:se});return}let P=null,H=()=>{let ee=Pt(e);C(Te=>Ft(Te,ee)?Te:ee)},E=()=>{P===null&&(P=requestAnimationFrame(()=>{P=null,H()}))};H();let fe=e.getAttribute("data-popmelt-subject-projection")==="true"&&!!h,he=fe?h.subscribeFrame(H):void 0,ge=fe||typeof ResizeObserver>"u"?null:new ResizeObserver(E);ge?.observe(e);let B=fe?null:new MutationObserver(E);B?.observe(e,{attributes:!0,attributeFilter:["style","class"]});let ae=_t(H,e.ownerDocument.defaultView??window),me=Mt(e.ownerDocument)?Ue(H):void 0;return()=>{ae(),me?.(),he?.(),ge?.disconnect(),B?.disconnect(),P!==null&&cancelAnimationFrame(P)}},[I,e,h]),Ct(()=>{if(!I||!e||g===void 0)return;let P=Pt(e);C(H=>Ft(H,P)?H:P)},[I,e,g]);let{fragments:N,radii:z}=t?{fragments:[t],radii:se}:b;if(N.length===0||!e&&!t)return null;let A=Ve(N,N[0]),T=e?.tagName.toLowerCase()??"",X=e?.id?`#${e.id}`:"",oe=e&&e.classList.length>0?"."+Array.from(e.classList).slice(0,2).join("."):"",ie=i?.reactComponent,Se=e?.getAttribute("data-popmelt-subject-adapter"),Ie=e?.getAttribute("data-popmelt-subject-label"),Pe=Se&&Ie?`<${Ie}>`:ie?`<${ie}> ${T}${X}${oe}`:`${T}${X}${oe}`,Z=$t({left:A.left,right:A.left+A.width,top:A.top,bottom:A.top+A.height,height:A.height},f,u,window.innerHeight,y,window.innerWidth),Me={zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:o,color:"#fff",fontSize:12,fontFamily:je,lineHeight:"14px",padding:"4px 8px",borderRadius:8,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400,position:"fixed",top:Z.top,left:Z.left},ze=!l&&R("div",{ref:P=>{e&&Nn(e,P)},"data-devtools":"tooltip",style:Me,children:[r!==void 0&&R("span",{children:[r,"."]}),x("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:Pe}),a!==void 0&&a>0&&R("span",{style:{opacity:.8},children:["(",a," ",a===1?"change":"changes",")"]})]});return R(W,{children:[!d&&N.map((P,H)=>x("div",{"data-devtools":"highlight",onContextMenu:v?E=>{E.preventDefault(),E.stopPropagation(),v()}:void 0,role:w?"button":void 0,tabIndex:w?0:void 0,"aria-label":w?"Open annotation thread":void 0,onPointerDown:w?E=>{E.preventDefault(),E.stopPropagation()}:void 0,onClick:w?E=>{E.preventDefault(),E.stopPropagation(),w()}:void 0,onKeyDown:w?E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),E.stopPropagation(),w())}:void 0,style:{position:"fixed",top:P.top,left:P.left,width:P.width,height:P.height,pointerEvents:w||v?"auto":"none",cursor:w?"pointer":void 0,zIndex:k,overflow:"visible"},children:x("div",{style:b.outline?{position:"absolute",inset:0,pointerEvents:"none"}:{position:"absolute",inset:0,boxSizing:"border-box",backgroundColor:s?"transparent":Xe(o,c),borderColor:o,borderStyle:n?"solid":"dashed",borderWidth:1,borderTopLeftRadius:z.topLeft,borderTopRightRadius:z.topRight,borderBottomRightRadius:z.bottomRight,borderBottomLeftRadius:z.bottomLeft,pointerEvents:"none"},children:b.outline?x("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",style:{display:"block",overflow:"visible"},"aria-hidden":"true",children:x("polygon",{points:b.outline,fill:s?"transparent":Xe(o,c),stroke:o,strokeWidth:1,strokeDasharray:n?void 0:"4 3",vectorEffect:"non-scaling-stroke"})}):null})},`${P.left}:${P.top}:${H}`)),m?m(Z,A):ze]})}function Bt(e){return e==="bottom-left"?[2,8,8,8]:e==="bottom-right"?[8,2,8,8]:e==="top-right"?[8,8,2,8]:[8,8,8,2]}function Eo(e){return Bt(e).map(t=>`${t}px`).join(" ")}var ve=1.1666666666666667,Ht=2048;function Ze(e){return e.length>Ht?`${e.slice(0,Ht)}\u2026`:e}function Co(e,t,n){let i=Ze(t);if(!i||e.measureText(i).width<=n)return[i];let o=i.split(/\s+/),r=[],a="";for(let l of o){let d=a?`${a} ${l}`:l;a&&e.measureText(d).width>n?(r.push(a),a=l):a=d}return a&&r.push(a),r.length>0?r:[i]}function Ao(e,t,n){return t.flatMap(i=>Co(e,i,n))}var ne=je,et=400,Wt=16,tt=60,Ro=12,nt=16;function jt(e){let t=window.innerWidth-e-Wt;return Math.max(tt,Math.min(et,t))}function ot(e,t,n){let i=Ze(t);if(i===t&&e.measureText(i).width<=n)return i;let o="\u2026",r=0,a=i.endsWith(o)?i.length-1:i.length;for(;r<a;){let l=Math.ceil((r+a)/2);e.measureText(i.slice(0,l)+o).width<=n?r=l:a=l-1}return r>0?i.slice(0,r)+o:o}function No(e,t,n){if(e===void 0||t===void 0||n.avoidLeft===void 0&&n.avoidRight===void 0)return!0;let i=typeof window<"u"?window.innerWidth:9999,o=n.avoidLeft??0,r=n.avoidRight??i;return e+t>o&&e<r}function Yt(e,t,n,i,o){let r=typeof window<"u"?window.innerHeight:9999,a=0,l=r;n&&No(i,o,n)&&(a=n.avoidTop??a,l=n.avoidBottom??l);let d=Math.max(a,l-t);return Math.max(a,Math.min(e,d))}function qt(e,t=12,n,i){let o=t*ve+8,r=e.y-4,a=e.x-8,l=Yt(r,o,n,a,i);return l===r?e:{...e,y:l+4}}function Lo(e,t,n,i,o=12,r,a,l,d="#dddddd",s,c=!1){if(!n)return;let h=o*ve,u=n.replace(/\n/g," "),f=r!==void 0?r+". "+u:u;e.font=`${o}px ${ne}`,e.textBaseline="middle";let y=a!==void 0?Math.min(et,Math.max(tt,window.innerWidth-a-Wt)):et,m=c?nt:0,g=ot(e,f,Math.max(tt,y-m)),k=e.measureText(g).width,w=m+k,v=qt(t,o,l,w+16);e.fillStyle=i;let I=v.x-8,b=v.y-4,C=w+16,N=h+8;e.beginPath(),e.roundRect(I,b,C,N,Bt(s)),e.fill();let z=v.y+h/2;if(c){let A=v.x,T=z-Ro/2;e.strokeStyle=d,e.lineWidth=1.5,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(A+7.5,T+4),e.lineTo(A+10.5,T+6.5),e.lineTo(A+7.5,T+9),e.moveTo(A+1.5,T+1.5),e.lineTo(A+1.5,T+4.5),e.quadraticCurveTo(A+1.5,T+6.5,A+3.5,T+6.5),e.lineTo(A+10.5,T+6.5),e.stroke()}e.fillStyle=d,e.fillText(g,v.x+m,z)}function Oo(e,t,n){let i=e.filter(o=>!o.captured&&o.selector===t&&(!o.pathname||o.pathname===n));return i.length?{type:"MODIFY_TEXT_CONTENTS",payload:i.map(o=>({...o,modified:o.original}))}:null}function Kt(e,t){return e.type!=="text"?!1:(e.groupId?t.filter(n=>n.groupId===e.groupId):[e]).every(n=>(n.status??"pending")==="pending"&&!n.threadId)}var Ut=Ke(0),it=`
2
+ import{c as He,b as En}from"./chunk-4LHTPRFY.mjs";import{a as Cn}from"./chunk-F6AMPRUB.mjs";import{j as St,a as Q,f as An,i as We,g as Rn,h as It}from"./chunk-EXDOFFFJ.mjs";import{b as je,g as Ye,e as qe}from"./chunk-V44RIEET.mjs";import{a as Nn,b as Ln}from"./chunk-LVEMYZOA.mjs";import{a as Mt,d as Ee,v as On,h as Dn,i as Tt,c as Ce,f as Ae,b as kt,e as $n,g as _n}from"./chunk-RCVAPQ7X.mjs";import{Clock as Et,OctagonAlert as Fn,MessageCircleQuestionMark as Pn,TriangleAlert as zn,Reply as Bn,Eye as Hn,SendHorizontal as Re,CornerDownLeft as Wn}from"lucide-react";import{createContext as Ke,useContext as de,useState as re,useEffect as V,useLayoutEffect as Ct,useId as jn,useRef as le,useMemo as Yn,useCallback as qn,useReducer as Kn,useSyncExternalStore as Un}from"react";import{jsxs as R,jsx as x,Fragment as W}from"react/jsx-runtime";var Ne=new Set,Le;function Ue(e){if(Ne.add(e),!Le){let t=new Map,n=new Map,i="",o=!0,r=!0,a=!1,l=!0,d=0,s=()=>{let h=new Set,u=new Map,f=y=>{if(h.add(y),!t.has(y)){let m=new MutationObserver(k=>{let w=k.filter(v=>!(v.target.nodeType===1?v.target:v.target.parentElement)?.closest("[data-devtools]"));w.length&&(o=!0),w.some(v=>v.type==="childList")&&(r=!0)});m.observe(y,{subtree:!0,childList:!0,characterData:!0,attributes:!0});let g=()=>{o=!0};y.addEventListener("scroll",g,!0),y.addEventListener("load",g,!0),t.set(y,()=>{m.disconnect(),y.removeEventListener("scroll",g,!0),y.removeEventListener("load",g,!0)})}for(let m of y.querySelectorAll("*")){if(m.shadowRoot&&!m.closest("[data-devtools]")&&f(m.shadowRoot),m.localName!=="iframe"||m.closest("[data-devtools],[data-popmelt-peer-surface]"))continue;let g=kt(m);u.set(m,g),g&&f(g)}};f(document);for(let[y,m]of t)h.has(y)||(m(),t.delete(y));n=u,r=!1,o=!0},c=()=>{if(!l)return;(r||[...n].some(([f,y])=>kt(f)!==y))&&s();let h=[];for(let[f,y]of n){let m=f.getBoundingClientRect();h.push(y?.URL,m.x,m.y,m.width,m.height,y?.defaultView?.scrollX,y?.defaultView?.scrollY)}let u=JSON.stringify(h);if((o||u!==i)&&(o=!1,i=u,a))for(let f of Ne)f();a=!0,l&&(d=requestAnimationFrame(c))};c(),Le=()=>{l=!1,cancelAnimationFrame(d);for(let h of t.values())h()}}return()=>{Ne.delete(e),Ne.size||(Le?.(),Le=void 0)}}var xe=Ke(!0);function Xe(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);if(n)return`oklch(${n[1]} / ${t})`;let i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(i){let o=parseInt(i[1],16),r=parseInt(i[2],16),a=parseInt(i[3],16);return`rgba(${o}, ${r}, ${a}, ${t})`}return`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function At(e,t){let n=Rn(e),i=t.toLowerCase(),o=-1;for(let r=n.length-1;r>=0;r--){let a=n[r].name;if(a===t){let l=It(n[r].fiber)??e;return{name:t,path:n.map(d=>d.name),depthIndex:r,rootElement:l}}if(o===-1){let l=a.toLowerCase();(l.length>=4&&i.includes(l)||i.length>=4&&l.includes(i))&&(o=r)}}if(o>=0){let r=It(n[o].fiber)??e;return{name:t,path:n.map(a=>a.name),depthIndex:o,rootElement:r}}return null}function Xn(e){let t=Oe(),n=[],i=new Set,o=t.currentNode;for(;o=t.nextNode();){let r=At(o,e);r&&!i.has(r.rootElement)&&(i.add(r.rootElement),n.push(r))}return n}function Qn(e){let t=new Map;if(e.size===0)return t;let n=new Set(e),i=Oe(),o=new Set,r=i.currentNode;for(;(r=i.nextNode())&&n.size>0;)for(let a of n){let l=At(r,a);if(!l||o.has(l.rootElement))continue;o.add(l.rootElement);let d=l.rootElement.getBoundingClientRect();t.set(a,d.top+window.scrollY),n.delete(a);break}for(let a of n)t.set(a,1/0);return t}function Oe(){return document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode(e){return e.closest("#devtools-toolbar, #devtools-canvas, #devtools-scrim, [data-popmelt-panel]")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}})}function q(e,t){return e.style.getPropertyValue(t)!==""}function Vn(e,t=30){if(e<=0)return[];let n=[],i=Oe(),o=.5,r=i.currentNode;for(;(r=i.nextNode())&&n.length<t;){let a=r,l=a.getBoundingClientRect();if(l.bottom<-50||l.top>window.innerHeight+50||l.right<-50||l.left>window.innerWidth+50||l.width<1||l.height<1)continue;let d=getComputedStyle(a);!q(a,"padding-top")&&Math.abs((parseFloat(d.paddingTop)||0)-e)<o&&n.push({element:a,property:"padding-top"}),!q(a,"padding-bottom")&&Math.abs((parseFloat(d.paddingBottom)||0)-e)<o&&n.length<t&&n.push({element:a,property:"padding-bottom"}),!q(a,"padding-left")&&Math.abs((parseFloat(d.paddingLeft)||0)-e)<o&&n.length<t&&n.push({element:a,property:"padding-left"}),!q(a,"padding-right")&&Math.abs((parseFloat(d.paddingRight)||0)-e)<o&&n.length<t&&n.push({element:a,property:"padding-right"}),!q(a,"margin-top")&&Math.abs((parseFloat(d.marginTop)||0)-e)<o&&n.length<t&&n.push({element:a,property:"margin-top"}),!q(a,"margin-bottom")&&Math.abs((parseFloat(d.marginBottom)||0)-e)<o&&n.length<t&&n.push({element:a,property:"margin-bottom"}),!q(a,"margin-left")&&Math.abs((parseFloat(d.marginLeft)||0)-e)<o&&n.length<t&&n.push({element:a,property:"margin-left"}),!q(a,"margin-right")&&Math.abs((parseFloat(d.marginRight)||0)-e)<o&&n.length<t&&n.push({element:a,property:"margin-right"});let s=d.display;if((s.includes("flex")||s.includes("grid"))&&n.length<t){let c=q(a,"gap"),h=parseFloat(d.gap)||0,u=parseFloat(d.rowGap)||0,f=parseFloat(d.columnGap)||0;!c&&Math.abs(h-e)<o?n.push({element:a,property:"gap"}):!q(a,"row-gap")&&Math.abs(u-e)<o?n.push({element:a,property:"row-gap"}):!q(a,"column-gap")&&Math.abs(f-e)<o&&n.push({element:a,property:"column-gap"})}}return n}function Gn(e){return typeof e=="string"?{value:e}:e}var Rt={gap:["gap","row-gap","column-gap"],padding:["padding-top","padding-bottom","padding-left","padding-right"],margin:["margin-top","margin-bottom","margin-left","margin-right"]};function Nt(e,t){let n=Rt[t];return n?n.includes(e):!1}function Jn(e,t){let n=e.split(/\s+/);for(let i of n){if(i===t)return!0;let o=i.lastIndexOf(":");if(o>=0&&i.slice(o+1)===t)return!0}return!1}function Zn(e){let t=e.lastIndexOf(":"),n=t>=0?e.slice(t+1):e,i=n.indexOf("-");if(i<0)return null;let o=n.slice(0,i),r={gap:"gap","gap-x":"column-gap","gap-y":"row-gap",p:"padding",pt:"padding-top",pb:"padding-bottom",pl:"padding-left",pr:"padding-right",px:"padding-left",py:"padding-top",m:"margin",mt:"margin-top",mb:"margin-bottom",ml:"margin-left",mr:"margin-right",mx:"margin-left",my:"margin-top"},a=n.slice(0,n.indexOf("-",i+1)>0?n.indexOf("-",i+1):i);return r[a]??r[o]??null}function eo(e,t=30){let n=parseFloat(e.value);if(isNaN(n)||n<=0)return[];if(e.bindings&&e.bindings.length>0){let o=[],r=Oe(),a=r.currentNode;for(;(a=r.nextNode())&&o.length<t;){let l=a,d=l.getBoundingClientRect();if(d.bottom<-50||d.top>window.innerHeight+50||d.right<-50||d.left>window.innerWidth+50||d.width<1||d.height<1)continue;let s=l.className;if(typeof s=="string")for(let c of e.bindings){if(!Jn(s,c))continue;let h=Zn(c);if(h&&!(e.property&&!Nt(h,e.property))){o.push({element:l,property:h});break}}}return o}let i=Vn(n,t*2);return e.property?i.filter(o=>Nt(o.property,e.property)).slice(0,t):i.slice(0,t)}function to(e,t){let n=new Set,i=we(t);for(let o of e){let r=Lt[o.property];if(!r)continue;let a=o.element.className;if(typeof a=="string")for(let l of r){let d=`${l}-${i}`;for(let s of a.split(/\s+/)){let c=s.lastIndexOf(":"),h=c>=0?s.slice(c+1):s;if(h===d){n.add(h);break}}}}return[...n]}function no(e){let t=new Set;for(let n of e)for(let[i,o]of Object.entries(Rt))if(o.includes(n.property)){t.add(i);break}if(t.size===1)return[...t][0]}function oo(e,t,n){if(t===n)return e;let i=we(t),o=we(n);return e.map(r=>{let a=r.lastIndexOf("-");if(a<0)return r;let l=r.slice(0,a),d=r.slice(a+1);return d===i||d===`[${t}px]`?`${l}-${o}`:r})}var io={0:"0",1:"px",2:"0.5",4:"1",6:"1.5",8:"2",12:"3",16:"4",20:"5",24:"6",28:"7",32:"8",40:"10",48:"12",64:"16",80:"20",96:"24"};function we(e){return io[e]??`[${e}px]`}var Lt={"padding-top":["pt","py","p"],"padding-bottom":["pb","py","p"],"padding-left":["pl","px","p"],"padding-right":["pr","px","p"],"margin-top":["mt","my","m"],"margin-bottom":["mb","my","m"],"margin-left":["ml","mx","m"],"margin-right":["mr","mx","m"],gap:["gap"],"row-gap":["gap-y","gap"],"column-gap":["gap-x","gap"]};function ao(e,t,n,i){let o=Lt[t];if(!o)return null;let r=we(n);for(let a of o){let l=new RegExp("(?:^|\\s)((?:[\\w-]+:)*"+a+"-(?:"+ro(r)+"|\\["+n+"px\\]))(?:\\s|$)"),d=e.match(l);if(d?.[1]){let s=we(i),c=d[1].lastIndexOf(":"),h=c>=0?d[1].slice(0,c+1):"";return{matched:d[1],suggested:`${h}${a}-${s}`}}}return null}function ro(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lo(e,t,n){let i=new Set,o=[];for(let r of e){let a=Q(r.element),l=`${a}::${r.property}`;if(i.has(l))continue;i.add(l);let d=An(r.element),s=r.element.className||"",c=ao(s,r.property,t,n);o.push({selector:a,reactComponent:d?.name,className:s,property:r.property,matchedClass:c?.matched,suggestedClass:c?.suggested})}return o}function so(e){let t=window.getComputedStyle(e).display;return t==="flex"||t==="inline-flex"||t==="grid"||t==="inline-grid"}function po(e){let t=window.getComputedStyle(e);return{row:parseFloat(t.rowGap)||0,column:parseFloat(t.columnGap)||0}}function co(e){let t=[];for(let n of e){let i=t.find(o=>o.axis!==n.axis?!1:n.axis==="row"?Math.abs(o.y-n.y)<2&&Math.abs(o.h-n.h)<2:Math.abs(o.x-n.x)<2&&Math.abs(o.w-n.w)<2);if(i)if(n.axis==="row"){let o=Math.min(i.x,n.x),r=Math.max(i.x+i.w,n.x+n.w);i.x=o,i.w=r-o}else{let o=Math.min(i.y,n.y),r=Math.max(i.y+i.h,n.y+n.h);i.y=o,i.h=r-o}else t.push({...n})}return t}function uo(e){let t=Array.from(e.children).filter(l=>{if(!(l instanceof HTMLElement))return!1;let d=window.getComputedStyle(l);return d.display!=="none"&&d.position!=="absolute"&&d.position!=="fixed"});if(t.length<2)return[];let n=[],i=e.getBoundingClientRect(),o=window.getComputedStyle(e).flexDirection,r=o==="column"||o==="column-reverse",a=6;for(let l=0;l<t.length-1;l++){let d=t[l].getBoundingClientRect(),s=t[l+1].getBoundingClientRect();if(s.left>d.right+.5&&n.push({axis:"column",x:d.right,y:i.top,w:s.left-d.right,h:i.height}),s.top>d.bottom+.5&&n.push({axis:"row",x:i.left,y:d.bottom,w:i.width,h:s.top-d.bottom}),!(s.left>d.right+.5)&&!(s.top>d.bottom+.5))if(r){let c=(d.bottom+s.top)/2;n.push({axis:"row",x:i.left,y:c-a/2,w:i.width,h:a})}else{let c=(d.right+s.left)/2;n.push({axis:"column",x:c-a/2,y:i.top,w:a,h:i.height})}}return co(n)}function fo(e,t){let n=window.getComputedStyle(e),i=n.display;if(i!=="flex"&&i!=="inline-flex")return!1;let o=n.justifyContent;if(o!=="space-between"&&o!=="space-around"&&o!=="space-evenly"&&o!=="stretch")return!1;let r=n.flexDirection;return!(t!==(r==="column"||r==="column-reverse"?"row":"column")||parseFloat(t==="row"?n.rowGap:n.columnGap)>0)}function ho(e){let t=window.getComputedStyle(e);return{top:parseFloat(t.paddingTop)||0,right:parseFloat(t.paddingRight)||0,bottom:parseFloat(t.paddingBottom)||0,left:parseFloat(t.paddingLeft)||0}}function go(e){let t=window.getComputedStyle(e);return{top:parseFloat(t.marginTop)||0,right:parseFloat(t.marginRight)||0,bottom:parseFloat(t.marginBottom)||0,left:parseFloat(t.marginLeft)||0}}function Ot(e){let t=window.getComputedStyle(e);return{topLeft:t.borderTopLeftRadius,topRight:t.borderTopRightRadius,bottomRight:t.borderBottomRightRadius,bottomLeft:t.borderBottomLeftRadius}}function Dt(e){let t=window.getComputedStyle(e);return{"top-left":parseFloat(t.borderTopLeftRadius)||0,"top-right":parseFloat(t.borderTopRightRadius)||0,"bottom-right":parseFloat(t.borderBottomRightRadius)||0,"bottom-left":parseFloat(t.borderBottomLeftRadius)||0}}function mo(e){for(let t of e.childNodes)if(t.nodeType===Node.TEXT_NODE&&(t.textContent||"").trim().length>0)return!0;return!1}function yo(e){let t=document.createRange(),n=!1;for(let c of e.childNodes)c.nodeType===Node.TEXT_NODE&&(c.textContent||"").trim().length>0&&(n||(t.setStart(c,0),n=!0),t.setEnd(c,c.textContent?.length??0));if(!n)return null;let i=t.getBoundingClientRect(),o=window.getComputedStyle(e),r=parseFloat(o.fontSize)||16,a=parseFloat(o.lineHeight);isNaN(a)&&(a=r*1.2);let l=Math.max(1,t.getClientRects().length),d=Math.max(i.height,l*a),s=(d-i.height)/2;return new DOMRect(i.x,i.y-s,i.width,d)}function xo(e){let t=window.getComputedStyle(e),n=parseFloat(t.fontSize)||16,i=parseFloat(t.lineHeight);return isNaN(i)&&(i=n*1.2),{fontSize:n,lineHeight:i}}function wo(e){let t=e.startsWith("top-");return{top:t?4:12,right:4,bottom:t?12:4,left:4}}function vo({hasCommentEntry:e,stagedChangeCount:t}){return e&&t===0?2:6}function bo({annotationNumber:e,stickerCount:t,interactionEpisodeStepCount:n,hasStatus:i,hasSend:o,controlGap:r}){let a=16+Math.max(1,e===void 0?0:String(e).length)*7.2,l=t*28-Math.max(0,t-1)*2,d=n>0?32+String(n).length*7.2:0,s=28,c=t>0?l+(d>0?d-2:0)+(o?s-2:0):0,h=[t>0?c:0,t===0?d:0,t===0&&o?s:0,i?s:0].filter(u=>u>0);return a+h.reduce((u,f)=>u+f,0)+h.length*r}function So(e,t,n){let i=e.horizontalAlignment==="right"?e.left-t:e.left;return{left:i,top:e.top,right:i+t,bottom:e.top+n}}function Io(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}function Mo(e,t,n){let i=Math.max(0,e.left+t-n);return Math.max(0,t-e.right)<i?"right":"left"}function $t(e,t,n,i,o=0,r=Number.POSITIVE_INFINITY){if(e.height>=i)return{anchor:"top-left",horizontalAlignment:"left",left:e.left+8,top:e.top+8};let a=Mo(e,o,r);return e.top>=t+n?{anchor:a==="right"?"top-right":"top-left",horizontalAlignment:a,left:a==="right"?e.right:e.left,top:e.top-t-n}:{anchor:a==="right"?"bottom-right":"bottom-left",horizontalAlignment:a,left:a==="right"?e.right:e.left,top:e.bottom+n}}function Qe(e){return e.left+e.width}function De(e){return e.top+e.height}function Ve(e,t){if(e.length===0)return t;let n=Math.min(...e.map(a=>a.left)),i=Math.min(...e.map(a=>a.top)),o=Math.max(...e.map(Qe)),r=Math.max(...e.map(De));return{left:n,top:i,width:o-n,height:r-i}}function Ge(e){let t=[...e].sort((i,o)=>i.top-o.top||i.left-o.left),n=[];for(let i of t){let o=i.top+i.height/2,r=n.find(c=>{let h=c.top+c.height/2;return Math.abs(o-h)<=Math.max(c.height,i.height)*.4});if(!r){n.push({...i});continue}let a=Math.min(r.left,i.left),l=Math.min(r.top,i.top),d=Math.max(Qe(r),Qe(i)),s=Math.max(De(r),De(i));r.left=a,r.top=l,r.width=d-a,r.height=s-l}return n.sort((i,o)=>i.top-o.top||i.left-o.left)}function To({display:e,fragmentRects:t,elementRect:n,parentContentRect:i}){let o=Ge(t),r=Ve(o,n);if(!(e==="inline"&&o.length>1&&i&&i.width>0))return{textRect:r,boundaryRect:n,boundaryRects:[n],firstLineIndent:0};let a=o[0],l={left:i.left,top:a.top,width:i.width,height:Math.max(r.height,De(r)-a.top)},d=Math.max(0,Math.min(l.width,a.left-l.left));return{textRect:r,boundaryRect:Ve(o,n),boundaryRects:o,flowRect:l,firstLineIndent:d}}var Je=new WeakMap;function ko(e){let t={listeners:new Set,rafId:null,schedule:()=>{t.rafId===null&&(t.rafId=e.requestAnimationFrame(()=>{t.rafId=null;for(let n of t.listeners)n()}))}};return Je.set(e,t),e.addEventListener("scroll",t.schedule,{passive:!0,capture:!0}),e.addEventListener("resize",t.schedule),t}function _t(e,t=window){let n=Je.get(t)??ko(t);return n.listeners.add(e),()=>{n.listeners.delete(e)&&(n.listeners.size>0||(t.removeEventListener("scroll",n.schedule,!0),t.removeEventListener("resize",n.schedule),n.rafId!==null&&t.cancelAnimationFrame(n.rafId),Je.delete(t)))}}var se={topLeft:"0px",topRight:"0px",bottomRight:"0px",bottomLeft:"0px"};function Ft(e,t){return e.radii.topLeft!==t.radii.topLeft||e.radii.topRight!==t.radii.topRight||e.radii.bottomRight!==t.radii.bottomRight||e.radii.bottomLeft!==t.radii.bottomLeft||e.outline!==t.outline||e.fragments.length!==t.fragments.length?!1:e.fragments.every((n,i)=>{let o=t.fragments[i];return!!o&&n.left===o.left&&n.top===o.top&&n.width===o.width&&n.height===o.height})}function Pt(e){if(!e.isConnected||!Dn(e.ownerDocument))return{fragments:[],radii:se};let t=Tt(Ee(e),e.ownerDocument);if(Mt(e.ownerDocument)&&(!t.width||!t.height))return{fragments:[],radii:se};if(e.getAttribute("data-popmelt-subject-projection")==="true")return{fragments:[{left:t.left,top:t.top,width:t.width,height:t.height}],radii:se,outline:e.getAttribute("data-popmelt-subject-outline")??void 0};let n=Array.from(e.getClientRects()).map(i=>Tt(Ce(i,e.ownerDocument),e.ownerDocument)).filter(i=>i.width>0&&i.height>0).map(i=>({left:i.left,top:i.top,width:i.width,height:i.height}));return{fragments:Ge(n.length>0?n:[{left:t.left,top:t.top,width:t.width,height:t.height}]),radii:Ot(e)}}function zt({element:e,projectedRect:t,isSelected:n=!1,elementInfo:i,color:o="#3b82f6",annotationNumber:r,changeCount:a,hideTooltip:l=!1,hideOutline:d=!1,hideFill:s=!1,fillOpacity:c=.05,subjectRegistry:h,railGap:u=2,railHeight:f=22,railWidth:y=0,renderRail:m,refreshKey:g,outlineZIndex:k=9996,onActivate:w,onRemove:v}){let I=de(xe),[b,C]=re({fragments:[],radii:se});V(()=>{if(!I)return;if(!e){C({fragments:[],radii:se});return}let P=null,H=()=>{let ee=Pt(e);C(Te=>Ft(Te,ee)?Te:ee)},E=()=>{P===null&&(P=requestAnimationFrame(()=>{P=null,H()}))};H();let fe=e.getAttribute("data-popmelt-subject-projection")==="true"&&!!h,he=fe?h.subscribeFrame(H):void 0,ge=fe||typeof ResizeObserver>"u"?null:new ResizeObserver(E);ge?.observe(e);let B=fe?null:new MutationObserver(E);B?.observe(e,{attributes:!0,attributeFilter:["style","class"]});let ae=_t(H,e.ownerDocument.defaultView??window),me=Mt(e.ownerDocument)?Ue(H):void 0;return()=>{ae(),me?.(),he?.(),ge?.disconnect(),B?.disconnect(),P!==null&&cancelAnimationFrame(P)}},[I,e,h]),Ct(()=>{if(!I||!e||g===void 0)return;let P=Pt(e);C(H=>Ft(H,P)?H:P)},[I,e,g]);let{fragments:N,radii:z}=t?{fragments:[t],radii:se}:b;if(N.length===0||!e&&!t)return null;let A=Ve(N,N[0]),T=e?.tagName.toLowerCase()??"",X=e?.id?`#${e.id}`:"",oe=e&&e.classList.length>0?"."+Array.from(e.classList).slice(0,2).join("."):"",ie=i?.reactComponent,Se=e?.getAttribute("data-popmelt-subject-adapter"),Ie=e?.getAttribute("data-popmelt-subject-label"),Pe=Se&&Ie?`<${Ie}>`:ie?`<${ie}> ${T}${X}${oe}`:`${T}${X}${oe}`,Z=$t({left:A.left,right:A.left+A.width,top:A.top,bottom:A.top+A.height,height:A.height},f,u,window.innerHeight,y,window.innerWidth),Me={zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:o,color:"#fff",fontSize:12,fontFamily:je,lineHeight:"14px",padding:"4px 8px",borderRadius:8,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400,position:"fixed",top:Z.top,left:Z.left},ze=!l&&R("div",{ref:P=>{e&&Nn(e,P)},"data-devtools":"tooltip",style:Me,children:[r!==void 0&&R("span",{children:[r,"."]}),x("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:Pe}),a!==void 0&&a>0&&R("span",{style:{opacity:.8},children:["(",a," ",a===1?"change":"changes",")"]})]});return R(W,{children:[!d&&N.map((P,H)=>x("div",{"data-devtools":"highlight",onContextMenu:v?E=>{E.preventDefault(),E.stopPropagation(),v()}:void 0,role:w?"button":void 0,tabIndex:w?0:void 0,"aria-label":w?"Open annotation thread":void 0,onPointerDown:w?E=>{E.preventDefault(),E.stopPropagation()}:void 0,onClick:w?E=>{E.preventDefault(),E.stopPropagation(),w()}:void 0,onKeyDown:w?E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),E.stopPropagation(),w())}:void 0,style:{position:"fixed",top:P.top,left:P.left,width:P.width,height:P.height,pointerEvents:w||v?"auto":"none",cursor:w?"pointer":void 0,zIndex:k,overflow:"visible"},children:x("div",{style:b.outline?{position:"absolute",inset:0,pointerEvents:"none"}:{position:"absolute",inset:0,boxSizing:"border-box",backgroundColor:s?"transparent":Xe(o,c),borderColor:o,borderStyle:n?"solid":"dashed",borderWidth:1,borderTopLeftRadius:z.topLeft,borderTopRightRadius:z.topRight,borderBottomRightRadius:z.bottomRight,borderBottomLeftRadius:z.bottomLeft,pointerEvents:"none"},children:b.outline?x("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",style:{display:"block",overflow:"visible"},"aria-hidden":"true",children:x("polygon",{points:b.outline,fill:s?"transparent":Xe(o,c),stroke:o,strokeWidth:1,strokeDasharray:n?void 0:"4 3",vectorEffect:"non-scaling-stroke"})}):null})},`${P.left}:${P.top}:${H}`)),m?m(Z,A):ze]})}function Bt(e){return e==="bottom-left"?[2,8,8,8]:e==="bottom-right"?[8,2,8,8]:e==="top-right"?[8,8,2,8]:[8,8,8,2]}function Eo(e){return Bt(e).map(t=>`${t}px`).join(" ")}var ve=1.1666666666666667,Ht=2048;function Ze(e){return e.length>Ht?`${e.slice(0,Ht)}\u2026`:e}function Co(e,t,n){let i=Ze(t);if(!i||e.measureText(i).width<=n)return[i];let o=i.split(/\s+/),r=[],a="";for(let l of o){let d=a?`${a} ${l}`:l;a&&e.measureText(d).width>n?(r.push(a),a=l):a=d}return a&&r.push(a),r.length>0?r:[i]}function Ao(e,t,n){return t.flatMap(i=>Co(e,i,n))}var ne=je,et=400,Wt=16,tt=60,Ro=12,nt=16;function jt(e){let t=window.innerWidth-e-Wt;return Math.max(tt,Math.min(et,t))}function ot(e,t,n){let i=Ze(t);if(i===t&&e.measureText(i).width<=n)return i;let o="\u2026",r=0,a=i.endsWith(o)?i.length-1:i.length;for(;r<a;){let l=Math.ceil((r+a)/2);e.measureText(i.slice(0,l)+o).width<=n?r=l:a=l-1}return r>0?i.slice(0,r)+o:o}function No(e,t,n){if(e===void 0||t===void 0||n.avoidLeft===void 0&&n.avoidRight===void 0)return!0;let i=typeof window<"u"?window.innerWidth:9999,o=n.avoidLeft??0,r=n.avoidRight??i;return e+t>o&&e<r}function Yt(e,t,n,i,o){let r=typeof window<"u"?window.innerHeight:9999,a=0,l=r;n&&No(i,o,n)&&(a=n.avoidTop??a,l=n.avoidBottom??l);let d=Math.max(a,l-t);return Math.max(a,Math.min(e,d))}function qt(e,t=12,n,i){let o=t*ve+8,r=e.y-4,a=e.x-8,l=Yt(r,o,n,a,i);return l===r?e:{...e,y:l+4}}function Lo(e,t,n,i,o=12,r,a,l,d="#dddddd",s,c=!1){if(!n)return;let h=o*ve,u=n.replace(/\n/g," "),f=r!==void 0?r+". "+u:u;e.font=`${o}px ${ne}`,e.textBaseline="middle";let y=a!==void 0?Math.min(et,Math.max(tt,window.innerWidth-a-Wt)):et,m=c?nt:0,g=ot(e,f,Math.max(tt,y-m)),k=e.measureText(g).width,w=m+k,v=qt(t,o,l,w+16);e.fillStyle=i;let I=v.x-8,b=v.y-4,C=w+16,N=h+8;e.beginPath(),e.roundRect(I,b,C,N,Bt(s)),e.fill();let z=v.y+h/2;if(c){let A=v.x,T=z-Ro/2;e.strokeStyle=d,e.lineWidth=1.5,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(A+7.5,T+4),e.lineTo(A+10.5,T+6.5),e.lineTo(A+7.5,T+9),e.moveTo(A+1.5,T+1.5),e.lineTo(A+1.5,T+4.5),e.quadraticCurveTo(A+1.5,T+6.5,A+3.5,T+6.5),e.lineTo(A+10.5,T+6.5),e.stroke()}e.fillStyle=d,e.fillText(g,v.x+m,z)}function Oo(e,t,n){let i=e.filter(o=>!o.captured&&o.selector===t&&(!o.pathname||o.pathname===n));return i.length?{type:"MODIFY_TEXT_CONTENTS",payload:i.map(o=>({...o,modified:o.original}))}:null}function Kt(e,t){return e.type!=="text"?!1:(e.groupId?t.filter(n=>n.groupId===e.groupId):[e]).every(n=>(n.status??"pending")==="pending"&&!n.threadId)}var Ut=Ke(0),it=`
3
3
  0%, 100% { translate: 0 0; }
4
4
  20% { translate: -4px 0; }
5
5
  45% { translate: 4px 0; }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{createHash as x}from"crypto";import{mkdir as l,readFile as u,readdir as S,stat as m,writeFile as I}from"fs/promises";import{tmpdir as C}from"os";import{join as a}from"path";function b(t,e,n){let s=new Map(t.candidates.map(r=>[r.storeId,r])),o=s.get(e);if(!o)return null;let i=[...new Set(n)].filter(r=>r!==e);return i.some(r=>!s.has(r))?null:{primary:o,mountedStores:i.map(r=>{let d=s.get(r);return{storeId:d.storeId,projectRoot:d.root,projectId:d.projectId}})}}function c(){return process.env.POPMELT_CODEX_SESSION_DIR||a(C(),"popmelt-core","codex-sessions")}function p(t){let e=x("sha256").update(t).digest("hex");return a(c(),`${e}.json`)}function j(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.storeId=="string"&&!!e.storeId&&typeof e.projectRoot=="string"&&!!e.projectRoot&&typeof e.projectId=="string"&&!!e.projectId}function w(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return typeof e.root=="string"&&!!e.root&&typeof e.storeId=="string"&&!!e.storeId&&typeof e.projectId=="string"&&!!e.projectId&&typeof e.reason=="string"&&Array.isArray(e.reasons)&&e.reasons.every(n=>typeof n=="string")&&typeof e.initialized=="boolean"}function P(t){if(typeof t.sessionId!="string"||!t.sessionId||typeof t.projectRoot!="string"||!t.projectRoot||typeof t.projectId!="string"||!t.projectId||!Number.isInteger(t.bridgePort)||typeof t.updatedAt!="string"||Number.isNaN(Date.parse(t.updatedAt)))return null;let e=Array.isArray(t.mountedStores)?t.mountedStores.filter(j):[],n=t.orientation==="automatic"||t.orientation==="explicit"||t.orientation==="workspace_default"?t.orientation:"legacy";return{version:2,status:"active",sessionId:t.sessionId,storeId:typeof t.storeId=="string"&&t.storeId?t.storeId:`store-${t.projectId}`,projectRoot:t.projectRoot,projectId:t.projectId,bridgePort:t.bridgePort,mountedStores:e,orientation:n,updatedAt:t.updatedAt}}function g(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return e.status==="orientation_required"?e.version!==2||typeof e.sessionId!="string"||!e.sessionId||typeof e.cwd!="string"||!e.cwd||!Array.isArray(e.candidates)||!e.candidates.every(w)||typeof e.updatedAt!="string"||Number.isNaN(Date.parse(e.updatedAt))?null:e:P(e)}async function f(t){let e=c();await l(e,{recursive:!0,mode:448}),await I(p(t.sessionId),`${JSON.stringify(t,null,2)}
3
+ `,{encoding:"utf8",mode:384})}async function h(t){await f(t)}async function N(t){await f(t)}async function y(t){try{let e=JSON.parse(await u(p(t),"utf8")),n=g(e);return n?.sessionId===t?n:null}catch{return null}}async function k(t){let e=await y(t);return e?.status==="active"?e:null}async function M(t){let e=await y(t);return e?.status==="orientation_required"?e:null}async function _(){let t=c(),n=(await S(t,{withFileTypes:!0}).catch(o=>{if(o.code==="ENOENT")return[];throw o})).filter(o=>o.isFile()&&/^[a-f0-9]{64}\.json$/.test(o.name));if(n.length>2048)throw new Error("Session registry exceeds discovery limit");return(await Promise.all(n.map(async o=>{let i=a(t,o.name);try{if((await m(i)).size>65536)return null;let r=g(JSON.parse(await u(i,"utf8")));return r?.status==="active"&&p(r.sessionId)===i?r:null}catch{return null}}))).filter(o=>o!==null)}export{b as a,h as b,N as c,y as d,k as e,M as f,_ as g};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{A as p}from"./chunk-253MCKJJ.mjs";import{j as m}from"./chunk-XOGBFVWI.mjs";var o=!1,f=()=>o;function E(c){o=!0;let t=null,r=!1,a=e=>{let n=e.composedPath()[0];return n instanceof Element&&(n.id==="devtools-canvas"||!p(n)&&!n.closest("[data-taste-editor], [data-taste-navigation]"))},i=e=>{e.preventDefault(),e.stopImmediatePropagation()},l=e=>{t=null,!(e.button!==0||!a(e))&&(t={x:e.clientX,y:e.clientY},r=!1,i(e))},d=e=>{t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>5&&(r=!0)},u=e=>{t&&i(e)},s=e=>{if(!a(e)||e.button!==0){t=null;return}i(e);let n=!!(t&&!r);if(t=null,!n)return;let w=m(e.clientX,e.clientY);w&&c(w)},v=()=>{t=null};return window.addEventListener("pointerdown",l,!0),window.addEventListener("pointermove",d,!0),window.addEventListener("pointerup",u,!0),window.addEventListener("pointercancel",v,!0),window.addEventListener("click",s,!0),()=>{o=!1,window.removeEventListener("pointerdown",l,!0),window.removeEventListener("pointermove",d,!0),window.removeEventListener("pointerup",u,!0),window.removeEventListener("pointercancel",v,!0),window.removeEventListener("click",s,!0)}}export{f as a,E as b};
2
+ import{A as p}from"./chunk-GNZ73T3H.mjs";import{j as m}from"./chunk-EXDOFFFJ.mjs";var o=!1,f=()=>o;function E(c){o=!0;let t=null,r=!1,a=e=>{let n=e.composedPath()[0];return n instanceof Element&&(n.id==="devtools-canvas"||!p(n)&&!n.closest("[data-taste-editor], [data-taste-navigation]"))},i=e=>{e.preventDefault(),e.stopImmediatePropagation()},l=e=>{t=null,!(e.button!==0||!a(e))&&(t={x:e.clientX,y:e.clientY},r=!1,i(e))},d=e=>{t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>5&&(r=!0)},u=e=>{t&&i(e)},s=e=>{if(!a(e)||e.button!==0){t=null;return}i(e);let n=!!(t&&!r);if(t=null,!n)return;let w=m(e.clientX,e.clientY);w&&c(w)},v=()=>{t=null};return window.addEventListener("pointerdown",l,!0),window.addEventListener("pointermove",d,!0),window.addEventListener("pointerup",u,!0),window.addEventListener("pointercancel",v,!0),window.addEventListener("click",s,!0),()=>{o=!1,window.removeEventListener("pointerdown",l,!0),window.removeEventListener("pointermove",d,!0),window.removeEventListener("pointerup",u,!0),window.removeEventListener("pointercancel",v,!0),window.removeEventListener("click",s,!0)}}export{f as a,E as b};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{c as f}from"./chunk-X3UK5M3S.mjs";import{A as d,c as p}from"./chunk-SKOSDB5K.mjs";import{e as c}from"./chunk-IKCHOC3U.mjs";async function S(t,e){let r=await c(t);if(!r||!e)return[];let n=await p(t,e);return n.length?(await Promise.all([r,...r.mountedStores].map(async i=>{try{let o=await f(i,t);if(!o)return[];let{endpoint:u,request:m}=o,s=[];for(let l of n){let a=await d(u,"/participants/read-canvas-receipt",{...m,method:"POST",body:JSON.stringify({receiptId:l})});a.response.ok&&s.push({storeId:i.storeId,receipt:a.body})}return s}catch{return[]}}))).flat():[]}export{S as a};
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import{f as N}from"./chunk-J4WDYITA.mjs";import{l as W,d as z}from"./chunk-HGW2U6PD.mjs";import{destroyContext as F,domToCanvas as J,createContext as X}from"modern-screenshot";function A(t,e,n){if(t===null||typeof t=="string"||typeof t=="boolean")return;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Comment metadata at ${e} must be finite.`);return}if(typeof t!="object")throw new TypeError(`Comment metadata at ${e} must be JSON-serializable.`);if(n.has(t))throw new TypeError(`Comment metadata at ${e} contains a cycle.`);let r=Object.getPrototypeOf(t);if(!Array.isArray(t)&&r!==Object.prototype&&r!==null)throw new TypeError(`Comment metadata at ${e} must use plain objects and arrays.`);if(n.add(t),Array.isArray(t))t.forEach((i,o)=>A(i,`${e}[${o}]`,n));else for(let[i,o]of Object.entries(t))A(o,`${e}.${i}`,n);n.delete(t)}function q(t){if(t===void 0)return;if(t===null||Array.isArray(t)||typeof t!="object")throw new TypeError("Comment metadata must be a JSON object.");A(t,"meta",new Set);let e=JSON.stringify(t);if(new TextEncoder().encode(e).byteLength>65536)throw new RangeError("Comment metadata exceeds the 65536 byte limit.");return JSON.parse(e)}var S="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",G=1500,Q=5e3,K=24e6,V=16e3,Z=4,_=["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 tt(t,e){try{let n=await t();if(n)return n}catch{}return e()}var C=new Map,$=new WeakMap,et=1;function p(){return typeof performance<"u"?performance.now():Date.now()}function R(t){if(t?.debug!==void 0)return t.debug;if(typeof window>"u")return!1;try{return window.localStorage.getItem("popmelt:screenshot-debug")==="true"}catch{return!1}}function nt(t){let e=0,n=0;for(let r of t.querySelectorAll("img[src]"))P(r.currentSrc||r.src)&&(e++,(!r.complete||r.naturalWidth===0)&&n++);return{remoteImages:e,unresolvedRemoteImages:n}}function ot(t){return new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error??new Error("Asset could not be read")),r.readAsDataURL(t)})}function rt(t,e){let n=null;return async r=>{if(!P(r))return!1;n??(n=Date.now()+t);let i=n-Date.now();if(i<=0)return e(),S;let o=new AbortController,a=setTimeout(()=>o.abort(),i);try{let s=await fetch(r,{cache:"force-cache",mode:"cors",signal:o.signal});if(!s.ok)throw new Error(`Asset returned ${s.status}`);return await ot(await s.blob())}catch{return e(),S}finally{clearTimeout(a)}}}function at(t,e,n){let r=$.get(t);r||(r=et++,$.set(t,r));let i=e.filter(o=>(o.status??"pending")==="pending").map(o=>{let a=o.points[0],s=o.points[o.points.length-1];return`${o.id}:${o.points.length}:${a?.x??""}:${a?.y??""}:${s?.x??""}:${s?.y??""}`}).join("|");return[r,window.location.href,window.innerWidth,window.innerHeight,n?.dpr??window.devicePixelRatio??1,n?.viewportOnly?window.scrollY:"",i].join("::")}function it(t,e,n){let r=Math.min(e,n);return{top:Math.max(0,Math.min(t,n-r)),height:r,annotations:[]}}function P(t){if(typeof window>"u")return!1;try{let e=new URL(t,window.location.href);return e.protocol!=="http:"&&e.protocol!=="https:"?!1:e.origin!==window.location.origin}catch{return!1}}function lt(t){let e=document.createElement("canvas").getContext("2d");return e?(e.fillStyle=t,e.fillStyle):"#888888"}function j(t,e=[],n,r,i=[],o=[],a){let s=new Map,c=[];for(let l of t)if(l.groupId){let m=s.get(l.groupId)||[];m.push(l),s.set(l.groupId,m)}else c.push(l);let u=[];for(let[l,m]of s){let h=m.find(d=>d.type!=="text"),g=m.find(d=>d.type==="text");if(h){let d=h.linkedSelector||g?.linkedSelector,f=g?.imageCount||h.imageCount,w=g?.attachments||h.attachments,y=g?.interactionEpisode||h.interactionEpisode,v=h.pathname||g?.pathname;u.push({id:h.id,type:h.type,instruction:g?.text,...d?{linkedSelector:d}:{},...h.target||g?.target?{target:h.target??g?.target}:{},...v?{pathname:v}:{},elements:h.elements||[],...f?{imageCount:f}:{},...w?.length?{attachments:w}:{},...y?{interactionEpisode:y}:{}})}}for(let l of c)u.push({id:l.id,type:l.type,instruction:l.type==="text"?l.text:void 0,...l.linkedSelector?{linkedSelector:l.linkedSelector}:{},...l.target?{target:l.target}:{},...l.pathname?{pathname:l.pathname}:{},elements:l.elements||[],...l.region?{region:l.region}:{},...l.imageCount?{imageCount:l.imageCount}:{},...l.attachments?.length?{attachments:l.attachments}:{},...l.interactionEpisode?{interactionEpisode:l.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:u,styleModifications:e,...i.length>0?{textModifications:i}:{},...o.length>0?{domModifications:o}:{},...n?{inspectedElement:n}:{},...r&&r.length>0?{spacingTokenChanges:r}:{},...a?{meta:a}:{}}}function st(t){if(!t.points||t.points.length===0)return null;let e=[...t.points,...t.region?.points??[]],n=e.map(i=>i.x),r=e.map(i=>i.y);return{minX:Math.min(...n),minY:Math.min(...r),maxX:Math.max(...n),maxY:Math.max(...r)}}function ct(t,e){if(t.length===0)return[];let n=t.map(l=>({annotation:l,bounds:st(l)})).filter(l=>l.bounds!==null);if(n.length===0)return[];n.sort((l,m)=>l.bounds.minY-m.bounds.minY);let r=Math.min(...n.map(l=>l.bounds.minY)),i=Math.max(...n.map(l=>l.bounds.maxY));if(i-r<=e){let l=(r+i)/2,m=Math.max(0,l-e/2);return[{top:m,bottom:m+e,annotations:t}]}let o=[],a=50,s=Math.max(0,r-a),c=[],u=s;for(let{annotation:l,bounds:m}of n){let h=m.maxY+a;if(h-s<=e)c.push(l),u=Math.max(u,h);else{if(c.length>0){let g=(s+u)/2,d=Math.max(0,g-e/2);o.push({top:d,bottom:d+e,annotations:c})}s=Math.max(0,m.minY-a),c=[l],u=m.maxY+a}}if(c.length>0){let l=(s+u)/2,m=Math.max(0,l-e/2);o.push({top:m,bottom:m+e,annotations:c})}return o}function dt(t){let e=new Map;for(let n of t)if(n.linkedSelector)try{let r=W(n.linkedSelector);if(r){let i=z(r);e.set(n.id,{x:i.left+window.scrollX,y:i.top+window.scrollY,width:i.width,height:i.height})}}catch{}return e}function T(t,e,n,r,i){if(t.save(),t.scale(r,r),i)for(let o of e){let a=i.get(o.id);if(!a)continue;let s=a.y-n;t.fillStyle=o.color,t.globalAlpha=.05,t.fillRect(a.x,s,a.width,a.height),t.globalAlpha=1,t.strokeStyle=o.color,t.lineWidth=1,t.setLineDash([2,4]),t.strokeRect(a.x,s,a.width,a.height),t.setLineDash([])}for(let o of e){let a=o.points.map(s=>({x:s.x,y:s.y-n}));switch(t.strokeStyle=o.color,t.fillStyle=o.color,t.lineWidth=o.strokeWidth,t.lineCap="round",t.lineJoin="round",o.region&&N(t,o.region.points.map(s=>({x:s.x,y:s.y-n})),o.color),o.type){case"freehand":if(a.length<2)break;t.beginPath(),t.moveTo(a[0].x,a[0].y);for(let s=1;s<a.length;s++)t.lineTo(a[s].x,a[s].y);t.stroke();break;case"line":if(a.length<2)break;t.beginPath(),t.moveTo(a[0].x,a[0].y),t.lineTo(a[a.length-1].x,a[a.length-1].y),t.stroke();break;case"rectangle":{if(a.length<2)break;let s=a[0],c=a[a.length-1],u=Math.min(s.x,c.x),l=Math.min(s.y,c.y),m=Math.abs(c.x-s.x),h=Math.abs(c.y-s.y);t.strokeRect(u,l,m,h);break}case"circle":{if(a.length<2)break;let s=a[0],c=a[a.length-1],u=(s.x+c.x)/2,l=(s.y+c.y)/2,m=Math.abs(c.x-s.x)/2,h=Math.abs(c.y-s.y)/2;t.beginPath(),t.ellipse(u,l,m,h,0,0,Math.PI*2),t.stroke();break}case"text":{if(!o.text||a.length<1)break;let s=a[0],c=o.fontSize||16;t.font=`${c}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=o.color;let u=(o.imageCount&&o.imageCount>0?`[${o.imageCount} image${o.imageCount>1?"s":""}] ${o.text}`:o.text).split(`
2
+ import{f as N}from"./chunk-J4WDYITA.mjs";import{l as W,d as z}from"./chunk-RCVAPQ7X.mjs";import{destroyContext as F,domToCanvas as J,createContext as X}from"modern-screenshot";function A(t,e,n){if(t===null||typeof t=="string"||typeof t=="boolean")return;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Comment metadata at ${e} must be finite.`);return}if(typeof t!="object")throw new TypeError(`Comment metadata at ${e} must be JSON-serializable.`);if(n.has(t))throw new TypeError(`Comment metadata at ${e} contains a cycle.`);let r=Object.getPrototypeOf(t);if(!Array.isArray(t)&&r!==Object.prototype&&r!==null)throw new TypeError(`Comment metadata at ${e} must use plain objects and arrays.`);if(n.add(t),Array.isArray(t))t.forEach((i,o)=>A(i,`${e}[${o}]`,n));else for(let[i,o]of Object.entries(t))A(o,`${e}.${i}`,n);n.delete(t)}function q(t){if(t===void 0)return;if(t===null||Array.isArray(t)||typeof t!="object")throw new TypeError("Comment metadata must be a JSON object.");A(t,"meta",new Set);let e=JSON.stringify(t);if(new TextEncoder().encode(e).byteLength>65536)throw new RangeError("Comment metadata exceeds the 65536 byte limit.");return JSON.parse(e)}var S="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",G=1500,Q=5e3,K=24e6,V=16e3,Z=4,_=["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 tt(t,e){try{let n=await t();if(n)return n}catch{}return e()}var C=new Map,$=new WeakMap,et=1;function p(){return typeof performance<"u"?performance.now():Date.now()}function R(t){if(t?.debug!==void 0)return t.debug;if(typeof window>"u")return!1;try{return window.localStorage.getItem("popmelt:screenshot-debug")==="true"}catch{return!1}}function nt(t){let e=0,n=0;for(let r of t.querySelectorAll("img[src]"))P(r.currentSrc||r.src)&&(e++,(!r.complete||r.naturalWidth===0)&&n++);return{remoteImages:e,unresolvedRemoteImages:n}}function ot(t){return new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>n(r.error??new Error("Asset could not be read")),r.readAsDataURL(t)})}function rt(t,e){let n=null;return async r=>{if(!P(r))return!1;n??(n=Date.now()+t);let i=n-Date.now();if(i<=0)return e(),S;let o=new AbortController,a=setTimeout(()=>o.abort(),i);try{let s=await fetch(r,{cache:"force-cache",mode:"cors",signal:o.signal});if(!s.ok)throw new Error(`Asset returned ${s.status}`);return await ot(await s.blob())}catch{return e(),S}finally{clearTimeout(a)}}}function at(t,e,n){let r=$.get(t);r||(r=et++,$.set(t,r));let i=e.filter(o=>(o.status??"pending")==="pending").map(o=>{let a=o.points[0],s=o.points[o.points.length-1];return`${o.id}:${o.points.length}:${a?.x??""}:${a?.y??""}:${s?.x??""}:${s?.y??""}`}).join("|");return[r,window.location.href,window.innerWidth,window.innerHeight,n?.dpr??window.devicePixelRatio??1,n?.viewportOnly?window.scrollY:"",i].join("::")}function it(t,e,n){let r=Math.min(e,n);return{top:Math.max(0,Math.min(t,n-r)),height:r,annotations:[]}}function P(t){if(typeof window>"u")return!1;try{let e=new URL(t,window.location.href);return e.protocol!=="http:"&&e.protocol!=="https:"?!1:e.origin!==window.location.origin}catch{return!1}}function lt(t){let e=document.createElement("canvas").getContext("2d");return e?(e.fillStyle=t,e.fillStyle):"#888888"}function j(t,e=[],n,r,i=[],o=[],a){let s=new Map,c=[];for(let l of t)if(l.groupId){let m=s.get(l.groupId)||[];m.push(l),s.set(l.groupId,m)}else c.push(l);let u=[];for(let[l,m]of s){let h=m.find(d=>d.type!=="text"),g=m.find(d=>d.type==="text");if(h){let d=h.linkedSelector||g?.linkedSelector,f=g?.imageCount||h.imageCount,w=g?.attachments||h.attachments,y=g?.interactionEpisode||h.interactionEpisode,v=h.pathname||g?.pathname;u.push({id:h.id,type:h.type,instruction:g?.text,...d?{linkedSelector:d}:{},...h.target||g?.target?{target:h.target??g?.target}:{},...v?{pathname:v}:{},elements:h.elements||[],...f?{imageCount:f}:{},...w?.length?{attachments:w}:{},...y?{interactionEpisode:y}:{}})}}for(let l of c)u.push({id:l.id,type:l.type,instruction:l.type==="text"?l.text:void 0,...l.linkedSelector?{linkedSelector:l.linkedSelector}:{},...l.target?{target:l.target}:{},...l.pathname?{pathname:l.pathname}:{},elements:l.elements||[],...l.region?{region:l.region}:{},...l.imageCount?{imageCount:l.imageCount}:{},...l.attachments?.length?{attachments:l.attachments}:{},...l.interactionEpisode?{interactionEpisode:l.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:u,styleModifications:e,...i.length>0?{textModifications:i}:{},...o.length>0?{domModifications:o}:{},...n?{inspectedElement:n}:{},...r&&r.length>0?{spacingTokenChanges:r}:{},...a?{meta:a}:{}}}function st(t){if(!t.points||t.points.length===0)return null;let e=[...t.points,...t.region?.points??[]],n=e.map(i=>i.x),r=e.map(i=>i.y);return{minX:Math.min(...n),minY:Math.min(...r),maxX:Math.max(...n),maxY:Math.max(...r)}}function ct(t,e){if(t.length===0)return[];let n=t.map(l=>({annotation:l,bounds:st(l)})).filter(l=>l.bounds!==null);if(n.length===0)return[];n.sort((l,m)=>l.bounds.minY-m.bounds.minY);let r=Math.min(...n.map(l=>l.bounds.minY)),i=Math.max(...n.map(l=>l.bounds.maxY));if(i-r<=e){let l=(r+i)/2,m=Math.max(0,l-e/2);return[{top:m,bottom:m+e,annotations:t}]}let o=[],a=50,s=Math.max(0,r-a),c=[],u=s;for(let{annotation:l,bounds:m}of n){let h=m.maxY+a;if(h-s<=e)c.push(l),u=Math.max(u,h);else{if(c.length>0){let g=(s+u)/2,d=Math.max(0,g-e/2);o.push({top:d,bottom:d+e,annotations:c})}s=Math.max(0,m.minY-a),c=[l],u=m.maxY+a}}if(c.length>0){let l=(s+u)/2,m=Math.max(0,l-e/2);o.push({top:m,bottom:m+e,annotations:c})}return o}function dt(t){let e=new Map;for(let n of t)if(n.linkedSelector)try{let r=W(n.linkedSelector);if(r){let i=z(r);e.set(n.id,{x:i.left+window.scrollX,y:i.top+window.scrollY,width:i.width,height:i.height})}}catch{}return e}function T(t,e,n,r,i){if(t.save(),t.scale(r,r),i)for(let o of e){let a=i.get(o.id);if(!a)continue;let s=a.y-n;t.fillStyle=o.color,t.globalAlpha=.05,t.fillRect(a.x,s,a.width,a.height),t.globalAlpha=1,t.strokeStyle=o.color,t.lineWidth=1,t.setLineDash([2,4]),t.strokeRect(a.x,s,a.width,a.height),t.setLineDash([])}for(let o of e){let a=o.points.map(s=>({x:s.x,y:s.y-n}));switch(t.strokeStyle=o.color,t.fillStyle=o.color,t.lineWidth=o.strokeWidth,t.lineCap="round",t.lineJoin="round",o.region&&N(t,o.region.points.map(s=>({x:s.x,y:s.y-n})),o.color),o.type){case"freehand":if(a.length<2)break;t.beginPath(),t.moveTo(a[0].x,a[0].y);for(let s=1;s<a.length;s++)t.lineTo(a[s].x,a[s].y);t.stroke();break;case"line":if(a.length<2)break;t.beginPath(),t.moveTo(a[0].x,a[0].y),t.lineTo(a[a.length-1].x,a[a.length-1].y),t.stroke();break;case"rectangle":{if(a.length<2)break;let s=a[0],c=a[a.length-1],u=Math.min(s.x,c.x),l=Math.min(s.y,c.y),m=Math.abs(c.x-s.x),h=Math.abs(c.y-s.y);t.strokeRect(u,l,m,h);break}case"circle":{if(a.length<2)break;let s=a[0],c=a[a.length-1],u=(s.x+c.x)/2,l=(s.y+c.y)/2,m=Math.abs(c.x-s.x)/2,h=Math.abs(c.y-s.y)/2;t.beginPath(),t.ellipse(u,l,m,h,0,0,Math.PI*2),t.stroke();break}case"text":{if(!o.text||a.length<1)break;let s=a[0],c=o.fontSize||16;t.font=`${c}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=o.color;let u=(o.imageCount&&o.imageCount>0?`[${o.imageCount} image${o.imageCount>1?"s":""}] ${o.text}`:o.text).split(`
3
3
  `),l=c*1.2,m=4,h=0;for(let g of u)h=Math.max(h,t.measureText(g).width);t.fillRect(s.x-m,s.y-m,h+m*2,u.length*l+m*2),t.fillStyle="#ffffff",u.forEach((g,d)=>{t.fillText(g,s.x,s.y+c+d*l)});break}}}t.restore()}async function mt(t,e,n=[],r){let i=at(t,n,r),o=C.get(i);if(o)return R(r)&&console.debug("[Screenshot] Reusing in-flight capture",i),o;let a=vt(t,n,r).finally(()=>C.delete(i));return C.set(i,a),a}function ht(){let t=getComputedStyle(document.documentElement).backgroundColor;return t&&t!=="rgba(0, 0, 0, 0)"&&t!=="transparent"?t:"#ffffff"}function ut(t){return t instanceof HTMLElement?t.id==="devtools-canvas"||t.id==="devtools-toolbar"||t.id==="devtools-scrim"?!1:t.dataset.devtools===void 0:!0}function gt(t,e,n,r){return t.length===0?[{top:Math.max(0,Math.min(r,Math.max(0,n-e))),height:Math.min(e,n||e),annotations:[]}]:t.map(i=>{let o=Math.min(e,n||e);return{top:Math.max(0,Math.min(i.top,Math.max(0,n-o))),height:o,annotations:i.annotations}})}function ft(t,e,n){if(t.length===0)return null;let r=Math.min(...t.map(a=>a.top)),i=Math.max(...t.map(a=>a.top+a.height))-r,o=e*i*n*n;return i>V||o>K?null:{top:r,height:i}}async function pt(t,e){let n=[];for(let r of t){let i=Object.getOwnPropertyDescriptor(r.element,"toDataURL");try{Object.defineProperty(r.element,"toDataURL",{configurable:!0,value:()=>r.dataUrl}),n.push(()=>{i?Object.defineProperty(r.element,"toDataURL",i):Reflect.deleteProperty(r.element,"toDataURL")})}catch{}}try{return await e()}finally{for(let r of n.reverse())r()}}async function wt(t,e,n,r,i,o,a,s){let c=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)>window.innerHeight*Z||t.querySelectorAll("*").length>2500,u=s?await s():[];return pt(u,()=>X(t,{autoDestruct:!1,filter:ut,features:{restoreScrollPosition:!0},onCloneNode:l=>{t===document.body&&(l.style.margin=getComputedStyle(t).margin)},onCloneEachNode:l=>{if(l.nodeType===1&&l.localName==="html"&&l.ownerDocument!==document){let m=l.style;m.overflow="hidden",m.display="inline-block",m.clipPath=`inset(0 round ${m.borderRadius||"0px"})`}},scale:r,backgroundColor:ht(),width:n,height:e.height,style:{transform:`translate(${-window.scrollX}px, ${-e.top}px)`,transformOrigin:"top left"},timeout:i,debug:o,includeStyleProperties:c?[..._]:null,fetchFn:rt(i,()=>{a.remoteAssetFallbacks++}),fetch:{requestInit:{cache:"force-cache"},placeholderImage:S}}))}async function yt(t,e,n){return t.width=n,t.height=e.height,t.style={transform:`translate(${-window.scrollX}px, ${-e.top}px)`,transformOrigin:"top left"},J(t)}async function bt(t,e,n){let r=document.createElement("canvas");r.width=e,r.height=n;let i=r.getContext("2d");if(!i)throw new Error("Canvas context unavailable");if(typeof createImageBitmap=="function"){let s=await createImageBitmap(t);return i.drawImage(s,0,0,e,n),s.close(),r}let o=new Image,a=URL.createObjectURL(t);try{return await new Promise((s,c)=>{o.onload=()=>s(),o.onerror=()=>c(new Error("Native screenshot could not be decoded")),o.src=a}),i.drawImage(o,0,0,e,n),r}finally{URL.revokeObjectURL(a)}}async function L(t,e,n,r,i,o){if(r?.nativeCapture){let u=p();try{let l=await r.nativeCapture({url:window.location.href,clip:{x:window.scrollX,y:t.top,width:e,height:t.height},scale:n});if(o.nativeMs+=p()-u,l)return o.mode=o.renderMs>0||o.contextMs>0?"mixed":"native",bt(l,Math.round(e*n),Math.round(t.height*n))}catch(l){o.nativeMs+=p()-u,R(r)&&console.debug("[Screenshot] Native capture unavailable; using DOM fallback",l)}}let a=await i(),s=p(),c=await yt(a,t,e);return o.renderMs+=p()-s,o.mode=o.mode==="native"?"mixed":"dom",c}function U(t,e,n,r,i,o){let a=document.createElement("canvas");a.width=Math.round(r*i),a.height=Math.round(n.height*i);let s=a.getContext("2d");if(!s)throw new Error("Canvas context unavailable");let c=Math.round((n.top-e)*i);return s.drawImage(t,0,c,a.width,a.height,0,0,a.width,a.height),T(s,n.annotations,n.top,i,o),a}function xt(t){if(t.length===1)return t[0];let e=document.createElement("canvas");e.width=t[0]?.width??0,e.height=t.reduce((i,o)=>i+o.height,0);let n=e.getContext("2d");if(!n)throw new Error("Canvas context unavailable");let r=0;for(let i of t)n.drawImage(i,0,r),r+=i.height;return e}function Mt(t,e="image/webp",n=.8){return new Promise(r=>t.toBlob(r,e,n))}async function vt(t,e,n){let r=p(),i=n?.dpr??(window.devicePixelRatio||1),o=window.innerWidth,a=window.innerHeight,s=Math.max(document.body.scrollHeight,document.documentElement.scrollHeight),c=Math.max(250,n?.mediaTimeoutMs??G),u=R(n),l=e.filter(b=>(b.status??"pending")==="pending"),m=dt(l),h=n?.viewportOnly?[it(window.scrollY,a,s)]:gt(ct(l,a),a,s,window.scrollY),g=nt(t),d={startedAt:r,mode:"dom",mediaTimeoutMs:c,ranges:h.length,...g,remoteAssetFallbacks:0,nativeMs:0,contextMs:0,renderMs:0,compositeMs:0,encodeMs:0};console.log("[Screenshot] Starting capture with",l.length,"active annotations (filtered",e.length-l.length,"captured);",`${h.length} range(s), ${g.remoteImages} remote image(s), ${g.unresolvedRemoteImages} unresolved`);let f=null,w=null,y=ft(h,o,i),v=y??h[0],E=async()=>{if(!f){let b=p();f=wt(t,v,o,i,c,u,d,n?.captureSurfaces).then(x=>(w=x,d.contextMs+=p()-b,x))}return f};try{let b=p(),x;if(y){let M=await L(y,o,i,n,E,d);x=h.map(k=>U(M,y.top,k,o,i,m))}else{x=[];for(let M of h){let k=await L(M,o,i,n,E,d);x.push(U(k,M.top,M,o,i,m))}}let Y=xt(x);d.compositeMs+=p()-b-d.renderMs-d.nativeMs-d.contextMs;let B=p(),I=await Mt(Y);d.encodeMs=p()-B;let O=p()-d.startedAt,H={mode:d.mode,totalMs:Math.round(O),mediaTimeoutMs:d.mediaTimeoutMs,ranges:d.ranges,remoteImages:d.remoteImages,unresolvedRemoteImages:d.unresolvedRemoteImages,remoteAssetFallbacks:d.remoteAssetFallbacks,nativeMs:Math.round(d.nativeMs),contextMs:Math.round(d.contextMs),renderMs:Math.round(d.renderMs),compositeMs:Math.max(0,Math.round(d.compositeMs)),encodeMs:Math.round(d.encodeMs),overBudget:O>Q};return console.log("[Screenshot] Capture complete",JSON.stringify(H)),I?[I]:[]}catch(b){return console.error("[Screenshot] Capture failed:",b),[]}finally{w&&F(w)}}async function D(t){if(t.length===0)return null;if(t.length===1)return t[0];let e=await Promise.all(t.map(s=>new Promise((c,u)=>{let l=new Image;l.onload=()=>c(l),l.onerror=u,l.src=URL.createObjectURL(s)}))),n=e[0].width,r=e.reduce((s,c)=>s+c.height,0),i=document.createElement("canvas");i.width=n,i.height=r;let o=i.getContext("2d");if(!o)return null;let a=0;for(let s of e)o.drawImage(s,0,a),a+=s.height,URL.revokeObjectURL(s.src);return new Promise(s=>{i.toBlob(c=>s(c),"image/webp",.8)})}async function kt(t,e,n,r,i){try{let o=Array.isArray(t)?t:[t];if(o.length===0)return!1;let a=await D(o);if(!a)return!1;let s=a;if(a.type!=="image/png"){let g=new Image,d=URL.createObjectURL(a);await new Promise(w=>{g.onload=()=>w(),g.src=d}),URL.revokeObjectURL(d);let f=document.createElement("canvas");f.width=g.naturalWidth,f.height=g.naturalHeight,f.getContext("2d").drawImage(g,0,0),s=await new Promise(w=>f.toBlob(y=>w(y),"image/png"))}let c={"image/png":s},u=e&&e.length>0,l=n&&n.length>0,m=r&&r.length>0,h=i&&i.length>0;if(u||l||m||h){let g=e?e.filter(d=>(d.status??"pending")==="pending"):[];if(g.length>0||l||m||h){let d=j(g,n||[],void 0,void 0,r||[],i||[]),f=new Blob([JSON.stringify(d,null,2)],{type:"text/plain"});c["text/plain"]=f}}return await navigator.clipboard.write([new ClipboardItem(c)]),!0}catch(o){return console.warn("Clipboard write failed:",o),!1}}export{q as a,tt as b,lt as c,j as d,T as e,mt as f,D as g,kt as h};