@popmelt.com/core 0.32.1 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +24 -1
  2. package/claude-plugin/.claude-plugin/plugin.json +1 -1
  3. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  4. package/dist/ExploreAttachment-CLFSAWKM.mjs +260 -0
  5. package/dist/ParticipantRuntime-HW3MOZI5.mjs +139 -0
  6. package/dist/PopmeltTasteConnectedPane-FKIJM3C7.mjs +215 -0
  7. package/dist/PreviewRuntime-LFPK56NW.mjs +2 -0
  8. package/dist/SuppliedContext-RWN6UR3K.mjs +2 -0
  9. package/dist/{ThreadErrorCard-WZ2UBVWE.mjs → ThreadErrorCard-7J62GD5W.mjs} +1 -1
  10. package/dist/ThreadPanel-RJIHV3P6.mjs +197 -0
  11. package/dist/bridge-entry.mjs +1 -2
  12. package/dist/browser-runtime-JJHSKIKD.mjs +2 -0
  13. package/dist/browser.mjs +1 -1
  14. package/dist/checkFixture-TJDFGPQI.mjs +2 -0
  15. package/dist/{chunk-C3VWS5R6.mjs → chunk-27ADDVGC.mjs} +1 -1
  16. package/dist/chunk-2IASPT6L.mjs +2 -0
  17. package/dist/chunk-2VCHBI7Y.mjs +11 -0
  18. package/dist/chunk-2ZJ4FBTG.mjs +2 -0
  19. package/dist/chunk-5K7SACPW.mjs +2 -0
  20. package/dist/chunk-6V2VCKPG.mjs +53 -0
  21. package/dist/{chunk-MTQ5IWIK.mjs → chunk-75PQGTKX.mjs} +1 -1
  22. package/dist/chunk-7IJGE5AK.mjs +31 -0
  23. package/dist/chunk-BVTLSUQT.mjs +2 -0
  24. package/dist/chunk-C5WXW6VL.mjs +1 -0
  25. package/dist/chunk-DMWB3IRD.mjs +1 -0
  26. package/dist/chunk-DNOKP3JS.mjs +2 -0
  27. package/dist/chunk-EAV2VV2V.mjs +2 -0
  28. package/dist/chunk-F5XSNRGT.mjs +2 -0
  29. package/dist/{chunk-QTGE5KAA.mjs → chunk-GASEZICN.mjs} +1 -1
  30. package/dist/chunk-GL4I4MI6.mjs +1 -3
  31. package/dist/chunk-H2UYAUX3.mjs +2 -0
  32. package/dist/chunk-HNCV37XO.mjs +2 -0
  33. package/dist/chunk-I63OQTCF.mjs +347 -0
  34. package/dist/chunk-IKCHOC3U.mjs +1 -2
  35. package/dist/chunk-J5SC3R5L.mjs +2 -0
  36. package/dist/{chunk-IPR652AZ.mjs → chunk-JMMP5JSP.mjs} +1 -1
  37. package/dist/chunk-NOHXTT24.mjs +1 -1
  38. package/dist/{chunk-V44RIEET.mjs → chunk-ODIGT4YJ.mjs} +2 -2
  39. package/dist/chunk-PHKDIU3X.mjs +30 -0
  40. package/dist/chunk-PQT5FYN5.mjs +2 -0
  41. package/dist/chunk-PSSHCTJ2.mjs +8 -0
  42. package/dist/chunk-QXVMGZFP.mjs +1 -1
  43. package/dist/chunk-V2I7PSJW.mjs +2 -0
  44. package/dist/chunk-W5NIRROD.mjs +7 -0
  45. package/dist/chunk-WHJEKDNP.mjs +2 -0
  46. package/dist/chunk-XKD2ABCO.mjs +7 -0
  47. package/dist/chunk-XMKYGH62.mjs +142 -0
  48. package/dist/{chunk-D32YV5O6.mjs → chunk-ZHJZPC7U.mjs} +1 -1
  49. package/dist/cli.mjs +1 -69
  50. package/dist/codex-note-context-YHKPQ4WP.mjs +2 -0
  51. package/dist/codex-project-7VYHYTWO.mjs +2 -0
  52. package/dist/codex-session-registry-SPRWY2WW.mjs +1 -1
  53. package/dist/focus-inspection-VBS5656D.mjs +2 -0
  54. package/dist/index.mjs +1 -1
  55. package/dist/memory-legacy.mjs +1 -1
  56. package/dist/memory-store.mjs +1 -1
  57. package/dist/peer-client-MTWZG2FB.mjs +2 -0
  58. package/dist/plugin-astro.mjs +1 -31
  59. package/dist/plugin-nuxt.mjs +1 -30
  60. package/dist/plugin-vite.mjs +1 -1
  61. package/dist/server.d.mts +2 -0
  62. package/dist/server.mjs +1 -14
  63. package/dist/{workspace-snapshot-O34KMJ2V.mjs → workspace-snapshot-RTTXNNUX.mjs} +1 -1
  64. package/package.json +24 -32
  65. package/dist/ParticipantRuntime-5KRRPLWL.mjs +0 -139
  66. package/dist/PopmeltTasteConnectedPane-7YIHIFPE.mjs +0 -221
  67. package/dist/PreviewRuntime-QDA4OF67.mjs +0 -2
  68. package/dist/SuppliedContext-NURVPZ4L.mjs +0 -2
  69. package/dist/browser-runtime-3EQH4ZUO.mjs +0 -2
  70. package/dist/chunk-4BQQAQ3P.mjs +0 -317
  71. package/dist/chunk-CGOQSIDR.mjs +0 -342
  72. package/dist/chunk-DIFC23QP.mjs +0 -1
  73. package/dist/chunk-EXDOFFFJ.mjs +0 -2
  74. package/dist/chunk-F6AMPRUB.mjs +0 -2
  75. package/dist/chunk-GDLI772N.mjs +0 -2
  76. package/dist/chunk-GNZ73T3H.mjs +0 -62
  77. package/dist/chunk-HGXCQKB6.mjs +0 -347
  78. package/dist/chunk-RCVAPQ7X.mjs +0 -2
  79. package/dist/chunk-ROIC72KJ.mjs +0 -1
  80. package/dist/chunk-U2MTWKH3.mjs +0 -2
  81. package/dist/chunk-XQV7EM46.mjs +0 -309
  82. package/dist/codex-note-context-OYDZYZXX.mjs +0 -2
  83. package/dist/codex-project-XLVIKWAE.mjs +0 -2
  84. package/dist/focus-inspection-G72JLJYG.mjs +0 -2
  85. package/dist/peer-client-5D6UOMB3.mjs +0 -2
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import{f as H}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 C="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 S=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(),C;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(),C}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&&H(t,o.region.points.map(s=>({x:s.x,y:s.y-n})),o.color),o.type){case"freehand":if(a.length<2)break;t.beginPath(),t.moveTo(a[0].x,a[0].y);for(let s=1;s<a.length;s++)t.lineTo(a[s].x,a[s].y);t.stroke();break;case"line":if(a.length<2)break;t.beginPath(),t.moveTo(a[0].x,a[0].y),t.lineTo(a[a.length-1].x,a[a.length-1].y),t.stroke();break;case"rectangle":{if(a.length<2)break;let s=a[0],c=a[a.length-1],u=Math.min(s.x,c.x),l=Math.min(s.y,c.y),m=Math.abs(c.x-s.x),h=Math.abs(c.y-s.y);t.strokeRect(u,l,m,h);break}case"circle":{if(a.length<2)break;let s=a[0],c=a[a.length-1],u=(s.x+c.x)/2,l=(s.y+c.y)/2,m=Math.abs(c.x-s.x)/2,h=Math.abs(c.y-s.y)/2;t.beginPath(),t.ellipse(u,l,m,h,0,0,Math.PI*2),t.stroke();break}case"text":{if(!o.text||a.length<1)break;let s=a[0],c=o.fontSize||16;t.font=`${c}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`,t.fillStyle=o.color;let u=(o.imageCount&&o.imageCount>0?`[${o.imageCount} image${o.imageCount>1?"s":""}] ${o.text}`:o.text).split(`
2
+ import{f as H}from"./chunk-J4WDYITA.mjs";import{l as W,d as z}from"./chunk-WHJEKDNP.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 C="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 S=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(),C;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(),C}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&&H(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=S.get(i);if(o)return R(r)&&console.debug("[Screenshot] Reusing in-flight capture",i),o;let a=vt(t,n,r).finally(()=>S.delete(i));return S.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:C}}))}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 N=p(),I=await Mt(Y);d.encodeMs=p()-N;let O=p()-d.startedAt,B={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(B)),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};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{A as u}from"./chunk-BVTLSUQT.mjs";import{a as s}from"./chunk-75PQGTKX.mjs";import{r as c}from"./chunk-WHJEKDNP.mjs";function f(r,l){let e=r.split(c()),t=l;try{for(let[n,i]of e.entries()){let a=t.querySelectorAll(i);if(a.length!==1)return null;let o=a[0];if(n===e.length-1)return o;if(!o.shadowRoot)return null;t=o.shadowRoot}}catch{}return null}function p(r,l){return r.targetBindings?.length?r.targetBindings.flatMap(({anchor:e})=>{if(e.type==="opaque"){let n={adapter:e.adapter,key:e.key};return[{selector:s(n),subject:n}]}let t=e.structuralSelector??e.runtimeSelector;return e.pathname===l&&t?[{selector:t}]:[]}).slice(0,8):(r.elementIdentifiers??[]).flatMap(e=>{let t=u(e,l);return t?[{selector:t}]:[]}).slice(0,8)}export{f as a,p as b};
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import{a as c}from"./chunk-V2I7PSJW.mjs";function m(t,e){if(c(t)){let n=t.style.getPropertyValue(e);if(n)return n}let o=e.replace(/-([a-z])/g,(n,i)=>i.toUpperCase());try{for(let n of document.styleSheets)try{let i=n.cssRules||n.rules;for(let l of i)if(l instanceof CSSStyleRule&&t.matches(l.selectorText)){let s=l.style.getPropertyValue(e);if(s)return s;let a=l.style[o];if(a)return a}}catch{}}catch{}return null}function w(t){let e=window.getComputedStyle(t).display;return e==="flex"||e==="inline-flex"||e==="grid"||e==="inline-grid"}function y(t){let e=window.getComputedStyle(t);return{row:parseFloat(e.rowGap)||0,column:parseFloat(e.columnGap)||0}}function x(t){let e=[];for(let o of t){let n=e.find(i=>i.axis!==o.axis?!1:o.axis==="row"?Math.abs(i.y-o.y)<2&&Math.abs(i.h-o.h)<2:Math.abs(i.x-o.x)<2&&Math.abs(i.w-o.w)<2);if(n)if(o.axis==="row"){let i=Math.min(n.x,o.x),l=Math.max(n.x+n.w,o.x+o.w);n.x=i,n.w=l-i}else{let i=Math.min(n.y,o.y),l=Math.max(n.y+n.h,o.y+o.h);n.y=i,n.h=l-i}else e.push({...o})}return e}function b(t){let e=Array.from(t.children).filter(a=>{if(!(a instanceof HTMLElement))return!1;let r=window.getComputedStyle(a);return r.display!=="none"&&r.position!=="absolute"&&r.position!=="fixed"});if(e.length<2)return[];let o=[],n=t.getBoundingClientRect(),i=window.getComputedStyle(t).flexDirection,l=i==="column"||i==="column-reverse",s=6;for(let a=0;a<e.length-1;a++){let r=e[a].getBoundingClientRect(),u=e[a+1].getBoundingClientRect();if(u.left>r.right+.5&&o.push({axis:"column",x:r.right,y:n.top,w:u.left-r.right,h:n.height}),u.top>r.bottom+.5&&o.push({axis:"row",x:n.left,y:r.bottom,w:n.width,h:u.top-r.bottom}),!(u.left>r.right+.5)&&!(u.top>r.bottom+.5))if(l){let d=(r.bottom+u.top)/2;o.push({axis:"row",x:n.left,y:d-s/2,w:n.width,h:s})}else{let d=(r.right+u.left)/2;o.push({axis:"column",x:d-s/2,y:n.top,w:s,h:n.height})}}return x(o)}function R(t,e){let o=window.getComputedStyle(t),n=o.display;if(n!=="flex"&&n!=="inline-flex")return!1;let i=o.justifyContent;if(i!=="space-between"&&i!=="space-around"&&i!=="space-evenly"&&i!=="stretch")return!1;let l=o.flexDirection;return!(e!==(l==="column"||l==="column-reverse"?"row":"column")||parseFloat(e==="row"?o.rowGap:o.columnGap)>0)}function C(t){let e=window.getComputedStyle(t);return{top:parseFloat(e.paddingTop)||0,right:parseFloat(e.paddingRight)||0,bottom:parseFloat(e.paddingBottom)||0,left:parseFloat(e.paddingLeft)||0}}function F(t){let e=window.getComputedStyle(t);return{top:parseFloat(e.marginTop)||0,right:parseFloat(e.marginRight)||0,bottom:parseFloat(e.marginBottom)||0,left:parseFloat(e.marginLeft)||0}}function v(t){let e=window.getComputedStyle(t);return{topLeft:e.borderTopLeftRadius,topRight:e.borderTopRightRadius,bottomRight:e.borderBottomRightRadius,bottomLeft:e.borderBottomLeftRadius}}function S(t){let e=window.getComputedStyle(t);return{"top-left":parseFloat(e.borderTopLeftRadius)||0,"top-right":parseFloat(e.borderTopRightRadius)||0,"bottom-right":parseFloat(e.borderBottomRightRadius)||0,"bottom-left":parseFloat(e.borderBottomLeftRadius)||0}}function T(t){for(let e of t.childNodes)if(e.nodeType===Node.TEXT_NODE&&(e.textContent||"").trim().length>0)return!0;return!1}function L(t){let e=document.createRange(),o=!1;for(let d of t.childNodes)d.nodeType===Node.TEXT_NODE&&(d.textContent||"").trim().length>0&&(o||(e.setStart(d,0),o=!0),e.setEnd(d,d.textContent?.length??0));if(!o)return null;let n=e.getBoundingClientRect(),i=window.getComputedStyle(t),l=parseFloat(i.fontSize)||16,s=parseFloat(i.lineHeight);isNaN(s)&&(s=l*1.2);let a=Math.max(1,e.getClientRects().length),r=Math.max(n.height,a*s),u=(r-n.height)/2;return new DOMRect(n.x,n.y-u,n.width,r)}function M(t){let e=window.getComputedStyle(t),o=parseFloat(e.fontSize)||16,n=parseFloat(e.lineHeight);return isNaN(n)&&(n=o*1.2),{fontSize:o,lineHeight:n}}var h=new WeakMap,f="popmelt:preview-viewport-change";function E(t){let e=t.ownerDocument.defaultView;e&&h.get(e)?.schedule(),t.dispatchEvent(new Event(f,{bubbles:!0}))}function B(t){let e={listeners:new Set,rafId:null,schedule:()=>{e.rafId===null&&(e.rafId=t.requestAnimationFrame(()=>{e.rafId=null;for(let o of e.listeners)o()}))}};return h.set(t,e),t.addEventListener("scroll",e.schedule,{passive:!0,capture:!0}),t.addEventListener("resize",e.schedule),e}function N(t,e=window){let o=h.get(e)??B(e);return o.listeners.add(t),()=>{o.listeners.delete(t)&&(o.listeners.size>0||(e.removeEventListener("scroll",o.schedule,!0),e.removeEventListener("resize",o.schedule),o.rafId!==null&&e.cancelAnimationFrame(o.rafId),h.delete(e)))}}function p(t){return`
3
+ <svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
4
+ <defs>
5
+ <mask id="cutout">
6
+ <rect width="100%" height="100%" fill="white" />
7
+ <rect x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" rx="${t.radius}" fill="black" />
8
+ </mask>
9
+ </defs>
10
+ <rect width="100%" height="100%" fill="white" mask="url(#cutout)" />
11
+ </svg>`}function g(t){return`url("data:image/svg+xml,${encodeURIComponent(t)}")`}var z=g(p({x:-100,y:-2,width:104,height:26,radius:10})),D=g(p({x:-100,y:-5.929,width:108,height:26,radius:10})),I=10;export{m as a,w as b,y as c,b as d,R as e,C as f,F as g,v as h,S as i,T as j,L as k,M as l,f as m,E as n,N as o,z as p,D as q,I as r};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{c as a}from"./chunk-DNOKP3JS.mjs";import{a as u}from"./chunk-V2I7PSJW.mjs";var b={isAnnotating:!1,activeTool:"inspector",activeColor:"oklch(0.628 0.258 29)",strokeWidth:3,annotations:[],undoStack:[],redoStack:[],selectedAnnotationIds:[],lastSelectedId:null,styleModifications:[],textModifications:[],domModifications:[],spacingTokenChanges:[],spacingTokenMods:[]},f=new WeakMap,c=new WeakMap;function S(t,e){if(u(e))for(let[o,r]of c.get(t)??[])r.value?e.style.setProperty(o,r.value,r.priority):e.style.removeProperty(o)}function v(t,e){f.set(t,new Set(e))}function P(t){f.delete(t)}function d(t,e){return u(t)&&(f.get(t)?.has(e)??!1)}function p(t){let e=t.sticker;return e?e.family==="padding"||e.family==="margin"?e.subproperty==="all"?10:e.subproperty==="x"||e.subproperty==="y"?20:30:e.family==="radius"||e.family==="border"?e.subproperty==="all"?10:20:10:0}function x(t){return t.changes.map((e,o)=>({change:e,index:o})).sort((e,o)=>p(e.change)-p(o.change)||e.index-o.index).map(({change:e})=>e)}function m(t,e,o){if(u(t)){let r=c.get(t);r||(r=new Map,c.set(t,r)),r.has(e)||r.set(e,{value:t.style.getPropertyValue(e),priority:t.style.getPropertyPriority(e)}),t.style.setProperty(e,o,"important")}}function k(t,e,o,r=!1){if(u(t)){let n=r?c.get(t)?.get(e):void 0;n?.value?t.style.setProperty(e,n.value,n.priority):t.style.removeProperty(e),c.get(t)?.delete(e)}}function y(t){let e=a(t.selector);if(!e&&t.durableSelector&&(e=a(t.durableSelector),e)){let o=t.selector.match(/\[data-pm="([^"]+)"\]/)?.[1];o&&e.setAttribute("data-pm",o)}return e}function A(t){for(let e of t){let o=y(e);if(o)for(let r of x(e))d(o,r.property)||m(o,r.property,r.modified)}}function M(t,e=!1){for(let o of t){let r=a(o.selector);if(r)for(let n of o.changes)d(r,n.property)||k(r,n.property,n.original,e)}}function g(t){let e=a(t.selector);if(!e&&t.durableSelector&&(e=a(t.durableSelector),e)){let o=t.selector.match(/\[data-pm="([^"]+)"\]/)?.[1];o&&e.setAttribute("data-pm",o)}return e}function h(t,e){let o=t;for(let r of e)o=o?.childNodes[r]??null;return o?.nodeType===Node.TEXT_NODE?o:null}function V(t){for(let e of t){if(e.captured)continue;let o=g(e);if(!o)continue;let r=h(o,e.textNodePath);r&&r.nodeValue===e.original&&r.nodeValue!==e.modified&&(r.nodeValue=e.modified)}}function N(t){for(let e of t){if(e.captured)continue;let o=g(e);if(!o)continue;let r=h(o,e.textNodePath);r&&r.nodeValue===e.modified&&r.nodeValue!==e.original&&(r.nodeValue=e.original)}}function l(t,e){if(!t)return null;let o=a(t);if(!o&&e&&(o=a(e),o)){let r=t.match(/\[data-pm="([^"]+)"\]/)?.[1];r&&o.setAttribute("data-pm",r)}return o}function T(t){t.removeAttribute("data-pm"),t.querySelectorAll("[data-pm]").forEach(e=>e.removeAttribute("data-pm"))}function w(t,e){let o=e.match(/\[data-pm="([^"]+)"\]/)?.[1];o&&t.setAttribute("data-pm",o)}function s(t,e,o){let r=Array.from(t.children).filter(i=>i!==e),n=Math.max(0,Math.min(o,r.length));t.insertBefore(e,r[n]??null)}function D(t){for(let e of t){let o=l(e.targetParentSelector,e.targetParentDurableSelector);if(!o)continue;if(e.operation==="move"){let i=l(e.selector,e.durableSelector);if(!i||i===o||i.contains(o))continue;s(o,i,e.targetIndex);continue}if(l(e.selector,e.durableSelector))continue;let r=l(e.sourceSelector,e.sourceDurableSelector);if(!r)continue;let n=r.cloneNode(!0);n instanceof Element&&(T(n),w(n,e.selector),s(o,n,e.targetIndex))}}function I(t){for(let e of[...t].reverse()){if(e.operation==="copy"){l(e.selector,e.durableSelector)?.remove();continue}let o=l(e.selector,e.durableSelector),r=l(e.originalParentSelector,e.originalParentDurableSelector);!o||!r||o===r||o.contains(r)||s(r,o,e.originalIndex??r.children.length)}}export{b as a,S as b,v as c,P as d,m as e,y as f,A as g,M as h,V as i,N as j,D as k,I as l};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ function l(i){let t=Object.keys(i).find(n=>n.startsWith("__reactFiber$")||n.startsWith("__reactInternalInstance$"));if(!t)return null;let e=i[t],a=[],r=e?._debugSource;for(;e;){let n=e.type,s=n?.displayName||n?.name;s&&typeof s=="string"&&/^[A-Z]/.test(s)&&!s.startsWith("_")&&s!=="Fragment"&&a.unshift(s),e=e.return}return a.length>0?{name:a[a.length-1],path:a,...r?.fileName&&Number.isFinite(r.lineNumber)?{source:r}:{}}:null}function u(i){let t=Object.keys(i).find(r=>r.startsWith("__reactFiber$")||r.startsWith("__reactInternalInstance$"));if(!t)return[];let e=i[t],a=[];for(;e;){let r=e.type,n=typeof r=="function"||typeof r=="object"?r?.displayName||r?.name:null;n&&typeof n=="string"&&/^[A-Z]/.test(n)&&!n.startsWith("_")&&n!=="Fragment"&&a.push({name:n,fiber:e}),e=e.return}return a.reverse(),a}function f(i){let t=i,e=new Set;for(;t&&!e.has(t);){if(e.add(t),t.stateNode instanceof Element)return t.stateNode;t.child?t=t.child:t=null}return null}export{l as a,u as b,f as c};
@@ -0,0 +1,53 @@
1
+ "use client";
2
+ import{c as We,b as In}from"./chunk-4LHTPRFY.mjs";import{a as Sn}from"./chunk-2ZJ4FBTG.mjs";import{g as bt,a as X,f as He}from"./chunk-DNOKP3JS.mjs";import{o as Tn,p as Me,r as wt,h as It,i as Mn}from"./chunk-2VCHBI7Y.mjs";import{b as je,g as Ye,e as Ke}from"./chunk-ODIGT4YJ.mjs";import{a as kn,b as En,c as St}from"./chunk-5K7SACPW.mjs";import{a as An,b as Cn}from"./chunk-LVEMYZOA.mjs";import{a as Tt,d as ke,v as Rn,h as Nn,i as Mt,c as Ee,f as Ae,b as kt,e as Ln,g as $n}from"./chunk-WHJEKDNP.mjs";import{Clock as Et,OctagonAlert as On,MessageCircleQuestionMark as Dn,TriangleAlert as _n,Reply as Pn,Eye as Fn,SendHorizontal as Ce,CornerDownLeft as zn}from"lucide-react";import{createContext as qe,useContext as ce,useState as re,useEffect as J,useLayoutEffect as At,useId as Bn,useRef as le,useMemo as Wn,useCallback as Hn,useReducer as jn,useSyncExternalStore as Yn}from"react";import{jsxs as C,jsx as x,Fragment as H}from"react/jsx-runtime";var Re=new Set,Ne;function Ue(e){if(Re.add(e),!Ne){let t=new Map,o=new Map,i="",n=!0,r=!0,a=!1,l=!0,s=0,d=()=>{let h=new Set,u=new Map,f=y=>{if(h.add(y),!t.has(y)){let g=new MutationObserver(k=>{let v=k.filter(b=>!(b.target.nodeType===1?b.target:b.target.parentElement)?.closest("[data-devtools]"));v.length&&(n=!0),v.some(b=>b.type==="childList")&&(r=!0)});g.observe(y,{subtree:!0,childList:!0,characterData:!0,attributes:!0});let m=()=>{n=!0};y.addEventListener("scroll",m,!0),y.addEventListener("load",m,!0),t.set(y,()=>{g.disconnect(),y.removeEventListener("scroll",m,!0),y.removeEventListener("load",m,!0)})}for(let g of y.querySelectorAll("*")){if(g.shadowRoot&&!g.closest("[data-devtools]")&&f(g.shadowRoot),g.localName!=="iframe"||g.closest("[data-devtools],[data-popmelt-peer-surface]"))continue;let m=kt(g);u.set(g,m),m&&f(m)}};f(document);for(let[y,g]of t)h.has(y)||(g(),t.delete(y));o=u,r=!1,n=!0},p=()=>{if(!l)return;(r||[...o].some(([f,y])=>kt(f)!==y))&&d();let h=[];for(let[f,y]of o){let g=f.getBoundingClientRect();h.push(y?.URL,g.x,g.y,g.width,g.height,y?.defaultView?.scrollX,y?.defaultView?.scrollY)}let u=JSON.stringify(h);if((n||u!==i)&&(n=!1,i=u,a))for(let f of Re)f();a=!0,l&&(s=requestAnimationFrame(p))};p(),Ne=()=>{l=!1,cancelAnimationFrame(s);for(let h of t.values())h()}}return()=>{Re.delete(e),Re.size||(Ne?.(),Ne=void 0)}}var ye=qe(!0);function Ve(e,t){let o=e.match(/^oklch\(([^)]+)\)$/i);if(o)return`oklch(${o[1]} / ${t})`;let i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(i){let n=parseInt(i[1],16),r=parseInt(i[2],16),a=parseInt(i[3],16);return`rgba(${n}, ${r}, ${a}, ${t})`}return`color-mix(in srgb, ${e} ${Math.round(t*100)}%, transparent)`}function Ct(e,t){let o=En(e),i=t.toLowerCase(),n=-1;for(let r=o.length-1;r>=0;r--){let a=o[r].name;if(a===t){let l=St(o[r].fiber)??e;return{name:t,path:o.map(s=>s.name),depthIndex:r,rootElement:l}}if(n===-1){let l=a.toLowerCase();(l.length>=4&&i.includes(l)||i.length>=4&&l.includes(i))&&(n=r)}}if(n>=0){let r=St(o[n].fiber)??e;return{name:t,path:o.map(a=>a.name),depthIndex:n,rootElement:r}}return null}function Kn(e){let t=Le(),o=[],i=new Set,n=t.currentNode;for(;n=t.nextNode();){let r=Ct(n,e);r&&!i.has(r.rootElement)&&(i.add(r.rootElement),o.push(r))}return o}function qn(e){let t=new Map;if(e.size===0)return t;let o=new Set(e),i=Le(),n=new Set,r=i.currentNode;for(;(r=i.nextNode())&&o.size>0;)for(let a of o){let l=Ct(r,a);if(!l||n.has(l.rootElement))continue;n.add(l.rootElement);let s=l.rootElement.getBoundingClientRect();t.set(a,s.top+window.scrollY),o.delete(a);break}for(let a of o)t.set(a,1/0);return t}function Le(){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 K(e,t){return e.style.getPropertyValue(t)!==""}function Un(e,t=30){if(e<=0)return[];let o=[],i=Le(),n=.5,r=i.currentNode;for(;(r=i.nextNode())&&o.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 s=getComputedStyle(a);!K(a,"padding-top")&&Math.abs((parseFloat(s.paddingTop)||0)-e)<n&&o.push({element:a,property:"padding-top"}),!K(a,"padding-bottom")&&Math.abs((parseFloat(s.paddingBottom)||0)-e)<n&&o.length<t&&o.push({element:a,property:"padding-bottom"}),!K(a,"padding-left")&&Math.abs((parseFloat(s.paddingLeft)||0)-e)<n&&o.length<t&&o.push({element:a,property:"padding-left"}),!K(a,"padding-right")&&Math.abs((parseFloat(s.paddingRight)||0)-e)<n&&o.length<t&&o.push({element:a,property:"padding-right"}),!K(a,"margin-top")&&Math.abs((parseFloat(s.marginTop)||0)-e)<n&&o.length<t&&o.push({element:a,property:"margin-top"}),!K(a,"margin-bottom")&&Math.abs((parseFloat(s.marginBottom)||0)-e)<n&&o.length<t&&o.push({element:a,property:"margin-bottom"}),!K(a,"margin-left")&&Math.abs((parseFloat(s.marginLeft)||0)-e)<n&&o.length<t&&o.push({element:a,property:"margin-left"}),!K(a,"margin-right")&&Math.abs((parseFloat(s.marginRight)||0)-e)<n&&o.length<t&&o.push({element:a,property:"margin-right"});let d=s.display;if((d.includes("flex")||d.includes("grid"))&&o.length<t){let p=K(a,"gap"),h=parseFloat(s.gap)||0,u=parseFloat(s.rowGap)||0,f=parseFloat(s.columnGap)||0;!p&&Math.abs(h-e)<n?o.push({element:a,property:"gap"}):!K(a,"row-gap")&&Math.abs(u-e)<n?o.push({element:a,property:"row-gap"}):!K(a,"column-gap")&&Math.abs(f-e)<n&&o.push({element:a,property:"column-gap"})}}return o}function Vn(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 o=Rt[t];return o?o.includes(e):!1}function Xn(e,t){let o=e.split(/\s+/);for(let i of o){if(i===t)return!0;let n=i.lastIndexOf(":");if(n>=0&&i.slice(n+1)===t)return!0}return!1}function Jn(e){let t=e.lastIndexOf(":"),o=t>=0?e.slice(t+1):e,i=o.indexOf("-");if(i<0)return null;let n=o.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=o.slice(0,o.indexOf("-",i+1)>0?o.indexOf("-",i+1):i);return r[a]??r[n]??null}function Qn(e,t=30){let o=parseFloat(e.value);if(isNaN(o)||o<=0)return[];if(e.bindings&&e.bindings.length>0){let n=[],r=Le(),a=r.currentNode;for(;(a=r.nextNode())&&n.length<t;){let l=a,s=l.getBoundingClientRect();if(s.bottom<-50||s.top>window.innerHeight+50||s.right<-50||s.left>window.innerWidth+50||s.width<1||s.height<1)continue;let d=l.className;if(typeof d=="string")for(let p of e.bindings){if(!Xn(d,p))continue;let h=Jn(p);if(h&&!(e.property&&!Nt(h,e.property))){n.push({element:l,property:h});break}}}return n}let i=Un(o,t*2);return e.property?i.filter(n=>Nt(n.property,e.property)).slice(0,t):i.slice(0,t)}function Gn(e,t){let o=new Set,i=xe(t);for(let n of e){let r=Lt[n.property];if(!r)continue;let a=n.element.className;if(typeof a=="string")for(let l of r){let s=`${l}-${i}`;for(let d of a.split(/\s+/)){let p=d.lastIndexOf(":"),h=p>=0?d.slice(p+1):d;if(h===s){o.add(h);break}}}}return[...o]}function Zn(e){let t=new Set;for(let o of e)for(let[i,n]of Object.entries(Rt))if(n.includes(o.property)){t.add(i);break}if(t.size===1)return[...t][0]}function eo(e,t,o){if(t===o)return e;let i=xe(t),n=xe(o);return e.map(r=>{let a=r.lastIndexOf("-");if(a<0)return r;let l=r.slice(0,a),s=r.slice(a+1);return s===i||s===`[${t}px]`?`${l}-${n}`:r})}var to={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 xe(e){return to[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 no(e,t,o,i){let n=Lt[t];if(!n)return null;let r=xe(o);for(let a of n){let l=new RegExp("(?:^|\\s)((?:[\\w-]+:)*"+a+"-(?:"+oo(r)+"|\\["+o+"px\\]))(?:\\s|$)"),s=e.match(l);if(s?.[1]){let d=xe(i),p=s[1].lastIndexOf(":"),h=p>=0?s[1].slice(0,p+1):"";return{matched:s[1],suggested:`${h}${a}-${d}`}}}return null}function oo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function io(e,t,o){let i=new Set,n=[];for(let r of e){let a=X(r.element),l=`${a}::${r.property}`;if(i.has(l))continue;i.add(l);let s=kn(r.element),d=r.element.className||"",p=no(d,r.property,t,o);n.push({selector:a,reactComponent:s?.name,className:d,property:r.property,matchedClass:p?.matched,suggestedClass:p?.suggested})}return n}function ao(e){let t=e.startsWith("top-");return{top:t?4:12,right:4,bottom:t?12:4,left:4}}function ro({hasCommentEntry:e,stagedChangeCount:t}){return e&&t===0?2:6}function lo({annotationNumber:e,stickerCount:t,interactionEpisodeStepCount:o,hasStatus:i,hasSend:n,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,s=o>0?32+String(o).length*7.2:0,d=28,p=t>0?l+(s>0?s-2:0)+(n?d-2:0):0,h=[t>0?p:0,t===0?s:0,t===0&&n?d:0,i?d:0].filter(u=>u>0);return a+h.reduce((u,f)=>u+f,0)+h.length*r}function so(e,t,o){let i=e.horizontalAlignment==="right"?e.left-t:e.left;return{left:i,top:e.top,right:i+t,bottom:e.top+o}}function co(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}function po(e,t,o){let i=Math.max(0,e.left+t-o);return Math.max(0,t-e.right)<i?"right":"left"}function $t(e,t,o,i,n=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=po(e,n,r);return e.top>=t+o?{anchor:a==="right"?"top-right":"top-left",horizontalAlignment:a,left:a==="right"?e.right:e.left,top:e.top-t-o}:{anchor:a==="right"?"bottom-right":"bottom-left",horizontalAlignment:a,left:a==="right"?e.right:e.left,top:e.bottom+o}}function Xe(e){return e.left+e.width}function $e(e){return e.top+e.height}function Je(e,t){if(e.length===0)return t;let o=Math.min(...e.map(a=>a.left)),i=Math.min(...e.map(a=>a.top)),n=Math.max(...e.map(Xe)),r=Math.max(...e.map($e));return{left:o,top:i,width:n-o,height:r-i}}function Qe(e){let t=[...e].sort((i,n)=>i.top-n.top||i.left-n.left),o=[];for(let i of t){let n=i.top+i.height/2,r=o.find(p=>{let h=p.top+p.height/2;return Math.abs(n-h)<=Math.max(p.height,i.height)*.4});if(!r){o.push({...i});continue}let a=Math.min(r.left,i.left),l=Math.min(r.top,i.top),s=Math.max(Xe(r),Xe(i)),d=Math.max($e(r),$e(i));r.left=a,r.top=l,r.width=s-a,r.height=d-l}return o.sort((i,n)=>i.top-n.top||i.left-n.left)}function uo({display:e,fragmentRects:t,elementRect:o,parentContentRect:i}){let n=Qe(t),r=Je(n,o);if(!(e==="inline"&&n.length>1&&i&&i.width>0))return{textRect:r,boundaryRect:o,boundaryRects:[o],firstLineIndent:0};let a=n[0],l={left:i.left,top:a.top,width:i.width,height:Math.max(r.height,$e(r)-a.top)},s=Math.max(0,Math.min(l.width,a.left-l.left));return{textRect:r,boundaryRect:Je(n,o),boundaryRects:n,flowRect:l,firstLineIndent:s}}var pe={topLeft:"0px",topRight:"0px",bottomRight:"0px",bottomLeft:"0px"};function Ot(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((o,i)=>{let n=t.fragments[i];return!!n&&o.left===n.left&&o.top===n.top&&o.width===n.width&&o.height===n.height})}function Dt(e){if(!e.isConnected||!Nn(e.ownerDocument))return{fragments:[],radii:pe};let t=Mt(ke(e),e.ownerDocument);if(Tt(e.ownerDocument)&&(!t.width||!t.height))return{fragments:[],radii:pe};if(e.getAttribute("data-popmelt-subject-projection")==="true")return{fragments:[{left:t.left,top:t.top,width:t.width,height:t.height}],radii:pe,outline:e.getAttribute("data-popmelt-subject-outline")??void 0};let o=Array.from(e.getClientRects()).map(i=>Mt(Ee(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:Qe(o.length>0?o:[{left:t.left,top:t.top,width:t.width,height:t.height}]),radii:It(e)}}function _t({element:e,projectedRect:t,isSelected:o=!1,elementInfo:i,color:n="#3b82f6",annotationNumber:r,changeCount:a,hideTooltip:l=!1,hideOutline:s=!1,hideFill:d=!1,fillOpacity:p=.05,subjectRegistry:h,railGap:u=2,railHeight:f=22,railWidth:y=0,renderRail:g,refreshKey:m,outlineZIndex:k=9996,onActivate:v,onRemove:b}){let S=ce(ye),[w,E]=re({fragments:[],radii:pe});J(()=>{if(!S)return;if(!e){E({fragments:[],radii:pe});return}let P=null,N=()=>{let Se=Dt(e);E(c=>Ot(c,Se)?c:Se)},B=()=>{P===null&&(P=requestAnimationFrame(()=>{P=null,N()}))};N();let ie=e.getAttribute("data-popmelt-subject-projection")==="true"&&!!h,Ie=ie?h.subscribeFrame(N):void 0,W=ie||typeof ResizeObserver>"u"?null:new ResizeObserver(B);W?.observe(e);let Z=ie?null:new MutationObserver(B);Z?.observe(e,{attributes:!0,attributeFilter:["style","class"]});let me=Tn(N,e.ownerDocument.defaultView??window),ae=Tt(e.ownerDocument)?Ue(N):void 0;return()=>{me(),ae?.(),Ie?.(),W?.disconnect(),Z?.disconnect(),P!==null&&cancelAnimationFrame(P)}},[S,e,h]),At(()=>{if(!S||!e||m===void 0)return;let P=Dt(e);E(N=>Ot(N,P)?N:P)},[S,e,m]);let{fragments:R,radii:z}=t?{fragments:[t],radii:pe}:w;if(R.length===0||!e&&!t)return null;let A=Je(R,R[0]),M=e?.tagName.toLowerCase()??"",V=e?.id?`#${e.id}`:"",ne=e&&e.classList.length>0?"."+Array.from(e.classList).slice(0,2).join("."):"",oe=i?.reactComponent,be=e?.getAttribute("data-popmelt-label")?.trim(),Pe=e?.getAttribute("data-popmelt-subject-adapter"),we=e?.getAttribute("data-popmelt-subject-label"),se=Pe&&we?`<${we}>`:be||(oe?`<${oe}> ${M}${V}${ne}`:`${M}${V}${ne}`),de=$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),Fe={zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:n,color:"#fff",fontSize:12,fontFamily:je,lineHeight:"14px",padding:"4px 8px",borderRadius:8,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400,position:"fixed",top:de.top,left:de.left},ze=!l&&C("div",{ref:P=>{e&&An(e,P)},"data-devtools":"tooltip",style:Fe,children:[r!==void 0&&C("span",{children:[r,"."]}),x("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:se}),a!==void 0&&a>0&&C("span",{style:{opacity:.8},children:["(",a," ",a===1?"change":"changes",")"]})]});return C(H,{children:[!s&&R.map((P,N)=>x("div",{"data-devtools":"highlight",onContextMenu:b?B=>{B.preventDefault(),B.stopPropagation(),b()}:void 0,role:v?"button":void 0,tabIndex:v?0:void 0,"aria-label":v?"Open annotation thread":void 0,onPointerDown:v?B=>{B.preventDefault(),B.stopPropagation()}:void 0,onClick:v?B=>{B.preventDefault(),B.stopPropagation(),v()}:void 0,onKeyDown:v?B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),B.stopPropagation(),v())}:void 0,style:{position:"fixed",top:P.top,left:P.left,width:P.width,height:P.height,pointerEvents:v||b?"auto":"none",cursor:v?"pointer":void 0,zIndex:k,overflow:"visible"},children:x("div",{style:w.outline?{position:"absolute",inset:0,pointerEvents:"none"}:{position:"absolute",inset:0,boxSizing:"border-box",backgroundColor:d?"transparent":Ve(n,p),borderColor:n,borderStyle:o?"solid":"dashed",borderWidth:1,borderTopLeftRadius:z.topLeft,borderTopRightRadius:z.topRight,borderBottomRightRadius:z.bottomRight,borderBottomLeftRadius:z.bottomLeft,pointerEvents:"none"},children:w.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:w.outline,fill:d?"transparent":Ve(n,p),stroke:n,strokeWidth:1,strokeDasharray:o?void 0:"4 3",vectorEffect:"non-scaling-stroke"})}):null})},`${P.left}:${P.top}:${N}`)),g?g(de,A):ze]})}function Pt(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 fo(e){return Pt(e).map(t=>`${t}px`).join(" ")}var ve=1.1666666666666667,Ft=2048;function Ge(e){return e.length>Ft?`${e.slice(0,Ft)}\u2026`:e}function ho(e,t,o){let i=Ge(t);if(!i||e.measureText(i).width<=o)return[i];let n=i.split(/\s+/),r=[],a="";for(let l of n){let s=a?`${a} ${l}`:l;a&&e.measureText(s).width>o?(r.push(a),a=l):a=s}return a&&r.push(a),r.length>0?r:[i]}function mo(e,t,o){return t.flatMap(i=>ho(e,i,o))}var te=je,Ze=400,zt=16,et=60,go=12,tt=16;function Bt(e){let t=window.innerWidth-e-zt;return Math.max(et,Math.min(Ze,t))}function nt(e,t,o){let i=Ge(t);if(i===t&&e.measureText(i).width<=o)return i;let n="\u2026",r=0,a=i.endsWith(n)?i.length-1:i.length;for(;r<a;){let l=Math.ceil((r+a)/2);e.measureText(i.slice(0,l)+n).width<=o?r=l:a=l-1}return r>0?i.slice(0,r)+n:n}function yo(e,t,o){if(e===void 0||t===void 0||o.avoidLeft===void 0&&o.avoidRight===void 0)return!0;let i=typeof window<"u"?window.innerWidth:9999,n=o.avoidLeft??0,r=o.avoidRight??i;return e+t>n&&e<r}function Wt(e,t,o,i,n){let r=typeof window<"u"?window.innerHeight:9999,a=0,l=r;o&&yo(i,n,o)&&(a=o.avoidTop??a,l=o.avoidBottom??l);let s=Math.max(a,l-t);return Math.max(a,Math.min(e,s))}function Ht(e,t=12,o,i){let n=t*ve+8,r=e.y-4,a=e.x-8,l=Wt(r,n,o,a,i);return l===r?e:{...e,y:l+4}}function xo(e,t,o,i,n=12,r,a,l,s="#dddddd",d,p=!1){if(!o)return;let h=n*ve,u=o.replace(/\n/g," "),f=r!==void 0?r+". "+u:u;e.font=`${n}px ${te}`,e.textBaseline="middle";let y=a!==void 0?Math.min(Ze,Math.max(et,window.innerWidth-a-zt)):Ze,g=p?tt:0,m=nt(e,f,Math.max(et,y-g)),k=e.measureText(m).width,v=g+k,b=Ht(t,n,l,v+16);e.fillStyle=i;let S=b.x-8,w=b.y-4,E=v+16,R=h+8;e.beginPath(),e.roundRect(S,w,E,R,Pt(d)),e.fill();let z=b.y+h/2;if(p){let A=b.x,M=z-go/2;e.strokeStyle=s,e.lineWidth=1.5,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(A+7.5,M+4),e.lineTo(A+10.5,M+6.5),e.lineTo(A+7.5,M+9),e.moveTo(A+1.5,M+1.5),e.lineTo(A+1.5,M+4.5),e.quadraticCurveTo(A+1.5,M+6.5,A+3.5,M+6.5),e.lineTo(A+10.5,M+6.5),e.stroke()}e.fillStyle=s,e.fillText(m,b.x+g,z)}function vo(e,t,o){let i=e.filter(n=>!n.captured&&n.selector===t&&(!n.pathname||n.pathname===o));return i.length?{type:"MODIFY_TEXT_CONTENTS",payload:i.map(n=>({...n,modified:n.original}))}:null}function jt(e,t){return e.type!=="text"?!1:(e.groupId?t.filter(o=>o.groupId===e.groupId):[e]).every(o=>(o.status??"pending")==="pending"&&!o.threadId)}var Yt=qe(0),ot=`
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 it(e=22){return{height:e,minHeight:e,maxHeight:e,boxSizing:"border-box",flexShrink:0}}function bo(e){if(!(!Number.isFinite(e)||e<=0))return Math.max(1,Math.round(e/We))*We}function wo(e,t,o){let i={topLeft:Math.max(0,o.topLeft),topRight:Math.max(0,o.topRight),bottomRight:Math.max(0,o.bottomRight),bottomLeft:Math.max(0,o.bottomLeft)},n=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*n,topRight:i.topRight*n,bottomRight:i.bottomRight*n,bottomLeft:i.bottomLeft*n}}function Io(e,t,o,i=.5){let n=Math.max(0,e-i*2),r=Math.max(0,t-i*2),a=wo(e,t,o),l=Math.max(0,a.topLeft-i),s=Math.max(0,a.topRight-i),d=Math.max(0,a.bottomRight-i),p=Math.max(0,a.bottomLeft-i),h=i+n,u=i+r;return[`M ${i+l} ${i}`,`H ${h-s}`,`A ${s} ${s} 0 0 1 ${h} ${i+s}`,`V ${u-d}`,`A ${d} ${d} 0 0 1 ${h-d} ${u}`,`H ${i+p}`,`A ${p} ${p} 0 0 1 ${i} ${u-p}`,`V ${i+l}`,`A ${l} ${l} 0 0 1 ${i+l} ${i}`,"Z"].join(" ")}var ue=12,Q=8,fe=8;function Kt(e){return e>0?16+String(e).length*7.2+16:0}function qt({stepCount:e,onClear:t,layered:o=!1,submitted:i=!1,style:n}){let[r]=Ye(),a=Ke[r];if(e<1)return null;let l=`${e} recorded ${e===1?"action":"actions"}${i?", sent":""}`;return C("span",{"data-devtools":"interaction-episode-badge","data-popmelt-submitted":i?"true":void 0,"aria-label":l,onContextMenu:s=>{s.preventDefault(),s.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:Q,color:i?"#dddddd":a.primary,fontFamily:te,fontSize:12,fontWeight:600,padding:o?`0 8px 0 ${wt*.7}px`:"0 8px 0 5.6px",gap:4,pointerEvents:t?"auto":"none",WebkitMaskImage:o?Me:void 0,maskImage:o?Me:void 0,...n},children:[C("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 So=3,To=250;function Mo(e){let t=e?.current?.getBoundingClientRect();return!t||typeof window>"u"?{}:t.top<window.innerHeight/2?{avoidTop:t.bottom+fe,avoidLeft:t.left-fe,avoidRight:t.right+fe}:{avoidBottom:t.top-fe,avoidLeft:t.left-fe,avoidRight:t.right+fe}}function ko(e,t,o){if(o.avoidLeft===void 0&&o.avoidRight===void 0)return!0;let i=typeof window<"u"?window.innerWidth:9999,n=o.avoidLeft??0,r=o.avoidRight??i;return e+t>n&&e<r}function at(e,t,o){return ko(t,o,e)?e:{}}function Eo(e,t,o){let i=o.avoidTop!==void 0?`${o.avoidTop}px`:"0px",n=o.avoidBottom!==void 0?`${o.avoidBottom}px`:"100dvh";return`translate(min(0px, calc(100vw - ${e} - 100%)), min(max(0px, calc(${i} - ${t})), calc(${n} - ${t} - 100%)))`}function Ut(e,t,o){if(o.avoidTop===void 0&&o.avoidBottom===void 0)return e;let i=typeof window<"u"?window.innerHeight:9999,n=o.avoidTop??0,r=o.avoidBottom??i,a=Math.max(n,r-t);return Math.max(n,Math.min(e,a))}function Vt({left:e,top:t,scrollX:o,scrollY:i,avoidTop:n,avoidBottom:r,style:a,children:l,...s}){let d=`calc(${e}px - var(--popmelt-scroll-x, ${o}px))`,p=`calc(${t}px - var(--popmelt-scroll-y, ${i}px))`,h=`calc(${e+ue}px - var(--popmelt-scroll-x, ${o}px))`,u=`calc(${t+ue}px - var(--popmelt-scroll-y, ${i}px))`;return x("div",{"data-devtools":"badge-hit-area",...s,style:{position:"fixed",left:0,top:0,padding:ue,...a,transform:`translate3d(${d}, ${p}, 0)`,willChange:"transform"},children:x("div",{style:{transform:Eo(h,u,{avoidTop:n,avoidBottom:r})},children:l})})}function Xt({bundleCount:e,style:t,layered:o=!1,compact:i=!1,description:n,replacementText:r,onHoverChange:a,onSend:l}){let[s,d]=re(!1),[p]=Ye(),h=Ke[p],u=ce(Yt),f=Bn(),y=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform)?"\u2318":"Ctrl",g=Math.max(1,e),m=i&&!s,k=E=>m?x(Ce,{size:12,strokeWidth:2,"aria-hidden":!0}):E?C(H,{children:[x("span",{style:{color:"inherit",fontWeight:600},children:g>1?`Send all ${g}`:"Send"}),x(Ce,{size:12,strokeWidth:2,"aria-hidden":!0})]}):C(H,{children:[C("span",{style:{display:"inline-flex",alignItems:"center",gap:2,color:"inherit",fontWeight:600},children:[x("span",{children:y}),x("span",{children:"+"}),x(zn,{size:12,strokeWidth:2,"aria-hidden":!0})]}),x("span",{style:{color:h.secondary,fontWeight:600},children:"to"}),x(Ce,{size:12,strokeWidth:2,"aria-hidden":!0}),g>1&&x("span",{style:{color:"inherit",fontWeight:600},children:g})]}),v=E=>C(H,{children:[x("span",{className:"popmelt-send-hint-desktop",style:{alignItems:"center",gap:4},children:k(E)}),C("span",{className:"popmelt-send-hint-mobile",style:{alignItems:"center",gap:4},children:[!m&&x("span",{style:{color:"inherit",fontWeight:600},children:"Send"}),x(Ce,{size:12,strokeWidth:2,"aria-hidden":!0})]})]}),b=r?x("span",{role:"tooltip","data-devtools":"parent-pinned-location-tooltip",style:{overflow:"hidden",textOverflow:"ellipsis"},children:r}):null,S={...it(),lineHeight:`${12*ve}px`,display:"flex",alignItems:"center",boxSizing:"border-box",backgroundColor:h.surface,border:`1px solid ${h.border}`,fontFamily:te,fontSize:12,color:h.primary,userSelect:"none",padding:o?`0 8px 0 ${wt}px`:"0 8px",gap:4,whiteSpace:"nowrap",borderRadius:Q,letterSpacing:"0.24px",WebkitMaskImage:o?Me:void 0,maskImage:o?Me:void 0},w=g>1?`Send all ${g} pending annotations`:"Send pending annotation";return C("div",{"data-devtools":"send-hint-hit-area","data-popmelt-send-rejection":u?u%2?"odd":"even":void 0,onMouseEnter:()=>{d(!0),a?.(!0)},onMouseLeave:()=>{d(!1),a?.(!1)},style:{display:"grid",width:"max-content",...t},children:[x("style",{children:`
9
+ @keyframes popmelt-send-rejection-odd { ${ot} }
10
+ @keyframes popmelt-send-rejection-even { ${ot} }
11
+ [data-popmelt-send-rejection="odd"] { animation: popmelt-send-rejection-odd 220ms ease-out; }
12
+ [data-popmelt-send-rejection="even"] { animation: popmelt-send-rejection-even 220ms ease-out; }
13
+ @media (prefers-reduced-motion: reduce) {
14
+ [data-popmelt-send-rejection] { animation: none; }
15
+ }
16
+ .popmelt-send-hint-desktop { display: inline-flex; }
17
+ .popmelt-send-hint-mobile { display: none; }
18
+ @media (max-width: 767px) {
19
+ .popmelt-send-hint-desktop { display: none; }
20
+ .popmelt-send-hint-mobile { display: inline-flex; }
21
+ }
22
+ `}),x("div",{"aria-hidden":!0,style:{...S,gridArea:"1 / 1",visibility:"hidden"},children:v(!1)}),C("button",{type:"button","data-devtools":"annotation-badge","aria-label":w,"aria-describedby":n?f:void 0,disabled:!l,onPointerDown:E=>{E.preventDefault(),E.stopPropagation()},onClick:E=>{E.preventDefault(),E.stopPropagation(),l?.()},style:{...S,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:[n&&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:n}),b??v(s)]})]})}function Jt({count:e,color:t,size:o=22,onHoverChange:i}){return C("div",{"data-devtools":"nested-annotation-count-badge",onMouseEnter:()=>i?.(!0),onMouseLeave:()=>i?.(!1),style:{height:o,display:"flex",alignItems:"center",backgroundColor:t,color:t==="#8c8c8c"?"#dddddd":"#ffffff",fontFamily:te,fontSize:12,fontWeight:600,lineHeight:1,padding:"0 8px",borderRadius:Q,userSelect:"none",whiteSpace:"nowrap"},children:["+",e]})}function Ao({annotations:e,supersededAnnotations:t,inFlightIds:o,orientationLabels:i,activeIds:n,queuePositions:r,scrollX:a,scrollY:l,annotationGroupMap:s,onViewThread:d,onSelectAnnotation:p,onDeleteDraftAnnotation:h,onClearInteractionEpisode:u,onHoverAnnotation:f,canvasRef:y,toolbarRef:g,activeBundleAnnotationIds:m,inactiveBundleOpacity:k=.5,animateBundleOpacity:v=!0,hoverRestoredAnnotationIds:b,nestedAnnotationCountById:S,nestedAnnotationIdsById:w,onHoverNestedAnnotations:E,onHoverSendBundle:R,onSend:z,sendHintAnchorId:A,pendingBundleCount:M=1,parentPinnedAnnotationIds:V,parentPinnedLocationLabels:ne,parentPinnedTooltipAnnotationId:oe,onActivateAnnotation:be,hiddenAnnotationIds:Pe,displayAnnotations:we}){let se=ce(ye),de=le(null),[Fe,ze]=re(0),P=!!(o&&o.size>0&&(n===void 0||n.size>0));J(()=>{if(!P||!se)return;let c=setInterval(()=>{ze(I=>(I+1)%So)},To);return()=>{clearInterval(c)}},[P,se]),J(()=>{if(!se)return;let c=de.current;if(!c)return;let I=()=>{c.style.setProperty("--popmelt-scroll-x",`${window.scrollX}px`),c.style.setProperty("--popmelt-scroll-y",`${window.scrollY}px`)};return I(),window.addEventListener("scroll",I,{passive:!0,capture:!0}),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[se]);let N=[],B=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform)?"\u2318":"Ctrl";for(let c of e){if(c.type!=="text"||!c.text||!c.points[0]||t.has(c)||Pe?.has(c.id))continue;let I=c.groupId?e.filter(T=>T.groupId===c.groupId):[c],O=c.status??"pending",F=M>0&&c.id===A,L=c.interactionEpisode?.steps.length??0,j=S?.get(c.id)??0,q=w?.get(c.id)??[],$=I.reduce((T,wn)=>Math.max(T,wn.replyCount??0),0),Y=O==="sending"||I.some(T=>T.status==="sending"),U=O==="awaiting_review",D=!Y&&(!!(o&&(o.has(c.id)||I.some(T=>o.has(T.id))))||c.status==="in_flight"||I.some(T=>T.status==="in_flight")),ge=I.some(T=>T.status==="resolved"&&(T.replyCount??0)>0||T.status==="needs_review"),ee=I.some(T=>T.threadId),un=!m||I.some(T=>m.has(T.id)||b?.has(T.id));if(!(F||Y||U||D||O==="resolved"||O==="failed"||O==="needs_review"||ge||ee||L>0)&&j===0)continue;let fn=c.threadId||I.find(T=>T.threadId)?.threadId,ut=O==="needs_review"||I.some(T=>T.status==="needs_review"),ft=O==="waiting_input"||I.some(T=>T.status==="waiting_input"),ht=O==="failed"||I.some(T=>T.status==="failed"),mt=F||Y||U||D||ut||ft||ht||$>0||O==="resolved"&&ee||L>0;if(!mt&&j===0)continue;let Be=c.points[0],gt=c.fontSize||12,hn=gt*ve,yt=s.get(c.id),xt=((we?.find(T=>T.id===c.id)??c).text??c.text).replace(/\n/g," "),mn=yt!==void 0?yt+". "+xt:xt,Te=y?.current?.getContext("2d")??document.createElement("canvas").getContext("2d");if(!Te)continue;Te.font=`${gt}px ${te}`;let gn=Be.x-a,vt=V?.has(c.id)?tt:0,yn=Math.max(60,Bt(gn)-vt),xn=nt(Te,mn,yn),vn=Te.measureText(xn).width,bn=D&&!!n&&!n.has(c.id)&&!I.some(T=>n.has(T.id));N.push({id:c.id,threadId:fn,linkedSelector:c.linkedSelector||I.find(T=>T.linkedSelector)?.linkedSelector,x:Be.x+vn+vt+8+2,y:Be.y-4,size:hn+8,color:F?"#000000":c.color,isSending:Y,isAwaitingReview:U,isInFlight:D,orientationLabel:i?.get(c.id)??I.map(T=>i?.get(T.id)).find(Boolean),isQueued:bn,queuePosition:void 0,isNeedsReview:ut,isQuestion:ft,isFailed:ht,replyCount:$>0?$:O==="resolved"&&ee?1:0,isInActiveBundle:un,isSendHint:F,interactionEpisodeStepCount:L,interactionEpisodeSubmitted:O!=="pending",nestedCount:j,nestedAnnotationIds:q,nestedColor:O==="pending"?c.color:"#8c8c8c",showActionBadge:mt,canDeleteDraft:jt(c,e)})}let ie=N.filter(c=>c.isQueued);if(ie.length>0&&ie.forEach((c,I)=>{c.queuePosition=r?.get(c.id)??`(${I+1}/${ie.length})`}),N.length===0)return null;let Ie=2,W=y?.current?.getContext("2d")??document.createElement("canvas").getContext("2d"),Z=N.map(c=>{W&&(W.font=`12px ${te}`);let I=c.nestedCount>0?(W?.measureText(`+${c.nestedCount}`).width??String(c.nestedCount).length*7.2+7.2)+16:0,O=Kt(c.interactionEpisodeStepCount);if(!c.showActionBadge)return I+O;let F=oe===c.id?ne?.get(c.id):void 0,L;F?L=F:c.isSendHint?L=B:c.isSending?L="Sending":c.isAwaitingReview?L="Awaiting review":c.isInFlight?L=c.isQueued?`Queued${c.queuePosition?` ${c.queuePosition}`:""}`:c.orientationLabel??"Thinking":c.isQuestion?L="Question":c.isFailed?L="Failed":c.replyCount>0?L="Replied":L="Needs decision";let j=c.isSendHint||F?0:12,q=4,$=L.length*7.2;W&&($=W.measureText(L).width);let Y=c.isSendHint&&W?W.measureText("to").width:c.isSendHint?14.4:0,U=c.isSendHint&&W?W.measureText("+").width:c.isSendHint?7.2:0,D=c.isSendHint&&M>1&&W?W.measureText(String(M)).width:c.isSendHint&&M>1?7.2:0,ge=F?Math.min($+16,320):c.isSendHint?$+U+Y+D+16+12+12+4+q*(M>1?3:2):6+j+q+$+8,ee=+(O>0)+ +(I>0)+1;return O+I+ge+(ee-1)*2}),me=Mo(g),ae=[];for(let c=0;c<N.length;c++){let I=N[c].y-l,O=N[c].x-a,F=at(me,O,Z[c]),L=Ut(I,N[c].size,F),j=L+N[c].size,q=O;for(let $=0;$<c;$++){let Y=N[$].y-l,U=at(me,ae[$],Z[$]),D=Ut(Y,N[$].size,U),ge=D+N[$].size;if(!(L<ge&&j>D))continue;let ee=ae[$]+Z[$];q<ee+Ie&&(q=ee+Ie)}ae.push(q)}let Se={position:"fixed",inset:0,pointerEvents:"none",zIndex:9999,"--popmelt-scroll-x":`${a}px`,"--popmelt-scroll-y":`${l}px`};return C("div",{ref:de,"data-devtools":"annotation-badge-layer",style:Se,children:[x("style",{dangerouslySetInnerHTML:{__html:`
23
+ [data-devtools="annotation-badge-layer"] [data-devtools="annotation-badge"]::selection,
24
+ [data-devtools="annotation-badge-layer"] [data-devtools="annotation-badge"] *::selection {
25
+ background: #000000;
26
+ color: #ffffff;
27
+ }
28
+ `}}),N.map((c,I)=>{let O=!!c.threadId,F=ne?.get(c.id),L=!!F&&oe===c.id,j=O||!!F,q=c.showActionBadge&&c.isSendHint,$=j&&!q,Y=()=>{if(be){be(c.id,c.threadId);return}p?.(c.id),c.threadId&&d?.(c.threadId)},U=at(me,ae[I],Z[I]);return x(Vt,{left:ae[I]+a-ue,top:c.y-ue,scrollX:a,scrollY:l,avoidTop:U.avoidTop,avoidBottom:U.avoidBottom,onMouseDown:D=>D.stopPropagation(),onContextMenu:D=>{D.preventDefault(),D.stopPropagation(),c.canDeleteDraft&&h&&h(c.id)},onClick:j?D=>{D.stopPropagation(),Y()}:void 0,onMouseEnter:()=>{f?.(c.id)},onMouseLeave:()=>{f?.(null)},onFocus:()=>f?.(c.id),onBlur:()=>f?.(null),onKeyDown:$?D=>{D.key!=="Enter"&&D.key!==" "||(D.preventDefault(),Y())}:void 0,role:$?"button":void 0,tabIndex:$?0:void 0,"aria-label":$&&F?`${F}. Activate to reveal the annotation source${O?" and open its thread":""}`:void 0,style:{pointerEvents:"auto",cursor:j?"pointer":void 0,zIndex:9999,minWidth:c.isSendHint?Z[I]:void 0},children:C("div",{style:{position:"relative",display:"flex",alignItems:"center",gap:2},children:[x(qt,{stepCount:c.interactionEpisodeStepCount,submitted:c.interactionEpisodeSubmitted,onClear:c.canDeleteDraft&&u?()=>u(c.id):void 0}),c.nestedCount>0&&x(Jt,{count:c.nestedCount,color:c.nestedColor,size:c.size,onHoverChange:D=>E?.(c.id,D?c.nestedAnnotationIds:null)}),c.showActionBadge&&(c.isSendHint?x(Xt,{bundleCount:M,description:F?`${F}. Activate the annotation label to reveal its source.`:void 0,replacementText:L?F:void 0,onHoverChange:R,onSend:z}):x("div",{"data-devtools":"annotation-badge",style:{...it(c.size),display:"flex",alignItems:"center",backgroundColor:c.color,fontFamily:te,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:Q,opacity:c.isInActiveBundle?1:k,transition:v?"opacity 120ms ease-out":"none"},children:L?x("span",{role:"tooltip","data-devtools":"parent-pinned-location-tooltip",style:{overflow:"hidden",textOverflow:"ellipsis"},children:F}):c.isAwaitingReview?C(H,{children:[x(Et,{size:12,strokeWidth:2.25}),"Awaiting review"]}):c.isQueued?C("span",{style:{opacity:.6,color:"inherit",display:"inline-flex",alignItems:"center",gap:4},children:[x(Et,{size:12,strokeWidth:2.25}),"Queued",c.queuePosition?` ${c.queuePosition}`:""]}):c.isSending||c.isInFlight?C(H,{children:[c.orientationLabel==="Approval needed"?x(On,{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:Fe===1?C(H,{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"})]}):C(H,{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:c.isSending?"Sending":c.isQueued?`Queued${c.queuePosition?` ${c.queuePosition}`:""}`:c.orientationLabel??"Thinking"})]}):C(H,{children:[c.isQuestion?x(Dn,{size:12,strokeWidth:2.25}):c.isFailed?x(_n,{size:12,strokeWidth:2.25}):c.replyCount>0?x(Pn,{size:12,strokeWidth:2.25}):C("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:c.isQuestion?"Question":c.isFailed?"Failed":c.replyCount>0?"Replied":"Needs decision"})]})}))]})},c.id)})]})}function Qt({d:e,color:t,animated:o}){let i=le(null);return At(()=>{let n=i.current;if(!n||typeof n.getTotalLength!="function")return;let r=bo(n.getTotalLength());r===void 0?n.removeAttribute("pathLength"):n.setAttribute("pathLength",String(r))},[e]),x("path",{ref:i,d:e,fill:"none",stroke:t,strokeWidth:1,strokeDasharray:o?In:void 0,"data-popmelt-marching-stroke":o||void 0,style:o?{animation:"popmelt-march 0.6s linear infinite"}:void 0})}function Gt(){return x("style",{children:`
29
+ @keyframes popmelt-march {
30
+ from { stroke-dashoffset: 0; }
31
+ to { stroke-dashoffset: -${We}; }
32
+ }
33
+ @media (prefers-reduced-motion: reduce) {
34
+ [data-popmelt-marching-stroke="true"] { animation: none !important; }
35
+ }
36
+ `})}function Co({annotations:e,activeIds:t,scrollX:o,scrollY:i,spotlightIds:n,emphasizedIds:r,hoverRestoredIds:a,inactiveOpacity:l=.5}){if(!ce(ye))return null;let s=e.filter(d=>d.region&&d.region.points.length>=3&&t?.has(d.id));return s.length?C(H,{children:[x(Gt,{}),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(${-o} ${-i})`,children:s.map(d=>{let p=n?.size?n.has(d.id)?1:.2:r&&!r.has(d.id)&&!a?.has(d.id)?l:1;return x("g",{"data-popmelt-region-id":d.id,opacity:p,children:x(Qt,{d:`${d.region.points.map((h,u)=>`${u?"L":"M"}${h.x} ${h.y}`).join(" ")} Z`,color:d.color,animated:!0})},d.id)})})})]}):null}function Ro({inFlightSelectorColors:e,animated:t=!0,subjectRegistry:o,selectorElementInfo:i}){let n=ce(ye),[r,a]=re([]);return J(()=>{if(!n)return;if(e.size===0){a([]);return}let l=null,s=()=>{let f=[];for(let[y,g]of e){let m=Rn(y,i?.get(y));if(!m)continue;let k=ke(m);f.push({selector:y,top:k.top,left:k.left,width:k.width,height:k.height,color:g,radius:Mn(m),radiusStyle:It(m)})}a(f)},d=()=>{l&&cancelAnimationFrame(l),l=requestAnimationFrame(s)};s(),window.addEventListener("scroll",d,!0),window.addEventListener("resize",d,!0);let p=new MutationObserver(d);p.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]});let h=o?.subscribeFrame(s),u=[...e.keys()].some(f=>f.startsWith("@frame("))?Ue(s):void 0;return()=>{window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d,!0),p.disconnect(),h?.(),u?.(),l&&cancelAnimationFrame(l)}},[e,o,i,n]),r.length===0?null:C(H,{children:[t&&x(Gt,{}),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(Qt,{d:Io(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 No({element:e,elements:t,registry:o,label:i="Looking",engaged:n=!0,outlineColor:r,inverse:a=!1}){let l=le(0),s=Wn(()=>t??(e?[e]:[]),[t,e]),[d,p]=re(()=>s.map(u=>({target:u,id:++l.current,animateEntrance:!0,exiting:!1}))),h=Hn(u=>{p(f=>f.filter(y=>y.id!==u))},[]);return J(()=>{s.length&&p(u=>{let f=u.some(({target:g})=>g.isConnected),y=s.map(g=>u.find(m=>m.target===g&&!m.exiting)??{target:g,id:++l.current,animateEntrance:!f,exiting:!1});return[...u.filter(g=>!g.exiting&&!s.includes(g.target)).map(g=>({...g,exiting:!0})),...y]})},[s]),x(H,{children:d.map(({target:u,id:f,animateEntrance:y,exiting:g})=>x(Lo,{id:f,element:n&&s.includes(u)?u:null,target:u,animateEntrance:y,exiting:g,registry:o,label:i,outlineColor:r,inverse:a,onDone:h},f))})}function Lo({id:e,element:t,target:o,animateEntrance:i,exiting:n,registry:r,label:a,outlineColor:l,inverse:s,onDone:d}){let[p]=Ye(),h=Ke[p],u=o,[f,y]=re(!1),g=le(Date.now()),[m,k]=re(null);return J(()=>{if(!u)return;let v,b=()=>{let S=Cn(u);k(w=>S?w?.left===S.left&&w.top===S.top?w:{left:S.left,top:S.top}:null),v=requestAnimationFrame(b)};return b(),()=>cancelAnimationFrame(v)},[u]),J(()=>{let v,b;return n?b=setTimeout(()=>d(e),200):t?(g.current=Date.now(),y(!1)):v=setTimeout(()=>{y(!0),b=setTimeout(()=>d(e),300)},Math.max(0,g.current+1700-Date.now())),()=>{clearTimeout(v),clearTimeout(b)}},[t,n,e,d]),u?.isConnected?C(H,{children:[x("style",{children:`
37
+ @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); } }
38
+ @keyframes popmelt-looking-out-left { from { opacity: 1; } to { opacity: 0; } }
39
+ @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); } }
40
+ @keyframes popmelt-looking-in-alone-up-left { from { opacity: 0; transform: translate(8px, 8px); } to { opacity: 1; transform: translate(0, 0); } }
41
+ @keyframes popmelt-looking-in-alone-down-left { from { opacity: 0; transform: translate(8px, -8px); } to { opacity: 1; transform: translate(0, 0); } }
42
+ @keyframes popmelt-looking-in-alone-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
43
+ @keyframes popmelt-looking-in-alone-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
44
+ @keyframes popmelt-looking-out-up { from { opacity: 1; } to { opacity: 0; } }
45
+ @keyframes popmelt-looking-fade-in { from { opacity: 0; } to { opacity: 1; } }
46
+ @keyframes popmelt-looking-fade-out { from { opacity: 1; } to { opacity: 0; } }
47
+ @keyframes popmelt-looking-blink { 0%, 40%, 72.5%, 100% { transform: scaleY(1); } 50%, 62.5% { transform: scaleY(0.1); } }
48
+ .popmelt-looking-eye { animation: popmelt-looking-blink 1000ms 200ms both; transform-origin: center; }
49
+ @media (prefers-reduced-motion: reduce) {
50
+ [data-devtools="focus-inspection"], .popmelt-looking-eye { animation: none !important; }
51
+ [data-popmelt-looking-exiting] { opacity: 0 !important; }
52
+ }
53
+ `}),x(_t,{element:u,subjectRegistry:r,hideOutline:!l||f||n,color:l,outlineZIndex:l?10002:void 0,hideFill:!0,hideTooltip:!0,railHeight:22,renderRail:(v,b)=>{let S=m??v,w=S.left>=28,E=!m&&v.anchor.startsWith("bottom-"),R=m?w?"left":"up":`${E?"down":"up"}${w?"-left":""}`,z=m&&!w?Math.max(4,S.top-22-2):S.top,A=w?S.left-22-2:S.left,M=b.left+b.width/2>=A+22/2,V=b.top+b.height/2>=z+22/2?M?"borderBottomRightRadius":"borderBottomLeftRadius":M?"borderTopRightRadius":"borderTopLeftRadius";return x("div",{"data-devtools":"focus-inspection","data-popmelt-looking-exiting":n?"true":void 0,"data-popmelt-canvas-block":!0,role:"status","aria-live":n?"off":"polite","aria-hidden":n||void 0,"aria-label":a,title:a,style:{position:"fixed",animation:n?"popmelt-looking-fade-out 200ms ease both":!f&&!i?"popmelt-looking-fade-in 200ms ease both":`popmelt-looking-${f?"out":m?"in":"in-alone"}-${f?w?"left":"up":R} ${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:s?h.actionSurface:h.surface,color:s?h.actionForeground:h.primary,border:`1px solid ${s?h.actionHover:h.border}`,borderTopLeftRadius:Q,borderTopRightRadius:Q,borderBottomLeftRadius:Q,borderBottomRightRadius:Q,...m?{}:{[V]:2},fontFamily:je,fontSize:12,letterSpacing:"0.24px",whiteSpace:"nowrap",pointerEvents:n?"none":"auto",zIndex:u.hasAttribute("data-popmelt-thread-header")?10006:10002},children:x(Fn,{className:i&&!n?"popmelt-looking-eye":void 0,size:12,"aria-hidden":!0})})}})]}):null}var $o={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 Oo(e){if(typeof e!="string")throw new Error("Unexpected sign-in destination.");let t=new URL(e);if(!Object.values($o).some(({issuer:o})=>t.origin===o)||t.pathname!=="/mcp/grant"||t.username||t.password||t.hash)throw new Error("Unexpected sign-in destination.");return t}var Oe={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:[" "]}},Do=[{type:"model",label:"Imprint",shortcut:"I"},{type:"sticker",label:"Steer",shortcut:"S"},{type:"inspector",label:"Chat",shortcut:"C"}];function _o(e){let t=e.toLowerCase();return Object.values(Oe.tools).find(o=>o.key===t)?.tool??null}function Po(e){let t=e.length===1?e.toLowerCase():e,o=Oe.omnidial;return[...o.previous,...o.next,...o.previousFacet,...o.nextFacet,...o.descendOrApply,...o.ascend,...o.query].includes(t)||/^[a-z0-9]$/i.test(e)}var Zt=qe(null),Fo=()=>()=>{},en=()=>null;function rt(){return Math.random().toString(36).substring(2,9)}function De(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 lt(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,lt(e)],redoStack:[]}}function zo(e,t){return{...e,isAnnotating:t}}function Bo(e,t){return{...e,activeTool:t}}function Wo(e,t){return{...e,activeColor:t}}function Ho(e,t){return{...e,strokeWidth:t}}function jo(e,t){let o={id:t.id??rt(),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,o]}}function Yo(e,t){return{..._(e),annotations:e.annotations.map(o=>o.id===t.id?{...o,text:t.text,...t.imageCount!=null?{imageCount:t.imageCount}:{},...t.attachments?{attachments:t.attachments}:{},...t.interactionEpisode?{interactionEpisode:t.interactionEpisode}:{}}:o)}}function Ko(e,t){return{..._(e),annotations:e.annotations.map(o=>{if(o.id!==t.id)return o;let i=o.interactionEpisode?.frames?.length??0,{interactionEpisode:n,...r}=o;if(i===0)return r;let a=Math.max(0,(o.imageCount??0)-i);if(a===0){let{imageCount:l,...s}=r;return s}return{...r,imageCount:a}})}}function qo(e,t){let o=_(e),i=e.annotations.find(r=>r.id===t.id)?.groupId,n=new Set(e.annotations.filter(r=>r.id===t.id||i&&r.groupId===i).map(r=>r.id));return{...o,annotations:e.annotations.filter(r=>r.id!==t.id&&!(i&&r.groupId===i)),selectedAnnotationIds:e.selectedAnnotationIds.filter(r=>!n.has(r)),lastSelectedId:e.lastSelectedId&&n.has(e.lastSelectedId)?null:e.lastSelectedId}}function Uo(e,t){let o=t.saveUndo?_(e):e,i=e.annotations.find(n=>n.id===t.id)?.groupId;return{...o,annotations:e.annotations.map(n=>{if(!(n.id===t.id||i&&n.groupId===i))return n;let r=t.delta.x,a=t.delta.y;return{...n,points:n.points.map(l=>({x:l.x+r,y:l.y+a}))}})}}function Vo(e,t){let o=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 n=0,r=0;if(i.type==="rectangle"&&i.groupId){let a=t.points,l=Math.min(a[0].x,a[1].x),s=Math.max(a[0].y,a[1].y),d=i.points[0],p=i.points[i.points.length-1],h=Math.min(d.x,p.x),u=Math.max(d.y,p.y);n=l-h,r=s-u}return{...o,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+n,y:l.y+r}))}:a)}}function Xo(e,t){return{..._(e),annotations:[...e.annotations,...t.annotations.map(De)]}}function Jo(e,t){let o=new Set,i=[];for(let n of t.annotations)o.has(n.id)||(o.add(n.id),i.push(De(n)));return{...e,annotations:i}}function Qo(e,t){let o=new Map(e.annotations.map(n=>[n.id,n])),i=t.annotations.map(n=>{let r=De(n),a=o.get(r.id);return!a||!r.linkedSelector||a.linkedSelector!==r.linkedSelector?r:{...r,points:a.points,linkedAnchor:a.linkedAnchor}});return{...e,annotations:i}}function Go(e,t){let o=new Set(e.annotations.map(n=>n.id)),i=t.annotations.filter(n=>!o.has(n.id)).map(De);return i.length>0?{...e,annotations:[...e.annotations,...i]}:e}function Zo(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,lt(e)]}}function ei(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,lt(e)]}}function ti(e,t){let{id:o,addToSelection:i}=t;if(o===null)return{...e,selectedAnnotationIds:[],lastSelectedId:null};if(i)if(e.selectedAnnotationIds.includes(o)){let n=e.selectedAnnotationIds.filter(r=>r!==o);return{...e,selectedAnnotationIds:n,lastSelectedId:n.length>0?n[n.length-1]:null}}else return{...e,selectedAnnotationIds:[...e.selectedAnnotationIds,o],lastSelectedId:o};return{...e,selectedAnnotationIds:[o],lastSelectedId:o}}function ni(e,t){let o=e.annotations.find(n=>n.id===t.id)?.groupId,i=new Set;for(let n of e.selectedAnnotationIds){let r=e.annotations.find(a=>a.id===n);r?.groupId&&i.add(r.groupId)}return{...e,annotations:e.annotations.map(n=>n.id===t.id||e.selectedAnnotationIds.includes(n.id)||n.groupId&&(n.groupId===o||i.has(n.groupId))?{...n,color:t.color}:n)}}function oi(e,t,o){let i=typeof window<"u"?window.location.pathname:"/",n=t?new Set(t):void 0,r=o??e.textModifications.filter(s=>!s.pathname||s.pathname===i),a=s=>s.filter(d=>!r.some(p=>d.pathname===p.pathname&&tn(d,p.selector,p.textNodePath,p.pathname??"")&&d.createdAt===p.createdAt&&d.original===p.original&&d.modified===p.modified)),l=s=>({...s,textModifications:a(s.textModifications)});return{...e,undoStack:e.undoStack.map(l),redoStack:e.redoStack.map(l),annotations:e.annotations.map(s=>n&&!n.has(s.id)?s:{...s,captured:!0,status:s.status==="pending"||s.status==="sending"||!s.status?"in_flight":s.status}),styleModifications:e.styleModifications.map(s=>!s.pathname||s.pathname===i?{...s,captured:!0}:s),textModifications:a(e.textModifications),domModifications:e.domModifications.map(s=>!s.pathname||s.pathname===i?{...s,captured:!0}:s),spacingTokenChanges:e.spacingTokenChanges.map(s=>({...s,captured:!0})),spacingTokenMods:e.spacingTokenMods.map(s=>({...s,captured:!0}))}}function ii(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 ai(e){return{...e,annotations:[],undoStack:[],redoStack:[],selectedAnnotationIds:[],lastSelectedId:null,textModifications:[],domModifications:[],spacingTokenChanges:[],spacingTokenMods:[]}}function ri(e,t){let{selector:o,element:i,property:n,original:r,modified:a}=t,l=typeof window<"u"?window.location.pathname:"/",s=e.styleModifications.findIndex(d=>d.selector===o&&(!d.pathname||d.pathname===l));if(r===a&&s<0)return e;if(s>=0){let d=e.styleModifications[s];if(d.captured){let y=_(e),g=y.styleModifications.map((m,k)=>k===s?{...m,changes:[{property:n,original:r,modified:a}],createdAt:m.createdAt??Date.now(),captured:!1,pathname:l}:m);return{...y,styleModifications:g}}let p=d.changes.findIndex(y=>y.property===n),h,u=e;if(p>=0){let y=d.changes[p];a===y.original?h=d.changes.filter((g,m)=>m!==p):h=d.changes.map((g,m)=>m===p?{...g,modified:a}:g)}else{if(r===a)return e;u=_(e),h=[...d.changes,{property:n,original:r,modified:a}]}if(h.length===0)return{...u,styleModifications:u.styleModifications.filter((y,g)=>g!==s)};let f=u.styleModifications.map((y,g)=>g===s?{...y,changes:h,createdAt:y.createdAt??Date.now()}:y);return{...u,styleModifications:f}}else{let d=_(e),p={selector:o,element:i,changes:[{property:n,original:r,modified:a}],createdAt:Date.now(),pathname:l};return{...d,styleModifications:[...d.styleModifications,p]}}}function li(e,t){let{selector:o,durableSelector:i,element:n,changes:r}=t,a=typeof window<"u"?window.location.pathname:"/",l=r.filter(p=>p.original!==p.modified);if(l.length===0)return e;let s=_(e),d=s.styleModifications.findIndex(p=>p.selector===o&&(!p.pathname||p.pathname===a));if(d>=0){let p=s.styleModifications[d],h=p.captured?[]:[...p.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,g)=>g!==f):h=h.map((y,g)=>g===f?{...y,modified:u.modified,token:u.token,sticker:u.sticker}:y):h.push(u)}return h.length===0?{...s,styleModifications:s.styleModifications.filter((u,f)=>f!==d)}:{...s,styleModifications:s.styleModifications.map((u,f)=>f===d?{...u,changes:h,createdAt:u.createdAt??Date.now(),captured:!1,pathname:a}:u)}}else return{...s,styleModifications:[...s.styleModifications,{selector:o,durableSelector:i,element:n,changes:l,createdAt:Date.now(),pathname:a}]}}function si(e,t){let{selector:o,property:i}=t,n=typeof window<"u"?window.location.pathname:"/",r=_(e),a=r.styleModifications.map(l=>l.selector!==o||l.pathname&&l.pathname!==n?l:{...l,changes:l.changes.filter(s=>s.property!==i)}).filter(l=>l.changes.length>0);return{...r,styleModifications:a}}function di(e,t){let{selector:o,sticker:i}=t,n=typeof window<"u"?window.location.pathname:"/";if(!e.styleModifications.find(l=>l.selector===o&&(!l.pathname||l.pathname===n)&&!l.captured&&l.changes.some(s=>s.sticker?.family===i.family&&s.sticker.subproperty===i.subproperty)))return e;let r=_(e),a=r.styleModifications.map(l=>l.selector!==o||l.pathname&&l.pathname!==n||l.captured?l:{...l,changes:l.changes.filter(s=>s.sticker?.family!==i.family||s.sticker.subproperty!==i.subproperty)}).filter(l=>l.changes.length>0);return{...r,styleModifications:a}}function ci(e){return e.styleModifications.length===0?e:{..._(e),styleModifications:[]}}function pi(e,t){let o=new Set(t.selectors);if(o.size===0)return e;let i=e.styleModifications.filter(n=>!n.captured||!o.has(n.selector)&&(!n.durableSelector||!o.has(n.durableSelector)));return i.length===e.styleModifications.length?e:{...e,styleModifications:i}}function ui(e,t){let o=Date.now();return{...e,styleModifications:t.map((i,n)=>({...i,createdAt:i.createdAt??o+n}))}}function tn(e,t,o,i){return e.selector===t&&(!e.pathname||e.pathname===i)&&e.textNodePath.length===o.length&&e.textNodePath.every((n,r)=>n===o[r])}function nn(e,t,o=!0){let{selector:i,durableSelector:n,element:r,textNodePath:a,original:l,modified:s}=t,d=typeof window<"u"?window.location.pathname:"/",p=e.textModifications.findIndex(u=>tn(u,i,a,d));if(l===s&&p<0)return e;if(p>=0){let u=e.textModifications[p],f=u.captured&&o?_(e):e,y=u.captured?l:u.original;return s===y?{...f,textModifications:f.textModifications.filter((g,m)=>m!==p)}:{...f,textModifications:f.textModifications.map((g,m)=>m===p?{...g,durableSelector:n,element:r,original:y,modified:s,createdAt:g.createdAt??Date.now(),captured:!1,pathname:d}:g)}}let h=o?_(e):e;return{...h,textModifications:[...h.textModifications,{selector:i,durableSelector:n,element:r,textNodePath:a,original:l,modified:s,createdAt:Date.now(),pathname:d}]}}function fi(e,t,o=!0){return t.length===0?e:t.reduce((i,n)=>nn(i,n,!1),o?_(e):e)}function hi(e,t){let o=Date.now();return{...e,textModifications:t.filter(i=>!i.captured).map((i,n)=>({...i,createdAt:i.createdAt??o+n}))}}function mi(e,t){let o=_(e),i=o.domModifications.findIndex(n=>n.id===t.id);return i>=0?{...o,domModifications:o.domModifications.map((n,r)=>r===i?{...t,captured:!1}:n)}:{...o,domModifications:[...o.domModifications,t]}}function gi(e,t){return{...e,domModifications:t}}function yi(e,t){let{updates:o}=t,i=new Map(o.map(n=>[n.id,n]));return{...e,annotations:e.annotations.map(n=>{let r=i.get(n.id);return r?{...n,points:[r.point,...n.points.slice(1)],...r.linkedAnchor?{linkedAnchor:r.linkedAnchor}:{}}:n})}}function xi(e,t){let o=new Set(t.ids);return{...e,annotations:e.annotations.map(i=>o.has(i.id)?{...i,status:t.status}:i)}}function vi(e,t){let o=new Set(t.ids),i=new Set;for(let n of e.annotations)o.has(n.id)&&n.groupId&&i.add(n.groupId);return{...e,annotations:e.annotations.map(n=>{if(!o.has(n.id)&&!(n.groupId&&i.has(n.groupId)))return n;let r=!!t.jobId&&n.replyJobIds?.includes(t.jobId),a=n.status==="waiting_input";return{...n,status:a?"waiting_input":"resolved",replyCount:(n.replyCount??0)+(r?0:1),replyJobIds:t.jobId&&!r?[...n.replyJobIds??[],t.jobId]:n.replyJobIds,threadId:n.threadId||t.threadId,question:a?n.question:void 0}})}}function bi(e,t){let o=new Set(t.ids),i=new Set;for(let n of e.annotations)o.has(n.id)&&n.groupId&&i.add(n.groupId);return{...e,annotations:e.annotations.map(n=>o.has(n.id)||n.groupId&&i.has(n.groupId)?{...n,status:"failed",threadId:n.threadId||t.threadId,question:void 0}:n)}}function wi(e,t){let o=new Set(t.ids),i=new Set;for(let n of e.annotations)o.has(n.id)&&n.groupId&&i.add(n.groupId);return{...e,annotations:e.annotations.map(n=>o.has(n.id)||n.groupId&&i.has(n.groupId)?{...n,threadId:t.threadId,targetBindingId:t.targetBindingId}:n)}}function Ii(e,t){let o=new Set(t.ids),i=new Set;for(let n of e.annotations)o.has(n.id)&&n.groupId&&i.add(n.groupId);return{...e,annotations:e.annotations.map(n=>o.has(n.id)||n.groupId&&i.has(n.groupId)?{...n,status:"waiting_input",question:t.question,threadId:t.threadId}:n)}}function Si(e,t){let o=new Map(t.resolutions.map(n=>[n.annotationId,n])),i=new Map;for(let n of e.annotations){let r=o.get(n.id);r&&n.groupId&&i.set(n.groupId,r)}return{...e,annotations:e.annotations.map(n=>{let r=o.get(n.id)||(n.groupId?i.get(n.groupId):void 0);if(!r)return n;let a=!!t.jobId&&n.replyJobIds?.includes(t.jobId);return{...n,status:r.status,resolutionSummary:r.summary,scope:r.finalScope??r.inferredScope??null,replyCount:(n.replyCount??0)+(a?0:1),replyJobIds:t.jobId&&!a?[...n.replyJobIds??[],t.jobId]:n.replyJobIds,question:void 0,threadId:n.threadId||t.threadId}})}}function Ti(e,t){let{linkedSelectors:o,styleSelectors:i}=t,n=new Set(o),r=new Set(i),a=typeof window<"u"?window.location.pathname:"/",l=new Set,s=new Set;for(let f of e.annotations)f.linkedSelector&&n.has(f.linkedSelector)&&(l.add(f.id),f.groupId&&s.add(f.groupId));for(let f of e.annotations)f.groupId&&s.has(f.groupId)&&l.add(f.id);let d=e.annotations.filter(f=>!l.has(f.id)),p=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(d.length===e.annotations.length&&p.length===e.styleModifications.length&&h.length===e.domModifications.length)return e;let u=e.selectedAnnotationIds.filter(f=>!l.has(f));return{...e,annotations:d,styleModifications:p,domModifications:h,selectedAnnotationIds:u,lastSelectedId:u.length>0?u[u.length-1]:null}}function Mi(e,t){let o=e.spacingTokenChanges.findIndex(i=>i.tokenPath===t.tokenPath);return o>=0?{...e,spacingTokenChanges:e.spacingTokenChanges.map((i,n)=>n===o?t:i)}:{...e,spacingTokenChanges:[...e.spacingTokenChanges,t]}}function ki(e,t){return{...e,spacingTokenChanges:t}}function Ei(e,t){let o=_(e),i=e.spacingTokenMods.findIndex(r=>r.tokenPath===t.tokenPath),n;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};n=e.spacingTokenMods.map((l,s)=>s===i?a:l)}else n=[...e.spacingTokenMods,{...t,captured:!1}];return{...o,spacingTokenMods:n}}function Ai(e,t){let o=_(e),i=e.spacingTokenMods.findIndex(d=>d.tokenPath===t.tokenPath),n=i>=0?e.spacingTokenMods[i]:null,r=i>=0?n.captured?n.currentValue:n.originalValue:t.originalValue,a=i>=0?n.captured?n.currentPx:n.originalPx:parseFloat(t.originalValue)||0,l={tokenPath:t.tokenPath,originalValue:r,currentValue:"__deleted__",targets:n?.targets??[],originalPx:a,currentPx:0,captured:!1},s;return i>=0?s=e.spacingTokenMods.map((d,p)=>p===i?l:d):s=[...e.spacingTokenMods,l],{...o,spacingTokenMods:s}}function on(e,t){switch(t.type){case"SET_ANNOTATING":return zo(e,t.payload);case"SET_TOOL":return Bo(e,t.payload);case"SET_COLOR":return Wo(e,t.payload);case"SET_STROKE_WIDTH":return Ho(e,t.payload);case"ADD_TEXT":return jo(e,t.payload);case"UPDATE_TEXT":return Yo(e,t.payload);case"CLEAR_INTERACTION_EPISODE":return Ko(e,t.payload);case"DELETE_ANNOTATION":return qo(e,t.payload);case"MOVE_ANNOTATION":return Uo(e,t.payload);case"RESIZE_ANNOTATION":return Vo(e,t.payload);case"PASTE_ANNOTATIONS":return Xo(e,t.payload);case"RESTORE_ANNOTATIONS":return Jo(e,t.payload);case"SYNC_ANNOTATIONS":return Qo(e,t.payload);case"MERGE_ANNOTATIONS":return Go(e,t.payload);case"UNDO":return Zo(e);case"REDO":return ei(e);case"SELECT_ANNOTATION":return ti(e,t.payload);case"UPDATE_ANNOTATION_COLOR":return ni(e,t.payload);case"MARK_CAPTURED":return oi(e,t.payload?.annotationIds,t.payload?.textModifications);case"CLEAR":return ai(e);case"DISCARD_DRAFT":return ii(e);case"MODIFY_STYLE":return ri(e,t.payload);case"MODIFY_STYLES_BATCH":return li(e,t.payload);case"CLEAR_STYLE":return si(e,t.payload);case"CLEAR_STICKER":return di(e,t.payload);case"CLEAR_ALL_STYLES":return ci(e);case"SETTLE_CAPTURED_STYLES":return pi(e,t.payload);case"RESTORE_STYLE_MODIFICATIONS":return ui(e,t.payload);case"MODIFY_TEXT_CONTENT":return nn(e,t.payload);case"MODIFY_TEXT_CONTENTS":return fi(e,t.payload,t.saveUndo??!0);case"RESTORE_TEXT_MODIFICATIONS":return hi(e,t.payload);case"MODIFY_DOM_STRUCTURE":return mi(e,t.payload);case"RESTORE_DOM_MODIFICATIONS":return gi(e,t.payload);case"UPDATE_LINKED_POSITIONS":return yi(e,t.payload);case"CLEANUP_ORPHANED":return Ti(e,t.payload);case"SET_ANNOTATION_STATUS":return xi(e,t.payload);case"MARK_ANNOTATIONS_REPLIED":return vi(e,t.payload);case"MARK_ANNOTATIONS_FAILED":return bi(e,t.payload);case"SET_ANNOTATION_THREAD":return wi(e,t.payload);case"SET_ANNOTATION_QUESTION":return Ii(e,t.payload);case"APPLY_RESOLUTIONS":return Si(e,t.payload);case"ADD_SPACING_TOKEN_CHANGE":return Mi(e,t.payload);case"RESTORE_SPACING_TOKEN_CHANGES":return ki(e,t.payload);case"MODIFY_SPACING_TOKEN":return Ei(e,t.payload);case"DELETE_SPACING_TOKEN":return Ai(e,t.payload);default:return t}}function Ci(e,t){let o=ce(Zt),[i,n]=jn(on,Sn),r=Yn(o?.subscribe??Fo,o?.getSnapshot??en,o?.getSnapshot??en)??i,a=o?.dispatch??n;J(()=>{if(!r.isAnnotating)return;let s=d=>{t?.current||d.defaultPrevented||d.isComposing||d.altKey||d.composedPath().some(p=>p instanceof Element&&(p.matches('input, textarea, select, [role="textbox"]')||p instanceof HTMLElement&&p.isContentEditable||p.hasAttribute("contenteditable")&&p.getAttribute("contenteditable")!=="false"))||(d.metaKey||d.ctrlKey)&&d.key.toLowerCase()===Oe.actions.undo.key&&(d.preventDefault(),d.shiftKey?a({type:"REDO"}):e?.current?.()||a({type:"UNDO"}))};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[a,r.isAnnotating,e,t]);let l=o?.getUndoHead?o.getUndoHead():r.undoStack.at(-1);return[r,a,l]}function he(e){return e?!!e.closest("#devtools-toolbar, #devtools-scrim, #devtools-text-input, [data-devtools], [data-popmelt-panel], [data-popmelt-shadow-host]"):!1}function Ri(e,t,o=document){let i=o,n=i.caretPositionFromPoint?.(e,t);if(n?.offsetNode?.nodeType===Node.TEXT_NODE)return n.offsetNode;let r=i.caretRangeFromPoint?.(e,t);return r?.startContainer?.nodeType===Node.TEXT_NODE?r.startContainer:null}function Ni(e,t){if(!e)return t();let o=e.style.pointerEvents;e.style.pointerEvents="none";try{return t()}finally{e.style.pointerEvents=o}}function Li(e,t,o){let i=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(r){return r.textContent?.trim()?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),n=i.nextNode();for(;n;){let r=n,a=e.ownerDocument.createRange();a.selectNodeContents(r);let l=Array.from(a.getClientRects());if(a.detach?.(),l.some(s=>t>=s.left&&t<=s.right&&o>=s.top&&o<=s.bottom))return r;n=i.nextNode()}return null}function $i(e,t,o){return Ni(o,()=>{let i=bt(e,t);if(!i||he(i))return null;let n=i?.ownerDocument??document,r=Ln(e,t,n),a=Ri(r.x,r.y,n);if(a&&!i.contains(a)&&(a=null),!a){let w=i;w&&!he(w)&&(a=Li(w,r.x,r.y))}if(!a||!$n(a.parentElement))return null;let l=a.parentElement;if(he(l))return null;for(;l.parentElement&&l!==n.body;){let w=Ae(l).getComputedStyle(l).display,E=w==="inline-block"&&l.childNodes.length===1&&l.firstChild?.nodeType===Node.ELEMENT_NODE;if(w!=="inline"&&w!=="contents"&&!E)break;let R=l.parentElement;if(he(R))break;if(Array.from(R.childNodes).some(M=>M.nodeType===Node.TEXT_NODE&&!!M.nodeValue?.trim())){l=R;continue}let z=Ae(R).getComputedStyle(R).display,A=z==="inline-block"&&R.childNodes.length===1&&R.firstChild?.nodeType===Node.ELEMENT_NODE;if(z==="inline"||z==="contents"||A){l=R;continue}break}let s=l.tagName.toLowerCase();if(s==="script"||s==="style"||s==="textarea"||s==="input")return null;let d=Di(l),p=d.map(w=>w.originalText).join("");if(!p.trim())return null;let h=an(l,a);if(!h)return null;let u=Ae(l).getComputedStyle(l),f=ln(d,l,u),{textRect:y,boundaryRect:g,boundaryRects:m,flowRect:k,firstLineIndent:v}=f;if(y.width<=0||y.height<=0)return null;let b=parseFloat(u.fontSize)||12,S=u.whiteSpace!=="nowrap"&&u.whiteSpace!=="pre"&&(Fi(a)||u.display!=="inline");return{textNode:a,targetElement:l,textNodePath:h,segments:d,originalText:p,rect:y,boundaryRect:g,boundaryRects:m,flowRect:k,firstLineIndent:v,styles:u,fontSize:b,wrapsText:S}})}function an(e,t){let o=[],i=t;for(;i&&i!==e;){let n=i.parentNode;if(!n)return null;o.unshift(Array.prototype.indexOf.call(n.childNodes,i)),i=n}return i===e?o:null}function Oi(e,t){let o=e.ownerDocument.createRange();o.selectNodeContents(e);let i=Ee(o.getBoundingClientRect(),e.ownerDocument);if(o.detach?.(),i.width>0&&i.height>0)return{left:i.left,top:i.top,width:i.width,height:i.height};let n=ke(t);return{left:n.left,top:n.top,width:n.width,height:n.height}}function Di(e){let t=[],o=i=>{if(i.nodeType===Node.TEXT_NODE){let r=i,a=an(e,r);a&&t.push({textNode:r,textNodePath:a,originalText:r.nodeValue??""});return}if(i.nodeType!==Node.ELEMENT_NODE&&i!==e)return;let n=i.tagName?.toLowerCase();n==="script"||n==="style"||i.childNodes.forEach(o)};return e.childNodes.forEach(o),t}function rn(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function _i(e){let t=[];for(let o of e){if(!o.textNode.isConnected||!o.originalText.trim())continue;let i=o.textNode.ownerDocument.createRange();i.selectNodeContents(o.textNode),t.push(...Array.from(i.getClientRects()).filter(n=>n.width>0&&n.height>0).map(n=>rn(Ee(n,o.textNode.ownerDocument)))),i.detach?.()}return Qe(t)}function Pi(e){let t=e.getBoundingClientRect(),o=Ae(e).getComputedStyle(e),i=(parseFloat(o.borderLeftWidth)||0)+(parseFloat(o.paddingLeft)||0),n=(parseFloat(o.borderRightWidth)||0)+(parseFloat(o.paddingRight)||0),r=(parseFloat(o.borderTopWidth)||0)+(parseFloat(o.paddingTop)||0),a=(parseFloat(o.borderBottomWidth)||0)+(parseFloat(o.paddingBottom)||0);return Ee({left:t.left+i,top:t.top+r,width:Math.max(0,t.width-i-n),height:Math.max(0,t.height-r-a)},e.ownerDocument)}function ln(e,t,o){let i=rn(ke(t)),n=_i(e),r=e[0]?.textNode?Oi(e[0].textNode,t):i,a=n.length>0?n:[r];return uo({display:o.display,fragmentRects:a,elementRect:i,parentContentRect:t.parentElement?Pi(t.parentElement):void 0})}function Fi(e){let t=e.ownerDocument.createRange();t.selectNodeContents(e);let o=Array.from(t.getClientRects()).filter(i=>i.width>0&&i.height>0).length;return t.detach?.(),o>1}function zi(e,t,o){if(t===o||e.length===0)return[];let i=0;for(;i<t.length&&i<o.length&&t[i]===o[i];)i+=1;let n=0;for(;n<t.length-i&&n<o.length-i&&t[t.length-1-n]===o[o.length-1-n];)n+=1;let r=i,a=t.length-n,l=o.slice(i,o.length-n),s=0,d=!1;return e.flatMap((p,h)=>{let u=s,f=u+p.originalText.length;s=f;let y=r===a,g=y&&(r>=u&&r<f||h===e.length-1&&r===f),m=!y&&f>r&&u<a;if(!g&&!m)return[];let k=Math.max(0,Math.min(p.originalText.length,r-u)),v=Math.max(0,Math.min(p.originalText.length,a-u)),b=p.originalText.slice(0,k);return d||(b+=l,d=!0),b+=p.originalText.slice(v),b===p.originalText?[]:[{segment:p,modifiedText:b}]})}function st(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 Bi(e,t){return!e||!t?e===t:st(e,t)}function Wi(e,t){return e.length===t.length&&e.every((o,i)=>st(o,t[i]))}function Hi(){return{isDragging:!1,hasMoved:!1,mode:"move",startX:0,startY:0,element:null,originalParent:null,originalIndex:-1,selector:null,durableSelector:null,elementInfo:null}}function _e(e){if(!e||e===document.body||e===document.documentElement||he(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 G(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 dt(e){return e.parentElement?Array.from(e.parentElement.children).indexOf(e):-1}function sn(e){e.removeAttribute("data-pm"),e.querySelectorAll("[data-pm]").forEach(t=>t.removeAttribute("data-pm"))}function dn(e,t,o,i,n=bt){let r=o.parentElement;if(!r)return null;let a=n(e,t);for(;a&&a!==document.body;){if(a===o||o.contains(a)){a=a.parentElement;continue}if(a.parentElement===r&&_e(a))break;a=a.parentElement}if(!a||a===document.body||a.parentElement!==r||a===i)return null;let l=a.getBoundingClientRect(),s=l.height>=l.width?t<l.top+l.height/2?"before":"after":e<l.left+l.width/2?"before":"after",d=dt(a),p=s==="before"?d:d+1;return{parent:r,reference:a,placement:s,index:p}}function ct(e,t,o){let i=Array.from(e.children).filter(r=>r!==t),n=Math.max(0,Math.min(o,i.length));e.insertBefore(t,i[n]??null)}function ji({drag:e,clientX:t,clientY:o,pathname:i,createId:n,rootElement:r,elementAtPoint:a}){let l=e.element;if(!l||!e.selector||!e.durableSelector||!e.elementInfo)return null;let s=dn(t,o,l,r,a);if(!s)return null;let d=e.originalParent===s.parent&&s.index>e.originalIndex?s.index-1:s.index;if(e.mode==="move"&&e.originalParent===s.parent&&(d===e.originalIndex||d===e.originalIndex+1))return null;let p=X(s.parent),h=G(s.parent),u=X(s.reference),f=G(s.reference),y=e.selector,g=e.durableSelector,m=e.elementInfo;if(e.mode==="copy"){let v=l.cloneNode(!0);if(!(v instanceof Element))return null;sn(v),ct(s.parent,v,d),y=G(v),g=X(v),m={...He(v),selector:y}}else ct(s.parent,l,d);let k=e.originalParent;return{id:n(),operation:e.mode,selector:y,durableSelector:g,element:m,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?G(k):void 0,originalParentDurableSelector:k?X(k):void 0,originalIndex:e.originalIndex,targetParentSelector:h,targetParentDurableSelector:p,targetIndex:d,referenceSelector:f,referenceDurableSelector:u,placement:s.placement,pathname:i}}function cn(e){return e instanceof HTMLElement&&(e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable===!0||e.getAttribute("contenteditable")==="true")}function Yi(){if(typeof document>"u")return null;let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e}function pt(e){let t=e.composedPath?.()[0]??e.target;return cn(t)||cn(Yi())}function pn(e,t,o){if(o)return[o];let i=new Set(t),n=new Map;for(let a of e)a.groupId&&a.threadId&&n.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?n.get(a.groupId):void 0);l&&r.add(l)}return[...r]}function Ki({state:e,stateRef:t,activeTextRef:o,selectedIdsRef:i,dispatch:n,clearSelection:r,selectAnnotation:a,handHoveredElement:l,onArchiveThread:s,openThreadId:d,currentPathname:p,hasOpenThread:h}){let u=le([]),f=le(0),y=le(null);J(()=>{let g=m=>{if(m.key==="Escape"){if(m.defaultPrevented||m.repeat||o.current||h||pt(m))return;if(i.current.length>0){m.preventDefault(),r();return}let v=t.current;if(v.annotations.some(b=>(b.status??"pending")==="pending")||v.styleModifications.some(b=>!b.captured)||v.textModifications.some(b=>!b.captured)||v.domModifications.some(b=>!b.captured)||v.spacingTokenChanges.some(b=>!b.captured)||v.spacingTokenMods.some(b=>!b.captured)){m.preventDefault(),n({type:"DISCARD_DRAFT"});return}}if((m.metaKey||m.ctrlKey)&&m.key.toLowerCase()==="c"&&e.activeTool==="hand"&&l&&!o.current){if(_e(l)){m.preventDefault();let v=G(l);y.current={source:l,sourceSelector:v,sourceDurableSelector:X(l),sourceElement:{...He(l),selector:v}}}return}if((m.metaKey||m.ctrlKey)&&m.key.toLowerCase()==="v"&&e.activeTool==="hand"&&y.current&&!o.current){let v=y.current,b=l&&_e(l)?l:v.source,S=b.parentElement;if(S){m.preventDefault();let w=X(S),E=G(S),R=X(b),z=G(b),A=dt(b)+1,M=v.source.cloneNode(!0);if(M instanceof Element){sn(M),ct(S,M,A);let V=G(M),ne=X(M),oe={...He(M),selector:V};n({type:"MODIFY_DOM_STRUCTURE",payload:{id:rt(),operation:"copy",selector:V,durableSelector:ne,element:oe,sourceSelector:v.sourceSelector,sourceDurableSelector:v.sourceDurableSelector,sourceElement:v.sourceElement,targetParentSelector:E,targetParentDurableSelector:w,targetIndex:A,referenceSelector:z,referenceDurableSelector:R,placement:"after",pathname:p}})}}return}if((m.metaKey||m.ctrlKey)&&m.key==="v"&&u.current.length>0&&!o.current){m.preventDefault(),f.current+=1;let v=f.current*20,b=u.current[0]?.groupId?Math.random().toString(36).substring(2,9):void 0,S=u.current.map(E=>({...E,id:Math.random().toString(36).substring(2,9),groupId:E.groupId?b:void 0,timestamp:Date.now(),points:E.points.map(R=>({x:R.x+v,y:R.y+v}))}));n({type:"PASTE_ANNOTATIONS",payload:{annotations:S}});let w=S.find(E=>E.type!=="text")??S[0];w&&a(w.id);return}let k=i.current;if(!o.current&&!pt(m)&&(m.key==="Delete"||m.key==="Backspace")&&!m.metaKey&&!m.ctrlKey&&!m.altKey){if(k.length===0&&!d)return;let v=pn(t.current.annotations,k,d);if(!s||v.length===0)return;m.preventDefault();for(let b of v)s(b);r()}};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[o,r,p,n,l,h,s,d,a,i,e.activeTool,t])}export{vo as $,dt as A,dn as B,ji as C,pt as D,pn as E,Ki as F,Ue as G,ye as H,Ve as I,ao as J,ro as K,lo as L,so as M,co as N,$t as O,_t as P,fo as Q,ve as R,Ge as S,mo as T,te as U,tt as V,Bt as W,nt as X,Wt as Y,Ht as Z,xo as _,Oe as a,jt as aa,Do as b,Yt as ba,_o as c,ot as ca,Po as d,it as da,Zt as e,ue as ea,rt as f,Q as fa,on as g,Kt as ga,Ci as h,qt as ha,Kn as i,Vt as ia,qn as j,Xt as ja,Vn as k,Jt as ka,Qn as l,Ao as la,Gn as m,Co as ma,Zn as n,Ro as na,eo as o,No as oa,io as p,Oo as pa,he as q,$i as r,ln as s,zi as t,st as u,Bi as v,Wi as w,Hi as x,_e as y,G as z};
@@ -1,2 +1,2 @@
1
1
  "use client";
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};
2
+ import{h as y,a as g,f as S}from"./chunk-DNOKP3JS.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 v(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 k=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,v as b,k as c};