@popmelt.com/core 0.33.1 → 0.34.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 (115) 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-BG7ZOQSA.mjs +1 -0
  5. package/dist/PagePreviewLayer-CBDGPMJQ.mjs +1 -0
  6. package/dist/ParticipantRuntime-FSZX2PUQ.mjs +1 -0
  7. package/dist/PhoneHostGate-OM7FLOJ2.mjs +1 -0
  8. package/dist/PopmeltTasteConnectedPane-KJSBPJQR.mjs +1 -0
  9. package/dist/{PreviewRuntime-LFPK56NW.mjs → PreviewRuntime-EYKB7MG5.mjs} +1 -1
  10. package/dist/SuppliedContext-7THB2WZY.mjs +1 -0
  11. package/dist/ThreadErrorCard-J2VTA5JW.mjs +1 -0
  12. package/dist/ThreadPanel-PNVMIIYJ.mjs +1 -0
  13. package/dist/bridge-entry.mjs +1 -1
  14. package/dist/bridgeSSEStream-K3UIMBTC.mjs +1 -0
  15. package/dist/{bridgeWebSocketStream-H3DCP4T3.mjs → bridgeWebSocketStream-2SUZUBE3.mjs} +1 -1
  16. package/dist/browser-runtime-FFT5NH66.mjs +1 -0
  17. package/dist/browser.mjs +1 -1
  18. package/dist/{canvas-chat-note-NHYL3T6J.mjs → canvas-chat-note-MGAEUYJO.mjs} +1 -1
  19. package/dist/{checkFixture-MWBOYIM2.mjs → checkFixture-AMLLLJNS.mjs} +1 -1
  20. package/dist/chunk-2ETPREWQ.mjs +1 -0
  21. package/dist/chunk-3GXLNBXU.mjs +1 -0
  22. package/dist/chunk-3WSTAV5B.mjs +1 -0
  23. package/dist/chunk-53SKVMWR.mjs +1 -0
  24. package/dist/chunk-57FM7XQV.mjs +1 -0
  25. package/dist/chunk-5D2ADU7H.mjs +1 -0
  26. package/dist/chunk-67OWRNU3.mjs +30 -0
  27. package/dist/chunk-67QNAAUC.mjs +1 -0
  28. package/dist/chunk-BACXPVHP.mjs +1 -0
  29. package/dist/chunk-BFVLMSG5.mjs +1 -0
  30. package/dist/chunk-BJ25TGJN.mjs +1 -0
  31. package/dist/chunk-DOCRI237.mjs +1 -0
  32. package/dist/{chunk-HVD5ZG6W.mjs → chunk-E5WNW4WE.mjs} +1 -1
  33. package/dist/chunk-FMI4VQDZ.mjs +1 -0
  34. package/dist/chunk-G2ZHJXHZ.mjs +1 -0
  35. package/dist/chunk-G6RYESYI.mjs +1 -0
  36. package/dist/{chunk-75PQGTKX.mjs → chunk-G7JR5Z3P.mjs} +1 -1
  37. package/dist/chunk-GRPDZGPP.mjs +1 -0
  38. package/dist/{chunk-GASEZICN.mjs → chunk-GSEMSZDB.mjs} +1 -1
  39. package/dist/chunk-H2RLTCUJ.mjs +1 -0
  40. package/dist/{chunk-EAV2VV2V.mjs → chunk-HAE5LUJX.mjs} +1 -1
  41. package/dist/{chunk-IKCHOC3U.mjs → chunk-HV7HRQ2S.mjs} +0 -1
  42. package/dist/{chunk-2ZJ4FBTG.mjs → chunk-JRP5XFYN.mjs} +1 -1
  43. package/dist/chunk-LD3532UC.mjs +1 -0
  44. package/dist/chunk-MJ2PFKF3.mjs +1 -0
  45. package/dist/chunk-MP6ZV2DN.mjs +1 -0
  46. package/dist/chunk-N66ZZG3L.mjs +1 -0
  47. package/dist/chunk-NSCO633B.mjs +1 -0
  48. package/dist/chunk-P4KM3K5M.mjs +1 -0
  49. package/dist/chunk-PH2MLB3T.mjs +1 -0
  50. package/dist/chunk-Q6C7ZA3H.mjs +1 -0
  51. package/dist/chunk-Q6N77LIS.mjs +1 -0
  52. package/dist/chunk-Q74FBX2I.mjs +1 -0
  53. package/dist/chunk-QQB5G3VB.mjs +1 -0
  54. package/dist/chunk-R3FPXDQS.mjs +1 -0
  55. package/dist/chunk-RK6UROPO.mjs +1 -0
  56. package/dist/chunk-RR4SHK7O.mjs +1 -0
  57. package/dist/chunk-RSUMSUAW.mjs +1 -0
  58. package/dist/{chunk-GL4I4MI6.mjs → chunk-RUJC32MA.mjs} +1 -1
  59. package/dist/{chunk-2IASPT6L.mjs → chunk-RUTWU5W2.mjs} +1 -1
  60. package/dist/chunk-TRHC7WBO.mjs +1 -0
  61. package/dist/chunk-XSMCZUDR.mjs +1 -0
  62. package/dist/{chunk-DNOKP3JS.mjs → chunk-XT6PHPPG.mjs} +1 -1
  63. package/dist/chunk-Y6WD56SO.mjs +1 -0
  64. package/dist/chunk-YC5CUNRU.mjs +1 -0
  65. package/dist/chunk-YFDD7HGT.mjs +1 -0
  66. package/dist/{chunk-JMMP5JSP.mjs → chunk-YTUQYKLM.mjs} +1 -1
  67. package/dist/chunk-YXPRWW6B.mjs +1 -0
  68. package/dist/chunk-ZVDKW7TO.mjs +1 -0
  69. package/dist/cli.mjs +1 -1
  70. package/dist/codex-note-context-NUKGR2WT.mjs +1 -0
  71. package/dist/codex-project-KE7ZZ6YX.mjs +1 -0
  72. package/dist/{codex-session-registry-SPRWY2WW.mjs → codex-session-registry-ONODFWFD.mjs} +1 -2
  73. package/dist/focus-inspection-BPPRCMNN.mjs +1 -0
  74. package/dist/index.d.mts +25 -0
  75. package/dist/index.mjs +1 -1
  76. package/dist/memory-store.mjs +1 -1
  77. package/dist/peer-client-UQDASAO7.mjs +1 -0
  78. package/dist/plugin-astro.mjs +1 -1
  79. package/dist/plugin-next.mjs +1 -1
  80. package/dist/plugin-nuxt.mjs +1 -1
  81. package/dist/plugin-vite.mjs +1 -1
  82. package/dist/server.mjs +1 -1
  83. package/dist/steerStyles-VKQD57KC.mjs +1 -0
  84. package/package.json +1 -1
  85. package/dist/ExploreAttachment-VKCCEIM7.mjs +0 -1
  86. package/dist/ParticipantRuntime-YS5SIZUQ.mjs +0 -1
  87. package/dist/PopmeltTasteConnectedPane-FKIJM3C7.mjs +0 -1
  88. package/dist/SuppliedContext-RWN6UR3K.mjs +0 -1
  89. package/dist/ThreadErrorCard-7J62GD5W.mjs +0 -1
  90. package/dist/ThreadPanel-KVNM67WO.mjs +0 -1
  91. package/dist/bridgeSSEStream-NEYI73TC.mjs +0 -1
  92. package/dist/browser-runtime-AP35S5MK.mjs +0 -1
  93. package/dist/chunk-27ADDVGC.mjs +0 -1
  94. package/dist/chunk-2VCHBI7Y.mjs +0 -1
  95. package/dist/chunk-6V2VCKPG.mjs +0 -1
  96. package/dist/chunk-6VXFTT5U.mjs +0 -1
  97. package/dist/chunk-BVTLSUQT.mjs +0 -1
  98. package/dist/chunk-CPOYMGYY.mjs +0 -1
  99. package/dist/chunk-H7XMDLGU.mjs +0 -30
  100. package/dist/chunk-N2QUNHV6.mjs +0 -1
  101. package/dist/chunk-N6JTX4PD.mjs +0 -2
  102. package/dist/chunk-ODIGT4YJ.mjs +0 -1
  103. package/dist/chunk-PSSHCTJ2.mjs +0 -1
  104. package/dist/chunk-QOJCTLQW.mjs +0 -1
  105. package/dist/chunk-RESPUCV7.mjs +0 -1
  106. package/dist/chunk-SHAIHRV2.mjs +0 -1
  107. package/dist/chunk-VPPVURBR.mjs +0 -2
  108. package/dist/chunk-W5NIRROD.mjs +0 -1
  109. package/dist/chunk-XKD2ABCO.mjs +0 -1
  110. package/dist/chunk-YLKEDOII.mjs +0 -31
  111. package/dist/chunk-ZHJZPC7U.mjs +0 -1
  112. package/dist/codex-note-context-4JYQ437H.mjs +0 -2
  113. package/dist/codex-project-FA4EK6VR.mjs +0 -2
  114. package/dist/focus-inspection-VBS5656D.mjs +0 -1
  115. package/dist/peer-client-KJCPXT76.mjs +0 -2
