@popmelt.com/core 0.31.0 → 0.31.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/codex-plugin/.codex-plugin/plugin.json +1 -1
- package/dist/{ParticipantRuntime-PPIOE3NJ.mjs → ParticipantRuntime-BGVZAWZH.mjs} +1 -1
- package/dist/{PopmeltTasteConnectedPane-4WRVLYUV.mjs → PopmeltTasteConnectedPane-7YIHIFPE.mjs} +1 -1
- package/dist/{PreviewRuntime-JAZLAGQE.mjs → PreviewRuntime-QDA4OF67.mjs} +1 -1
- package/dist/bridge-entry.mjs +1 -1
- package/dist/{browser-runtime-OZCPXHEN.mjs → browser-runtime-VSD5R2HG.mjs} +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/{chunk-F3S6L45N.mjs → chunk-2TFOULRG.mjs} +1 -1
- package/dist/{chunk-G25T4PMF.mjs → chunk-7VW2KD6D.mjs} +1 -1
- package/dist/chunk-EXDOFFFJ.mjs +2 -0
- package/dist/chunk-F6AMPRUB.mjs +2 -0
- package/dist/chunk-GNZ73T3H.mjs +62 -0
- package/dist/{chunk-NE263MLG.mjs → chunk-IPR652AZ.mjs} +1 -1
- package/dist/{chunk-RXRZTZPN.mjs → chunk-JU7D4I76.mjs} +1 -1
- package/dist/{chunk-JQHZFDY5.mjs → chunk-MTQ5IWIK.mjs} +1 -1
- package/dist/{chunk-YM6BOUNF.mjs → chunk-Q5QRV4KJ.mjs} +3 -3
- package/dist/{chunk-PBQCGGJL.mjs → chunk-QENHLODE.mjs} +14 -29
- package/dist/{chunk-4AEU4OCH.mjs → chunk-QLN5IYRL.mjs} +1 -1
- package/dist/{chunk-SWTSMLHA.mjs → chunk-QTGE5KAA.mjs} +1 -1
- package/dist/chunk-RCVAPQ7X.mjs +2 -0
- package/dist/{chunk-A7DRONSB.mjs → chunk-SQA3PHME.mjs} +1 -1
- package/dist/{chunk-DPU2WFIZ.mjs → chunk-UZUYF4D5.mjs} +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/codex-note-context-SGNCDBK4.mjs +2 -0
- package/dist/{codex-project-3OAJJ7ZI.mjs → codex-project-PA5DEEPH.mjs} +1 -1
- package/dist/{focus-inspection-GJKMI6OE.mjs → focus-inspection-WPHGCN6Y.mjs} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/peer-client-BEU2VKYY.mjs +2 -0
- package/dist/plugin-astro.mjs +1 -1
- package/dist/plugin-nuxt.mjs +1 -1
- package/dist/plugin-vite.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/{workspace-snapshot-LKQWBDNS.mjs → workspace-snapshot-O34KMJ2V.mjs} +1 -1
- package/package.json +1 -1
- package/dist/chunk-HGW2U6PD.mjs +0 -2
- package/dist/chunk-MP7S5ALD.mjs +0 -2
- package/dist/chunk-UU5ISCUC.mjs +0 -62
- package/dist/chunk-XOGBFVWI.mjs +0 -2
- package/dist/codex-note-context-MKZ7WCS7.mjs +0 -2
- package/dist/peer-client-WF35M2Y4.mjs +0 -2
- /package/dist/{chunk-MINAH2EM.mjs → chunk-J5HW2SCX.mjs} +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
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
|
+
0%, 100% { translate: 0 0; }
|
|
4
|
+
20% { translate: -4px 0; }
|
|
5
|
+
45% { translate: 4px 0; }
|
|
6
|
+
70% { translate: -2px 0; }
|
|
7
|
+
88% { translate: 1px 0; }
|
|
8
|
+
`;function at(e=22){return{height:e,minHeight:e,maxHeight:e,boxSizing:"border-box",flexShrink:0}}function Xt(e){return`
|
|
9
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
|
|
10
|
+
<defs>
|
|
11
|
+
<mask id="cutout">
|
|
12
|
+
<rect width="100%" height="100%" fill="white" />
|
|
13
|
+
<rect x="${e.x}" y="${e.y}" width="${e.width}" height="${e.height}" rx="${e.radius}" fill="black" />
|
|
14
|
+
</mask>
|
|
15
|
+
</defs>
|
|
16
|
+
<rect width="100%" height="100%" fill="white" mask="url(#cutout)" />
|
|
17
|
+
</svg>`}function Qt(e){return`url("data:image/svg+xml,${encodeURIComponent(e)}")`}var be=Qt(Xt({x:-100,y:-2,width:104,height:26,radius:10})),Do=Qt(Xt({x:-100,y:-5.929,width:108,height:26,radius:10})),rt=10;function $o(e){if(!(!Number.isFinite(e)||e<=0))return Math.max(1,Math.round(e/He))*He}function _o(e,t,n){let i={topLeft:Math.max(0,n.topLeft),topRight:Math.max(0,n.topRight),bottomRight:Math.max(0,n.bottomRight),bottomLeft:Math.max(0,n.bottomLeft)},o=Math.min(1,e/Math.max(1,i.topLeft+i.topRight),e/Math.max(1,i.bottomLeft+i.bottomRight),t/Math.max(1,i.topLeft+i.bottomLeft),t/Math.max(1,i.topRight+i.bottomRight));return{topLeft:i.topLeft*o,topRight:i.topRight*o,bottomRight:i.bottomRight*o,bottomLeft:i.bottomLeft*o}}function Fo(e,t,n,i=.5){let o=Math.max(0,e-i*2),r=Math.max(0,t-i*2),a=_o(e,t,n),l=Math.max(0,a.topLeft-i),d=Math.max(0,a.topRight-i),s=Math.max(0,a.bottomRight-i),c=Math.max(0,a.bottomLeft-i),h=i+o,u=i+r;return[`M ${i+l} ${i}`,`H ${h-d}`,`A ${d} ${d} 0 0 1 ${h} ${i+d}`,`V ${u-s}`,`A ${s} ${s} 0 0 1 ${h-s} ${u}`,`H ${i+c}`,`A ${c} ${c} 0 0 1 ${i} ${u-c}`,`V ${i+l}`,`A ${l} ${l} 0 0 1 ${i+l} ${i}`,"Z"].join(" ")}var pe=12,G=8,ce=8;function Vt(e){return e>0?16+String(e).length*7.2+16:0}function Gt({stepCount:e,onClear:t,layered:n=!1,submitted:i=!1,style:o}){let[r]=Ye(),a=qe[r];if(e<1)return null;let l=`${e} recorded ${e===1?"action":"actions"}${i?", sent":""}`;return R("span",{"data-devtools":"interaction-episode-badge","data-popmelt-submitted":i?"true":void 0,"aria-label":l,onContextMenu:d=>{d.preventDefault(),d.stopPropagation(),t?.()},style:{height:22,display:"inline-flex",alignItems:"center",boxSizing:"border-box",backgroundColor:i?"#8c8c8c":a.surface,border:`1px solid ${i?"#8c8c8c":a.border}`,borderRadius:G,color:i?"#dddddd":a.primary,fontFamily:ne,fontSize:12,fontWeight:600,padding:n?`0 8px 0 ${rt*.7}px`:"0 8px 0 5.6px",gap:4,pointerEvents:t?"auto":"none",WebkitMaskImage:n?be:void 0,maskImage:n?be:void 0,...o},children:[R("svg",{"aria-hidden":!0,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[x("path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"}),x("path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"})]}),x("span",{children:e})]})}var Po=3,zo=250;function Bo(e){let t=e?.current?.getBoundingClientRect();return!t||typeof window>"u"?{}:t.top<window.innerHeight/2?{avoidTop:t.bottom+ce,avoidLeft:t.left-ce,avoidRight:t.right+ce}:{avoidBottom:t.top-ce,avoidLeft:t.left-ce,avoidRight:t.right+ce}}function Ho(e,t,n){if(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 lt(e,t,n){return Ho(t,n,e)?e:{}}function Wo(e,t,n){let i=n.avoidTop!==void 0?`${n.avoidTop}px`:"0px",o=n.avoidBottom!==void 0?`${n.avoidBottom}px`:"100dvh";return`translate(min(0px, calc(100vw - ${e} - 100%)), min(max(0px, calc(${i} - ${t})), calc(${o} - ${t} - 100%)))`}function Jt(e,t,n){if(n.avoidTop===void 0&&n.avoidBottom===void 0)return e;let i=typeof window<"u"?window.innerHeight:9999,o=n.avoidTop??0,r=n.avoidBottom??i,a=Math.max(o,r-t);return Math.max(o,Math.min(e,a))}function Zt({left:e,top:t,scrollX:n,scrollY:i,avoidTop:o,avoidBottom:r,style:a,children:l,...d}){let s=`calc(${e}px - var(--popmelt-scroll-x, ${n}px))`,c=`calc(${t}px - var(--popmelt-scroll-y, ${i}px))`,h=`calc(${e+pe}px - var(--popmelt-scroll-x, ${n}px))`,u=`calc(${t+pe}px - var(--popmelt-scroll-y, ${i}px))`;return x("div",{"data-devtools":"badge-hit-area",...d,style:{position:"fixed",left:0,top:0,padding:pe,...a,transform:`translate3d(${s}, ${c}, 0)`,willChange:"transform"},children:x("div",{style:{transform:Wo(h,u,{avoidTop:o,avoidBottom:r})},children:l})})}function en({bundleCount:e,style:t,layered:n=!1,compact:i=!1,description:o,replacementText:r,onHoverChange:a,onSend:l}){let[d,s]=re(!1),[c]=Ye(),h=qe[c],u=de(Ut),f=jn(),y=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform)?"\u2318":"Ctrl",m=Math.max(1,e),g=i&&!d,k=C=>g?x(Re,{size:12,strokeWidth:2,"aria-hidden":!0}):C?R(W,{children:[x("span",{style:{color:"inherit",fontWeight:600},children:m>1?`Send all ${m}`:"Send"}),x(Re,{size:12,strokeWidth:2,"aria-hidden":!0})]}):R(W,{children:[R("span",{style:{display:"inline-flex",alignItems:"center",gap:2,color:"inherit",fontWeight:600},children:[x("span",{children:y}),x("span",{children:"+"}),x(Wn,{size:12,strokeWidth:2,"aria-hidden":!0})]}),x("span",{style:{color:h.secondary,fontWeight:600},children:"to"}),x(Re,{size:12,strokeWidth:2,"aria-hidden":!0}),m>1&&x("span",{style:{color:"inherit",fontWeight:600},children:m})]}),w=C=>R(W,{children:[x("span",{className:"popmelt-send-hint-desktop",style:{alignItems:"center",gap:4},children:k(C)}),R("span",{className:"popmelt-send-hint-mobile",style:{alignItems:"center",gap:4},children:[!g&&x("span",{style:{color:"inherit",fontWeight:600},children:"Send"}),x(Re,{size:12,strokeWidth:2,"aria-hidden":!0})]})]}),v=r?x("span",{role:"tooltip","data-devtools":"parent-pinned-location-tooltip",style:{overflow:"hidden",textOverflow:"ellipsis"},children:r}):null,I={...at(),lineHeight:`${12*ve}px`,display:"flex",alignItems:"center",boxSizing:"border-box",backgroundColor:h.surface,border:`1px solid ${h.border}`,fontFamily:ne,fontSize:12,color:h.primary,userSelect:"none",padding:n?`0 8px 0 ${rt}px`:"0 8px",gap:4,whiteSpace:"nowrap",borderRadius:G,letterSpacing:"0.24px",WebkitMaskImage:n?be:void 0,maskImage:n?be:void 0},b=m>1?`Send all ${m} pending annotations`:"Send pending annotation";return R("div",{"data-devtools":"send-hint-hit-area","data-popmelt-send-rejection":u?u%2?"odd":"even":void 0,onMouseEnter:()=>{s(!0),a?.(!0)},onMouseLeave:()=>{s(!1),a?.(!1)},style:{display:"grid",width:"max-content",...t},children:[x("style",{children:`
|
|
18
|
+
@keyframes popmelt-send-rejection-odd { ${it} }
|
|
19
|
+
@keyframes popmelt-send-rejection-even { ${it} }
|
|
20
|
+
[data-popmelt-send-rejection="odd"] { animation: popmelt-send-rejection-odd 220ms ease-out; }
|
|
21
|
+
[data-popmelt-send-rejection="even"] { animation: popmelt-send-rejection-even 220ms ease-out; }
|
|
22
|
+
@media (prefers-reduced-motion: reduce) {
|
|
23
|
+
[data-popmelt-send-rejection] { animation: none; }
|
|
24
|
+
}
|
|
25
|
+
.popmelt-send-hint-desktop { display: inline-flex; }
|
|
26
|
+
.popmelt-send-hint-mobile { display: none; }
|
|
27
|
+
@media (max-width: 767px) {
|
|
28
|
+
.popmelt-send-hint-desktop { display: none; }
|
|
29
|
+
.popmelt-send-hint-mobile { display: inline-flex; }
|
|
30
|
+
}
|
|
31
|
+
`}),x("div",{"aria-hidden":!0,style:{...I,gridArea:"1 / 1",visibility:"hidden"},children:w(!1)}),R("button",{type:"button","data-devtools":"annotation-badge","aria-label":b,"aria-describedby":o?f:void 0,disabled:!l,onPointerDown:C=>{C.preventDefault(),C.stopPropagation()},onClick:C=>{C.preventDefault(),C.stopPropagation(),l?.()},style:{...I,gridArea:"1 / 1",justifySelf:"start",maxWidth:r?"min(320px, calc(100vw - 16px))":void 0,overflow:r?"hidden":void 0,appearance:"none",margin:0,opacity:1,cursor:l?"pointer":"default",touchAction:"manipulation"},children:[o&&x("span",{id:f,style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:o}),v??w(d)]})]})}function tn({count:e,color:t,size:n=22,onHoverChange:i}){return R("div",{"data-devtools":"nested-annotation-count-badge",onMouseEnter:()=>i?.(!0),onMouseLeave:()=>i?.(!1),style:{height:n,display:"flex",alignItems:"center",backgroundColor:t,color:t==="#8c8c8c"?"#dddddd":"#ffffff",fontFamily:ne,fontSize:12,fontWeight:600,lineHeight:1,padding:"0 8px",borderRadius:G,userSelect:"none",whiteSpace:"nowrap"},children:["+",e]})}function jo({annotations:e,supersededAnnotations:t,inFlightIds:n,orientationLabels:i,activeIds:o,queuePositions:r,scrollX:a,scrollY:l,annotationGroupMap:d,onViewThread:s,onSelectAnnotation:c,onDeleteDraftAnnotation:h,onClearInteractionEpisode:u,onHoverAnnotation:f,canvasRef:y,toolbarRef:m,activeBundleAnnotationIds:g,inactiveBundleOpacity:k=.5,animateBundleOpacity:w=!0,hoverRestoredAnnotationIds:v,nestedAnnotationCountById:I,nestedAnnotationIdsById:b,onHoverNestedAnnotations:C,onHoverSendBundle:N,onSend:z,sendHintAnchorId:A,pendingBundleCount:T=1,parentPinnedAnnotationIds:X,parentPinnedLocationLabels:oe,parentPinnedTooltipAnnotationId:ie,onActivateAnnotation:Se,hiddenAnnotationIds:Ie,displayAnnotations:Pe}){let Z=de(xe),Me=le(null),[ze,P]=re(0),H=!!(n&&n.size>0&&(o===void 0||o.size>0));V(()=>{if(!H||!Z)return;let p=setInterval(()=>{P(S=>(S+1)%Po)},zo);return()=>{clearInterval(p)}},[H,Z]),V(()=>{if(!Z)return;let p=Me.current;if(!p)return;let S=()=>{p.style.setProperty("--popmelt-scroll-x",`${window.scrollX}px`),p.style.setProperty("--popmelt-scroll-y",`${window.scrollY}px`)};return S(),window.addEventListener("scroll",S,{passive:!0,capture:!0}),window.addEventListener("resize",S),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S)}},[Z]);let E=[],fe=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform)?"\u2318":"Ctrl";for(let p of e){if(p.type!=="text"||!p.text||!p.points[0]||t.has(p)||Ie?.has(p.id))continue;let S=p.groupId?e.filter(M=>M.groupId===p.groupId):[p],D=p.status??"pending",F=T>0&&p.id===A,L=p.interactionEpisode?.steps.length??0,j=I?.get(p.id)??0,K=b?.get(p.id)??[],O=S.reduce((M,kn)=>Math.max(M,kn.replyCount??0),0),Y=D==="sending"||S.some(M=>M.status==="sending"),U=D==="awaiting_review",$=!Y&&(!!(n&&(n.has(p.id)||S.some(M=>n.has(M.id))))||p.status==="in_flight"||S.some(M=>M.status==="in_flight")),ye=S.some(M=>M.status==="resolved"&&(M.replyCount??0)>0||M.status==="needs_review"),te=S.some(M=>M.threadId),yn=!g||S.some(M=>g.has(M.id)||v?.has(M.id));if(!(F||Y||U||$||D==="resolved"||D==="failed"||D==="needs_review"||ye||te||L>0)&&j===0)continue;let xn=p.threadId||S.find(M=>M.threadId)?.threadId,ht=D==="needs_review"||S.some(M=>M.status==="needs_review"),gt=D==="waiting_input"||S.some(M=>M.status==="waiting_input"),mt=D==="failed"||S.some(M=>M.status==="failed"),yt=F||Y||U||$||ht||gt||mt||O>0||D==="resolved"&&te||L>0;if(!yt&&j===0)continue;let Be=p.points[0],xt=p.fontSize||12,wn=xt*ve,wt=d.get(p.id),vt=((Pe?.find(M=>M.id===p.id)??p).text??p.text).replace(/\n/g," "),vn=wt!==void 0?wt+". "+vt:vt,ke=y?.current?.getContext("2d")??document.createElement("canvas").getContext("2d");if(!ke)continue;ke.font=`${xt}px ${ne}`;let bn=Be.x-a,bt=X?.has(p.id)?nt:0,Sn=Math.max(60,jt(bn)-bt),In=ot(ke,vn,Sn),Mn=ke.measureText(In).width,Tn=$&&!!o&&!o.has(p.id)&&!S.some(M=>o.has(M.id));E.push({id:p.id,threadId:xn,linkedSelector:p.linkedSelector||S.find(M=>M.linkedSelector)?.linkedSelector,x:Be.x+Mn+bt+8+2,y:Be.y-4,size:wn+8,color:F?"#000000":p.color,isSending:Y,isAwaitingReview:U,isInFlight:$,orientationLabel:i?.get(p.id)??S.map(M=>i?.get(M.id)).find(Boolean),isQueued:Tn,queuePosition:void 0,isNeedsReview:ht,isQuestion:gt,isFailed:mt,replyCount:O>0?O:D==="resolved"&&te?1:0,isInActiveBundle:yn,isSendHint:F,interactionEpisodeStepCount:L,interactionEpisodeSubmitted:D!=="pending",nestedCount:j,nestedAnnotationIds:K,nestedColor:D==="pending"?p.color:"#8c8c8c",showActionBadge:yt,canDeleteDraft:Kt(p,e)})}let he=E.filter(p=>p.isQueued);if(he.length>0&&he.forEach((p,S)=>{p.queuePosition=r?.get(p.id)??`(${S+1}/${he.length})`}),E.length===0)return null;let ge=2,B=y?.current?.getContext("2d")??document.createElement("canvas").getContext("2d"),ae=E.map(p=>{B&&(B.font=`12px ${ne}`);let S=p.nestedCount>0?(B?.measureText(`+${p.nestedCount}`).width??String(p.nestedCount).length*7.2+7.2)+16:0,D=Vt(p.interactionEpisodeStepCount);if(!p.showActionBadge)return S+D;let F=ie===p.id?oe?.get(p.id):void 0,L;F?L=F:p.isSendHint?L=fe:p.isSending?L="Sending":p.isAwaitingReview?L="Awaiting review":p.isInFlight?L=p.isQueued?`Queued${p.queuePosition?` ${p.queuePosition}`:""}`:p.orientationLabel??"Thinking":p.isQuestion?L="Question":p.isFailed?L="Failed":p.replyCount>0?L="Replied":L="Needs decision";let j=p.isSendHint||F?0:12,K=4,O=L.length*7.2;B&&(O=B.measureText(L).width);let Y=p.isSendHint&&B?B.measureText("to").width:p.isSendHint?14.4:0,U=p.isSendHint&&B?B.measureText("+").width:p.isSendHint?7.2:0,$=p.isSendHint&&T>1&&B?B.measureText(String(T)).width:p.isSendHint&&T>1?7.2:0,ye=F?Math.min(O+16,320):p.isSendHint?O+U+Y+$+16+12+12+4+K*(T>1?3:2):6+j+K+O+8,te=+(D>0)+ +(S>0)+1;return D+S+ye+(te-1)*2}),me=Bo(m),ee=[];for(let p=0;p<E.length;p++){let S=E[p].y-l,D=E[p].x-a,F=lt(me,D,ae[p]),L=Jt(S,E[p].size,F),j=L+E[p].size,K=D;for(let O=0;O<p;O++){let Y=E[O].y-l,U=lt(me,ee[O],ae[O]),$=Jt(Y,E[O].size,U),ye=$+E[O].size;if(!(L<ye&&j>$))continue;let te=ee[O]+ae[O];K<te+ge&&(K=te+ge)}ee.push(K)}let Te={position:"fixed",inset:0,pointerEvents:"none",zIndex:9999,"--popmelt-scroll-x":`${a}px`,"--popmelt-scroll-y":`${l}px`};return R("div",{ref:Me,"data-devtools":"annotation-badge-layer",style:Te,children:[x("style",{dangerouslySetInnerHTML:{__html:`
|
|
32
|
+
[data-devtools="annotation-badge-layer"] [data-devtools="annotation-badge"]::selection,
|
|
33
|
+
[data-devtools="annotation-badge-layer"] [data-devtools="annotation-badge"] *::selection {
|
|
34
|
+
background: #000000;
|
|
35
|
+
color: #ffffff;
|
|
36
|
+
}
|
|
37
|
+
`}}),E.map((p,S)=>{let D=!!p.threadId,F=oe?.get(p.id),L=!!F&&ie===p.id,j=D||!!F,K=p.showActionBadge&&p.isSendHint,O=j&&!K,Y=()=>{if(Se){Se(p.id,p.threadId);return}c?.(p.id),p.threadId&&s?.(p.threadId)},U=lt(me,ee[S],ae[S]);return x(Zt,{left:ee[S]+a-pe,top:p.y-pe,scrollX:a,scrollY:l,avoidTop:U.avoidTop,avoidBottom:U.avoidBottom,onMouseDown:$=>$.stopPropagation(),onContextMenu:$=>{$.preventDefault(),$.stopPropagation(),p.canDeleteDraft&&h&&h(p.id)},onClick:j?$=>{$.stopPropagation(),Y()}:void 0,onMouseEnter:()=>{f?.(p.id)},onMouseLeave:()=>{f?.(null)},onFocus:()=>f?.(p.id),onBlur:()=>f?.(null),onKeyDown:O?$=>{$.key!=="Enter"&&$.key!==" "||($.preventDefault(),Y())}:void 0,role:O?"button":void 0,tabIndex:O?0:void 0,"aria-label":O&&F?`${F}. Activate to reveal the annotation source${D?" and open its thread":""}`:void 0,style:{pointerEvents:"auto",cursor:j?"pointer":void 0,zIndex:9999,minWidth:p.isSendHint?ae[S]:void 0},children:R("div",{style:{position:"relative",display:"flex",alignItems:"center",gap:2},children:[x(Gt,{stepCount:p.interactionEpisodeStepCount,submitted:p.interactionEpisodeSubmitted,onClear:p.canDeleteDraft&&u?()=>u(p.id):void 0}),p.nestedCount>0&&x(tn,{count:p.nestedCount,color:p.nestedColor,size:p.size,onHoverChange:$=>C?.(p.id,$?p.nestedAnnotationIds:null)}),p.showActionBadge&&(p.isSendHint?x(en,{bundleCount:T,description:F?`${F}. Activate the annotation label to reveal its source.`:void 0,replacementText:L?F:void 0,onHoverChange:N,onSend:z}):x("div",{"data-devtools":"annotation-badge",style:{...at(p.size),display:"flex",alignItems:"center",backgroundColor:p.color,fontFamily:ne,fontSize:12,color:"#ffffff",userSelect:"none",padding:"0 8px 0 6px",gap:4,whiteSpace:"nowrap",maxWidth:L?"min(320px, calc(100vw - 16px))":void 0,overflow:L?"hidden":void 0,borderRadius:G,opacity:p.isInActiveBundle?1:k,transition:w?"opacity 120ms ease-out":"none"},children:L?x("span",{role:"tooltip","data-devtools":"parent-pinned-location-tooltip",style:{overflow:"hidden",textOverflow:"ellipsis"},children:F}):p.isAwaitingReview?R(W,{children:[x(Et,{size:12,strokeWidth:2.25}),"Awaiting review"]}):p.isQueued?R("span",{style:{opacity:.6,color:"inherit",display:"inline-flex",alignItems:"center",gap:4},children:[x(Et,{size:12,strokeWidth:2.25}),"Queued",p.queuePosition?` ${p.queuePosition}`:""]}):p.isSending||p.isInFlight?R(W,{children:[p.orientationLabel==="Approval needed"?x(Fn,{size:12,"aria-label":"Approval needed"}):x("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{verticalAlign:"middle",opacity:.6},children:ze===1?R(W,{children:[x("circle",{cx:"7",cy:"7",r:"2"}),x("circle",{cx:"17",cy:"7",r:"2"}),x("circle",{cx:"7",cy:"17",r:"2"}),x("circle",{cx:"17",cy:"17",r:"2"})]}):R(W,{children:[x("circle",{cx:"12",cy:"6",r:"2"}),x("circle",{cx:"6",cy:"12",r:"2"}),x("circle",{cx:"18",cy:"12",r:"2"}),x("circle",{cx:"12",cy:"18",r:"2"})]})}),x("span",{style:{opacity:.6,color:"inherit"},children:p.isSending?"Sending":p.isQueued?`Queued${p.queuePosition?` ${p.queuePosition}`:""}`:p.orientationLabel??"Thinking"})]}):R(W,{children:[p.isQuestion?x(Pn,{size:12,strokeWidth:2.25}):p.isFailed?x(zn,{size:12,strokeWidth:2.25}):p.replyCount>0?x(Bn,{size:12,strokeWidth:2.25}):R("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[x("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9"}),x("path",{d:"M10 21h4"})]}),x("span",{style:{color:"inherit"},children:p.isQuestion?"Question":p.isFailed?"Failed":p.replyCount>0?"Replied":"Needs decision"})]})}))]})},p.id)})]})}function nn({d:e,color:t,animated:n}){let i=le(null);return Ct(()=>{let o=i.current;if(!o||typeof o.getTotalLength!="function")return;let r=$o(o.getTotalLength());r===void 0?o.removeAttribute("pathLength"):o.setAttribute("pathLength",String(r))},[e]),x("path",{ref:i,d:e,fill:"none",stroke:t,strokeWidth:1,strokeDasharray:n?En:void 0,"data-popmelt-marching-stroke":n||void 0,style:n?{animation:"popmelt-march 0.6s linear infinite"}:void 0})}function on(){return x("style",{children:`
|
|
38
|
+
@keyframes popmelt-march {
|
|
39
|
+
from { stroke-dashoffset: 0; }
|
|
40
|
+
to { stroke-dashoffset: -${He}; }
|
|
41
|
+
}
|
|
42
|
+
@media (prefers-reduced-motion: reduce) {
|
|
43
|
+
[data-popmelt-marching-stroke="true"] { animation: none !important; }
|
|
44
|
+
}
|
|
45
|
+
`})}function Yo({annotations:e,activeIds:t,scrollX:n,scrollY:i,spotlightIds:o,emphasizedIds:r,hoverRestoredIds:a,inactiveOpacity:l=.5}){if(!de(xe))return null;let d=e.filter(s=>s.region&&s.region.points.length>=3&&t?.has(s.id));return d.length?R(W,{children:[x(on,{}),x("svg",{"data-devtools":"marching-lasso","aria-hidden":!0,style:{position:"fixed",inset:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:9995,overflow:"visible"},children:x("g",{transform:`translate(${-n} ${-i})`,children:d.map(s=>{let c=o?.size?o.has(s.id)?1:.2:r&&!r.has(s.id)&&!a?.has(s.id)?l:1;return x("g",{"data-popmelt-region-id":s.id,opacity:c,children:x(nn,{d:`${s.region.points.map((h,u)=>`${u?"L":"M"}${h.x} ${h.y}`).join(" ")} Z`,color:s.color,animated:!0})},s.id)})})})]}):null}function qo({inFlightSelectorColors:e,animated:t=!0,subjectRegistry:n,selectorElementInfo:i}){let o=de(xe),[r,a]=re([]);return V(()=>{if(!o)return;if(e.size===0){a([]);return}let l=null,d=()=>{let f=[];for(let[y,m]of e){let g=On(y,i?.get(y));if(!g)continue;let k=Ee(g);f.push({selector:y,top:k.top,left:k.left,width:k.width,height:k.height,color:m,radius:Dt(g),radiusStyle:Ot(g)})}a(f)},s=()=>{l&&cancelAnimationFrame(l),l=requestAnimationFrame(d)};d(),window.addEventListener("scroll",s,!0),window.addEventListener("resize",s,!0);let c=new MutationObserver(s);c.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]});let h=n?.subscribeFrame(d),u=[...e.keys()].some(f=>f.startsWith("@frame("))?Ue(d):void 0;return()=>{window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",s,!0),c.disconnect(),h?.(),u?.(),l&&cancelAnimationFrame(l)}},[e,n,i,o]),r.length===0?null:R(W,{children:[t&&x(on,{}),r.map(l=>x("div",{"data-devtools":"marching-ants",style:{position:"fixed",top:l.top,left:l.left,width:l.width,height:l.height,pointerEvents:"none",zIndex:9995,overflow:"visible",borderTopLeftRadius:l.radiusStyle.topLeft,borderTopRightRadius:l.radiusStyle.topRight,borderBottomRightRadius:l.radiusStyle.bottomRight,borderBottomLeftRadius:l.radiusStyle.bottomLeft},children:x("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:x(nn,{d:Fo(l.width,l.height,{topLeft:l.radius["top-left"],topRight:l.radius["top-right"],bottomRight:l.radius["bottom-right"],bottomLeft:l.radius["bottom-left"]}),color:l.color,animated:t})})},l.selector))]})}function Ko({element:e,elements:t,registry:n,label:i="Looking",engaged:o=!0,outlineColor:r,inverse:a=!1}){let l=le(0),d=Yn(()=>t??(e?[e]:[]),[t,e]),[s,c]=re(()=>d.map(u=>({target:u,id:++l.current,animateEntrance:!0,exiting:!1}))),h=qn(u=>{c(f=>f.filter(y=>y.id!==u))},[]);return V(()=>{d.length&&c(u=>{let f=u.some(({target:m})=>m.isConnected),y=d.map(m=>u.find(g=>g.target===m&&!g.exiting)??{target:m,id:++l.current,animateEntrance:!f,exiting:!1});return[...u.filter(m=>!m.exiting&&!d.includes(m.target)).map(m=>({...m,exiting:!0})),...y]})},[d]),x(W,{children:s.map(({target:u,id:f,animateEntrance:y,exiting:m})=>x(Uo,{id:f,element:o&&d.includes(u)?u:null,target:u,animateEntrance:y,exiting:m,registry:n,label:i,outlineColor:r,inverse:a,onDone:h},f))})}function Uo({id:e,element:t,target:n,animateEntrance:i,exiting:o,registry:r,label:a,outlineColor:l,inverse:d,onDone:s}){let[c]=Ye(),h=qe[c],u=n,[f,y]=re(!1),m=le(Date.now()),[g,k]=re(null);return V(()=>{if(!u)return;let w,v=()=>{let I=Ln(u);k(b=>I?b?.left===I.left&&b.top===I.top?b:{left:I.left,top:I.top}:null),w=requestAnimationFrame(v)};return v(),()=>cancelAnimationFrame(w)},[u]),V(()=>{let w,v;return o?v=setTimeout(()=>s(e),200):t?(m.current=Date.now(),y(!1)):w=setTimeout(()=>{y(!0),v=setTimeout(()=>s(e),300)},Math.max(0,m.current+1700-Date.now())),()=>{clearTimeout(w),clearTimeout(v)}},[t,o,e,s]),u?.isConnected?R(W,{children:[x("style",{children:`
|
|
46
|
+
@keyframes popmelt-looking-in-left { from { opacity: 0; transform: translateX(26px); clip-path: inset(0 100% 0 0); } to { opacity: 1; transform: translateX(0); clip-path: inset(0); } }
|
|
47
|
+
@keyframes popmelt-looking-out-left { from { opacity: 1; } to { opacity: 0; } }
|
|
48
|
+
@keyframes popmelt-looking-in-up { from { opacity: 0; transform: translateY(26px); clip-path: inset(0 0 100% 0); } to { opacity: 1; transform: translateY(0); clip-path: inset(0); } }
|
|
49
|
+
@keyframes popmelt-looking-in-alone-up-left { from { opacity: 0; transform: translate(8px, 8px); } to { opacity: 1; transform: translate(0, 0); } }
|
|
50
|
+
@keyframes popmelt-looking-in-alone-down-left { from { opacity: 0; transform: translate(8px, -8px); } to { opacity: 1; transform: translate(0, 0); } }
|
|
51
|
+
@keyframes popmelt-looking-in-alone-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
|
|
52
|
+
@keyframes popmelt-looking-in-alone-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
|
|
53
|
+
@keyframes popmelt-looking-out-up { from { opacity: 1; } to { opacity: 0; } }
|
|
54
|
+
@keyframes popmelt-looking-fade-in { from { opacity: 0; } to { opacity: 1; } }
|
|
55
|
+
@keyframes popmelt-looking-fade-out { from { opacity: 1; } to { opacity: 0; } }
|
|
56
|
+
@keyframes popmelt-looking-blink { 0%, 40%, 72.5%, 100% { transform: scaleY(1); } 50%, 62.5% { transform: scaleY(0.1); } }
|
|
57
|
+
.popmelt-looking-eye { animation: popmelt-looking-blink 1000ms 200ms both; transform-origin: center; }
|
|
58
|
+
@media (prefers-reduced-motion: reduce) {
|
|
59
|
+
[data-devtools="focus-inspection"], .popmelt-looking-eye { animation: none !important; }
|
|
60
|
+
[data-popmelt-looking-exiting] { opacity: 0 !important; }
|
|
61
|
+
}
|
|
62
|
+
`}),x(zt,{element:u,subjectRegistry:r,hideOutline:!l||f||o,color:l,outlineZIndex:l?10002:void 0,hideFill:!0,hideTooltip:!0,railHeight:22,renderRail:(w,v)=>{let I=g??w,b=I.left>=28,C=!g&&w.anchor.startsWith("bottom-"),N=g?b?"left":"up":`${C?"down":"up"}${b?"-left":""}`,z=g&&!b?Math.max(4,I.top-22-2):I.top,A=b?I.left-22-2:I.left,T=v.left+v.width/2>=A+22/2,X=v.top+v.height/2>=z+22/2?T?"borderBottomRightRadius":"borderBottomLeftRadius":T?"borderTopRightRadius":"borderTopLeftRadius";return x("div",{"data-devtools":"focus-inspection","data-popmelt-looking-exiting":o?"true":void 0,"data-popmelt-canvas-block":!0,role:"status","aria-live":o?"off":"polite","aria-hidden":o||void 0,"aria-label":a,title:a,style:{position:"fixed",animation:o?"popmelt-looking-fade-out 200ms ease both":!f&&!i?"popmelt-looking-fade-in 200ms ease both":`popmelt-looking-${f?"out":g?"in":"in-alone"}-${f?b?"left":"up":N} ${f?300:200}ms ease both`,left:A,top:z,height:22,width:22,boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center",backgroundColor:d?h.actionSurface:h.surface,color:d?h.actionForeground:h.primary,border:`1px solid ${d?h.actionHover:h.border}`,borderTopLeftRadius:G,borderTopRightRadius:G,borderBottomLeftRadius:G,borderBottomRightRadius:G,...g?{}:{[X]:2},fontFamily:je,fontSize:12,letterSpacing:"0.24px",whiteSpace:"nowrap",pointerEvents:o?"none":"auto",zIndex:u.hasAttribute("data-popmelt-thread-header")?10005:10002},children:x(Hn,{className:i&&!o?"popmelt-looking-eye":void 0,size:12,"aria-hidden":!0})})}})]}):null}var Xo={production:{issuer:"https://popmelt.com",resource:"https://mcp.popmelt.com"},staging:{issuer:"https://webapp-staging-1bed.up.railway.app",resource:"https://mcp-staging-8731.up.railway.app"}};function Qo(e){if(typeof e!="string")throw new Error("Unexpected sign-in destination.");let t=new URL(e);if(!Object.values(Xo).some(({issuer:n})=>t.origin===n)||t.pathname!=="/mcp/grant"||t.username||t.password||t.hash)throw new Error("Unexpected sign-in destination.");return t}var $e={toolbar:{toggleKey:["Meta","Control"],toggleTaps:2,toggleWindowMs:300},tools:{imprint:{key:"i",tool:"model"},steer:{key:"s",tool:"sticker"},comment:{key:"c",tool:"inspector"}},actions:{send:{key:"Enter",commandOrControl:!0},screenshot:{key:"c",commandOrControl:!0},clear:{keys:["Backspace","Delete"],commandOrControl:!0},undo:{key:"z",commandOrControl:!0},redo:{key:"z",commandOrControl:!0,shift:!0}},omnidial:{previous:["a","ArrowLeft"],next:["d","ArrowRight"],previousFacet:["q"],nextFacet:["e"],descendOrApply:["w","Enter"],ascend:["s","Escape"],query:[" "]}},Vo=[{type:"model",label:"Imprint",shortcut:"I"},{type:"sticker",label:"Steer",shortcut:"S"},{type:"inspector",label:"Chat",shortcut:"C"}];function Go(e){let t=e.toLowerCase();return Object.values($e.tools).find(n=>n.key===t)?.tool??null}function Jo(e){let t=e.length===1?e.toLowerCase():e,n=$e.omnidial;return[...n.previous,...n.next,...n.previousFacet,...n.nextFacet,...n.descendOrApply,...n.ascend,...n.query].includes(t)||/^[a-z0-9]$/i.test(e)}var an=Ke(null),Zo=()=>()=>{},rn=()=>null;function dt(){return Math.random().toString(36).substring(2,9)}function _e(e){return e.type==="text"&&e.region?.kind==="lasso"&&(e={...e,fontSize:12,linkedAnchor:e.linkedAnchor??"bottom-left"}),e.status?e:e.captured?{...e,status:"in_flight"}:{...e,status:"pending"}}function st(e){return{annotations:e.annotations,styleModifications:e.styleModifications,textModifications:e.textModifications,domModifications:e.domModifications,spacingTokenChanges:e.spacingTokenChanges,spacingTokenMods:e.spacingTokenMods}}function _(e){return{...e,undoStack:[...e.undoStack,st(e)],redoStack:[]}}function ei(e,t){return{...e,isAnnotating:t}}function ti(e,t){return{...e,activeTool:t}}function ni(e,t){return{...e,activeColor:t}}function oi(e,t){return{...e,strokeWidth:t}}function ii(e,t){let n={id:t.id??dt(),type:"text",points:[t.point],text:t.text,fontSize:t.fontSize||12,color:e.activeColor,strokeWidth:e.strokeWidth,timestamp:Date.now(),status:"pending",pathname:typeof window<"u"?window.location.pathname:"/",groupId:t.groupId,linkedSelector:t.linkedSelector,target:t.target,linkedAnchor:t.linkedAnchor,elements:t.elements,...t.region?{region:t.region}:{},...t.imageCount?{imageCount:t.imageCount}:{},...t.attachments?.length?{attachments:t.attachments}:{},...t.interactionEpisode?{interactionEpisode:t.interactionEpisode}:{}};return{...t.groupId?e:_(e),annotations:[...e.annotations,n]}}function ai(e,t){return{..._(e),annotations:e.annotations.map(n=>n.id===t.id?{...n,text:t.text,...t.imageCount!=null?{imageCount:t.imageCount}:{},...t.attachments?{attachments:t.attachments}:{},...t.interactionEpisode?{interactionEpisode:t.interactionEpisode}:{}}:n)}}function ri(e,t){return{..._(e),annotations:e.annotations.map(n=>{if(n.id!==t.id)return n;let i=n.interactionEpisode?.frames?.length??0,{interactionEpisode:o,...r}=n;if(i===0)return r;let a=Math.max(0,(n.imageCount??0)-i);if(a===0){let{imageCount:l,...d}=r;return d}return{...r,imageCount:a}})}}function li(e,t){let n=_(e),i=e.annotations.find(r=>r.id===t.id)?.groupId,o=new Set(e.annotations.filter(r=>r.id===t.id||i&&r.groupId===i).map(r=>r.id));return{...n,annotations:e.annotations.filter(r=>r.id!==t.id&&!(i&&r.groupId===i)),selectedAnnotationIds:e.selectedAnnotationIds.filter(r=>!o.has(r)),lastSelectedId:e.lastSelectedId&&o.has(e.lastSelectedId)?null:e.lastSelectedId}}function di(e,t){let n=t.saveUndo?_(e):e,i=e.annotations.find(o=>o.id===t.id)?.groupId;return{...n,annotations:e.annotations.map(o=>{if(!(o.id===t.id||i&&o.groupId===i))return o;let r=t.delta.x,a=t.delta.y;return{...o,points:o.points.map(l=>({x:l.x+r,y:l.y+a}))}})}}function si(e,t){let n=t.saveUndo?_(e):e,i=e.annotations.find(a=>a.id===t.id);if(!i||i.type==="text"||i.points.length<2)return e;let o=0,r=0;if(i.type==="rectangle"&&i.groupId){let a=t.points,l=Math.min(a[0].x,a[1].x),d=Math.max(a[0].y,a[1].y),s=i.points[0],c=i.points[i.points.length-1],h=Math.min(s.x,c.x),u=Math.max(s.y,c.y);o=l-h,r=d-u}return{...n,annotations:e.annotations.map(a=>a.id===t.id?{...a,points:t.points}:i.groupId&&a.groupId===i.groupId&&a.type==="text"?{...a,points:a.points.map(l=>({x:l.x+o,y:l.y+r}))}:a)}}function pi(e,t){return{..._(e),annotations:[...e.annotations,...t.annotations.map(_e)]}}function ci(e,t){let n=new Set,i=[];for(let o of t.annotations)n.has(o.id)||(n.add(o.id),i.push(_e(o)));return{...e,annotations:i}}function ui(e,t){let n=new Map(e.annotations.map(o=>[o.id,o])),i=t.annotations.map(o=>{let r=_e(o),a=n.get(r.id);return!a||!r.linkedSelector||a.linkedSelector!==r.linkedSelector?r:{...r,points:a.points,linkedAnchor:a.linkedAnchor}});return{...e,annotations:i}}function fi(e,t){let n=new Set(e.annotations.map(o=>o.id)),i=t.annotations.filter(o=>!n.has(o.id)).map(_e);return i.length>0?{...e,annotations:[...e.annotations,...i]}:e}function hi(e){if(e.undoStack.length===0)return e;let t=e.undoStack[e.undoStack.length-1];return{...e,annotations:t?.annotations||[],styleModifications:t?.styleModifications||[],textModifications:t?.textModifications||[],domModifications:t?.domModifications||[],spacingTokenChanges:t?.spacingTokenChanges||[],spacingTokenMods:t?.spacingTokenMods||[],undoStack:e.undoStack.slice(0,-1),redoStack:[...e.redoStack,st(e)]}}function gi(e){if(e.redoStack.length===0)return e;let t=e.redoStack[e.redoStack.length-1];return{...e,annotations:t?.annotations||[],styleModifications:t?.styleModifications||[],textModifications:t?.textModifications||[],domModifications:t?.domModifications||[],spacingTokenChanges:t?.spacingTokenChanges||[],spacingTokenMods:t?.spacingTokenMods||[],redoStack:e.redoStack.slice(0,-1),undoStack:[...e.undoStack,st(e)]}}function mi(e,t){let{id:n,addToSelection:i}=t;if(n===null)return{...e,selectedAnnotationIds:[],lastSelectedId:null};if(i)if(e.selectedAnnotationIds.includes(n)){let o=e.selectedAnnotationIds.filter(r=>r!==n);return{...e,selectedAnnotationIds:o,lastSelectedId:o.length>0?o[o.length-1]:null}}else return{...e,selectedAnnotationIds:[...e.selectedAnnotationIds,n],lastSelectedId:n};return{...e,selectedAnnotationIds:[n],lastSelectedId:n}}function yi(e,t){let n=e.annotations.find(o=>o.id===t.id)?.groupId,i=new Set;for(let o of e.selectedAnnotationIds){let r=e.annotations.find(a=>a.id===o);r?.groupId&&i.add(r.groupId)}return{...e,annotations:e.annotations.map(o=>o.id===t.id||e.selectedAnnotationIds.includes(o.id)||o.groupId&&(o.groupId===n||i.has(o.groupId))?{...o,color:t.color}:o)}}function xi(e,t,n){let i=typeof window<"u"?window.location.pathname:"/",o=t?new Set(t):void 0,r=n??e.textModifications.filter(d=>!d.pathname||d.pathname===i),a=d=>d.filter(s=>!r.some(c=>s.pathname===c.pathname&&ln(s,c.selector,c.textNodePath,c.pathname??"")&&s.createdAt===c.createdAt&&s.original===c.original&&s.modified===c.modified)),l=d=>({...d,textModifications:a(d.textModifications)});return{...e,undoStack:e.undoStack.map(l),redoStack:e.redoStack.map(l),annotations:e.annotations.map(d=>o&&!o.has(d.id)?d:{...d,captured:!0,status:d.status==="pending"||d.status==="sending"||!d.status?"in_flight":d.status}),styleModifications:e.styleModifications.map(d=>!d.pathname||d.pathname===i?{...d,captured:!0}:d),textModifications:a(e.textModifications),domModifications:e.domModifications.map(d=>!d.pathname||d.pathname===i?{...d,captured:!0}:d),spacingTokenChanges:e.spacingTokenChanges.map(d=>({...d,captured:!0})),spacingTokenMods:e.spacingTokenMods.map(d=>({...d,captured:!0}))}}function wi(e){return e.annotations.some(t=>(t.status??"pending")==="pending")||e.styleModifications.some(t=>!t.captured)||e.textModifications.some(t=>!t.captured)||e.domModifications.some(t=>!t.captured)||e.spacingTokenChanges.some(t=>!t.captured)||e.spacingTokenMods.some(t=>!t.captured)?{..._(e),annotations:e.annotations.filter(t=>(t.status??"pending")!=="pending"),styleModifications:e.styleModifications.filter(t=>t.captured),textModifications:e.textModifications.filter(t=>t.captured),domModifications:e.domModifications.filter(t=>t.captured),spacingTokenChanges:e.spacingTokenChanges.filter(t=>t.captured),spacingTokenMods:e.spacingTokenMods.filter(t=>t.captured),selectedAnnotationIds:[],lastSelectedId:null}:e}function vi(e){return{...e,annotations:[],undoStack:[],redoStack:[],selectedAnnotationIds:[],lastSelectedId:null,textModifications:[],domModifications:[],spacingTokenChanges:[],spacingTokenMods:[]}}function bi(e,t){let{selector:n,element:i,property:o,original:r,modified:a}=t,l=typeof window<"u"?window.location.pathname:"/",d=e.styleModifications.findIndex(s=>s.selector===n&&(!s.pathname||s.pathname===l));if(r===a&&d<0)return e;if(d>=0){let s=e.styleModifications[d];if(s.captured){let y=_(e),m=y.styleModifications.map((g,k)=>k===d?{...g,changes:[{property:o,original:r,modified:a}],createdAt:g.createdAt??Date.now(),captured:!1,pathname:l}:g);return{...y,styleModifications:m}}let c=s.changes.findIndex(y=>y.property===o),h,u=e;if(c>=0){let y=s.changes[c];a===y.original?h=s.changes.filter((m,g)=>g!==c):h=s.changes.map((m,g)=>g===c?{...m,modified:a}:m)}else{if(r===a)return e;u=_(e),h=[...s.changes,{property:o,original:r,modified:a}]}if(h.length===0)return{...u,styleModifications:u.styleModifications.filter((y,m)=>m!==d)};let f=u.styleModifications.map((y,m)=>m===d?{...y,changes:h,createdAt:y.createdAt??Date.now()}:y);return{...u,styleModifications:f}}else{let s=_(e),c={selector:n,element:i,changes:[{property:o,original:r,modified:a}],createdAt:Date.now(),pathname:l};return{...s,styleModifications:[...s.styleModifications,c]}}}function Si(e,t){let{selector:n,durableSelector:i,element:o,changes:r}=t,a=typeof window<"u"?window.location.pathname:"/",l=r.filter(c=>c.original!==c.modified);if(l.length===0)return e;let d=_(e),s=d.styleModifications.findIndex(c=>c.selector===n&&(!c.pathname||c.pathname===a));if(s>=0){let c=d.styleModifications[s],h=c.captured?[]:[...c.changes];for(let u of l){let f=h.findIndex(y=>y.property===u.property);f>=0?u.modified===h[f].original?h=h.filter((y,m)=>m!==f):h=h.map((y,m)=>m===f?{...y,modified:u.modified,token:u.token,sticker:u.sticker}:y):h.push(u)}return h.length===0?{...d,styleModifications:d.styleModifications.filter((u,f)=>f!==s)}:{...d,styleModifications:d.styleModifications.map((u,f)=>f===s?{...u,changes:h,createdAt:u.createdAt??Date.now(),captured:!1,pathname:a}:u)}}else return{...d,styleModifications:[...d.styleModifications,{selector:n,durableSelector:i,element:o,changes:l,createdAt:Date.now(),pathname:a}]}}function Ii(e,t){let{selector:n,property:i}=t,o=typeof window<"u"?window.location.pathname:"/",r=_(e),a=r.styleModifications.map(l=>l.selector!==n||l.pathname&&l.pathname!==o?l:{...l,changes:l.changes.filter(d=>d.property!==i)}).filter(l=>l.changes.length>0);return{...r,styleModifications:a}}function Mi(e,t){let{selector:n,sticker:i}=t,o=typeof window<"u"?window.location.pathname:"/";if(!e.styleModifications.find(l=>l.selector===n&&(!l.pathname||l.pathname===o)&&!l.captured&&l.changes.some(d=>d.sticker?.family===i.family&&d.sticker.subproperty===i.subproperty)))return e;let r=_(e),a=r.styleModifications.map(l=>l.selector!==n||l.pathname&&l.pathname!==o||l.captured?l:{...l,changes:l.changes.filter(d=>d.sticker?.family!==i.family||d.sticker.subproperty!==i.subproperty)}).filter(l=>l.changes.length>0);return{...r,styleModifications:a}}function Ti(e){return e.styleModifications.length===0?e:{..._(e),styleModifications:[]}}function ki(e,t){let n=new Set(t.selectors);if(n.size===0)return e;let i=e.styleModifications.filter(o=>!o.captured||!n.has(o.selector)&&(!o.durableSelector||!n.has(o.durableSelector)));return i.length===e.styleModifications.length?e:{...e,styleModifications:i}}function Ei(e,t){let n=Date.now();return{...e,styleModifications:t.map((i,o)=>({...i,createdAt:i.createdAt??n+o}))}}function ln(e,t,n,i){return e.selector===t&&(!e.pathname||e.pathname===i)&&e.textNodePath.length===n.length&&e.textNodePath.every((o,r)=>o===n[r])}function dn(e,t,n=!0){let{selector:i,durableSelector:o,element:r,textNodePath:a,original:l,modified:d}=t,s=typeof window<"u"?window.location.pathname:"/",c=e.textModifications.findIndex(u=>ln(u,i,a,s));if(l===d&&c<0)return e;if(c>=0){let u=e.textModifications[c],f=u.captured&&n?_(e):e,y=u.captured?l:u.original;return d===y?{...f,textModifications:f.textModifications.filter((m,g)=>g!==c)}:{...f,textModifications:f.textModifications.map((m,g)=>g===c?{...m,durableSelector:o,element:r,original:y,modified:d,createdAt:m.createdAt??Date.now(),captured:!1,pathname:s}:m)}}let h=n?_(e):e;return{...h,textModifications:[...h.textModifications,{selector:i,durableSelector:o,element:r,textNodePath:a,original:l,modified:d,createdAt:Date.now(),pathname:s}]}}function Ci(e,t,n=!0){return t.length===0?e:t.reduce((i,o)=>dn(i,o,!1),n?_(e):e)}function Ai(e,t){let n=Date.now();return{...e,textModifications:t.filter(i=>!i.captured).map((i,o)=>({...i,createdAt:i.createdAt??n+o}))}}function Ri(e,t){let n=_(e),i=n.domModifications.findIndex(o=>o.id===t.id);return i>=0?{...n,domModifications:n.domModifications.map((o,r)=>r===i?{...t,captured:!1}:o)}:{...n,domModifications:[...n.domModifications,t]}}function Ni(e,t){return{...e,domModifications:t}}function Li(e,t){let{updates:n}=t,i=new Map(n.map(o=>[o.id,o]));return{...e,annotations:e.annotations.map(o=>{let r=i.get(o.id);return r?{...o,points:[r.point,...o.points.slice(1)],...r.linkedAnchor?{linkedAnchor:r.linkedAnchor}:{}}:o})}}function Oi(e,t){let n=new Set(t.ids);return{...e,annotations:e.annotations.map(i=>n.has(i.id)?{...i,status:t.status}:i)}}function Di(e,t){let n=new Set(t.ids),i=new Set;for(let o of e.annotations)n.has(o.id)&&o.groupId&&i.add(o.groupId);return{...e,annotations:e.annotations.map(o=>{if(!n.has(o.id)&&!(o.groupId&&i.has(o.groupId)))return o;let r=!!t.jobId&&o.replyJobIds?.includes(t.jobId),a=o.status==="waiting_input";return{...o,status:a?"waiting_input":"resolved",replyCount:(o.replyCount??0)+(r?0:1),replyJobIds:t.jobId&&!r?[...o.replyJobIds??[],t.jobId]:o.replyJobIds,threadId:o.threadId||t.threadId,question:a?o.question:void 0}})}}function $i(e,t){let n=new Set(t.ids),i=new Set;for(let o of e.annotations)n.has(o.id)&&o.groupId&&i.add(o.groupId);return{...e,annotations:e.annotations.map(o=>n.has(o.id)||o.groupId&&i.has(o.groupId)?{...o,status:"failed",threadId:o.threadId||t.threadId,question:void 0}:o)}}function _i(e,t){let n=new Set(t.ids),i=new Set;for(let o of e.annotations)n.has(o.id)&&o.groupId&&i.add(o.groupId);return{...e,annotations:e.annotations.map(o=>n.has(o.id)||o.groupId&&i.has(o.groupId)?{...o,threadId:t.threadId,targetBindingId:t.targetBindingId}:o)}}function Fi(e,t){let n=new Set(t.ids),i=new Set;for(let o of e.annotations)n.has(o.id)&&o.groupId&&i.add(o.groupId);return{...e,annotations:e.annotations.map(o=>n.has(o.id)||o.groupId&&i.has(o.groupId)?{...o,status:"waiting_input",question:t.question,threadId:t.threadId}:o)}}function Pi(e,t){let n=new Map(t.resolutions.map(o=>[o.annotationId,o])),i=new Map;for(let o of e.annotations){let r=n.get(o.id);r&&o.groupId&&i.set(o.groupId,r)}return{...e,annotations:e.annotations.map(o=>{let r=n.get(o.id)||(o.groupId?i.get(o.groupId):void 0);if(!r)return o;let a=!!t.jobId&&o.replyJobIds?.includes(t.jobId);return{...o,status:r.status,resolutionSummary:r.summary,scope:r.finalScope??r.inferredScope??null,replyCount:(o.replyCount??0)+(a?0:1),replyJobIds:t.jobId&&!a?[...o.replyJobIds??[],t.jobId]:o.replyJobIds,question:void 0,threadId:o.threadId||t.threadId}})}}function zi(e,t){let{linkedSelectors:n,styleSelectors:i}=t,o=new Set(n),r=new Set(i),a=typeof window<"u"?window.location.pathname:"/",l=new Set,d=new Set;for(let f of e.annotations)f.linkedSelector&&o.has(f.linkedSelector)&&(l.add(f.id),f.groupId&&d.add(f.groupId));for(let f of e.annotations)f.groupId&&d.has(f.groupId)&&l.add(f.id);let s=e.annotations.filter(f=>!l.has(f.id)),c=e.styleModifications.filter(f=>!r.has(f.selector)||f.pathname&&f.pathname!==a),h=e.domModifications.filter(f=>!r.has(f.selector)||f.pathname&&f.pathname!==a);if(s.length===e.annotations.length&&c.length===e.styleModifications.length&&h.length===e.domModifications.length)return e;let u=e.selectedAnnotationIds.filter(f=>!l.has(f));return{...e,annotations:s,styleModifications:c,domModifications:h,selectedAnnotationIds:u,lastSelectedId:u.length>0?u[u.length-1]:null}}function Bi(e,t){let n=e.spacingTokenChanges.findIndex(i=>i.tokenPath===t.tokenPath);return n>=0?{...e,spacingTokenChanges:e.spacingTokenChanges.map((i,o)=>o===n?t:i)}:{...e,spacingTokenChanges:[...e.spacingTokenChanges,t]}}function Hi(e,t){return{...e,spacingTokenChanges:t}}function Wi(e,t){let n=_(e),i=e.spacingTokenMods.findIndex(r=>r.tokenPath===t.tokenPath),o;if(i>=0){let r=e.spacingTokenMods[i],a={...t,originalValue:r.captured?r.currentValue:r.originalValue,originalPx:r.captured?r.currentPx:r.originalPx,captured:!1};o=e.spacingTokenMods.map((l,d)=>d===i?a:l)}else o=[...e.spacingTokenMods,{...t,captured:!1}];return{...n,spacingTokenMods:o}}function ji(e,t){let n=_(e),i=e.spacingTokenMods.findIndex(s=>s.tokenPath===t.tokenPath),o=i>=0?e.spacingTokenMods[i]:null,r=i>=0?o.captured?o.currentValue:o.originalValue:t.originalValue,a=i>=0?o.captured?o.currentPx:o.originalPx:parseFloat(t.originalValue)||0,l={tokenPath:t.tokenPath,originalValue:r,currentValue:"__deleted__",targets:o?.targets??[],originalPx:a,currentPx:0,captured:!1},d;return i>=0?d=e.spacingTokenMods.map((s,c)=>c===i?l:s):d=[...e.spacingTokenMods,l],{...n,spacingTokenMods:d}}function sn(e,t){switch(t.type){case"SET_ANNOTATING":return ei(e,t.payload);case"SET_TOOL":return ti(e,t.payload);case"SET_COLOR":return ni(e,t.payload);case"SET_STROKE_WIDTH":return oi(e,t.payload);case"ADD_TEXT":return ii(e,t.payload);case"UPDATE_TEXT":return ai(e,t.payload);case"CLEAR_INTERACTION_EPISODE":return ri(e,t.payload);case"DELETE_ANNOTATION":return li(e,t.payload);case"MOVE_ANNOTATION":return di(e,t.payload);case"RESIZE_ANNOTATION":return si(e,t.payload);case"PASTE_ANNOTATIONS":return pi(e,t.payload);case"RESTORE_ANNOTATIONS":return ci(e,t.payload);case"SYNC_ANNOTATIONS":return ui(e,t.payload);case"MERGE_ANNOTATIONS":return fi(e,t.payload);case"UNDO":return hi(e);case"REDO":return gi(e);case"SELECT_ANNOTATION":return mi(e,t.payload);case"UPDATE_ANNOTATION_COLOR":return yi(e,t.payload);case"MARK_CAPTURED":return xi(e,t.payload?.annotationIds,t.payload?.textModifications);case"CLEAR":return vi(e);case"DISCARD_DRAFT":return wi(e);case"MODIFY_STYLE":return bi(e,t.payload);case"MODIFY_STYLES_BATCH":return Si(e,t.payload);case"CLEAR_STYLE":return Ii(e,t.payload);case"CLEAR_STICKER":return Mi(e,t.payload);case"CLEAR_ALL_STYLES":return Ti(e);case"SETTLE_CAPTURED_STYLES":return ki(e,t.payload);case"RESTORE_STYLE_MODIFICATIONS":return Ei(e,t.payload);case"MODIFY_TEXT_CONTENT":return dn(e,t.payload);case"MODIFY_TEXT_CONTENTS":return Ci(e,t.payload,t.saveUndo??!0);case"RESTORE_TEXT_MODIFICATIONS":return Ai(e,t.payload);case"MODIFY_DOM_STRUCTURE":return Ri(e,t.payload);case"RESTORE_DOM_MODIFICATIONS":return Ni(e,t.payload);case"UPDATE_LINKED_POSITIONS":return Li(e,t.payload);case"CLEANUP_ORPHANED":return zi(e,t.payload);case"SET_ANNOTATION_STATUS":return Oi(e,t.payload);case"MARK_ANNOTATIONS_REPLIED":return Di(e,t.payload);case"MARK_ANNOTATIONS_FAILED":return $i(e,t.payload);case"SET_ANNOTATION_THREAD":return _i(e,t.payload);case"SET_ANNOTATION_QUESTION":return Fi(e,t.payload);case"APPLY_RESOLUTIONS":return Pi(e,t.payload);case"ADD_SPACING_TOKEN_CHANGE":return Bi(e,t.payload);case"RESTORE_SPACING_TOKEN_CHANGES":return Hi(e,t.payload);case"MODIFY_SPACING_TOKEN":return Wi(e,t.payload);case"DELETE_SPACING_TOKEN":return ji(e,t.payload);default:return t}}function Yi(e,t){let n=de(an),[i,o]=Kn(sn,Cn),r=Un(n?.subscribe??Zo,n?.getSnapshot??rn,n?.getSnapshot??rn)??i,a=n?.dispatch??o;V(()=>{if(!r.isAnnotating)return;let d=s=>{t?.current||s.defaultPrevented||s.isComposing||s.altKey||s.composedPath().some(c=>c instanceof Element&&(c.matches('input, textarea, select, [role="textbox"]')||c instanceof HTMLElement&&c.isContentEditable||c.hasAttribute("contenteditable")&&c.getAttribute("contenteditable")!=="false"))||(s.metaKey||s.ctrlKey)&&s.key.toLowerCase()===$e.actions.undo.key&&(s.preventDefault(),s.shiftKey?a({type:"REDO"}):e?.current?.()||a({type:"UNDO"}))};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[a,r.isAnnotating,e,t]);let l=n?.getUndoHead?n.getUndoHead():r.undoStack.at(-1);return[r,a,l]}function ue(e){return e?!!e.closest("#devtools-toolbar, #devtools-scrim, #devtools-text-input, [data-devtools], [data-popmelt-panel], [data-popmelt-shadow-host]"):!1}function qi(e,t,n=document){let i=n,o=i.caretPositionFromPoint?.(e,t);if(o?.offsetNode?.nodeType===Node.TEXT_NODE)return o.offsetNode;let r=i.caretRangeFromPoint?.(e,t);return r?.startContainer?.nodeType===Node.TEXT_NODE?r.startContainer:null}function Ki(e,t){if(!e)return t();let n=e.style.pointerEvents;e.style.pointerEvents="none";try{return t()}finally{e.style.pointerEvents=n}}function Ui(e,t,n){let i=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(r){return r.textContent?.trim()?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),o=i.nextNode();for(;o;){let r=o,a=e.ownerDocument.createRange();a.selectNodeContents(r);let l=Array.from(a.getClientRects());if(a.detach?.(),l.some(d=>t>=d.left&&t<=d.right&&n>=d.top&&n<=d.bottom))return r;o=i.nextNode()}return null}function Xi(e,t,n){return Ki(n,()=>{let i=St(e,t);if(!i||ue(i))return null;let o=i?.ownerDocument??document,r=$n(e,t,o),a=qi(r.x,r.y,o);if(a&&!i.contains(a)&&(a=null),!a){let b=i;b&&!ue(b)&&(a=Ui(b,r.x,r.y))}if(!a||!_n(a.parentElement))return null;let l=a.parentElement;if(ue(l))return null;for(;l.parentElement&&l!==o.body;){let b=Ae(l).getComputedStyle(l).display,C=b==="inline-block"&&l.childNodes.length===1&&l.firstChild?.nodeType===Node.ELEMENT_NODE;if(b!=="inline"&&b!=="contents"&&!C)break;let N=l.parentElement;if(ue(N))break;if(Array.from(N.childNodes).some(T=>T.nodeType===Node.TEXT_NODE&&!!T.nodeValue?.trim())){l=N;continue}let z=Ae(N).getComputedStyle(N).display,A=z==="inline-block"&&N.childNodes.length===1&&N.firstChild?.nodeType===Node.ELEMENT_NODE;if(z==="inline"||z==="contents"||A){l=N;continue}break}let d=l.tagName.toLowerCase();if(d==="script"||d==="style"||d==="textarea"||d==="input")return null;let s=Vi(l),c=s.map(b=>b.originalText).join("");if(!c.trim())return null;let h=pn(l,a);if(!h)return null;let u=Ae(l).getComputedStyle(l),f=un(s,l,u),{textRect:y,boundaryRect:m,boundaryRects:g,flowRect:k,firstLineIndent:w}=f;if(y.width<=0||y.height<=0)return null;let v=parseFloat(u.fontSize)||12,I=u.whiteSpace!=="nowrap"&&u.whiteSpace!=="pre"&&(Zi(a)||u.display!=="inline");return{textNode:a,targetElement:l,textNodePath:h,segments:s,originalText:c,rect:y,boundaryRect:m,boundaryRects:g,flowRect:k,firstLineIndent:w,styles:u,fontSize:v,wrapsText:I}})}function pn(e,t){let n=[],i=t;for(;i&&i!==e;){let o=i.parentNode;if(!o)return null;n.unshift(Array.prototype.indexOf.call(o.childNodes,i)),i=o}return i===e?n:null}function Qi(e,t){let n=e.ownerDocument.createRange();n.selectNodeContents(e);let i=Ce(n.getBoundingClientRect(),e.ownerDocument);if(n.detach?.(),i.width>0&&i.height>0)return{left:i.left,top:i.top,width:i.width,height:i.height};let o=Ee(t);return{left:o.left,top:o.top,width:o.width,height:o.height}}function Vi(e){let t=[],n=i=>{if(i.nodeType===Node.TEXT_NODE){let r=i,a=pn(e,r);a&&t.push({textNode:r,textNodePath:a,originalText:r.nodeValue??""});return}if(i.nodeType!==Node.ELEMENT_NODE&&i!==e)return;let o=i.tagName?.toLowerCase();o==="script"||o==="style"||i.childNodes.forEach(n)};return e.childNodes.forEach(n),t}function cn(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function Gi(e){let t=[];for(let n of e){if(!n.textNode.isConnected||!n.originalText.trim())continue;let i=n.textNode.ownerDocument.createRange();i.selectNodeContents(n.textNode),t.push(...Array.from(i.getClientRects()).filter(o=>o.width>0&&o.height>0).map(o=>cn(Ce(o,n.textNode.ownerDocument)))),i.detach?.()}return Ge(t)}function Ji(e){let t=e.getBoundingClientRect(),n=Ae(e).getComputedStyle(e),i=(parseFloat(n.borderLeftWidth)||0)+(parseFloat(n.paddingLeft)||0),o=(parseFloat(n.borderRightWidth)||0)+(parseFloat(n.paddingRight)||0),r=(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.paddingTop)||0),a=(parseFloat(n.borderBottomWidth)||0)+(parseFloat(n.paddingBottom)||0);return Ce({left:t.left+i,top:t.top+r,width:Math.max(0,t.width-i-o),height:Math.max(0,t.height-r-a)},e.ownerDocument)}function un(e,t,n){let i=cn(Ee(t)),o=Gi(e),r=e[0]?.textNode?Qi(e[0].textNode,t):i,a=o.length>0?o:[r];return To({display:n.display,fragmentRects:a,elementRect:i,parentContentRect:t.parentElement?Ji(t.parentElement):void 0})}function Zi(e){let t=e.ownerDocument.createRange();t.selectNodeContents(e);let n=Array.from(t.getClientRects()).filter(i=>i.width>0&&i.height>0).length;return t.detach?.(),n>1}function ea(e,t,n){if(t===n||e.length===0)return[];let i=0;for(;i<t.length&&i<n.length&&t[i]===n[i];)i+=1;let o=0;for(;o<t.length-i&&o<n.length-i&&t[t.length-1-o]===n[n.length-1-o];)o+=1;let r=i,a=t.length-o,l=n.slice(i,n.length-o),d=0,s=!1;return e.flatMap((c,h)=>{let u=d,f=u+c.originalText.length;d=f;let y=r===a,m=y&&(r>=u&&r<f||h===e.length-1&&r===f),g=!y&&f>r&&u<a;if(!m&&!g)return[];let k=Math.max(0,Math.min(c.originalText.length,r-u)),w=Math.max(0,Math.min(c.originalText.length,a-u)),v=c.originalText.slice(0,k);return s||(v+=l,s=!0),v+=c.originalText.slice(w),v===c.originalText?[]:[{segment:c,modifiedText:v}]})}function pt(e,t){return Math.abs(e.left-t.left)<.5&&Math.abs(e.top-t.top)<.5&&Math.abs(e.width-t.width)<.5&&Math.abs(e.height-t.height)<.5}function ta(e,t){return!e||!t?e===t:pt(e,t)}function na(e,t){return e.length===t.length&&e.every((n,i)=>pt(n,t[i]))}function oa(){return{isDragging:!1,hasMoved:!1,mode:"move",startX:0,startY:0,element:null,originalParent:null,originalIndex:-1,selector:null,durableSelector:null,elementInfo:null}}function Fe(e){if(!e||e===document.body||e===document.documentElement||ue(e))return!1;let t=e.tagName.toLowerCase();return["script","style","link","meta","head","html","body","input","textarea","select","option","button"].includes(t)?!1:!!e.parentElement}function J(e){let t=e.getAttribute("data-pm");return t||(t=Math.random().toString(36).substring(2,8),e.setAttribute("data-pm",t)),`[data-pm="${t}"]`}function ct(e){return e.parentElement?Array.from(e.parentElement.children).indexOf(e):-1}function fn(e){e.removeAttribute("data-pm"),e.querySelectorAll("[data-pm]").forEach(t=>t.removeAttribute("data-pm"))}function hn(e,t,n,i,o=St){let r=n.parentElement;if(!r)return null;let a=o(e,t);for(;a&&a!==document.body;){if(a===n||n.contains(a)){a=a.parentElement;continue}if(a.parentElement===r&&Fe(a))break;a=a.parentElement}if(!a||a===document.body||a.parentElement!==r||a===i)return null;let l=a.getBoundingClientRect(),d=l.height>=l.width?t<l.top+l.height/2?"before":"after":e<l.left+l.width/2?"before":"after",s=ct(a),c=d==="before"?s:s+1;return{parent:r,reference:a,placement:d,index:c}}function ut(e,t,n){let i=Array.from(e.children).filter(r=>r!==t),o=Math.max(0,Math.min(n,i.length));e.insertBefore(t,i[o]??null)}function ia({drag:e,clientX:t,clientY:n,pathname:i,createId:o,rootElement:r,elementAtPoint:a}){let l=e.element;if(!l||!e.selector||!e.durableSelector||!e.elementInfo)return null;let d=hn(t,n,l,r,a);if(!d)return null;let s=e.originalParent===d.parent&&d.index>e.originalIndex?d.index-1:d.index;if(e.mode==="move"&&e.originalParent===d.parent&&(s===e.originalIndex||s===e.originalIndex+1))return null;let c=Q(d.parent),h=J(d.parent),u=Q(d.reference),f=J(d.reference),y=e.selector,m=e.durableSelector,g=e.elementInfo;if(e.mode==="copy"){let w=l.cloneNode(!0);if(!(w instanceof Element))return null;fn(w),ut(d.parent,w,s),y=J(w),m=Q(w),g={...We(w),selector:y}}else ut(d.parent,l,s);let k=e.originalParent;return{id:o(),operation:e.mode,selector:y,durableSelector:m,element:g,sourceSelector:e.mode==="copy"?e.selector:void 0,sourceDurableSelector:e.mode==="copy"?e.durableSelector:void 0,sourceElement:e.mode==="copy"?e.elementInfo:void 0,originalParentSelector:k?J(k):void 0,originalParentDurableSelector:k?Q(k):void 0,originalIndex:e.originalIndex,targetParentSelector:h,targetParentDurableSelector:c,targetIndex:s,referenceSelector:f,referenceDurableSelector:u,placement:d.placement,pathname:i}}function gn(e){return e instanceof HTMLElement&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable===!0||e.getAttribute("contenteditable")==="true")}function aa(){if(typeof document>"u")return null;let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e}function ft(e){let t=e.composedPath?.()[0]??e.target;return gn(t)||gn(aa())}function mn(e,t,n){if(n)return[n];let i=new Set(t),o=new Map;for(let a of e)a.groupId&&a.threadId&&o.set(a.groupId,a.threadId);let r=new Set;for(let a of e){if(!i.has(a.id))continue;let l=a.threadId||(a.groupId?o.get(a.groupId):void 0);l&&r.add(l)}return[...r]}function ra({state:e,stateRef:t,activeTextRef:n,selectedIdsRef:i,dispatch:o,clearSelection:r,selectAnnotation:a,handHoveredElement:l,onArchiveThread:d,openThreadId:s,currentPathname:c,hasOpenThread:h}){let u=le([]),f=le(0),y=le(null);V(()=>{let m=g=>{if(g.key==="Escape"){if(g.defaultPrevented||g.repeat||n.current||h||ft(g))return;if(i.current.length>0){g.preventDefault(),r();return}let w=t.current;if(w.annotations.some(v=>(v.status??"pending")==="pending")||w.styleModifications.some(v=>!v.captured)||w.textModifications.some(v=>!v.captured)||w.domModifications.some(v=>!v.captured)||w.spacingTokenChanges.some(v=>!v.captured)||w.spacingTokenMods.some(v=>!v.captured)){g.preventDefault(),o({type:"DISCARD_DRAFT"});return}}if((g.metaKey||g.ctrlKey)&&g.key.toLowerCase()==="c"&&e.activeTool==="hand"&&l&&!n.current){if(Fe(l)){g.preventDefault();let w=J(l);y.current={source:l,sourceSelector:w,sourceDurableSelector:Q(l),sourceElement:{...We(l),selector:w}}}return}if((g.metaKey||g.ctrlKey)&&g.key.toLowerCase()==="v"&&e.activeTool==="hand"&&y.current&&!n.current){let w=y.current,v=l&&Fe(l)?l:w.source,I=v.parentElement;if(I){g.preventDefault();let b=Q(I),C=J(I),N=Q(v),z=J(v),A=ct(v)+1,T=w.source.cloneNode(!0);if(T instanceof Element){fn(T),ut(I,T,A);let X=J(T),oe=Q(T),ie={...We(T),selector:X};o({type:"MODIFY_DOM_STRUCTURE",payload:{id:dt(),operation:"copy",selector:X,durableSelector:oe,element:ie,sourceSelector:w.sourceSelector,sourceDurableSelector:w.sourceDurableSelector,sourceElement:w.sourceElement,targetParentSelector:C,targetParentDurableSelector:b,targetIndex:A,referenceSelector:z,referenceDurableSelector:N,placement:"after",pathname:c}})}}return}if((g.metaKey||g.ctrlKey)&&g.key==="v"&&u.current.length>0&&!n.current){g.preventDefault(),f.current+=1;let w=f.current*20,v=u.current[0]?.groupId?Math.random().toString(36).substring(2,9):void 0,I=u.current.map(C=>({...C,id:Math.random().toString(36).substring(2,9),groupId:C.groupId?v:void 0,timestamp:Date.now(),points:C.points.map(N=>({x:N.x+w,y:N.y+w}))}));o({type:"PASTE_ANNOTATIONS",payload:{annotations:I}});let b=I.find(C=>C.type!=="text")??I[0];b&&a(b.id);return}let k=i.current;if(!n.current&&!ft(g)&&(g.key==="Delete"||g.key==="Backspace")&&!g.metaKey&&!g.ctrlKey&&!g.altKey){if(k.length===0&&!s)return;let w=mn(t.current.annotations,k,s);if(!d||w.length===0)return;g.preventDefault();for(let v of w)d(v);r()}};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[n,r,c,o,l,h,d,s,a,i,e.activeTool,t])}export{Eo as $,ue as A,Yo as Aa,Xi as B,qo as Ba,un as C,Ko as Ca,ea as D,Qo as Da,pt as E,ta as F,na as G,oa as H,Fe as I,J,ct as K,hn as L,ia as M,ft as N,mn as O,ra as P,Ue as Q,xe as R,Xe as S,wo as T,vo as U,bo as V,So as W,Io as X,$t as Y,_t as Z,zt as _,$e as a,ve as aa,Vo as b,Ze as ba,Go as c,Ao as ca,Jo as d,ne as da,an as e,nt as ea,dt as f,jt as fa,sn as g,ot as ga,Yi as h,Yt as ha,Xn as i,qt as ia,Qn as j,Lo as ja,Gn as k,Oo as ka,eo as l,Kt as la,to as m,Ut as ma,no as n,it as na,oo as o,at as oa,lo as p,be as pa,so as q,Do as qa,po as r,rt as ra,uo as s,pe as sa,fo as t,G as ta,ho as u,Vt as ua,go as v,Gt as va,Dt as w,Zt as wa,mo as x,en as xa,yo as y,tn as ya,xo as z,jo as za};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{A as p}from"./chunk-
|
|
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};
|
|
@@ -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-
|
|
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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{k as y,a as g,i as S}from"./chunk-
|
|
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};
|