import{s as g}from"./chunk-DZLz74EQ.js";import{t as f}from"./react-BcIddLXZ.js";import{n as w}from"./jsx-runtime-DvsdsEjx.js";import{o as u,u as c}from"./hotkeys-Lbk6RHir.js";import{n as v}from"./constants-DIZnpo2K.js";import{g as y}from"./config-BjdJmdrN.js";import{t as h}from"./createLucideIcon-DA8ZBm4D.js";var x=h("case-sensitive",[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]]);const S=typeof window<"u"&&window.parent!==window;function _(){new URLSearchParams(window.location.search).has(v.vscode)&&(!S||y()||(c.log("[vscode] Registering VS Code bindings"),E(),k(),b(),L()))}function k(){window.addEventListener("copy",()=>{var e;i({command:"copy",text:((e=window.getSelection())==null?void 0:e.toString())??""})}),window.addEventListener("cut",()=>{var t;let e=((t=window.getSelection())==null?void 0:t.toString())??"";u()&&document.execCommand("insertText",!1,""),i({command:"cut",text:e})}),window.addEventListener("message",async e=>{try{let t=e.data,o=u();switch(t.command){case"paste":if(c.log(`[vscode] Received paste mac=${o}`,t),o){let a=document.activeElement;if(!a){c.warn("[vscode] No active element to paste into"),document.execCommand("insertText",!1,t.text);return}let s=new DataTransfer;s.setData("text/plain",t.text),a.dispatchEvent(new ClipboardEvent("paste",{clipboardData:s}))}else c.log("[vscode] Not pasting on mac");return}}catch(t){c.error("Error in paste message handler",t)}})}function E(){document.addEventListener("keydown",e=>{var t,o;if((e.ctrlKey||e.metaKey)&&e.key==="c"){let a=((t=window.getSelection())==null?void 0:t.toString())??"";c.log("[vscode] Sending copy",a),i({command:"copy",text:a});return}if((e.ctrlKey||e.metaKey)&&e.key==="x"){let a=((o=window.getSelection())==null?void 0:o.toString())??"";u()&&document.execCommand("insertText",!1,""),c.log("[vscode] Sending cut",a),i({command:"cut",text:a});return}if((e.ctrlKey||e.metaKey)&&e.key==="v"){c.log("[vscode] Sending paste"),i({command:"paste"});return}})}function b(){document.addEventListener("click",e=>{let t=e.target;if(t.tagName!=="A")return;let o=t.getAttribute("href");o&&(o.startsWith("http://")||o.startsWith("https://"))&&(e.preventDefault(),i({command:"external_link",url:o}))})}function L(){document.addEventListener("contextmenu",e=>{e.preventDefault(),i({command:"context_menu"})})}function i(e){var t;(t=window.parent)==null||t.postMessage(e,"*")}var K=g(w(),1),C=g(f(),1);function D(e){let t=(0,K.c)(6),[o,a]=(0,C.useState)(e),s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=n=>{var r;(r=n==null?void 0:n.stopPropagation)==null||r.call(n),a(!0)},t[0]=s):s=t[0];let m;t[1]===Symbol.for("react.memo_cache_sentinel")?(m=n=>{var r;(r=n==null?void 0:n.stopPropagation)==null||r.call(n),a(!1)},t[1]=m):m=t[1];let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=n=>{var r;(r=n==null?void 0:n.stopPropagation)==null||r.call(n),a(T)},t[2]=d):d=t[2];let l;t[3]===Symbol.for("react.memo_cache_sentinel")?(l={setTrue:s,setFalse:m,toggle:d},t[3]=l):l=t[3];let p;return t[4]===o?p=t[5]:(p=[o,l],t[4]=o,t[5]=p),p}function T(e){return!e}export{x as i,_ as n,i as r,D as t};