@@ -1 +0,0 @@
1
- "use client";import{c as e,b as t}from"./chunk-4LHTPRFY.mjs";import{a as n}from"./chunk-2ZJ4FBTG.mjs";import{g as o,a as i,f as a}from"./chunk-DNOKP3JS.mjs";import{o as r,p as l,r as d,h as s,i as c}from"./chunk-2VCHBI7Y.mjs";import{b as p,g as u,e as f}from"./chunk-ODIGT4YJ.mjs";import{a as h,b as m,c as g}from"./chunk-5K7SACPW.mjs";import{a as y,b as v}from"./chunk-LVEMYZOA.mjs";import{a as x,d as w,v as b,h as I,i as S,c as T,f as M,b as k,e as E,g as A}from"./chunk-WHJEKDNP.mjs";import{Clock as C,OctagonAlert as R,MessageCircleQuestionMark as N,TriangleAlert as L,Reply as O,Eye as D,SendHorizontal as $,CornerDownLeft as _}from"lucide-react";import{createContext as P,useContext as F,useState as z,useEffect as B,useLayoutEffect as W,useId as H,useRef as j,useMemo as Y,useCallback as K,useReducer as q,useSyncExternalStore as U}from"react";import{jsxs as V,jsx as X,Fragment as J}from"react/jsx-runtime";var G,Q=new Set;function Z(e){if(Q.add(e),!G){let e=new Map,t=new Map,n="",o=!0,i=!0,a=!1,r=!0,l=0,d=()=>{let n=new Set,a=new Map,r=t=>{if(n.add(t),!e.has(t)){let n=new MutationObserver(e=>{let t=e.filter(e=>!(1===e.target.nodeType?e.target:e.target.parentElement)?.closest("[data-devtools]"));t.length&&(o=!0),t.some(e=>"childList"===e.type)&&(i=!0)});n.observe(t,{subtree:!0,childList:!0,characterData:!0,attributes:!0});let a=()=>{o=!0};t.addEventListener("scroll",a,!0),t.addEventListener("load",a,!0),e.set(t,()=>{n.disconnect(),t.removeEventListener("scroll",a,!0),t.removeEventListener("load",a,!0)})}for(let e of t.querySelectorAll("*")){if(e.shadowRoot&&!e.closest("[data-devtools]")&&r(e.shadowRoot),"iframe"!==e.localName||e.closest("[data-devtools],[data-popmelt-peer-surface]"))continue;let t=k(e);a.set(e,t),t&&r(t)}};r(document);for(let[t,o]of e)n.has(t)||(o(),e.delete(t));t=a,i=!1,o=!0},s=()=>{if(!r)return;(i||[...t].some(([e,t])=>k(e)!==t))&&d();let e=[];for(let[n,o]of t){let t=n.getBoundingClientRect();e.push(o?.URL,t.x,t.y,t.width,t.height,o?.defaultView?.scrollX,o?.defaultView?.scrollY)}let c=JSON.stringify(e);if((o||c!==n)&&(o=!1,n=c,a))for(let e of Q)e();a=!0,r&&(l=requestAnimationFrame(s))};s(),G=()=>{r=!1,cancelAnimationFrame(l);for(let t of e.values())t()}}return()=>{Q.delete(e),Q.size||(G?.(),G=void 0)}}var ee=P(!0);function te(e,t){let n=e.match(/^oklch\(([^)]+)\)$/i);if(n)return`oklch(${n[1]} / ${t})`;let o=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(o){return`rgba(${parseInt(o[1],16)}, ${parseInt(o[2],16)}, ${parseInt(o[3],16)}, ${t})`}return`color-mix(in srgb, ${e} ${Math.round(100*t)}%, transparent)`}function ne(e,t){let n=m(e),o=t.toLowerCase(),i=-1;for(let a=n.length-1;a>=0;a--){let r=n[a].name;if(r===t){let o=g(n[a].fiber)??e;return{name:t,path:n.map(e=>e.name),depthIndex:a,rootElement:o}}if(-1===i){let e=r.toLowerCase();(e.length>=4&&o.includes(e)||o.length>=4&&e.includes(o))&&(i=a)}}if(i>=0){let o=g(n[i].fiber)??e;return{name:t,path:n.map(e=>e.name),depthIndex:i,rootElement:o}}return null}function oe(e){let t=ae(),n=[],o=new Set,i=t.currentNode;for(;i=t.nextNode();){let t=ne(i,e);t&&!o.has(t.rootElement)&&(o.add(t.rootElement),n.push(t))}return n}function ie(e){let t=new Map;if(0===e.size)return t;let n=new Set(e),o=ae(),i=new Set,a=o.currentNode;for(;(a=o.nextNode())&&n.size>0;)for(let e of n){let o=ne(a,e);if(!o||i.has(o.rootElement))continue;i.add(o.rootElement);let r=o.rootElement.getBoundingClientRect();t.set(e,r.top+window.scrollY),n.delete(e);break}for(let e of n)t.set(e,1/0);return t}function ae(){return document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.closest("#devtools-toolbar, #devtools-canvas, #devtools-scrim, [data-popmelt-panel]")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT})}function re(e,t){return""!==e.style.getPropertyValue(t)}function le(e){return"string"==typeof e?{value:e}:e}var de={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 se(e,t){let n=de[t];return!!n&&n.includes(e)}function ce(e,t){let n=e.split(/\s+/);for(let e of n){if(e===t)return!0;let n=e.lastIndexOf(":");if(n>=0&&e.slice(n+1)===t)return!0}return!1}function pe(e){let t=e.lastIndexOf(":"),n=t>=0?e.slice(t+1):e,o=n.indexOf("-");if(o<0)return null;let i=n.slice(0,o),a={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"};return a[n.slice(0,n.indexOf("-",o+1)>0?n.indexOf("-",o+1):o)]??a[i]??null}function ue(e,t=30){let n=parseFloat(e.value);if(isNaN(n)||n<=0)return[];if(e.bindings&&e.bindings.length>0){let n=[],o=ae(),i=o.currentNode;for(;(i=o.nextNode())&&n.length<t;){let t=i,o=t.getBoundingClientRect();if(o.bottom<-50||o.top>window.innerHeight+50||o.right<-50||o.left>window.innerWidth+50||o.width<1||o.height<1)continue;let a=t.className;if("string"==typeof a)for(let o of e.bindings){if(!ce(a,o))continue;let i=pe(o);if(i&&(!e.property||se(i,e.property))){n.push({element:t,property:i});break}}}return n}let o=function(e,t=30){if(e<=0)return[];let n=[],o=ae(),i=.5,a=o.currentNode;for(;(a=o.nextNode())&&n.length<t;){let o=a,r=o.getBoundingClientRect();if(r.bottom<-50||r.top>window.innerHeight+50||r.right<-50||r.left>window.innerWidth+50||r.width<1||r.height<1)continue;let l=getComputedStyle(o);!re(o,"padding-top")&&Math.abs((parseFloat(l.paddingTop)||0)-e)<i&&n.push({element:o,property:"padding-top"}),!re(o,"padding-bottom")&&Math.abs((parseFloat(l.paddingBottom)||0)-e)<i&&n.length<t&&n.push({element:o,property:"padding-bottom"}),!re(o,"padding-left")&&Math.abs((parseFloat(l.paddingLeft)||0)-e)<i&&n.length<t&&n.push({element:o,property:"padding-left"}),!re(o,"padding-right")&&Math.abs((parseFloat(l.paddingRight)||0)-e)<i&&n.length<t&&n.push({element:o,property:"padding-right"}),!re(o,"margin-top")&&Math.abs((parseFloat(l.marginTop)||0)-e)<i&&n.length<t&&n.push({element:o,property:"margin-top"}),!re(o,"margin-bottom")&&Math.abs((parseFloat(l.marginBottom)||0)-e)<i&&n.length<t&&n.push({element:o,property:"margin-bottom"}),!re(o,"margin-left")&&Math.abs((parseFloat(l.marginLeft)||0)-e)<i&&n.length<t&&n.push({element:o,property:"margin-left"}),!re(o,"margin-right")&&Math.abs((parseFloat(l.marginRight)||0)-e)<i&&n.length<t&&n.push({element:o,property:"margin-right"});let d=l.display;if((d.includes("flex")||d.includes("grid"))&&n.length<t){let t=re(o,"gap"),a=parseFloat(l.gap)||0,r=parseFloat(l.rowGap)||0,d=parseFloat(l.columnGap)||0;!t&&Math.abs(a-e)<i?n.push({element:o,property:"gap"}):!re(o,"row-gap")&&Math.abs(r-e)<i?n.push({element:o,property:"row-gap"}):!re(o,"column-gap")&&Math.abs(d-e)<i&&n.push({element:o,property:"column-gap"})}}return n}(n,2*t);return e.property?o.filter(t=>se(t.property,e.property)).slice(0,t):o.slice(0,t)}function fe(e,t){let n=new Set,o=ye(t);for(let t of e){let e=ve[t.property];if(!e)continue;let i=t.element.className;if("string"==typeof i)for(let t of e){let e=`${t}-${o}`;for(let t of i.split(/\s+/)){let o=t.lastIndexOf(":"),i=o>=0?t.slice(o+1):t;if(i===e){n.add(i);break}}}}return[...n]}function he(e){let t=new Set;for(let n of e)for(let[e,o]of Object.entries(de))if(o.includes(n.property)){t.add(e);break}if(1===t.size)return[...t][0]}function me(e,t,n){if(t===n)return e;let o=ye(t),i=ye(n);return e.map(e=>{let n=e.lastIndexOf("-");if(n<0)return e;let a=e.slice(0,n),r=e.slice(n+1);return r===o||r===`[${t}px]`?`${a}-${i}`:e})}var ge={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 ye(e){return ge[e]??`[${e}px]`}var ve={"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 xe(e,t,n,o){let i=ve[t];if(!i)return null;let a=ye(n);for(let t of i){let i=new RegExp("(?:^|\\s)((?:[\\w-]+:)*"+t+"-(?:"+we(a)+"|\\["+n+"px\\]))(?:\\s|$)"),r=e.match(i);if(r?.[1]){let e=ye(o),n=r[1].lastIndexOf(":"),i=n>=0?r[1].slice(0,n+1):"";return{matched:r[1],suggested:`${i}${t}-${e}`}}}return null}function we(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function be(e,t,n){let o=new Set,a=[];for(let r of e){let e=i(r.element),l=`${e}::${r.property}`;if(o.has(l))continue;o.add(l);let d=h(r.element),s=r.element.className||"",c=xe(s,r.property,t,n);a.push({selector:e,reactComponent:d?.name,className:s,property:r.property,matchedClass:c?.matched,suggestedClass:c?.suggested})}return a}function Ie(e){let t=e.startsWith("top-");return{top:t?4:12,right:4,bottom:t?12:4,left:4}}function Se({hasCommentEntry:e,stagedChangeCount:t}){return e&&0===t?2:6}function Te({annotationNumber:e,stickerCount:t,interactionEpisodeStepCount:n,hasStatus:o,hasSend:i,controlGap:a}){let r=16+7.2*Math.max(1,void 0===e?0:String(e).length),l=28*t-2*Math.max(0,t-1),d=n>0?32+7.2*String(n).length:0,s=[t>0?t>0?l+(d>0?d-2:0)+(i?26:0):0:0,0===t?d:0,0===t&&i?28:0,o?28:0].filter(e=>e>0);return r+s.reduce((e,t)=>e+t,0)+s.length*a}function Me(e,t,n){let o="right"===e.horizontalAlignment?e.left-t:e.left;return{left:o,top:e.top,right:o+t,bottom:e.top+n}}function ke(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}function Ee(e,t,n,o,i=0,a=Number.POSITIVE_INFINITY){if(e.height>=o)return{anchor:"top-left",horizontalAlignment:"left",left:e.left+8,top:e.top+8};let r=function(e,t,n){let o=Math.max(0,e.left+t-n);return Math.max(0,t-e.right)<o?"right":"left"}(e,i,a);return e.top>=t+n?{anchor:"right"===r?"top-right":"top-left",horizontalAlignment:r,left:"right"===r?e.right:e.left,top:e.top-t-n}:{anchor:"right"===r?"bottom-right":"bottom-left",horizontalAlignment:r,left:"right"===r?e.right:e.left,top:e.bottom+n}}function Ae(e){return e.left+e.width}function Ce(e){return e.top+e.height}function Re(e,t){if(0===e.length)return t;let n=Math.min(...e.map(e=>e.left)),o=Math.min(...e.map(e=>e.top));return{left:n,top:o,width:Math.max(...e.map(Ae))-n,height:Math.max(...e.map(Ce))-o}}function Ne(e){let t=[...e].sort((e,t)=>e.top-t.top||e.left-t.left),n=[];for(let e of t){let t=e.top+e.height/2,o=n.find(n=>{let o=n.top+n.height/2;return Math.abs(t-o)<=.4*Math.max(n.height,e.height)});if(!o){n.push({...e});continue}let i=Math.min(o.left,e.left),a=Math.min(o.top,e.top),r=Math.max(Ae(o),Ae(e)),l=Math.max(Ce(o),Ce(e));o.left=i,o.top=a,o.width=r-i,o.height=l-a}return n.sort((e,t)=>e.top-t.top||e.left-t.left)}var Le={topLeft:"0px",topRight:"0px",bottomRight:"0px",bottomLeft:"0px"};function Oe(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&&e.fragments.every((e,n)=>{let o=t.fragments[n];return!!o&&e.left===o.left&&e.top===o.top&&e.width===o.width&&e.height===o.height})}function De(e){if(!e.isConnected||!I(e.ownerDocument))return{fragments:[],radii:Le};let t=S(w(e),e.ownerDocument);if(x(e.ownerDocument)&&(!t.width||!t.height))return{fragments:[],radii:Le};if("true"===e.getAttribute("data-popmelt-subject-projection"))return{fragments:[{left:t.left,top:t.top,width:t.width,height:t.height}],radii:Le,outline:e.getAttribute("data-popmelt-subject-outline")??void 0};let n=Array.from(e.getClientRects()).map(t=>S(T(t,e.ownerDocument),e.ownerDocument)).filter(e=>e.width>0&&e.height>0).map(e=>({left:e.left,top:e.top,width:e.width,height:e.height}));return{fragments:Ne(n.length>0?n:[{left:t.left,top:t.top,width:t.width,height:t.height}]),radii:s(e)}}function $e({element:e,projectedRect:t,isSelected:n=!1,elementInfo:o,color:i="#3b82f6",annotationNumber:a,changeCount:l,hideTooltip:d=!1,hideOutline:s=!1,hideFill:c=!1,fillOpacity:u=.05,subjectRegistry:f,railGap:h=2,railHeight:m=22,railWidth:g=0,renderRail:v,refreshKey:w,outlineZIndex:b=9996,onActivate:I,onRemove:S}){let T=F(ee),[M,k]=z({fragments:[],radii:Le});B(()=>{if(!T)return;if(!e)return void k({fragments:[],radii:Le});let t=null,n=()=>{let t=De(e);k(e=>Oe(e,t)?e:t)},o=()=>{null===t&&(t=requestAnimationFrame(()=>{t=null,n()}))};n();let i="true"===e.getAttribute("data-popmelt-subject-projection")&&!!f,a=i?f.subscribeFrame(n):void 0,l=i||typeof ResizeObserver>"u"?null:new ResizeObserver(o);l?.observe(e);let d=i?null:new MutationObserver(o);d?.observe(e,{attributes:!0,attributeFilter:["style","class"]});let s=r(n,e.ownerDocument.defaultView??window),c=x(e.ownerDocument)?Z(n):void 0;return()=>{s(),c?.(),a?.(),l?.disconnect(),d?.disconnect(),null!==t&&cancelAnimationFrame(t)}},[T,e,f]),W(()=>{if(!T||!e||void 0===w)return;let t=De(e);k(e=>Oe(e,t)?e:t)},[T,e,w]);let{fragments:E,radii:A}=t?{fragments:[t],radii:Le}:M;if(0===E.length||!e&&!t)return null;let C=Re(E,E[0]),R=e?.tagName.toLowerCase()??"",N=e?.id?`#${e.id}`:"",L=e&&e.classList.length>0?"."+Array.from(e.classList).slice(0,2).join("."):"",O=o?.reactComponent,D=e?.getAttribute("data-popmelt-label")?.trim(),$=e?.getAttribute("data-popmelt-subject-adapter"),_=e?.getAttribute("data-popmelt-subject-label"),P=$&&_?`<${_}>`:D||(O?`<${O}> ${R}${N}${L}`:`${R}${N}${L}`),H=Ee({left:C.left,right:C.left+C.width,top:C.top,bottom:C.top+C.height,height:C.height},m,h,window.innerHeight,g,window.innerWidth),j={zIndex:9997,display:"flex",alignItems:"center",gap:6,backgroundColor:i,color:"#fff",fontSize:12,fontFamily:p,lineHeight:"14px",padding:"4px 8px",borderRadius:8,pointerEvents:"none",whiteSpace:"nowrap",maxWidth:400,position:"fixed",top:H.top,left:H.left},Y=!d&&V("div",{ref:t=>{e&&y(e,t)},"data-devtools":"tooltip",style:j,children:[void 0!==a&&V("span",{children:[a,"."]}),X("span",{style:{overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:P}),void 0!==l&&l>0&&V("span",{style:{opacity:.8},children:["(",l," ",1===l?"change":"changes",")"]})]});return V(J,{children:[!s&&E.map((e,t)=>X("div",{"data-devtools":"highlight",onContextMenu:S?e=>{e.preventDefault(),e.stopPropagation(),S()}:void 0,role:I?"button":void 0,tabIndex:I?0:void 0,"aria-label":I?"Open annotation thread":void 0,onPointerDown:I?e=>{e.preventDefault(),e.stopPropagation()}:void 0,onClick:I?e=>{e.preventDefault(),e.stopPropagation(),I()}:void 0,onKeyDown:I?e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),e.stopPropagation(),I())}:void 0,style:{position:"fixed",top:e.top,left:e.left,width:e.width,height:e.height,pointerEvents:I||S?"auto":"none",cursor:I?"pointer":void 0,zIndex:b,overflow:"visible"},children:X("div",{style:M.outline?{position:"absolute",inset:0,pointerEvents:"none"}:{position:"absolute",inset:0,boxSizing:"border-box",backgroundColor:c?"transparent":te(i,u),borderColor:i,borderStyle:n?"solid":"dashed",borderWidth:1,borderTopLeftRadius:A.topLeft,borderTopRightRadius:A.topRight,borderBottomRightRadius:A.bottomRight,borderBottomLeftRadius:A.bottomLeft,pointerEvents:"none"},children:M.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:M.outline,fill:c?"transparent":te(i,u),stroke:i,strokeWidth:1,strokeDasharray:n?void 0:"4 3",vectorEffect:"non-scaling-stroke"})}):null})},`${e.left}:${e.top}:${t}`)),v?v(H,C):Y]})}function _e(e){return"bottom-left"===e?[2,8,8,8]:"bottom-right"===e?[8,2,8,8]:"top-right"===e?[8,8,2,8]:[8,8,8,2]}function Pe(e){return _e(e).map(e=>`${e}px`).join(" ")}var Fe=1.1666666666666667;function ze(e){return e.length>2048?`${e.slice(0,2048)}…`:e}function Be(e,t,n){return t.flatMap(t=>function(e,t,n){let o=ze(t);if(!o||e.measureText(o).width<=n)return[o];let i=o.split(/\s+/),a=[],r="";for(let t of i){let o=r?`${r} ${t}`:t;r&&e.measureText(o).width>n?(a.push(r),r=t):r=o}return r&&a.push(r),a.length>0?a:[o]}(e,t,n))}var We=p,He=16;function je(e){let t=window.innerWidth-e-16;return Math.max(60,Math.min(400,t))}function Ye(e,t,n){let o=ze(t);if(o===t&&e.measureText(o).width<=n)return o;let i="…",a=0,r=o.endsWith(i)?o.length-1:o.length;for(;a<r;){let t=Math.ceil((a+r)/2);e.measureText(o.slice(0,t)+i).width<=n?a=t:r=t-1}return a>0?o.slice(0,a)+i:i}function Ke(e,t,n,o,i){let a=0,r=typeof window<"u"?window.innerHeight:9999;n&&function(e,t,n){if(void 0===e||void 0===t||void 0===n.avoidLeft&&void 0===n.avoidRight)return!0;let o=typeof window<"u"?window.innerWidth:9999,i=n.avoidLeft??0,a=n.avoidRight??o;return e+t>i&&e<a}(o,i,n)&&(a=n.avoidTop??a,r=n.avoidBottom??r);let l=Math.max(a,r-t);return Math.max(a,Math.min(e,l))}function qe(e,t=12,n,o){let i=t*Fe+8,a=e.y-4,r=Ke(a,i,n,e.x-8,o);return r===a?e:{...e,y:r+4}}function Ue(e,t,n,o,i=12,a,r,l,d="#dddddd",s,c=!1){if(!n)return;let p=i*Fe,u=n.replace(/\n/g," "),f=void 0!==a?a+". "+u:u;e.font=`${i}px ${We}`,e.textBaseline="middle";let h=void 0!==r?Math.min(400,Math.max(60,window.innerWidth-r-16)):400,m=c?16:0,g=Ye(e,f,Math.max(60,h-m)),y=m+e.measureText(g).width,v=qe(t,i,l,y+16);e.fillStyle=o;let x=v.x-8,w=v.y-4,b=y+16,I=p+8;e.beginPath(),e.roundRect(x,w,b,I,_e(s)),e.fill();let S=v.y+p/2;if(c){let t=v.x,n=S-6;e.strokeStyle=d,e.lineWidth=1.5,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(t+7.5,n+4),e.lineTo(t+10.5,n+6.5),e.lineTo(t+7.5,n+9),e.moveTo(t+1.5,n+1.5),e.lineTo(t+1.5,n+4.5),e.quadraticCurveTo(t+1.5,n+6.5,t+3.5,n+6.5),e.lineTo(t+10.5,n+6.5),e.stroke()}e.fillStyle=d,e.fillText(g,v.x+m,S)}function Ve(e,t,n){let o=e.filter(e=>!(e.captured||e.selector!==t||e.pathname&&e.pathname!==n));return o.length?{type:"MODIFY_TEXT_CONTENTS",payload:o.map(e=>({...e,modified:e.original}))}:null}function Xe(e,t){return"text"===e.type&&(e.groupId?t.filter(t=>t.groupId===e.groupId):[e]).every(e=>"pending"===(e.status??"pending")&&!e.threadId)}var Je=P(0),Ge="\n 0%, 100% { translate: 0 0; }\n 20% { translate: -4px 0; }\n 45% { translate: 4px 0; }\n 70% { translate: -2px 0; }\n 88% { translate: 1px 0; }\n";function Qe(e=22){return{height:e,minHeight:e,maxHeight:e,boxSizing:"border-box",flexShrink:0}}function Ze(e,t,n,o=.5){let i=Math.max(0,e-2*o),a=Math.max(0,t-2*o),r=function(e,t,n){let o=Math.max(0,n.topLeft),i=Math.max(0,n.topRight),a=Math.max(0,n.bottomRight),r=Math.max(0,n.bottomLeft),l=Math.min(1,e/Math.max(1,o+i),e/Math.max(1,r+a),t/Math.max(1,o+r),t/Math.max(1,i+a));return{topLeft:o*l,topRight:i*l,bottomRight:a*l,bottomLeft:r*l}}(e,t,n),l=Math.max(0,r.topLeft-o),d=Math.max(0,r.topRight-o),s=Math.max(0,r.bottomRight-o),c=Math.max(0,r.bottomLeft-o),p=o+i,u=o+a;return[`M ${o+l} ${o}`,"H "+(p-d),`A ${d} ${d} 0 0 1 ${p} ${o+d}`,"V "+(u-s),`A ${s} ${s} 0 0 1 ${p-s} ${u}`,`H ${o+c}`,`A ${c} ${c} 0 0 1 ${o} ${u-c}`,`V ${o+l}`,`A ${l} ${l} 0 0 1 ${o+l} ${o}`,"Z"].join(" ")}var et=12,tt=8;function nt(e){return e>0?16+7.2*String(e).length+16:0}function ot({stepCount:e,onClear:t,layered:n=!1,submitted:o=!1,style:i}){let[a]=u(),r=f[a];return e<1?null:V("span",{"data-devtools":"interaction-episode-badge","data-popmelt-submitted":o?"true":void 0,"aria-label":`${e} recorded ${1===e?"action":"actions"}${o?", sent":""}`,onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),t?.()},style:{height:22,display:"inline-flex",alignItems:"center",boxSizing:"border-box",backgroundColor:o?"#8c8c8c":r.surface,border:`1px solid ${o?"#8c8c8c":r.border}`,borderRadius:8,color:o?"#dddddd":r.primary,fontFamily:We,fontSize:12,fontWeight:600,padding:n?`0 8px 0 ${.7*d}px`:"0 8px 0 5.6px",gap:4,pointerEvents:t?"auto":"none",WebkitMaskImage:n?l:void 0,maskImage:n?l:void 0,...i},children:[V("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})]})}function it(e,t,n){return function(e,t,n){if(void 0===n.avoidLeft&&void 0===n.avoidRight)return!0;let o=typeof window<"u"?window.innerWidth:9999,i=n.avoidLeft??0,a=n.avoidRight??o;return e+t>i&&e<a}(t,n,e)?e:{}}function at(e,t,n){return`translate(min(0px, calc(100vw - ${e} - 100%)), min(max(0px, calc(${void 0!==n.avoidTop?`${n.avoidTop}px`:"0px"} - ${t})), calc(${void 0!==n.avoidBottom?`${n.avoidBottom}px`:"100dvh"} - ${t} - 100%)))`}function rt(e,t,n){if(void 0===n.avoidTop&&void 0===n.avoidBottom)return e;let o=typeof window<"u"?window.innerHeight:9999,i=n.avoidTop??0,a=n.avoidBottom??o,r=Math.max(i,a-t);return Math.max(i,Math.min(e,r))}function lt({left:e,top:t,scrollX:n,scrollY:o,avoidTop:i,avoidBottom:a,style:r,children:l,...d}){return X("div",{"data-devtools":"badge-hit-area",...d,style:{position:"fixed",left:0,top:0,padding:et,...r,transform:`translate3d(${`calc(${e}px - var(--popmelt-scroll-x, ${n}px))`}, ${`calc(${t}px - var(--popmelt-scroll-y, ${o}px))`}, 0)`,willChange:"transform"},children:X("div",{style:{transform:at(`calc(${e+et}px - var(--popmelt-scroll-x, ${n}px))`,`calc(${t+et}px - var(--popmelt-scroll-y, ${o}px))`,{avoidTop:i,avoidBottom:a})},children:l})})}function dt({bundleCount:e,style:t,layered:n=!1,compact:o=!1,description:i,replacementText:a,onHoverChange:r,onSend:s}){let[c,p]=z(!1),[h]=u(),m=f[h],g=F(Je),y=H(),v=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform)?"⌘":"Ctrl",x=Math.max(1,e),w=o&&!c,b=e=>w?X($,{size:12,strokeWidth:2,"aria-hidden":!0}):V(J,e?{children:[X("span",{style:{color:"inherit",fontWeight:600},children:x>1?`Send all ${x}`:"Send"}),X($,{size:12,strokeWidth:2,"aria-hidden":!0})]}:{children:[V("span",{style:{display:"inline-flex",alignItems:"center",gap:2,color:"inherit",fontWeight:600},children:[X("span",{children:v}),X("span",{children:"+"}),X(_,{size:12,strokeWidth:2,"aria-hidden":!0})]}),X("span",{style:{color:m.secondary,fontWeight:600},children:"to"}),X($,{size:12,strokeWidth:2,"aria-hidden":!0}),x>1&&X("span",{style:{color:"inherit",fontWeight:600},children:x})]}),I=e=>V(J,{children:[X("span",{className:"popmelt-send-hint-desktop",style:{alignItems:"center",gap:4},children:b(e)}),V("span",{className:"popmelt-send-hint-mobile",style:{alignItems:"center",gap:4},children:[!w&&X("span",{style:{color:"inherit",fontWeight:600},children:"Send"}),X($,{size:12,strokeWidth:2,"aria-hidden":!0})]})]}),S=a?X("span",{role:"tooltip","data-devtools":"parent-pinned-location-tooltip",style:{overflow:"hidden",textOverflow:"ellipsis"},children:a}):null,T={...Qe(),lineHeight:"14px",display:"flex",alignItems:"center",boxSizing:"border-box",backgroundColor:m.surface,border:`1px solid ${m.border}`,fontFamily:We,fontSize:12,color:m.primary,userSelect:"none",padding:n?`0 8px 0 ${d}px`:"0 8px",gap:4,whiteSpace:"nowrap",borderRadius:8,letterSpacing:"0.24px",WebkitMaskImage:n?l:void 0,maskImage:n?l:void 0},M=x>1?`Send all ${x} pending annotations`:"Send pending annotation";return V("div",{"data-devtools":"send-hint-hit-area","data-popmelt-send-rejection":g?g%2?"odd":"even":void 0,onMouseEnter:()=>{p(!0),r?.(!0)},onMouseLeave:()=>{p(!1),r?.(!1)},style:{display:"grid",width:"max-content",...t},children:[X("style",{children:`\n@keyframes popmelt-send-rejection-odd { ${Ge} }\n@keyframes popmelt-send-rejection-even { ${Ge} }\n[data-popmelt-send-rejection="odd"] { animation: popmelt-send-rejection-odd 220ms ease-out; }\n[data-popmelt-send-rejection="even"] { animation: popmelt-send-rejection-even 220ms ease-out; }\n@media (prefers-reduced-motion: reduce) {\n [data-popmelt-send-rejection] { animation: none; }\n}\n.popmelt-send-hint-desktop { display: inline-flex; }\n.popmelt-send-hint-mobile { display: none; }\n@media (max-width: 767px) {\n .popmelt-send-hint-desktop { display: none; }\n .popmelt-send-hint-mobile { display: inline-flex; }\n}\n `}),X("div",{"aria-hidden":!0,style:{...T,gridArea:"1 / 1",visibility:"hidden"},children:I(!1)}),V("button",{type:"button","data-devtools":"annotation-badge","aria-label":M,"aria-describedby":i?y:void 0,disabled:!s,onPointerDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation(),s?.()},style:{...T,gridArea:"1 / 1",justifySelf:"start",maxWidth:a?"min(320px, calc(100vw - 16px))":void 0,overflow:a?"hidden":void 0,appearance:"none",margin:0,opacity:1,cursor:s?"pointer":"default",touchAction:"manipulation"},children:[i&&X("span",{id:y,style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:i}),S??I(c)]})]})}function st({count:e,color:t,size:n=22,onHoverChange:o}){return V("div",{"data-devtools":"nested-annotation-count-badge",onMouseEnter:()=>o?.(!0),onMouseLeave:()=>o?.(!1),style:{height:n,display:"flex",alignItems:"center",backgroundColor:t,color:"#8c8c8c"===t?"#dddddd":"#ffffff",fontFamily:We,fontSize:12,fontWeight:600,lineHeight:1,padding:"0 8px",borderRadius:8,userSelect:"none",whiteSpace:"nowrap"},children:["+",e]})}function ct({annotations:e,supersededAnnotations:t,inFlightIds:n,orientationLabels:o,activeIds:i,queuePositions:a,scrollX:r,scrollY:l,annotationGroupMap:d,onViewThread:s,onSelectAnnotation:c,onDeleteDraftAnnotation:p,onClearInteractionEpisode:u,onHoverAnnotation:f,canvasRef:h,toolbarRef:m,activeBundleAnnotationIds:g,inactiveBundleOpacity:y=.5,animateBundleOpacity:v=!0,hoverRestoredAnnotationIds:x,nestedAnnotationCountById:w,nestedAnnotationIdsById:b,onHoverNestedAnnotations:I,onHoverSendBundle:S,onSend:T,sendHintAnchorId:M,pendingBundleCount:k=1,parentPinnedAnnotationIds:E,parentPinnedLocationLabels:A,parentPinnedTooltipAnnotationId:D,onActivateAnnotation:$,hiddenAnnotationIds:_,displayAnnotations:P}){let W=F(ee),H=j(null),[Y,K]=z(0),q=!!(n&&n.size>0&&(void 0===i||i.size>0));B(()=>{if(!q||!W)return;let e=setInterval(()=>{K(e=>(e+1)%3)},250);return()=>{clearInterval(e)}},[q,W]),B(()=>{if(!W)return;let e=H.current;if(!e)return;let t=()=>{e.style.setProperty("--popmelt-scroll-x",`${window.scrollX}px`),e.style.setProperty("--popmelt-scroll-y",`${window.scrollY}px`)};return t(),window.addEventListener("scroll",t,{passive:!0,capture:!0}),window.addEventListener("resize",t),()=>{window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[W]);let U=[],G=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform)?"⌘":"Ctrl";for(let a of e){if("text"!==a.type||!a.text||!a.points[0]||t.has(a)||_?.has(a.id))continue;let l=a.groupId?e.filter(e=>e.groupId===a.groupId):[a],s=a.status??"pending",c=k>0&&a.id===M,p=a.interactionEpisode?.steps.length??0,u=w?.get(a.id)??0,f=b?.get(a.id)??[],m=l.reduce((e,t)=>Math.max(e,t.replyCount??0),0),y="sending"===s||l.some(e=>"sending"===e.status),v="awaiting_review"===s,I=!y&&(!(!n||!n.has(a.id)&&!l.some(e=>n.has(e.id)))||"in_flight"===a.status||l.some(e=>"in_flight"===e.status)),S=l.some(e=>"resolved"===e.status&&(e.replyCount??0)>0||"needs_review"===e.status),T=l.some(e=>e.threadId),A=!g||l.some(e=>g.has(e.id)||x?.has(e.id));if(!(c||y||v||I||"resolved"===s||"failed"===s||"needs_review"===s||S||T||p>0)&&0===u)continue;let C=a.threadId||l.find(e=>e.threadId)?.threadId,R="needs_review"===s||l.some(e=>"needs_review"===e.status),N="waiting_input"===s||l.some(e=>"waiting_input"===e.status),L="failed"===s||l.some(e=>"failed"===e.status),O=c||y||v||I||R||N||L||m>0||"resolved"===s&&T||p>0;if(!O&&0===u)continue;let D=a.points[0],$=a.fontSize||12,F=$*Fe,z=d.get(a.id),B=((P?.find(e=>e.id===a.id)??a).text??a.text).replace(/\n/g," "),W=void 0!==z?z+". "+B:B,H=h?.current?.getContext("2d")??document.createElement("canvas").getContext("2d");if(!H)continue;H.font=`${$}px ${We}`;let j=D.x-r,Y=E?.has(a.id)?16:0,K=Ye(H,W,Math.max(60,je(j)-Y)),q=H.measureText(K).width,V=I&&!!i&&!i.has(a.id)&&!l.some(e=>i.has(e.id));U.push({id:a.id,threadId:C,linkedSelector:a.linkedSelector||l.find(e=>e.linkedSelector)?.linkedSelector,x:D.x+q+Y+8+2,y:D.y-4,size:F+8,color:c?"#000000":a.color,isSending:y,isAwaitingReview:v,isInFlight:I,orientationLabel:o?.get(a.id)??l.map(e=>o?.get(e.id)).find(Boolean),isQueued:V,queuePosition:void 0,isNeedsReview:R,isQuestion:N,isFailed:L,replyCount:m>0?m:"resolved"===s&&T?1:0,isInActiveBundle:A,isSendHint:c,interactionEpisodeStepCount:p,interactionEpisodeSubmitted:"pending"!==s,nestedCount:u,nestedAnnotationIds:f,nestedColor:"pending"===s?a.color:"#8c8c8c",showActionBadge:O,canDeleteDraft:Xe(a,e)})}let Q=U.filter(e=>e.isQueued);if(Q.length>0&&Q.forEach((e,t)=>{e.queuePosition=a?.get(e.id)??`(${t+1}/${Q.length})`}),0===U.length)return null;let Z=h?.current?.getContext("2d")??document.createElement("canvas").getContext("2d"),te=U.map(e=>{Z&&(Z.font=`12px ${We}`);let t=e.nestedCount>0?(Z?.measureText(`+${e.nestedCount}`).width??7.2*String(e.nestedCount).length+7.2)+16:0,n=nt(e.interactionEpisodeStepCount);if(!e.showActionBadge)return t+n;let o,i=D===e.id?A?.get(e.id):void 0;o=i||(e.isSendHint?G:e.isSending?"Sending":e.isAwaitingReview?"Awaiting review":e.isInFlight?e.isQueued?"Queued"+(e.queuePosition?` ${e.queuePosition}`:""):e.orientationLabel??"Thinking":e.isQuestion?"Question":e.isFailed?"Failed":e.replyCount>0?"Replied":"Needs decision");let a=e.isSendHint||i?0:12,r=7.2*o.length;Z&&(r=Z.measureText(o).width);let l=e.isSendHint&&Z?Z.measureText("to").width:e.isSendHint?14.4:0,d=e.isSendHint&&Z?Z.measureText("+").width:e.isSendHint?7.2:0,s=e.isSendHint&&k>1&&Z?Z.measureText(String(k)).width:e.isSendHint&&k>1?7.2:0;return n+t+(i?Math.min(r+16,320):e.isSendHint?r+d+l+s+16+12+12+4+4*(k>1?3:2):6+a+4+r+8)+2*(+(n>0)+ +(t>0)+1-1)}),ne=function(e){let t=e?.current?.getBoundingClientRect();return!t||typeof window>"u"?{}:t.top<window.innerHeight/2?{avoidTop:t.bottom+8,avoidLeft:t.left-8,avoidRight:t.right+8}:{avoidBottom:t.top-8,avoidLeft:t.left-8,avoidRight:t.right+8}}(m),oe=[];for(let e=0;e<U.length;e++){let t=U[e].y-l,n=U[e].x-r,o=it(ne,n,te[e]),i=rt(t,U[e].size,o),a=i+U[e].size,d=n;for(let t=0;t<e;t++){let e=U[t].y-l,n=it(ne,oe[t],te[t]),o=rt(e,U[t].size,n);if(!(i<o+U[t].size&&a>o))continue;let r=oe[t]+te[t];d<r+2&&(d=r+2)}oe.push(d)}return V("div",{ref:H,"data-devtools":"annotation-badge-layer",style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:9999,"--popmelt-scroll-x":`${r}px`,"--popmelt-scroll-y":`${l}px`},children:[X("style",{dangerouslySetInnerHTML:{__html:'\n[data-devtools="annotation-badge-layer"] [data-devtools="annotation-badge"]::selection,\n[data-devtools="annotation-badge-layer"] [data-devtools="annotation-badge"] *::selection {\n background: #000000;\n color: #ffffff;\n}\n'}}),U.map((e,t)=>{let n=!!e.threadId,o=A?.get(e.id),i=!!o&&D===e.id,a=n||!!o,d=e.showActionBadge&&e.isSendHint,h=a&&!d,m=()=>{$?$(e.id,e.threadId):(c?.(e.id),e.threadId&&s?.(e.threadId))},g=it(ne,oe[t],te[t]);return X(lt,{left:oe[t]+r-et,top:e.y-et,scrollX:r,scrollY:l,avoidTop:g.avoidTop,avoidBottom:g.avoidBottom,onMouseDown:e=>e.stopPropagation(),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),e.canDeleteDraft&&p&&p(e.id)},onClick:a?e=>{e.stopPropagation(),m()}:void 0,onMouseEnter:()=>{f?.(e.id)},onMouseLeave:()=>{f?.(null)},onFocus:()=>f?.(e.id),onBlur:()=>f?.(null),onKeyDown:h?e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),m())}:void 0,role:h?"button":void 0,tabIndex:h?0:void 0,"aria-label":h&&o?`${o}. Activate to reveal the annotation source${n?" and open its thread":""}`:void 0,style:{pointerEvents:"auto",cursor:a?"pointer":void 0,zIndex:9999,minWidth:e.isSendHint?te[t]:void 0},children:V("div",{style:{position:"relative",display:"flex",alignItems:"center",gap:2},children:[X(ot,{stepCount:e.interactionEpisodeStepCount,submitted:e.interactionEpisodeSubmitted,onClear:e.canDeleteDraft&&u?()=>u(e.id):void 0}),e.nestedCount>0&&X(st,{count:e.nestedCount,color:e.nestedColor,size:e.size,onHoverChange:t=>I?.(e.id,t?e.nestedAnnotationIds:null)}),e.showActionBadge&&(e.isSendHint?X(dt,{bundleCount:k,description:o?`${o}. Activate the annotation label to reveal its source.`:void 0,replacementText:i?o:void 0,onHoverChange:S,onSend:T}):X("div",{"data-devtools":"annotation-badge",style:{...Qe(e.size),display:"flex",alignItems:"center",backgroundColor:e.color,fontFamily:We,fontSize:12,color:"#ffffff",userSelect:"none",padding:"0 8px 0 6px",gap:4,whiteSpace:"nowrap",maxWidth:i?"min(320px, calc(100vw - 16px))":void 0,overflow:i?"hidden":void 0,borderRadius:8,opacity:e.isInActiveBundle?1:y,transition:v?"opacity 120ms ease-out":"none"},children:i?X("span",{role:"tooltip","data-devtools":"parent-pinned-location-tooltip",style:{overflow:"hidden",textOverflow:"ellipsis"},children:o}):e.isAwaitingReview?V(J,{children:[X(C,{size:12,strokeWidth:2.25}),"Awaiting review"]}):e.isQueued?V("span",{style:{opacity:.6,color:"inherit",display:"inline-flex",alignItems:"center",gap:4},children:[X(C,{size:12,strokeWidth:2.25}),"Queued",e.queuePosition?` ${e.queuePosition}`:""]}):e.isSending||e.isInFlight?V(J,{children:["Approval needed"===e.orientationLabel?X(R,{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:V(J,1===Y?{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"})]}:{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:e.isSending?"Sending":e.isQueued?"Queued"+(e.queuePosition?` ${e.queuePosition}`:""):e.orientationLabel??"Thinking"})]}):V(J,{children:[e.isQuestion?X(N,{size:12,strokeWidth:2.25}):e.isFailed?X(L,{size:12,strokeWidth:2.25}):e.replyCount>0?X(O,{size:12,strokeWidth:2.25}):V("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:e.isQuestion?"Question":e.isFailed?"Failed":e.replyCount>0?"Replied":"Needs decision"})]})}))]})},e.id)})]})}function pt({d:n,color:o,animated:i}){let a=j(null);return W(()=>{let t=a.current;if(!t||"function"!=typeof t.getTotalLength)return;let n=function(t){if(Number.isFinite(t)&&!(t<=0))return Math.max(1,Math.round(t/e))*e}(t.getTotalLength());void 0===n?t.removeAttribute("pathLength"):t.setAttribute("pathLength",String(n))},[n]),X("path",{ref:a,d:n,fill:"none",stroke:o,strokeWidth:1,strokeDasharray:i?t:void 0,"data-popmelt-marching-stroke":i||void 0,style:i?{animation:"popmelt-march 0.6s linear infinite"}:void 0})}function ut(){return X("style",{children:`\n @keyframes popmelt-march {\n from { stroke-dashoffset: 0; }\n to { stroke-dashoffset: -${e}; }\n }\n @media (prefers-reduced-motion: reduce) {\n [data-popmelt-marching-stroke="true"] { animation: none !important; }\n }\n `})}function ft({annotations:e,activeIds:t,scrollX:n,scrollY:o,spotlightIds:i,emphasizedIds:a,hoverRestoredIds:r,inactiveOpacity:l=.5}){if(!F(ee))return null;let d=e.filter(e=>e.region&&e.region.points.length>=3&&t?.has(e.id));return d.length?V(J,{children:[X(ut,{}),X("svg",{"data-devtools":"marching-lasso","aria-hidden":!0,style:{position:"fixed",inset:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:9995,overflow:"visible"},children:X("g",{transform:`translate(${-n} ${-o})`,children:d.map(e=>{let t=i?.size?i.has(e.id)?1:.2:!a||a.has(e.id)||r?.has(e.id)?1:l;return X("g",{"data-popmelt-region-id":e.id,opacity:t,children:X(pt,{d:`${e.region.points.map((e,t)=>`${t?"L":"M"}${e.x} ${e.y}`).join(" ")} Z`,color:e.color,animated:!0})},e.id)})})})]}):null}function ht({inFlightSelectorColors:e,animated:t=!0,subjectRegistry:n,selectorElementInfo:o}){let i=F(ee),[a,r]=z([]);return B(()=>{if(!i)return;if(0===e.size)return void r([]);let t=null,a=()=>{let t=[];for(let[n,i]of e){let e=b(n,o?.get(n));if(!e)continue;let a=w(e);t.push({selector:n,top:a.top,left:a.left,width:a.width,height:a.height,color:i,radius:c(e),radiusStyle:s(e)})}r(t)},l=()=>{t&&cancelAnimationFrame(t),t=requestAnimationFrame(a)};a(),window.addEventListener("scroll",l,!0),window.addEventListener("resize",l,!0);let d=new MutationObserver(l);d.observe(document.body,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["style","class"]});let p=n?.subscribeFrame(a),u=[...e.keys()].some(e=>e.startsWith("@frame("))?Z(a):void 0;return()=>{window.removeEventListener("scroll",l,!0),window.removeEventListener("resize",l,!0),d.disconnect(),p?.(),u?.(),t&&cancelAnimationFrame(t)}},[e,n,o,i]),0===a.length?null:V(J,{children:[t&&X(ut,{}),a.map(e=>X("div",{"data-devtools":"marching-ants",style:{position:"fixed",top:e.top,left:e.left,width:e.width,height:e.height,pointerEvents:"none",zIndex:9995,overflow:"visible",borderTopLeftRadius:e.radiusStyle.topLeft,borderTopRightRadius:e.radiusStyle.topRight,borderBottomRightRadius:e.radiusStyle.bottomRight,borderBottomLeftRadius:e.radiusStyle.bottomLeft},children:X("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:X(pt,{d:Ze(e.width,e.height,{topLeft:e.radius["top-left"],topRight:e.radius["top-right"],bottomRight:e.radius["bottom-right"],bottomLeft:e.radius["bottom-left"]}),color:e.color,animated:t})})},e.selector))]})}function mt({element:e,elements:t,registry:n,label:o="Looking",engaged:i=!0,outlineColor:a,inverse:r=!1}){let l=j(0),d=Y(()=>t??(e?[e]:[]),[t,e]),[s,c]=z(()=>d.map(e=>({target:e,id:++l.current,animateEntrance:!0,exiting:!1}))),p=K(e=>{c(t=>t.filter(t=>t.id!==e))},[]);return B(()=>{d.length&&c(e=>{let t=e.some(({target:e})=>e.isConnected),n=d.map(n=>e.find(e=>e.target===n&&!e.exiting)??{target:n,id:++l.current,animateEntrance:!t,exiting:!1});return[...e.filter(e=>!e.exiting&&!d.includes(e.target)).map(e=>({...e,exiting:!0})),...n]})},[d]),X(J,{children:s.map(({target:e,id:t,animateEntrance:l,exiting:s})=>X(gt,{id:t,element:i&&d.includes(e)?e:null,target:e,animateEntrance:l,exiting:s,registry:n,label:o,outlineColor:a,inverse:r,onDone:p},t))})}function gt({id:e,element:t,target:n,animateEntrance:o,exiting:i,registry:a,label:r,outlineColor:l,inverse:d,onDone:s}){let[c]=u(),h=f[c],m=n,[g,y]=z(!1),x=j(Date.now()),[w,b]=z(null);return B(()=>{if(!m)return;let e,t=()=>{let n=v(m);b(e=>n?e?.left===n.left&&e.top===n.top?e:{left:n.left,top:n.top}:null),e=requestAnimationFrame(t)};return t(),()=>cancelAnimationFrame(e)},[m]),B(()=>{let n,o;return i?o=setTimeout(()=>s(e),200):t?(x.current=Date.now(),y(!1)):n=setTimeout(()=>{y(!0),o=setTimeout(()=>s(e),300)},Math.max(0,x.current+1700-Date.now())),()=>{clearTimeout(n),clearTimeout(o)}},[t,i,e,s]),m?.isConnected?V(J,{children:[X("style",{children:'\n @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); } }\n @keyframes popmelt-looking-out-left { from { opacity: 1; } to { opacity: 0; } }\n @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); } }\n @keyframes popmelt-looking-in-alone-up-left { from { opacity: 0; transform: translate(8px, 8px); } to { opacity: 1; transform: translate(0, 0); } }\n @keyframes popmelt-looking-in-alone-down-left { from { opacity: 0; transform: translate(8px, -8px); } to { opacity: 1; transform: translate(0, 0); } }\n @keyframes popmelt-looking-in-alone-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }\n @keyframes popmelt-looking-in-alone-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }\n @keyframes popmelt-looking-out-up { from { opacity: 1; } to { opacity: 0; } }\n @keyframes popmelt-looking-fade-in { from { opacity: 0; } to { opacity: 1; } }\n @keyframes popmelt-looking-fade-out { from { opacity: 1; } to { opacity: 0; } }\n @keyframes popmelt-looking-blink { 0%, 40%, 72.5%, 100% { transform: scaleY(1); } 50%, 62.5% { transform: scaleY(0.1); } }\n .popmelt-looking-eye { animation: popmelt-looking-blink 1000ms 200ms both; transform-origin: center; }\n @media (prefers-reduced-motion: reduce) {\n [data-devtools="focus-inspection"], .popmelt-looking-eye { animation: none !important; }\n [data-popmelt-looking-exiting] { opacity: 0 !important; }\n }\n '}),X($e,{element:m,subjectRegistry:a,hideOutline:!l||g||i,color:l,outlineZIndex:l?10002:void 0,hideFill:!0,hideTooltip:!0,railHeight:22,renderRail:(e,t)=>{let n=w??e,a=n.left>=28,l=!w&&e.anchor.startsWith("bottom-"),s=w?a?"left":"up":`${l?"down":"up"}${a?"-left":""}`,c=w&&!a?Math.max(4,n.top-22-2):n.top,u=a?n.left-22-2:n.left,f=t.left+t.width/2>=u+11,y=t.top+t.height/2>=c+11?f?"borderBottomRightRadius":"borderBottomLeftRadius":f?"borderTopRightRadius":"borderTopLeftRadius";return X("div",{"data-devtools":"focus-inspection","data-popmelt-looking-exiting":i?"true":void 0,"data-popmelt-canvas-block":!0,role:"status","aria-live":i?"off":"polite","aria-hidden":i||void 0,"aria-label":r,title:r,style:{position:"fixed",animation:i?"popmelt-looking-fade-out 200ms ease both":g||o?`popmelt-looking-${g?"out":w?"in":"in-alone"}-${g?a?"left":"up":s} ${g?300:200}ms ease both`:"popmelt-looking-fade-in 200ms ease both",left:u,top:c,height:22,width:22,boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center",backgroundColor:d?h.actionSurface:h.surface,color:d?h.actionForeground:h.primary,border:`1px solid ${d?h.actionHover:h.border}`,borderTopLeftRadius:8,borderTopRightRadius:8,borderBottomLeftRadius:8,borderBottomRightRadius:8,...w?{}:{[y]:2},fontFamily:p,fontSize:12,letterSpacing:"0.24px",whiteSpace:"nowrap",pointerEvents:i?"none":"auto",zIndex:m.hasAttribute("data-popmelt-thread-header")?10006:10002},children:X(D,{className:o&&!i?"popmelt-looking-eye":void 0,size:12,"aria-hidden":!0})})}})]}):null}var yt={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 vt(e){if("string"!=typeof e)throw new Error("Unexpected sign-in destination.");let t=new URL(e);if(!Object.values(yt).some(({issuer:e})=>t.origin===e)||"/mcp/grant"!==t.pathname||t.username||t.password||t.hash)throw new Error("Unexpected sign-in destination.");return t}var xt={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:[" "]}},wt=[{type:"model",label:"Imprint",shortcut:"I"},{type:"sticker",label:"Steer",shortcut:"S"},{type:"inspector",label:"Chat",shortcut:"C"}];function bt(e){let t=e.toLowerCase();return Object.values(xt.tools).find(e=>e.key===t)?.tool??null}function It(e){let t=1===e.length?e.toLowerCase():e,n=xt.omnidial;return[...n.previous,...n.next,...n.previousFacet,...n.nextFacet,...n.descendOrApply,...n.ascend,...n.query].includes(t)||/^[a-z0-9]$/i.test(e)}var St=P(null),Tt=()=>()=>{},Mt=()=>null;function kt(){return Math.random().toString(36).substring(2,9)}function Et(e){return"text"===e.type&&"lasso"===e.region?.kind&&(e={...e,fontSize:12,linkedAnchor:e.linkedAnchor??"bottom-left"}),e.status?e:e.captured?{...e,status:"in_flight"}:{...e,status:"pending"}}function At(e){return{annotations:e.annotations,styleModifications:e.styleModifications,textModifications:e.textModifications,domModifications:e.domModifications,spacingTokenChanges:e.spacingTokenChanges,spacingTokenMods:e.spacingTokenMods}}function Ct(e){return{...e,undoStack:[...e.undoStack,At(e)],redoStack:[]}}function Rt(e,t,n,o){return e.selector===t&&(!e.pathname||e.pathname===o)&&e.textNodePath.length===n.length&&e.textNodePath.every((e,t)=>e===n[t])}function Nt(e,t,n=!0){let{selector:o,durableSelector:i,element:a,textNodePath:r,original:l,modified:d}=t,s=typeof window<"u"?window.location.pathname:"/",c=e.textModifications.findIndex(e=>Rt(e,o,r,s));if(l===d&&c<0)return e;if(c>=0){let t=e.textModifications[c],o=t.captured&&n?Ct(e):e,r=t.captured?l:t.original;return d===r?{...o,textModifications:o.textModifications.filter((e,t)=>t!==c)}:{...o,textModifications:o.textModifications.map((e,t)=>t===c?{...e,durableSelector:i,element:a,original:r,modified:d,createdAt:e.createdAt??Date.now(),captured:!1,pathname:s}:e)}}let p=n?Ct(e):e;return{...p,textModifications:[...p.textModifications,{selector:o,durableSelector:i,element:a,textNodePath:r,original:l,modified:d,createdAt:Date.now(),pathname:s}]}}function Lt(e,t){switch(t.type){case"SET_ANNOTATING":return function(e,t){return{...e,isAnnotating:t}}(e,t.payload);case"SET_TOOL":return function(e,t){return{...e,activeTool:t}}(e,t.payload);case"SET_COLOR":return function(e,t){return{...e,activeColor:t}}(e,t.payload);case"SET_STROKE_WIDTH":return function(e,t){return{...e,strokeWidth:t}}(e,t.payload);case"ADD_TEXT":return function(e,t){let n={id:t.id??kt(),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:Ct(e),annotations:[...e.annotations,n]}}(e,t.payload);case"UPDATE_TEXT":return function(e,t){return{...Ct(e),annotations:e.annotations.map(e=>e.id===t.id?{...e,text:t.text,...null!=t.imageCount?{imageCount:t.imageCount}:{},...t.attachments?{attachments:t.attachments}:{},...t.interactionEpisode?{interactionEpisode:t.interactionEpisode}:{}}:e)}}(e,t.payload);case"CLEAR_INTERACTION_EPISODE":return function(e,t){return{...Ct(e),annotations:e.annotations.map(e=>{if(e.id!==t.id)return e;let n=e.interactionEpisode?.frames?.length??0,{interactionEpisode:o,...i}=e;if(0===n)return i;let a=Math.max(0,(e.imageCount??0)-n);if(0===a){let{imageCount:e,...t}=i;return t}return{...i,imageCount:a}})}}(e,t.payload);case"DELETE_ANNOTATION":return function(e,t){let n=Ct(e),o=e.annotations.find(e=>e.id===t.id)?.groupId,i=new Set(e.annotations.filter(e=>e.id===t.id||o&&e.groupId===o).map(e=>e.id));return{...n,annotations:e.annotations.filter(e=>e.id!==t.id&&!(o&&e.groupId===o)),selectedAnnotationIds:e.selectedAnnotationIds.filter(e=>!i.has(e)),lastSelectedId:e.lastSelectedId&&i.has(e.lastSelectedId)?null:e.lastSelectedId}}(e,t.payload);case"MOVE_ANNOTATION":return function(e,t){let n=t.saveUndo?Ct(e):e,o=e.annotations.find(e=>e.id===t.id)?.groupId;return{...n,annotations:e.annotations.map(e=>{if(!(e.id===t.id||o&&e.groupId===o))return e;let n=t.delta.x,i=t.delta.y;return{...e,points:e.points.map(e=>({x:e.x+n,y:e.y+i}))}})}}(e,t.payload);case"RESIZE_ANNOTATION":return function(e,t){let n=t.saveUndo?Ct(e):e,o=e.annotations.find(e=>e.id===t.id);if(!o||"text"===o.type||o.points.length<2)return e;let i=0,a=0;if("rectangle"===o.type&&o.groupId){let e=t.points,n=Math.min(e[0].x,e[1].x),r=Math.max(e[0].y,e[1].y),l=o.points[0],d=o.points[o.points.length-1],s=Math.min(l.x,d.x),c=Math.max(l.y,d.y);i=n-s,a=r-c}return{...n,annotations:e.annotations.map(e=>e.id===t.id?{...e,points:t.points}:o.groupId&&e.groupId===o.groupId&&"text"===e.type?{...e,points:e.points.map(e=>({x:e.x+i,y:e.y+a}))}:e)}}(e,t.payload);case"PASTE_ANNOTATIONS":return function(e,t){return{...Ct(e),annotations:[...e.annotations,...t.annotations.map(Et)]}}(e,t.payload);case"RESTORE_ANNOTATIONS":return function(e,t){let n=new Set,o=[];for(let e of t.annotations)n.has(e.id)||(n.add(e.id),o.push(Et(e)));return{...e,annotations:o}}(e,t.payload);case"SYNC_ANNOTATIONS":return function(e,t){let n=new Map(e.annotations.map(e=>[e.id,e])),o=t.annotations.map(e=>{let t=Et(e),o=n.get(t.id);return o&&t.linkedSelector&&o.linkedSelector===t.linkedSelector?{...t,points:o.points,linkedAnchor:o.linkedAnchor}:t});return{...e,annotations:o}}(e,t.payload);case"MERGE_ANNOTATIONS":return function(e,t){let n=new Set(e.annotations.map(e=>e.id)),o=t.annotations.filter(e=>!n.has(e.id)).map(Et);return o.length>0?{...e,annotations:[...e.annotations,...o]}:e}(e,t.payload);case"UNDO":return function(e){if(0===e.undoStack.length)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,At(e)]}}(e);case"REDO":return function(e){if(0===e.redoStack.length)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,At(e)]}}(e);case"SELECT_ANNOTATION":return function(e,t){let{id:n,addToSelection:o}=t;if(null===n)return{...e,selectedAnnotationIds:[],lastSelectedId:null};if(o){if(e.selectedAnnotationIds.includes(n)){let t=e.selectedAnnotationIds.filter(e=>e!==n);return{...e,selectedAnnotationIds:t,lastSelectedId:t.length>0?t[t.length-1]:null}}return{...e,selectedAnnotationIds:[...e.selectedAnnotationIds,n],lastSelectedId:n}}return{...e,selectedAnnotationIds:[n],lastSelectedId:n}}(e,t.payload);case"UPDATE_ANNOTATION_COLOR":return function(e,t){let n=e.annotations.find(e=>e.id===t.id)?.groupId,o=new Set;for(let t of e.selectedAnnotationIds){let n=e.annotations.find(e=>e.id===t);n?.groupId&&o.add(n.groupId)}return{...e,annotations:e.annotations.map(i=>i.id===t.id||e.selectedAnnotationIds.includes(i.id)||i.groupId&&(i.groupId===n||o.has(i.groupId))?{...i,color:t.color}:i)}}(e,t.payload);case"MARK_CAPTURED":return function(e,t,n){let o=typeof window<"u"?window.location.pathname:"/",i=t?new Set(t):void 0,a=n??e.textModifications.filter(e=>!e.pathname||e.pathname===o),r=e=>e.filter(e=>!a.some(t=>e.pathname===t.pathname&&Rt(e,t.selector,t.textNodePath,t.pathname??"")&&e.createdAt===t.createdAt&&e.original===t.original&&e.modified===t.modified)),l=e=>({...e,textModifications:r(e.textModifications)});return{...e,undoStack:e.undoStack.map(l),redoStack:e.redoStack.map(l),annotations:e.annotations.map(e=>i&&!i.has(e.id)?e:{...e,captured:!0,status:"pending"!==e.status&&"sending"!==e.status&&e.status?e.status:"in_flight"}),styleModifications:e.styleModifications.map(e=>e.pathname&&e.pathname!==o?e:{...e,captured:!0}),textModifications:r(e.textModifications),domModifications:e.domModifications.map(e=>e.pathname&&e.pathname!==o?e:{...e,captured:!0}),spacingTokenChanges:e.spacingTokenChanges.map(e=>({...e,captured:!0})),spacingTokenMods:e.spacingTokenMods.map(e=>({...e,captured:!0}))}}(e,t.payload?.annotationIds,t.payload?.textModifications);case"CLEAR":return function(e){return{...e,annotations:[],undoStack:[],redoStack:[],selectedAnnotationIds:[],lastSelectedId:null,textModifications:[],domModifications:[],spacingTokenChanges:[],spacingTokenMods:[]}}(e);case"DISCARD_DRAFT":return function(e){return e.annotations.some(e=>"pending"===(e.status??"pending"))||e.styleModifications.some(e=>!e.captured)||e.textModifications.some(e=>!e.captured)||e.domModifications.some(e=>!e.captured)||e.spacingTokenChanges.some(e=>!e.captured)||e.spacingTokenMods.some(e=>!e.captured)?{...Ct(e),annotations:e.annotations.filter(e=>"pending"!==(e.status??"pending")),styleModifications:e.styleModifications.filter(e=>e.captured),textModifications:e.textModifications.filter(e=>e.captured),domModifications:e.domModifications.filter(e=>e.captured),spacingTokenChanges:e.spacingTokenChanges.filter(e=>e.captured),spacingTokenMods:e.spacingTokenMods.filter(e=>e.captured),selectedAnnotationIds:[],lastSelectedId:null}:e}(e);case"MODIFY_STYLE":return function(e,t){let{selector:n,element:o,property:i,original:a,modified:r}=t,l=typeof window<"u"?window.location.pathname:"/",d=e.styleModifications.findIndex(e=>e.selector===n&&(!e.pathname||e.pathname===l));if(a===r&&d<0)return e;if(d>=0){let t=e.styleModifications[d];if(t.captured){let t=Ct(e),n=t.styleModifications.map((e,t)=>t===d?{...e,changes:[{property:i,original:a,modified:r}],createdAt:e.createdAt??Date.now(),captured:!1,pathname:l}:e);return{...t,styleModifications:n}}let n,o=t.changes.findIndex(e=>e.property===i),s=e;if(o>=0){let e=t.changes[o];n=r===e.original?t.changes.filter((e,t)=>t!==o):t.changes.map((e,t)=>t===o?{...e,modified:r}:e)}else{if(a===r)return e;s=Ct(e),n=[...t.changes,{property:i,original:a,modified:r}]}if(0===n.length)return{...s,styleModifications:s.styleModifications.filter((e,t)=>t!==d)};let c=s.styleModifications.map((e,t)=>t===d?{...e,changes:n,createdAt:e.createdAt??Date.now()}:e);return{...s,styleModifications:c}}{let t=Ct(e),d={selector:n,element:o,changes:[{property:i,original:a,modified:r}],createdAt:Date.now(),pathname:l};return{...t,styleModifications:[...t.styleModifications,d]}}}(e,t.payload);case"MODIFY_STYLES_BATCH":return function(e,t){let{selector:n,durableSelector:o,element:i,changes:a}=t,r=typeof window<"u"?window.location.pathname:"/",l=a.filter(e=>e.original!==e.modified);if(0===l.length)return e;let d=Ct(e),s=d.styleModifications.findIndex(e=>e.selector===n&&(!e.pathname||e.pathname===r));if(s>=0){let e=d.styleModifications[s],t=e.captured?[]:[...e.changes];for(let e of l){let n=t.findIndex(t=>t.property===e.property);n>=0?t=e.modified===t[n].original?t.filter((e,t)=>t!==n):t.map((t,o)=>o===n?{...t,modified:e.modified,token:e.token,sticker:e.sticker}:t):t.push(e)}return 0===t.length?{...d,styleModifications:d.styleModifications.filter((e,t)=>t!==s)}:{...d,styleModifications:d.styleModifications.map((e,n)=>n===s?{...e,changes:t,createdAt:e.createdAt??Date.now(),captured:!1,pathname:r}:e)}}return{...d,styleModifications:[...d.styleModifications,{selector:n,durableSelector:o,element:i,changes:l,createdAt:Date.now(),pathname:r}]}}(e,t.payload);case"CLEAR_STYLE":return function(e,t){let{selector:n,property:o}=t,i=typeof window<"u"?window.location.pathname:"/",a=Ct(e),r=a.styleModifications.map(e=>e.selector!==n||e.pathname&&e.pathname!==i?e:{...e,changes:e.changes.filter(e=>e.property!==o)}).filter(e=>e.changes.length>0);return{...a,styleModifications:r}}(e,t.payload);case"CLEAR_STICKER":return function(e,t){let{selector:n,sticker:o}=t,i=typeof window<"u"?window.location.pathname:"/";if(!e.styleModifications.find(e=>e.selector===n&&(!e.pathname||e.pathname===i)&&!e.captured&&e.changes.some(e=>e.sticker?.family===o.family&&e.sticker.subproperty===o.subproperty)))return e;let a=Ct(e),r=a.styleModifications.map(e=>e.selector!==n||e.pathname&&e.pathname!==i||e.captured?e:{...e,changes:e.changes.filter(e=>e.sticker?.family!==o.family||e.sticker.subproperty!==o.subproperty)}).filter(e=>e.changes.length>0);return{...a,styleModifications:r}}(e,t.payload);case"CLEAR_ALL_STYLES":return function(e){return 0===e.styleModifications.length?e:{...Ct(e),styleModifications:[]}}(e);case"SETTLE_CAPTURED_STYLES":return function(e,t){let n=new Set(t.selectors);if(0===n.size)return e;let o=e.styleModifications.filter(e=>!(e.captured&&(n.has(e.selector)||e.durableSelector&&n.has(e.durableSelector))));return o.length===e.styleModifications.length?e:{...e,styleModifications:o}}(e,t.payload);case"RESTORE_STYLE_MODIFICATIONS":return function(e,t){let n=Date.now();return{...e,styleModifications:t.map((e,t)=>({...e,createdAt:e.createdAt??n+t}))}}(e,t.payload);case"MODIFY_TEXT_CONTENT":return Nt(e,t.payload);case"MODIFY_TEXT_CONTENTS":return function(e,t,n=!0){return 0===t.length?e:t.reduce((e,t)=>Nt(e,t,!1),n?Ct(e):e)}(e,t.payload,t.saveUndo??!0);case"RESTORE_TEXT_MODIFICATIONS":return function(e,t){let n=Date.now();return{...e,textModifications:t.filter(e=>!e.captured).map((e,t)=>({...e,createdAt:e.createdAt??n+t}))}}(e,t.payload);case"MODIFY_DOM_STRUCTURE":return function(e,t){let n=Ct(e),o=n.domModifications.findIndex(e=>e.id===t.id);return o>=0?{...n,domModifications:n.domModifications.map((e,n)=>n===o?{...t,captured:!1}:e)}:{...n,domModifications:[...n.domModifications,t]}}(e,t.payload);case"RESTORE_DOM_MODIFICATIONS":return function(e,t){return{...e,domModifications:t}}(e,t.payload);case"UPDATE_LINKED_POSITIONS":return function(e,t){let{updates:n}=t,o=new Map(n.map(e=>[e.id,e]));return{...e,annotations:e.annotations.map(e=>{let t=o.get(e.id);return t?{...e,points:[t.point,...e.points.slice(1)],...t.linkedAnchor?{linkedAnchor:t.linkedAnchor}:{}}:e})}}(e,t.payload);case"CLEANUP_ORPHANED":return function(e,t){let{linkedSelectors:n,styleSelectors:o}=t,i=new Set(n),a=new Set(o),r=typeof window<"u"?window.location.pathname:"/",l=new Set,d=new Set;for(let t of e.annotations)t.linkedSelector&&i.has(t.linkedSelector)&&(l.add(t.id),t.groupId&&d.add(t.groupId));for(let t of e.annotations)t.groupId&&d.has(t.groupId)&&l.add(t.id);let s=e.annotations.filter(e=>!l.has(e.id)),c=e.styleModifications.filter(e=>!a.has(e.selector)||e.pathname&&e.pathname!==r),p=e.domModifications.filter(e=>!a.has(e.selector)||e.pathname&&e.pathname!==r);if(s.length===e.annotations.length&&c.length===e.styleModifications.length&&p.length===e.domModifications.length)return e;let u=e.selectedAnnotationIds.filter(e=>!l.has(e));return{...e,annotations:s,styleModifications:c,domModifications:p,selectedAnnotationIds:u,lastSelectedId:u.length>0?u[u.length-1]:null}}(e,t.payload);case"SET_ANNOTATION_STATUS":return function(e,t){let n=new Set(t.ids);return{...e,annotations:e.annotations.map(e=>n.has(e.id)?{...e,status:t.status}:e)}}(e,t.payload);case"MARK_ANNOTATIONS_REPLIED":return function(e,t){let n=new Set(t.ids),o=new Set;for(let t of e.annotations)n.has(t.id)&&t.groupId&&o.add(t.groupId);return{...e,annotations:e.annotations.map(e=>{if(!(n.has(e.id)||e.groupId&&o.has(e.groupId)))return e;let i=!!t.jobId&&e.replyJobIds?.includes(t.jobId),a="waiting_input"===e.status;return{...e,status:a?"waiting_input":"resolved",replyCount:(e.replyCount??0)+(i?0:1),replyJobIds:t.jobId&&!i?[...e.replyJobIds??[],t.jobId]:e.replyJobIds,threadId:e.threadId||t.threadId,question:a?e.question:void 0}})}}(e,t.payload);case"MARK_ANNOTATIONS_FAILED":return function(e,t){let n=new Set(t.ids),o=new Set;for(let t of e.annotations)n.has(t.id)&&t.groupId&&o.add(t.groupId);return{...e,annotations:e.annotations.map(e=>n.has(e.id)||e.groupId&&o.has(e.groupId)?{...e,status:"failed",threadId:e.threadId||t.threadId,question:void 0}:e)}}(e,t.payload);case"SET_ANNOTATION_THREAD":return function(e,t){let n=new Set(t.ids),o=new Set;for(let t of e.annotations)n.has(t.id)&&t.groupId&&o.add(t.groupId);return{...e,annotations:e.annotations.map(e=>n.has(e.id)||e.groupId&&o.has(e.groupId)?{...e,threadId:t.threadId,targetBindingId:t.targetBindingId}:e)}}(e,t.payload);case"SET_ANNOTATION_QUESTION":return function(e,t){let n=new Set(t.ids),o=new Set;for(let t of e.annotations)n.has(t.id)&&t.groupId&&o.add(t.groupId);return{...e,annotations:e.annotations.map(e=>n.has(e.id)||e.groupId&&o.has(e.groupId)?{...e,status:"waiting_input",question:t.question,threadId:t.threadId}:e)}}(e,t.payload);case"APPLY_RESOLUTIONS":return function(e,t){let n=new Map(t.resolutions.map(e=>[e.annotationId,e])),o=new Map;for(let t of e.annotations){let e=n.get(t.id);e&&t.groupId&&o.set(t.groupId,e)}return{...e,annotations:e.annotations.map(e=>{let i=n.get(e.id)||(e.groupId?o.get(e.groupId):void 0);if(!i)return e;let a=!!t.jobId&&e.replyJobIds?.includes(t.jobId);return{...e,status:i.status,resolutionSummary:i.summary,scope:i.finalScope??i.inferredScope??null,replyCount:(e.replyCount??0)+(a?0:1),replyJobIds:t.jobId&&!a?[...e.replyJobIds??[],t.jobId]:e.replyJobIds,question:void 0,threadId:e.threadId||t.threadId}})}}(e,t.payload);case"ADD_SPACING_TOKEN_CHANGE":return function(e,t){let n=e.spacingTokenChanges.findIndex(e=>e.tokenPath===t.tokenPath);return n>=0?{...e,spacingTokenChanges:e.spacingTokenChanges.map((e,o)=>o===n?t:e)}:{...e,spacingTokenChanges:[...e.spacingTokenChanges,t]}}(e,t.payload);case"RESTORE_SPACING_TOKEN_CHANGES":return function(e,t){return{...e,spacingTokenChanges:t}}(e,t.payload);case"MODIFY_SPACING_TOKEN":return function(e,t){let n,o=Ct(e),i=e.spacingTokenMods.findIndex(e=>e.tokenPath===t.tokenPath);if(i>=0){let o=e.spacingTokenMods[i],a={...t,originalValue:o.captured?o.currentValue:o.originalValue,originalPx:o.captured?o.currentPx:o.originalPx,captured:!1};n=e.spacingTokenMods.map((e,t)=>t===i?a:e)}else n=[...e.spacingTokenMods,{...t,captured:!1}];return{...o,spacingTokenMods:n}}(e,t.payload);case"DELETE_SPACING_TOKEN":return function(e,t){let n,o=Ct(e),i=e.spacingTokenMods.findIndex(e=>e.tokenPath===t.tokenPath),a=i>=0?e.spacingTokenMods[i]:null,r=i>=0?a.captured?a.currentValue:a.originalValue:t.originalValue,l=i>=0?a.captured?a.currentPx:a.originalPx:parseFloat(t.originalValue)||0,d={tokenPath:t.tokenPath,originalValue:r,currentValue:"__deleted__",targets:a?.targets??[],originalPx:l,currentPx:0,captured:!1};return n=i>=0?e.spacingTokenMods.map((e,t)=>t===i?d:e):[...e.spacingTokenMods,d],{...o,spacingTokenMods:n}}(e,t.payload);default:return t}}function Ot(e,t){let o=F(St),[i,a]=q(Lt,n),r=U(o?.subscribe??Tt,o?.getSnapshot??Mt,o?.getSnapshot??Mt)??i,l=o?.dispatch??a;B(()=>{if(!r.isAnnotating)return;let n=n=>{t?.current||n.defaultPrevented||n.isComposing||n.altKey||n.composedPath().some(e=>e instanceof Element&&(e.matches('input, textarea, select, [role="textbox"]')||e instanceof HTMLElement&&e.isContentEditable||e.hasAttribute("contenteditable")&&"false"!==e.getAttribute("contenteditable")))||(n.metaKey||n.ctrlKey)&&n.key.toLowerCase()===xt.actions.undo.key&&(n.preventDefault(),n.shiftKey?l({type:"REDO"}):e?.current?.()||l({type:"UNDO"}))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[l,r.isAnnotating,e,t]);let d=o?.getUndoHead?o.getUndoHead():r.undoStack.at(-1);return[r,l,d]}function Dt(e){return!!e&&!!e.closest("#devtools-toolbar, #devtools-scrim, #devtools-text-input, [data-devtools], [data-popmelt-panel], [data-popmelt-shadow-host]")}function $t(e,t,n){return function(e,t){if(!e)return t();let n=e.style.pointerEvents;e.style.pointerEvents="none";try{return t()}finally{e.style.pointerEvents=n}}(n,()=>{let n=o(e,t);if(!n||Dt(n))return null;let i=n?.ownerDocument??document,a=E(e,t,i),r=function(e,t,n=document){let o=n,i=o.caretPositionFromPoint?.(e,t);if(i?.offsetNode?.nodeType===Node.TEXT_NODE)return i.offsetNode;let a=o.caretRangeFromPoint?.(e,t);return a?.startContainer?.nodeType===Node.TEXT_NODE?a.startContainer:null}(a.x,a.y,i);if(r&&!n.contains(r)&&(r=null),!r){let e=n;e&&!Dt(e)&&(r=function(e,t,n){let o=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:e=>e.textContent?.trim()?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}),i=o.nextNode();for(;i;){let a=i,r=e.ownerDocument.createRange();r.selectNodeContents(a);let l=Array.from(r.getClientRects());if(r.detach?.(),l.some(e=>t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom))return a;i=o.nextNode()}return null}(e,a.x,a.y))}if(!r||!A(r.parentElement))return null;let l=r.parentElement;if(Dt(l))return null;for(;l.parentElement&&l!==i.body;){let e=M(l).getComputedStyle(l).display,t="inline-block"===e&&1===l.childNodes.length&&l.firstChild?.nodeType===Node.ELEMENT_NODE;if("inline"!==e&&"contents"!==e&&!t)break;let n=l.parentElement;if(Dt(n))break;if(Array.from(n.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&!!e.nodeValue?.trim())){l=n;continue}let o=M(n).getComputedStyle(n).display,i="inline-block"===o&&1===n.childNodes.length&&n.firstChild?.nodeType===Node.ELEMENT_NODE;if("inline"!==o&&"contents"!==o&&!i)break;l=n}let d=l.tagName.toLowerCase();if("script"===d||"style"===d||"textarea"===d||"input"===d)return null;let s=function(e){let t=[],n=o=>{if(o.nodeType===Node.TEXT_NODE){let n=o,i=_t(e,n);return void(i&&t.push({textNode:n,textNodePath:i,originalText:n.nodeValue??""}))}if(o.nodeType!==Node.ELEMENT_NODE&&o!==e)return;let i=o.tagName?.toLowerCase();"script"===i||"style"===i||o.childNodes.forEach(n)};return e.childNodes.forEach(n),t}(l),c=s.map(e=>e.originalText).join("");if(!c.trim())return null;let p=_t(l,r);if(!p)return null;let u=M(l).getComputedStyle(l),f=zt(s,l,u),{textRect:h,boundaryRect:m,boundaryRects:g,flowRect:y,firstLineIndent:v}=f;if(h.width<=0||h.height<=0)return null;let x=parseFloat(u.fontSize)||12,w="nowrap"!==u.whiteSpace&&"pre"!==u.whiteSpace&&(function(e){let t=e.ownerDocument.createRange();t.selectNodeContents(e);let n=Array.from(t.getClientRects()).filter(e=>e.width>0&&e.height>0).length;return t.detach?.(),n>1}(r)||"inline"!==u.display);return{textNode:r,targetElement:l,textNodePath:p,segments:s,originalText:c,rect:h,boundaryRect:m,boundaryRects:g,flowRect:y,firstLineIndent:v,styles:u,fontSize:x,wrapsText:w}})}function _t(e,t){let n=[],o=t;for(;o&&o!==e;){let e=o.parentNode;if(!e)return null;n.unshift(Array.prototype.indexOf.call(e.childNodes,o)),o=e}return o===e?n:null}function Pt(e){return{left:e.left,top:e.top,width:e.width,height:e.height}}function Ft(e){let t=e.getBoundingClientRect(),n=M(e).getComputedStyle(e),o=(parseFloat(n.borderLeftWidth)||0)+(parseFloat(n.paddingLeft)||0),i=(parseFloat(n.borderRightWidth)||0)+(parseFloat(n.paddingRight)||0),a=(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.paddingTop)||0),r=(parseFloat(n.borderBottomWidth)||0)+(parseFloat(n.paddingBottom)||0);return T({left:t.left+o,top:t.top+a,width:Math.max(0,t.width-o-i),height:Math.max(0,t.height-a-r)},e.ownerDocument)}function zt(e,t,n){let o=Pt(w(t)),i=function(e){let t=[];for(let n of e){if(!n.textNode.isConnected||!n.originalText.trim())continue;let e=n.textNode.ownerDocument.createRange();e.selectNodeContents(n.textNode),t.push(...Array.from(e.getClientRects()).filter(e=>e.width>0&&e.height>0).map(e=>Pt(T(e,n.textNode.ownerDocument)))),e.detach?.()}return Ne(t)}(e),a=e[0]?.textNode?function(e,t){let n=e.ownerDocument.createRange();n.selectNodeContents(e);let o=T(n.getBoundingClientRect(),e.ownerDocument);if(n.detach?.(),o.width>0&&o.height>0)return{left:o.left,top:o.top,width:o.width,height:o.height};let i=w(t);return{left:i.left,top:i.top,width:i.width,height:i.height}}(e[0].textNode,t):o,r=i.length>0?i:[a];return function({display:e,fragmentRects:t,elementRect:n,parentContentRect:o}){let i=Ne(t),a=Re(i,n);if(!("inline"===e&&i.length>1&&o&&o.width>0))return{textRect:a,boundaryRect:n,boundaryRects:[n],firstLineIndent:0};let r=i[0],l={left:o.left,top:r.top,width:o.width,height:Math.max(a.height,Ce(a)-r.top)},d=Math.max(0,Math.min(l.width,r.left-l.left));return{textRect:a,boundaryRect:Re(i,n),boundaryRects:i,flowRect:l,firstLineIndent:d}}({display:n.display,fragmentRects:r,elementRect:o,parentContentRect:t.parentElement?Ft(t.parentElement):void 0})}function Bt(e,t,n){if(t===n||0===e.length)return[];let o=0;for(;o<t.length&&o<n.length&&t[o]===n[o];)o+=1;let i=0;for(;i<t.length-o&&i<n.length-o&&t[t.length-1-i]===n[n.length-1-i];)i+=1;let a=o,r=t.length-i,l=n.slice(o,n.length-i),d=0,s=!1;return e.flatMap((t,n)=>{let o=d,i=o+t.originalText.length;d=i;let c=a===r;if(!(c&&(a>=o&&a<i||n===e.length-1&&a===i))&&!(!c&&i>a&&o<r))return[];let p=Math.max(0,Math.min(t.originalText.length,a-o)),u=Math.max(0,Math.min(t.originalText.length,r-o)),f=t.originalText.slice(0,p);return s||(f+=l,s=!0),f+=t.originalText.slice(u),f===t.originalText?[]:[{segment:t,modifiedText:f}]})}function Wt(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 Ht(e,t){return e&&t?Wt(e,t):e===t}function jt(e,t){return e.length===t.length&&e.every((e,n)=>Wt(e,t[n]))}function Yt(){return{isDragging:!1,hasMoved:!1,mode:"move",startX:0,startY:0,element:null,originalParent:null,originalIndex:-1,selector:null,durableSelector:null,elementInfo:null}}function Kt(e){if(!e||e===document.body||e===document.documentElement||Dt(e))return!1;let t=e.tagName.toLowerCase();return!["script","style","link","meta","head","html","body","input","textarea","select","option","button"].includes(t)&&!!e.parentElement}function qt(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 Ut(e){return e.parentElement?Array.from(e.parentElement.children).indexOf(e):-1}function Vt(e){e.removeAttribute("data-pm"),e.querySelectorAll("[data-pm]").forEach(e=>e.removeAttribute("data-pm"))}function Xt(e,t,n,i,a=o){let r=n.parentElement;if(!r)return null;let l=a(e,t);for(;l&&l!==document.body;)if(l===n||n.contains(l))l=l.parentElement;else{if(l.parentElement===r&&Kt(l))break;l=l.parentElement}if(!l||l===document.body||l.parentElement!==r||l===i)return null;let d=l.getBoundingClientRect(),s=d.height>=d.width?t<d.top+d.height/2?"before":"after":e<d.left+d.width/2?"before":"after",c=Ut(l);return{parent:r,reference:l,placement:s,index:"before"===s?c:c+1}}function Jt(e,t,n){let o=Array.from(e.children).filter(e=>e!==t),i=Math.max(0,Math.min(n,o.length));e.insertBefore(t,o[i]??null)}function Gt({drag:e,clientX:t,clientY:n,pathname:o,createId:r,rootElement:l,elementAtPoint:d}){let s=e.element;if(!(s&&e.selector&&e.durableSelector&&e.elementInfo))return null;let c=Xt(t,n,s,l,d);if(!c)return null;let p=e.originalParent===c.parent&&c.index>e.originalIndex?c.index-1:c.index;if("move"===e.mode&&e.originalParent===c.parent&&(p===e.originalIndex||p===e.originalIndex+1))return null;let u=i(c.parent),f=qt(c.parent),h=i(c.reference),m=qt(c.reference),g=e.selector,y=e.durableSelector,v=e.elementInfo;if("copy"===e.mode){let e=s.cloneNode(!0);if(!(e instanceof Element))return null;Vt(e),Jt(c.parent,e,p),g=qt(e),y=i(e),v={...a(e),selector:g}}else Jt(c.parent,s,p);let x=e.originalParent;return{id:r(),operation:e.mode,selector:g,durableSelector:y,element:v,sourceSelector:"copy"===e.mode?e.selector:void 0,sourceDurableSelector:"copy"===e.mode?e.durableSelector:void 0,sourceElement:"copy"===e.mode?e.elementInfo:void 0,originalParentSelector:x?qt(x):void 0,originalParentDurableSelector:x?i(x):void 0,originalIndex:e.originalIndex,targetParentSelector:f,targetParentDurableSelector:u,targetIndex:p,referenceSelector:m,referenceDurableSelector:h,placement:c.placement,pathname:o}}function Qt(e){return e instanceof HTMLElement&&("INPUT"===e.tagName||"TEXTAREA"===e.tagName||!0===e.isContentEditable||"true"===e.getAttribute("contenteditable"))}function Zt(e){return Qt(e.composedPath?.()[0]??e.target)||Qt(function(){if(typeof document>"u")return null;let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e}())}function en(e,t,n){if(n)return[n];let o=new Set(t),i=new Map;for(let t of e)t.groupId&&t.threadId&&i.set(t.groupId,t.threadId);let a=new Set;for(let t of e){if(!o.has(t.id))continue;let e=t.threadId||(t.groupId?i.get(t.groupId):void 0);e&&a.add(e)}return[...a]}function tn({state:e,stateRef:t,activeTextRef:n,selectedIdsRef:o,dispatch:r,clearSelection:l,selectAnnotation:d,handHoveredElement:s,onArchiveThread:c,openThreadId:p,currentPathname:u,hasOpenThread:f}){let h=j([]),m=j(0),g=j(null);B(()=>{let y=y=>{if("Escape"===y.key){if(y.defaultPrevented||y.repeat||n.current||f||Zt(y))return;if(o.current.length>0)return y.preventDefault(),void l();let e=t.current;if(e.annotations.some(e=>"pending"===(e.status??"pending"))||e.styleModifications.some(e=>!e.captured)||e.textModifications.some(e=>!e.captured)||e.domModifications.some(e=>!e.captured)||e.spacingTokenChanges.some(e=>!e.captured)||e.spacingTokenMods.some(e=>!e.captured))return y.preventDefault(),void r({type:"DISCARD_DRAFT"})}if((y.metaKey||y.ctrlKey)&&"c"===y.key.toLowerCase()&&"hand"===e.activeTool&&s&&!n.current){if(Kt(s)){y.preventDefault();let e=qt(s);g.current={source:s,sourceSelector:e,sourceDurableSelector:i(s),sourceElement:{...a(s),selector:e}}}return}if((y.metaKey||y.ctrlKey)&&"v"===y.key.toLowerCase()&&"hand"===e.activeTool&&g.current&&!n.current){let e=g.current,t=s&&Kt(s)?s:e.source,n=t.parentElement;if(n){y.preventDefault();let o=i(n),l=qt(n),d=i(t),s=qt(t),c=Ut(t)+1,p=e.source.cloneNode(!0);if(p instanceof Element){Vt(p),Jt(n,p,c);let t=qt(p),f=i(p),h={...a(p),selector:t};r({type:"MODIFY_DOM_STRUCTURE",payload:{id:kt(),operation:"copy",selector:t,durableSelector:f,element:h,sourceSelector:e.sourceSelector,sourceDurableSelector:e.sourceDurableSelector,sourceElement:e.sourceElement,targetParentSelector:l,targetParentDurableSelector:o,targetIndex:c,referenceSelector:s,referenceDurableSelector:d,placement:"after",pathname:u}})}}return}if((y.metaKey||y.ctrlKey)&&"v"===y.key&&h.current.length>0&&!n.current){y.preventDefault(),m.current+=1;let e=20*m.current,t=h.current[0]?.groupId?Math.random().toString(36).substring(2,9):void 0,n=h.current.map(n=>({...n,id:Math.random().toString(36).substring(2,9),groupId:n.groupId?t:void 0,timestamp:Date.now(),points:n.points.map(t=>({x:t.x+e,y:t.y+e}))}));r({type:"PASTE_ANNOTATIONS",payload:{annotations:n}});let o=n.find(e=>"text"!==e.type)??n[0];return void(o&&d(o.id))}let v=o.current;if(!(n.current||Zt(y)||"Delete"!==y.key&&"Backspace"!==y.key||y.metaKey||y.ctrlKey||y.altKey)){if(0===v.length&&!p)return;let e=en(t.current.annotations,v,p);if(!c||0===e.length)return;y.preventDefault();for(let t of e)c(t);l()}};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n,l,u,r,s,f,c,p,d,o,e.activeTool,t])}export{Ve as $,Ut as A,Xt as B,Gt as C,Zt as D,en as E,tn as F,Z as G,ee as H,te as I,Ie as J,Se as K,Te as L,Me as M,ke as N,Ee as O,$e as P,Pe as Q,Fe as R,ze as S,Be as T,We as U,He as V,je as W,Ye as X,Ke as Y,qe as Z,Ue as _,xt as a,Xe as aa,wt as b,Je as ba,bt as c,Ge as ca,It as d,Qe as da,St as e,et as ea,kt as f,tt as fa,Lt as g,nt as ga,Ot as h,ot as ha,oe as i,lt as ia,ie as j,dt as ja,le as k,st as ka,ue as l,ct as la,fe as m,ft as ma,he as n,ht as na,me as o,mt as oa,be as p,vt as pa,Dt as q,$t as r,zt as s,Bt as t,Wt as u,Ht as v,jt as w,Yt as x,Kt as y,qt as z};
@@ -1 +0,0 @@
1
- "use client";var e=new Map;function r(r,t,a){let i=new URL(r);if("http:"!==i.protocol||!["localhost","127.0.0.1","[::1]"].includes(i.hostname)||"/"!==i.pathname||i.search||i.hash||i.username||i.password)throw new Error("Bridge scope requires a local origin");if(e.has(i.origin))throw new Error("This bridge already has an active participant in this page");let n={headers:{...t},pathPrefix:a};return e.set(i.origin,n),()=>{e.get(i.origin)===n&&e.delete(i.origin)}}function t(e){return!!a(e)}function a(r){try{let t=new URL(r),a=e.get(t.origin);return a?.pathPrefix?("string"==typeof a.pathPrefix?[a.pathPrefix]:a.pathPrefix).some(e=>e.endsWith("/")?t.pathname.startsWith(e):t.pathname===e)?a:void 0:a}catch{return}}function i(e,r){let t=a(e);if(!t)return r;let i=new Headers(r.headers);for(let[e,r]of Object.entries(t.headers))i.set(e,r);return{...r,headers:i,redirect:"error",credentials:"omit"}}export{r as a,t as b,i as c};
@@ -1 +0,0 @@
1
- "use client";import{a as e}from"./chunk-ODIGT4YJ.mjs";import{createContext as t,useState as n,useRef as r,useCallback as i,useLayoutEffect as o,useEffect as a,useMemo as l}from"react";import{jsx as s,jsxs as u,Fragment as d}from"react/jsx-runtime";import{Search as c,Bot as p,Brain as f,Zap as h,Leaf as L,ChevronDown as g,Check as m}from"lucide-react";var b=t(null),C=t(void 0);function v(e){return e<=767}function x(e){return v(e)?8:16}function y(e){let t=x(e);return e<=480?Math.max(0,e-2*t):Math.min(360,Math.max(0,e-2*t))}var M=100,w=200,k={surface:null,phase:"visible"};function S({openDelayMs:e=100,exitDurationMs:t=200,pinnedSurface:l=null}={}){let[s,u]=n(k),d=r(k),c=r(null),p=r(l);p.current=l;let f=r(null),h=r(null),L=i(e=>{d.current.surface===e.surface&&d.current.phase===e.phase||(d.current=e,u(e))},[]),g=i(()=>{f.current&&(clearTimeout(f.current),f.current=null)},[]),m=i(()=>{h.current&&(clearTimeout(h.current),h.current=null)},[]),b=i(e=>{c.current=e,g(),m(),L({surface:e,phase:"visible"})},[m,g,L]),C=i(t=>{if(!p.current||d.current.surface!==p.current||t===p.current){if(c.current=t,g(),m(),null!==d.current.surface)return void L({surface:t,phase:"visible"});f.current=setTimeout(()=>{f.current=null,c.current===t&&L({surface:t,phase:"visible"})},e)}},[m,g,e,L]),v=i(e=>{e!==p.current&&(c.current===e&&(c.current=null),g(),d.current.surface===e&&(m(),L({surface:e,phase:"exiting"}),h.current=setTimeout(()=>{h.current=null,null===c.current&&L(k)},t)))},[m,g,t,L]),x=i(e=>{e&&d.current.surface!==e||(c.current=null,g(),m(),L(k))},[m,g,L]);return o(()=>{l&&d.current.surface===l&&b(l)},[l,b]),a(()=>()=>{g(),m()},[m,g]),{surface:s.surface,phase:s.phase,enter:C,leave:v,show:b,dismiss:x}}var I={id:"",label:"Codex default",source:"cli",isDefault:!0};function T(e){return[I,...e.filter(e=>""!==e.id)]}var z={id:"",label:"Claude default",source:"static"};function P(e){return/^claude-(?:ai|code)(?:$|[-.])/i.test(e)}function R(e){return[z,...e.filter(e=>e.id&&!P(e.id))]}function E({size:e=16,style:t}){return s("svg",{width:e,height:e,viewBox:"0 0 1200 1200",fill:"currentColor",stroke:"none",style:{flexShrink:0,...t},children:s("path",{d:"M 233.959793 800.214905 L 468.644287 668.536987 L 472.590637 657.100647 L 468.644287 650.738403 L 457.208069 650.738403 L 417.986633 648.322144 L 283.892639 644.69812 L 167.597321 639.865845 L 54.926208 633.825623 L 26.577238 627.785339 L 3.3e-05 592.751709 L 2.73832 575.27533 L 26.577238 559.248352 L 60.724873 562.228149 L 136.187973 567.382629 L 249.422867 575.194763 L 331.570496 580.026978 L 453.261841 592.671082 L 472.590637 592.671082 L 475.328857 584.859009 L 468.724915 580.026978 L 463.570557 575.194763 L 346.389313 495.785217 L 219.543671 411.865906 L 153.100723 363.543762 L 117.181267 339.060425 L 99.060455 316.107361 L 91.248367 266.01355 L 123.865784 230.093994 L 167.677887 233.073853 L 178.872513 236.053772 L 223.248367 270.201477 L 318.040283 343.570496 L 441.825592 434.738342 L 459.946411 449.798706 L 467.194672 444.64447 L 468.080597 441.020203 L 459.946411 427.409485 L 392.617493 305.718323 L 320.778564 181.932983 L 288.80542 130.630859 L 280.348999 99.865845 C 277.369171 87.221436 275.194641 76.590698 275.194641 63.624268 L 312.322174 13.20813 L 332.8591 6.604126 L 382.389313 13.20813 L 403.248352 31.328979 L 434.013519 101.71814 L 483.865753 212.537048 L 561.181274 363.221497 L 583.812134 407.919434 L 595.892639 449.315491 L 600.40271 461.959839 L 608.214783 461.959839 L 608.214783 454.711609 L 614.577271 369.825623 L 626.335632 265.61084 L 637.771851 131.516846 L 641.718201 93.745117 L 660.402832 48.483276 L 697.530334 24.000122 L 726.52356 37.852417 L 750.362549 72 L 747.060486 94.067139 L 732.886047 186.201416 L 705.100708 330.52356 L 686.979919 427.167847 L 697.530334 427.167847 L 709.61084 415.087341 L 758.496704 350.174561 L 840.644348 247.490051 L 876.885925 206.738342 L 919.167847 161.71814 L 946.308838 140.29541 L 997.61084 140.29541 L 1035.38269 196.429626 L 1018.469849 254.416199 L 965.637634 321.422852 L 921.825562 378.201538 L 859.006714 462.765259 L 819.785278 530.41626 L 823.409424 535.812073 L 832.75177 534.92627 L 974.657776 504.724915 L 1051.328979 490.872559 L 1142.818848 475.167786 L 1184.214844 494.496582 L 1188.724854 514.147644 L 1172.456421 554.335693 L 1074.604126 578.496765 L 959.838989 601.449829 L 788.939636 641.879272 L 786.845764 643.409485 L 789.261841 646.389343 L 866.255127 653.637634 L 899.194702 655.409424 L 979.812134 655.409424 L 1129.932861 666.604187 L 1169.154419 692.537109 L 1192.671265 724.268677 L 1188.724854 748.429688 L 1128.322144 779.194641 L 1046.818848 759.865845 L 856.590759 714.604126 L 791.355774 698.335754 L 782.335693 698.335754 L 782.335693 703.731567 L 836.69812 756.885986 L 936.322205 846.845581 L 1061.073975 962.81897 L 1067.436279 991.490112 L 1051.409424 1014.120911 L 1034.496704 1011.704712 L 924.885986 929.234924 L 882.604126 892.107544 L 786.845764 811.48999 L 780.483276 811.48999 L 780.483276 819.946289 L 802.550415 852.241699 L 919.087341 1027.409424 L 925.127625 1081.127686 L 916.671204 1098.604126 L 886.469849 1109.154419 L 853.288696 1103.114136 L 785.073914 1007.355835 L 714.684631 899.516785 L 657.906067 802.872498 L 650.979858 806.81897 L 617.476624 1167.704834 L 601.771851 1186.147705 L 565.530212 1200 L 535.328857 1177.046997 L 519.302124 1139.919556 L 535.328857 1066.550537 L 554.657776 970.792053 L 570.362488 894.68457 L 584.536926 800.134277 L 592.993347 768.724976 L 592.429626 766.630859 L 585.503479 767.516968 L 514.22821 865.369263 L 405.825531 1011.865906 L 320.053711 1103.677979 L 299.516815 1111.812256 L 263.919525 1093.369263 L 267.221497 1060.429688 L 287.114136 1031.114136 L 405.825531 880.107361 L 477.422913 786.52356 L 523.651062 732.483276 L 523.328918 724.671265 L 520.590698 724.671265 L 205.288605 929.395935 L 149.154434 936.644409 L 124.993355 914.01355 L 127.973183 876.885986 L 139.409409 864.80542 L 234.201385 799.570435 L 233.879227 799.8927 Z"})})}function D({size:e=16,style:t}){return s("svg",{width:e,height:e,viewBox:"1.7 1.7 20.6 20.6",fill:"currentColor",stroke:"none",style:{flexShrink:0,...t},children:s("path",{fillRule:"evenodd",d:"M9.3316 2.03768C11.1644 1.54688 13.0268 2.04668 14.356 3.20174C16.0859 2.86512 17.9511 3.36418 19.2935 4.70663C20.6356 6.04882 21.1326 7.91288 20.7964 9.64217C21.9527 10.9716 22.4534 12.8349 21.9625 14.6685C21.4711 16.5025 20.1051 17.8657 18.439 18.439C17.8658 20.1047 16.503 21.47 14.6695 21.9615C12.8356 22.4528 10.9727 21.9519 9.64312 20.7955C7.91371 21.1319 6.04993 20.635 4.70757 19.2926C3.36558 17.9505 2.86659 16.0866 3.20269 14.357C2.04693 13.0273 1.54757 11.1638 2.03863 9.33065C2.52997 7.49759 3.89436 6.13282 5.56011 5.55917C6.13382 3.8935 7.49837 2.52891 9.3316 2.03768Z M16.0005 13.5992C16.4972 13.5995 16.9007 14.0029 16.9009 14.4996C16.9009 14.9965 16.4974 15.3997 16.0005 15.4H13.0005C12.5035 15.4 12.1002 14.9967 12.1002 14.4996C12.1004 14.0027 12.5036 13.5992 13.0005 13.5992H16.0005Z M8.03765 8.72811C8.46377 8.47284 9.01638 8.61074 9.27203 9.03671L10.6177 11.2789C10.8836 11.7221 10.8834 12.277 10.6177 12.7203L9.27203 14.9625C9.01633 15.3887 8.46385 15.5267 8.03765 15.2711C7.61143 15.0153 7.47333 14.4629 7.72906 14.0367L8.95074 11.9996L7.72906 9.96249C7.47341 9.53628 7.61146 8.98382 8.03765 8.72811Z"})})}function j({size:e=16,style:t}){return s("svg",{width:e,height:e,viewBox:"0 0 49.7202 40.0402",fill:"currentColor",stroke:"none",style:{flexShrink:0,...t},children:s("path",{d:"M29.8768 25.3531C30.9809 25.3531 31.876 26.2481 31.876 27.3522V31.3505C31.876 32.4545 30.9809 33.3496 29.8768 33.3496C28.7727 33.3496 27.8777 32.4545 27.8777 31.3505V27.3522C27.8777 26.2481 28.7727 25.3531 29.8768 25.3531ZM19.8812 25.3531C20.9852 25.3531 21.8803 26.2481 21.8803 27.3522V31.3505C21.8803 32.4545 20.9852 33.3496 19.8812 33.3496C18.7771 33.3496 17.882 32.4545 17.882 31.3505V27.3522C17.882 26.2481 18.7771 25.3531 19.8812 25.3531ZM24.8601 40.8772C36.974 40.8772 46.9603 33.8278 48.6801 30.8403C48.8058 30.6218 48.8464 30.3723 48.8464 30.1202V24.8018C48.8464 24.5813 48.8124 24.3622 48.7308 24.1574C47.9871 22.2899 46.0394 19.5773 43.5257 18.8495C43.1925 17.994 42.6989 16.7433 42.2384 15.8201C42.3154 15.1138 42.3426 14.3853 42.3426 13.6492C42.3426 10.99 41.7789 8.65743 40.0805 6.92044C39.2872 6.10915 38.3028 5.48684 37.1355 5.01903C34.3398 2.74775 30.2723 0.837036 24.8169 0.837036C19.3616 0.837036 15.3805 2.74775 12.5847 5.01903C11.4174 5.48684 10.433 6.10915 9.63975 6.92044C7.9413 8.65743 7.37764 10.99 7.37764 13.6492C7.37764 14.3853 7.40477 15.1138 7.48186 15.8201C7.02133 16.7433 6.52774 17.994 6.19449 18.8495C3.68082 19.5773 1.73309 22.2899 0.989389 24.1574C0.907813 24.3622 0.873779 24.5813 0.873779 24.8018V30.1202C0.873779 30.3723 0.914376 30.6218 1.04014 30.8403C2.75994 33.8278 12.7462 40.8772 24.8601 40.8772ZM26.485 13.0046C26.4 12.3422 26.3595 11.749 26.3584 11.2191L26.3584 11.1772C26.361 9.63975 26.6971 8.63938 27.2339 8.02499C27.9156 7.2448 29.3246 6.64707 32.2941 6.96844C35.3026 7.29402 36.9842 8.04072 37.9376 9.01574C38.8606 9.95971 39.3455 11.372 39.3455 13.6492C39.3455 16.0687 38.9969 17.4982 38.2302 18.3678C37.5012 19.1946 36.0656 19.8674 32.9214 19.8674C30.5041 19.8674 29.1221 19.0812 28.2386 17.9939C27.2899 16.8264 26.7559 15.1161 26.485 13.0046ZM23.2353 13.0046C23.3203 12.3422 23.3607 11.749 23.3619 11.2191L23.3619 11.1772C23.3592 9.63974 23.0232 8.63937 22.4863 8.02498C21.8046 7.24479 20.3957 6.64707 17.4261 6.96843C14.4176 7.29402 12.736 8.04071 11.7826 9.01573C10.8596 9.9597 10.3747 11.372 10.3747 13.6492C10.3747 16.0687 10.7234 17.4982 11.49 18.3677C12.219 19.1946 13.6546 19.8674 16.7989 19.8674C19.2161 19.8674 20.5981 19.0812 21.4816 17.9939C22.4304 16.8264 22.9643 15.1161 23.2353 13.0046ZM25.2042 18.8676L25.0543 18.8676C24.8715 18.8678 24.6005 18.868 24.516 18.8676C24.3045 19.2218 24.0693 19.5618 23.8075 19.884C22.2697 21.7764 19.9741 22.8644 16.7988 22.8644C13.3524 22.8644 10.8266 22.1471 9.24196 20.3498C9.15187 20.2476 9.07125 20.1406 9.07125 20.1406L8.87613 20.3498V33.5049C11.7429 35.0628 17.8959 37.8586 24.8601 37.8586C31.8243 37.8586 37.9773 35.0628 40.8441 33.5049V20.3498L40.649 20.1406C40.649 20.1406 40.5829 20.231 40.4783 20.3498C38.8936 22.1471 36.3678 22.8644 32.9214 22.8644C29.7461 22.8644 27.4506 21.7764 25.9127 19.884C25.6509 19.5618 25.4157 19.2218 25.2042 18.8676Z",fillRule:"evenodd",clipRule:"evenodd"})})}function O({size:e=16,style:t}){return s("svg",{width:e,height:e,viewBox:"8 8 48 48",fill:"none",style:{flexShrink:0,...t},children:s("path",{fill:"currentColor",d:"M14 16h36v8H40v32h-8V24h-6v22h-8V24h-4z"})})}function $({provider:e,size:t=16,style:n}){return s("codex"===e?D:"copilot"===e?j:"omp"===e?O:E,{size:t,style:n})}var B=[{effort:"low"},{effort:"medium"},{effort:"high"},{effort:"xhigh"},{effort:"max"}],A=[z,{id:"claude-opus-4-6",label:"Opus 4.6",source:"static",supportedReasoningLevels:B},{id:"claude-sonnet-4-6",label:"Sonn 4.6",source:"static",supportedReasoningLevels:B}],V=[I],Z=[{id:"",label:"Default",source:"static"}],F=[{id:"",label:"OMP default",source:"static"}],N=[...A,...V,...Z,...F];function W(e,t){if("copilot"===t&&!e)return"Copilot";if("omp"===t&&!e)return"OMP";if(!e)return"codex"===t?"Codex":"Claude Code";let n=N.find(t=>t.id===e);return n?n.label:e.replace(/-\d{8,}$/,"")}function G(e){let t=(e.id||e.label).replace(/^.*\//,"").match(/(?:^|[\s-])(\d+)(?:[.\s-](\d{1,2}))?/);return t?1e3*Number(t[1])+Number(t[2]??0):0}function H(e){if(void 0!==e.tierRank)return e.tierRank;let t=`${e.id} ${e.label}`.toLowerCase();return/\b(nano|spark|haiku)\b/.test(t)?1:/\b(mini|luna|flash)\b/.test(t)?2:/\b(terra|sonnet)\b/.test(t)?3:/\b(sol|opus|pro)\b/.test(t)?4:/\b(fable|ultra)\b/.test(t)?5:3}function U(e){let t=e.length>0&&e.every(({model:e})=>e.releaseDate&&Number.isFinite(Date.parse(e.releaseDate)));return[...e].sort((e,n)=>(t?Date.parse(e.model.releaseDate)-Date.parse(n.model.releaseDate):G(e.model)-G(n.model))||H(e.model)-H(n.model)||(n.model.catalogPriority??-n.index)-(e.model.catalogPriority??-e.index))}function q(e,t){return U(t.map((e,t)=>({index:t,model:e})))}function X(e,t){return t?U(e.flatMap((e,n)=>e.upstreamProvider===t?[{index:n,model:e}]:[])):[]}function J(e){let t={anthropic:"Anthropic","openai-codex":"OpenAI Codex",openai:"OpenAI",openrouter:"OpenRouter"};return t[e]?t[e]:e.split(/[-_]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function K(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"")}var Q=e,Y={minimal:"Minimal",low:"Low",medium:"Medium",high:"High",xhigh:"X-high",max:"Max",ultra:"Ultra"};function _(e){let t=e.replace(/-/g," ").replace(/^claude\s+/i,"").replace(/^GPT\s*/i,"GPT ").replace(/^Sonn\b/i,"Sonnet").replace(/^(fable|opus|sonnet)\b/i,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()),n=t.match(/^GPT\s+(\d+)(?:\.(\d+))?\b/i);if(!n)return t;let r=Number(n[1]),i=Number(n[2]??0);return r>5||5===r&&i>=6?t.replace(/^GPT\s+/i,""):t}function ee({count:e,index:t,pill:n}){let r=Math.min(e,7),i=e<=1?0:Math.round(t*(r-1)/(e-1));return s("span",{title:`${t+1} of ${e}`,style:{alignItems:"center",background:n?"#333":"transparent",borderRadius:9,display:"inline-flex",gap:2,justifyContent:"center",padding:n?"2px 4px":4,transition:"background-color 120ms ease, padding 120ms ease"},children:Array.from({length:r},(e,t)=>{let n=t===i;return s("span",{style:0!==t||n?{background:n?"#fff":"#888",borderRadius:999,height:n?3:2,width:n?3:2,transition:"background-color 120ms ease, height 120ms ease, width 120ms ease"}:{background:"#555",borderRadius:2,height:6,width:1,transition:"background-color 120ms ease, height 120ms ease, width 120ms ease"}},t)})})}function te({icon:e,options:t,selectedIndex:i,displayLabel:o,onSelect:a,scrub:l=!1,indicator:d="scale",indicatorActive:c=!0,onScrubChange:p}){let f=r(null),h=r(!1),[L,g]=n(!1),[b,C]=n(!1),v=i>=0&&i<t.length?i:0,x=t[v],y=!a||t.length<=1;return u("button",{type:"button",disabled:y,onPointerDown:e=>{!l||y||(f.current={x:e.clientX,index:v,moved:!1},C(!0),p?.(!0),e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{let n=f.current;if(!n||!l||!a)return;let r=e.clientX-n.x;Math.abs(r)>=4&&(n.moved=!0);let i=Math.max(0,Math.min(t.length-1,n.index+Math.round(r/22)));n.moved&&i!==v&&a(i)},onPointerUp:e=>{let t=f.current;t&&(e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),h.current=t.moved,f.current=null,C(!1),p?.(!1))},onPointerCancel:()=>{f.current=null,C(!1),p?.(!1)},onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),onClick:()=>{h.current?h.current=!1:y||a((v+1)%t.length)},style:{alignItems:"center",background:"transparent",border:0,borderRadius:24,color:"check"!==d&&(L||b)?"#eee":"#aaa",cursor:y?"default":l?"ew-resize":"pointer",display:"flex",fontFamily:Q,fontSize:12,height:30,justifyContent:"space-between",letterSpacing:"0.12px",padding:"8px 6px 8px 10px",touchAction:l?"none":"auto",userSelect:"none",width:"100%",transition:"background-color 120ms ease, color 120ms ease"},children:[u("span",{style:{alignItems:"center",display:"inline-flex",gap:6,minWidth:0},children:[s(e,{"aria-hidden":"true",size:12,strokeWidth:1.75}),s("span",{style:{lineHeight:1.35,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o??x?.label??"Unavailable"})]}),"check"===d?s(m,{"aria-hidden":"true",color:"#fff",size:12,strokeWidth:2,style:{opacity:c?1:0,transition:"opacity 120ms ease"}}):s(ee,{count:t.length,index:i,pill:L||b})]})}function ne({visible:e,style:t,provider:r,availableProviders:i=[],models:o,modelIndex:g,agentSettings:m={},onProviderChange:b,onModelChange:C,onAgentSettingsChange:v,onMouseEnter:x,onMouseLeave:y,onScrubChange:M}){let w=o[g]??o[0],k=l(()=>function(e){return[...new Set(e.flatMap(e=>e.upstreamProvider?[e.upstreamProvider]:[]))]}(o),[o]),S=w?.upstreamProvider??k[0],[I,T]=n(""),[z,P]=n(!1),[R,E]=n(!1),D=l(()=>function(e,t){let n=K(t);return n?e.filter(e=>K(`${e} ${J(e)}`).includes(n)):e}(k,I),[I,k]),j=function(e,t){if(!e||!t)return"";let n=J(e);return K(`${e} ${n}`).includes(K(t))?n:""}(D[0],I),O=j.toLowerCase().indexOf(I.trim().toLowerCase());a(()=>{z||T(S?J(S):"")},[z,S]);let B=e=>{let t=function(e,t){let n=X(e,t);return n.find(e=>e.model.isDefault)?.index??n[0]?.index??0}(o,e),n=o[t];T(J(e)),P(!1),C?.(t),m.serviceTier&&!n?.speedTiers?.some(e=>e.id===m.serviceTier)&&v?.({...m,serviceTier:void 0})},A=l(()=>"omp"===r?X(o,S):q(0,o),[o,r,S]),V=A.findIndex(e=>e.index===g),Z=A.map(e=>({value:String(e.index),label:_(e.model.label)})),F="claude"===r?["low","medium","high","xhigh","max"]:["low","medium","high","xhigh"],N=w?.supportedReasoningLevels?.map(e=>e.effort)??F,W=N.map(e=>({value:e,label:Y[e]??e})),G=m.reasoningEffort??w?.defaultReasoningLevel??N[0],H=Math.max(0,N.indexOf(G??"")),U=[{value:"",label:"Standard"},...(w?.speedTiers??[]).filter(e=>"default"!==e.id).map(e=>({value:e.id,label:e.label}))],ee=Math.max(0,U.findIndex(e=>e.value===(m.serviceTier??""))),ne=(w?.speedTiers?.length??0)>0,re=["codex","claude","omp","copilot"].filter(e=>0===i.length||i.includes(e));return u("div",{"data-model-picker":!0,"data-popmelt-font":"sans",onMouseEnter:x,onMouseLeave:y,style:{background:"#222",border:"1px solid #ddd",borderRadius:20,bottom:39,boxSizing:"border-box",display:"flex",flexDirection:"column",left:0,opacity:e?1:0,padding:4,pointerEvents:e?"auto":"none",fontFamily:Q,position:"absolute",transition:"opacity 120ms ease",width:139,zIndex:4,...t},children:[s("div",{style:{display:"flex",width:"100%"},children:re.map(e=>{let t=r===e;return s("button",{type:"button","aria-label":"Use "+("codex"===e?"GPT":"claude"===e?"Claude":"copilot"===e?"Copilot":"OMP"),"aria-pressed":t,disabled:!b,onClick:()=>b?.(e),style:{alignItems:"center",background:t?"#333":"transparent",border:0,borderRadius:24,color:t?"#eee":"#aaa",cursor:b?"pointer":"default",display:"flex",flex:1,justifyContent:"center",padding:"8px 10px",transition:"background-color 120ms ease, color 120ms ease"},children:s($,{provider:e,size:12})},e)})}),"omp"===r&&k.length>0&&u("div",{style:{position:"relative",width:"100%"},children:[s(c,{"aria-hidden":"true",size:12,strokeWidth:1.75,style:{color:"#777",left:10,opacity:R?1:0,pointerEvents:"none",position:"absolute",top:8,transition:"opacity 120ms ease",zIndex:3}}),z&&j&&s("div",{"aria-hidden":"true",style:{color:"#666",fontFamily:Q,fontSize:12,height:28,left:0,lineHeight:"28px",overflow:"hidden",padding:R?"0 10px 0 28px":"0 10px",pointerEvents:"none",position:"absolute",right:0,top:0,transition:"padding-left 120ms ease",whiteSpace:"pre",zIndex:1},children:O>=0?u(d,{children:[j.slice(0,O),s("span",{style:{color:"#eee"},children:j.slice(O,O+I.trim().length)}),j.slice(O+I.trim().length)]}):j}),s("input",{"aria-label":"OMP provider","aria-autocomplete":"inline",autoComplete:"off",onBlur:()=>{P(!1)},onChange:e=>{T(e.currentTarget.value),P(!0)},onFocus:e=>{P(!0),e.currentTarget.select()},onKeyDown:e=>{if("Enter"===e.key){let t=D[0];t&&(e.preventDefault(),B(t),e.currentTarget.blur())}else if("Tab"===e.key){let e=D[0];e&&j&&B(e)}else"Escape"===e.key&&e.currentTarget.blur()},onMouseEnter:()=>E(!0),onMouseLeave:()=>E(!1),placeholder:"Provider",value:I,style:{background:"transparent",border:0,borderRadius:0,boxSizing:"border-box",color:z&&j?"transparent":z||R?"#eee":"#aaa",caretColor:z&&!j?"#eee":"transparent",cursor:z?"text":"pointer",fontFamily:Q,fontSize:12,height:28,outline:"none",padding:R?"6px 10px 6px 28px":"6px 10px",position:"relative",transition:"color 120ms ease, padding-left 120ms ease",width:"100%",zIndex:2}})]}),s(te,{icon:p,options:Z,selectedIndex:V,displayLabel:V<0&&w?_(w.label):void 0,onSelect:C?e=>{let t=A[e];t&&(C?.(t.index),m.serviceTier&&!t.model.speedTiers?.some(e=>e.id===m.serviceTier)&&v?.({...m,serviceTier:void 0}))}:void 0,onScrubChange:M,scrub:!0}),s(te,{icon:f,options:W,selectedIndex:H,onSelect:v?e=>v({...m,reasoningEffort:W[e].value}):void 0,onScrubChange:M,scrub:!0,indicator:"effort"}),ne&&s(d,{children:s(te,{icon:ee>0?h:L,options:U,selectedIndex:ee,onSelect:v&&U.length>1?e=>v({...m,serviceTier:U[e].value||void 0}):void 0,indicator:"check",indicatorActive:ee>0})})]})}function re({provider:e,open:t,onClick:r,onMouseEnter:i,onMouseLeave:o,style:a}){let[l,d]=n(!1);return u("button",{type:"button","data-model-picker":!0,"aria-expanded":t,"aria-label":"Choose model settings",onMouseEnter:()=>{d(!0),i?.()},onMouseLeave:()=>{d(!1),o?.()},onClick:r,style:{alignItems:"center",background:t||l?"var(--popmelt-thread-control, #eaeaea)":"transparent",border:0,borderRadius:40,color:"var(--popmelt-thread-muted-strong, #888)",cursor:"pointer",display:"flex",gap:2,height:24,padding:"0 3px 0 6px",...a,transition:"background-color 120ms ease, color 120ms ease"},children:[s($,{provider:e,size:14}),s(g,{"aria-hidden":"true",size:12,strokeWidth:1.75,style:{transform:t?"rotate(180deg)":"rotate(0deg)",transition:"transform 120ms ease"}})]})}function ie(e,t){let n=new Set;for(let t of e){if("done"!==t.type&&"error"!==t.type)continue;let e=String(t.data.jobId??"");e&&n.add(e)}return t&&n.add(t),n}function oe(e,t,n){let r=new Set(t);return e.filter(e=>!r.has(e)&&!n.has(e))}function ae(e,t,n,r,i){if(!e)return null;let o=n=>!i.has(n)&&(t[n]?.threadId===e||r[n]===e);return n.find(o)??Object.keys(t).find(o)??null}function le(e,t){return new Set(e.filter(e=>"human"===e.lastMessageRole&&!t.has(e.id)).map(e=>e.id))}function se(e){return new Set(e.flatMap(e=>e.acknowledgedJobIds??[]))}function ue(e){return new Set(e.filter(e=>!e.pendingQuestion).map(e=>e.id))}function de(e,t){return!t||e.some(e=>!(e.jobId!==t||"assistant"!==e.role&&!e.error&&!e.cancelled||e.queued))}function ce(e,t){let n=`${t||"/"}:`;return e.startsWith(n)?e.slice(n.length)||null:e.startsWith("/")?null:e}function pe(e,t,n){let r=new Map,i=new Map;for(let n of e)if(0===(n.targetBindings?.length??0))for(let e of n.elementIdentifiers??[]){let n=ce(e,t);n&&i.set(n,(i.get(n)??0)+1)}for(let o of e){if(!o.lifecycle?.jobId)continue;let e={...o.lifecycle,jobId:o.lifecycle.jobId,color:o.color,title:o.title,annotationNumber:o.annotationNumber};if((o.targetBindings?.length??0)>0)for(let i of o.targetBindings??[]){if("opaque"===i.anchor.type){let t=n?.(i.anchor);if(!t?.length)continue;r.set(i.id,{...e,targetBindingId:i.id,selectors:t,continuationEligible:i.continuationEligible??!1});continue}if(i.anchor.pathname!==t)continue;let o=[i.anchor.runtimeSelector,i.anchor.structuralSelector,...i.anchor.legacySelectors??[]].filter(e=>!!e);r.set(i.id,{...e,targetBindingId:i.id,selectors:o,continuationEligible:i.continuationEligible??!1,...i.anchor.targetFingerprint?{targetFingerprint:i.anchor.targetFingerprint}:{}})}else for(let n of o.elementIdentifiers??[]){let a=ce(n,t);a&&![...r.values()].some(e=>e.selectors?.includes(a))&&r.set(`legacy:${o.lifecycle.threadId}:${a}`,{...e,selectors:[a],continuationEligible:1===(o.elementIdentifiers?.length??0)&&1===i.get(a)})}}return r}export{ce as A,pe as B,T as a,P as b,R as c,b as d,C as e,v as f,x as g,y as h,M as i,w as j,S as k,q as l,$ as m,A as n,Z as o,F as p,W as q,ne as r,re as s,ie as t,oe as u,ae as v,le as w,se as x,ue as y,de as z};
@@ -1 +0,0 @@
1
- "use client";import{b as e,c as t}from"./chunk-6VXFTT5U.mjs";var r=new Set;function n(t){return r.has(new URL(t).origin)?new a(t,!0):e(t)?new a(t):new EventSource(t)}var a=class{constructor(e,t=!1){this.readyState=0,this.onerror=null,this.controller=new AbortController,this.listeners=new Map,this.fail=()=>{this.controller.signal.aborted||(this.readyState=2,this.controller.abort(),this.emit("error",""),this.onerror?.call(this,new Event("error")))},typeof document<"u"&&document.addEventListener("resume",this.fail,{signal:this.controller.signal}),this.read(e,t)}addEventListener(e,t){let r=this.listeners.get(e)??new Set;r.add(t),this.listeners.set(e,r)}close(){this.readyState=2,this.controller.abort(),this.listeners.clear()}emit(e,t){let r=new MessageEvent(e,{data:t});for(let t of this.listeners.get(e)??[])t(r)}async read(e,t){try{if(t){let{readBridgeWebSocket:t}=await(import("./bridgeWebSocketStream-H3DCP4T3.mjs"));return void await t(e,this.controller.signal,(e,t)=>{"connected"===e&&(this.readyState=1),this.emit(e,t)})}let{readBridgeSSE:r}=await(import("./bridgeSSEStream-NEYI73TC.mjs"));await r(e,this.controller.signal,()=>{this.readyState=1},(e,t)=>this.emit(e,t))}catch{this.fail()}}},o="http://localhost:1111",i=new Map;function s(){return typeof window<"u"?window.__POPMELT_PROJECT_ID__??null:null}function l(e,r={}){return fetch(e,t(e,function(e={}){let t=s();if(!t)return e;let r=new Headers(e.headers);return r.set("X-Popmelt-Project-Id",t),{...e,headers:r}}(r)))}async function c(e,t,r){let n=new URLSearchParams({annotationId:t,kind:r.kind,name:r.name}),a=await h(`${e}/draft-attachments?${n}`,{method:"POST",headers:{"Content-Type":r.blob.type},body:r.blob},15e3);if(!a.ok)throw new Error((await a.json().catch(()=>null))?.error||`Bridge returned ${a.status}`);return(await a.json()).attachment}async function d(e,t){0!==t.length&&await h(`${e}/draft-attachments/claim`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:t})},5e3)}async function u(e,t){await h(`${e}/draft-attachments/${encodeURIComponent(t)}`,{method:"DELETE"},5e3)}async function p(e,t){if((i.get(e)??0)>Date.now())return null;try{let r=await h(`${e}/capture/native`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pageUrl:t.url,clip:t.clip,scale:t.scale})},2500);if(!r.ok)return i.set(e,Date.now()+(404===r.status||501===r.status?6e4:1e4)),null;let n=await r.blob();return n.size>0?n:null}catch{return i.set(e,Date.now()+1e4),null}}function h(e,t={},r=15e3){let n=new AbortController;t.signal&&t.signal.addEventListener("abort",()=>n.abort());let a=setTimeout(()=>n.abort(),r);return l(e,{...t,signal:n.signal}).finally(()=>clearTimeout(a))}async function f(e=o){try{let t=await h(`${e}/ui-preferences`,{},5e3);return t.ok?await t.json():null}catch{return null}}async function w(e,t){try{let r=await h(`${e}/ui-preferences`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({theme:t})},5e3);return r.ok?await r.json():null}catch{return null}}async function g(e=o,t){try{let r=t?`?refresh=${encodeURIComponent(t)}`:"",n=await h(`${e}/capabilities${r}`,{},t?35e3:5e3);return n.ok?await n.json():null}catch{return null}}async function m(e,t){let n=new AbortController,a=setTimeout(()=>n.abort(),t);try{let t=await l(`${e}/status`,{signal:n.signal});if(!t.ok)return null;let a=await t.json();return function(e,t){let n=new URL(e).origin;"websocket"===t?r.add(n):r.delete(n)}(e,a.eventTransport),a}catch{return null}finally{n.abort(),clearTimeout(a)}}async function y(e=o){return m(e,2e3)}async function b(e){return m(`http://localhost:${e}`,500)}async function $(e,t){if(e&&"http://localhost:1111"!==e)try{let r=new URL(e),n=await async function(e){return y(e)}(e);if(!n&&!t)return null;if((n||!t)&&(!n||!t||n.projectId===t)){if(n?.projectId&&!t)return null;if(n)return{url:e,port:parseInt(r.port,10)||1111,projectId:n.projectId}}}catch{if(!t)return null}let r=typeof window<"u"?window.location.origin:null,n=await b(1111);if(n){if(t&&n.projectId===t)return{url:"http://localhost:1111",port:1111,projectId:n.projectId};if(n.devOrigin&&r&&n.devOrigin===r&&(t||!n.projectId))return{url:"http://localhost:1111",port:1111,projectId:n.projectId}}let a=Array.from({length:8},(e,t)=>{let r=1112+t;return b(r).then(e=>e?{status:e,port:r}:null)}),o=(await Promise.all(a)).filter(e=>null!==e),i=[];n&&i.push({port:1111,devOrigin:n.devOrigin,projectId:n.projectId});for(let e of o)i.push({port:e.port,devOrigin:e.status.devOrigin,projectId:e.status.projectId});if(t){let e=i.find(e=>e.projectId===t);if(e)return{url:`http://localhost:${e.port}`,port:e.port,projectId:e.projectId}}if(r){let e=i.find(e=>e.devOrigin===r&&(t||!e.projectId));if(e)return{url:`http://localhost:${e.port}`,port:e.port,projectId:e.projectId}}return 1!==i.length||i[0].projectId?null:{url:`http://localhost:${i[0].port}`,port:i[0].port,projectId:i[0].projectId}}async function I(e=o,t,r=-1,n={}){try{let a=await h(`${e}/jobs/${t}/events?afterSeq=${r}`,{},5e3);if(404===a.status||410===a.status)return null;if(!a.ok){if(n.retryUnavailable&&(429===a.status||a.status>=500))throw new Error("Bridge history is temporarily unavailable");return null}return await a.json()}catch(e){if(n.retryUnavailable)throw e;return null}}async function j(e,t,r=o,n,a,i,s,l,c,d,u,p,f){let w=S({screenshots:e,feedbackJson:t,color:n,provider:a,model:i,pastedImages:s,sourceId:l,agentSettings:c,continuationThreadId:d,continuationSelectorAliases:u,continuationTargetBindingId:p}),g=await h(`${r}/send`,{method:"POST",body:w,...f?{headers:{"X-Popmelt-Peer-Grant":f}}:{}},3e4);if(!g.ok){let e=await g.text();throw new Error(`Bridge returned ${g.status}: ${e}`)}return g.json()}function S({screenshots:e,feedbackJson:t,color:r,provider:n,model:a,pastedImages:o,sourceId:i,agentSettings:s,continuationThreadId:l,continuationSelectorAliases:c,continuationTargetBindingId:d}){let u=new FormData;if(e instanceof Map){let t=!0;for(let[r,n]of e){let e=encodeURIComponent(r);u.append(`screenshot-${e}`,n,`screenshot-${e}.webp`),t&&(u.append("screenshot",n,"screenshot.webp"),t=!1)}t&&u.append("screenshot",new Blob([],{type:"image/webp"}),"screenshot.webp")}else u.append("screenshot",e,"screenshot.webp");if(u.append("feedback",t),r&&u.append("color",r),n&&u.append("provider",n),a&&u.append("model",a),function(e,t){t?.reasoningEffort&&e.append("reasoningEffort",t.reasoningEffort),t?.serviceTier&&e.append("serviceTier",t.serviceTier)}(u,s),i&&u.append("sourceId",i),l&&u.append("continuationThreadId",l),d&&u.append("continuationTargetBindingId",d),c?.length&&u.append("continuationSelectorAliases",JSON.stringify(c)),o)for(let[e,t]of o)for(let r=0;r<t.length;r++)u.append(`image-${e}-${r}`,t[r],`image-${e}-${r}.webp`);return u}async function k(e=o){let t=()=>({head:{sequence:0,updatedAt:new Date(0).toISOString()},counts:{total:0,emerging:0,testing:0,grounded:0,challenged:0,retired:0,needsGrounding:0},explanations:[]});try{let r=await h(`${e}/memory/imprint-view`,{},5e3);return r.ok?r.json():t()}catch{return t()}}function T(e){return new Promise(t=>setTimeout(t,e))}async function v(e=o,t,r=15e3){let n=Date.now();try{let t=await h(`${e}/restart`,{method:"POST"},5e3);if(!t.ok){let e=await t.text().catch(()=>"");return{ok:!1,error:e?`Bridge restart returned ${t.status}: ${e}`:`Bridge restart returned ${t.status}`,elapsedMs:Date.now()-n}}}catch(e){return{ok:!1,error:e instanceof Error?e.message:"Bridge restart request failed",elapsedMs:Date.now()-n}}let a=null,i=e,l=s();for(;Date.now()-n<r;){if(await T(350),a=await y(i),!a?.ok&&l){let t=await $(e,l);t?.url&&(i=t.url,a=await y(i))}if(a?.ok&&(!l||a.projectId===l)&&(!t||a.version===t))return{ok:!0,status:a,elapsedMs:Date.now()-n,bridgeUrl:i}}let c=t?` with version ${t}`:"";return a?.ok&&t&&a.version!==t?{ok:!1,error:`Bridge is running version ${a.version??"unknown"}, but this page expects ${t}. Refresh the page to load the current package. If the mismatch remains, rebuild or update the package used by the bridge, then restart it.`,status:a,elapsedMs:Date.now()-n}:{ok:!1,error:`Bridge did not come back${c} within ${Math.round(r/1e3)}s`,status:a,elapsedMs:Date.now()-n}}async function O(e=o){return(await v(e)).ok}async function E(e,t,r=o,n,a,i,s,l,c,d){let u,p=`${r}/reply`;if(s&&s.length>0){let r=new FormData,o=new Blob([new Uint8Array([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,6,0,0,0,31,21,196,137,0,0,0,10,73,68,65,84,120,156,98,0,0,0,2,0,1,229,39,222,252,0,0,0,0,73,69,78,68,174,66,96,130])],{type:"image/png"});r.append("screenshot",o,"screenshot.png"),r.append("feedback",JSON.stringify({threadId:e,reply:t,color:n,provider:a,model:i,sourceId:l,...c,...d}));for(let e=0;e<s.length;e++)r.append(`image-reply-${e}`,s[e],`reply-image-${e}.webp`);u={method:"POST",body:r}}else u={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:e,reply:t,color:n,provider:a,model:i,sourceId:l,...c,...d})};let f=await h(p,u,3e4);if(!f.ok){let e=await f.text();throw new Error(`Bridge returned ${f.status}: ${e}`)}return f.json()}async function P(e,t=o){let r=await h(`${t}/thread/${encodeURIComponent(e)}/archive`,{method:"POST"},15e3);if(!r.ok&&404!==r.status){let e=await r.text();throw new Error(`Bridge returned ${r.status}: ${e}`)}return r.json()}async function B(e,t=o){let r=await h(`${t}/thread/${encodeURIComponent(e)}/restore`,{method:"POST"},15e3);if(!r.ok)throw new Error(`Thread restore failed: ${r.status}`)}async function C(e=o){let t=await h(`${e}/workspace/clear`,{method:"POST"},5e3);if(!t.ok){let e=await t.text();throw new Error(`Bridge returned ${t.status}: ${e}`)}return t.json()}export{n as a,l as b,c,d,u as e,p as f,f as g,w as h,g as i,y as j,$ as k,I as l,j as m,S as n,k as o,v as p,O as q,E as r,P as s,B as t,C as u};