import{M as i,T as c}from"./messages-CjQo1qp0.js";(function(){chrome.runtime.onMessage.addListener((t,r,n)=>{if(t&&t.type===i.GET_SELECTION_CONTEXT){try{const e={selection:d(),title:document.title||"",url:location.href};n({type:i.SELECTION_CONTEXT,payload:e})}catch(e){n({type:i.SELECTION_CONTEXT,error:String(e)})}return!0}if(t&&t.type===i.TOAST){const{message:e,variant:o=c.SUCCESS}=t.payload||{};a(e||"",o)}});function d(){try{const t=window.getSelection&&window.getSelection();return t?t.toString().trim():""}catch{return""}}function a(t,r=c.SUCCESS){try{const n="mem0-context-toast",e=document.getElementById(n);e&&e.remove();const o=document.createElement("div");o.id=n,o.textContent=t,o.style.cssText=`
            position: fixed;
            top: 16px;
            right: 16px;
            z-index: 2147483647;
            background: ${r===c.ERROR?"#7f1d1d":"#14532d"};
            color: #fff;
            padding: 10px 12px;
            border-radius: 8px;
            font-size: 13px;
            box-shadow: 0 6px 18px rgba(0,0,0,0.25);
            max-width: 360px;
          `,document.body.appendChild(o),setTimeout(()=>{o.remove()},2200)}catch{}}})();
