import{s as x}from"./chunk-LvLJmgfZ.js";import{p}from"./useEvent-D91BmmQi.js";import{t as y}from"./react-Bj1aDYRI.js";import{t as S}from"./compiler-runtime-B3qBwwSJ.js";import{f as w,g as s}from"./useEventListener-C0195JsF.js";import{r as b}from"./constants-CDyU_g2F.js";import{M as z}from"./config-B-Q7J_6d.js";import{t as k}from"./createLucideIcon-w-Qo9n0R.js";var E=k("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"}]]),f=x(y(),1);const _=e=>{let t=null,n=async()=>(t||(t=e()),t);return{preload:n,Component:f.lazy(()=>n())}},R=typeof window<"u"&&window.parent!==window;function C(){new URLSearchParams(window.location.search).has(b.vscode)&&(!R||z()||(s.log("[vscode] Registering VS Code bindings"),D(),L(),K(),T()))}function L(){window.addEventListener("copy",()=>{var e;d({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())??"";w()&&document.execCommand("insertText",!1,""),d({command:"cut",text:e})}),window.addEventListener("message",async e=>{try{let t=e.data,n=w();switch(t.command){case"paste":if(s.log(`[vscode] Received paste mac=${n}`,t),n){let r=document.activeElement;if(!r){s.warn("[vscode] No active element to paste into"),document.execCommand("insertText",!1,t.text);return}let i=new DataTransfer;i.setData("text/plain",t.text),r.dispatchEvent(new ClipboardEvent("paste",{clipboardData:i}))}else s.log("[vscode] Not pasting on mac");return}}catch(t){s.error("Error in paste message handler",t)}})}function D(){document.addEventListener("keydown",e=>{var t,n;if((e.ctrlKey||e.metaKey)&&e.key==="c"){let r=((t=window.getSelection())==null?void 0:t.toString())??"";s.log("[vscode] Sending copy",r),d({command:"copy",text:r});return}if((e.ctrlKey||e.metaKey)&&e.key==="x"){let r=((n=window.getSelection())==null?void 0:n.toString())??"";w()&&document.execCommand("insertText",!1,""),s.log("[vscode] Sending cut",r),d({command:"cut",text:r});return}if((e.ctrlKey||e.metaKey)&&e.key==="v"){s.log("[vscode] Sending paste"),d({command:"paste"});return}})}function K(){document.addEventListener("click",e=>{let t=e.target;if(t.tagName!=="A")return;let n=t.getAttribute("href");n&&(n.startsWith("http://")||n.startsWith("https://"))&&(e.preventDefault(),d({command:"external_link",url:n}))})}function T(){document.addEventListener("contextmenu",e=>{e.preventDefault(),d({command:"context_menu"})})}function d(e){var t;(t=window.parent)==null||t.postMessage(e,"*")}var P={width:void 0,height:void 0};function A(e){let{ref:t,box:n="content-box",skip:r}=e,i=(0,f.useRef)({...P}),c=(0,f.useRef)(void 0);c.current=e.onResize,(0,f.useEffect)(()=>{if(!t.current||r||typeof window>"u"||!("ResizeObserver"in window))return;let m=new ResizeObserver(([l])=>{let u=n==="border-box"?"borderBoxSize":n==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",o=g(l,u,"inlineSize"),a=g(l,u,"blockSize");if(i.current.width!==o||i.current.height!==a){let h={width:o,height:a};i.current.width=o,i.current.height=a,c.current&&c.current(h)}});return m.observe(t.current,{box:n}),()=>{m.disconnect()}},[n,t,r])}function g(e,t,n){return e[t]?Array.isArray(e[t])?e[t][0][n]:e[t][n]:t==="contentBoxSize"?e.contentRect[n==="inlineSize"?"width":"height"]:void 0}const v=p(!1),B=p(new Set),M=p(e=>{var t;return((t=e(B))==null?void 0:t.size)===0}),N=p(!1);p(e=>e(N)&&e(v)===!1);var O=S();function q(e){let t=(0,O.c)(6),[n,r]=(0,f.useState)(e),i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=o=>{var a;(a=o==null?void 0:o.stopPropagation)==null||a.call(o),r(!0)},t[0]=i):i=t[0];let c;t[1]===Symbol.for("react.memo_cache_sentinel")?(c=o=>{var a;(a=o==null?void 0:o.stopPropagation)==null||a.call(o),r(!1)},t[1]=c):c=t[1];let m;t[2]===Symbol.for("react.memo_cache_sentinel")?(m=o=>{var a;(a=o==null?void 0:o.stopPropagation)==null||a.call(o),r(W)},t[2]=m):m=t[2];let l;t[3]===Symbol.for("react.memo_cache_sentinel")?(l={setTrue:i,setFalse:c,toggle:m},t[3]=l):l=t[3];let u;return t[4]===n?u=t[5]:(u=[n,l],t[4]=n,t[5]=u),u}function W(e){return!e}export{C as a,E as c,A as i,M as n,d as o,v as r,_ as s,q as t};
