import{w}from"./chunk-UIGDSWPH-BWkP6tD5.js";import{j as d}from"./jsx-runtime-C5WNSv3b.js";import{r as u}from"./index-Az39ZADK.js";import{E as g,D as h}from"./epic-video-Rho2ab6H.js";import"./index-_LzGTKVC.js";import"./misc-BapXpylh.js";import"./tooltip-C2AQeNhD.js";import"./index-CjiomtK6.js";import"./root-loader-C5P2c7MU.js";import"./pe-Bs-DFNma.js";import"./types-Cl2NuNg4.js";import"./online-Dw7HU4wM.js";import"./loading-DyvhEH4Q.js";import"./user-DtZkTMil.js";import"./workshop-config-DCYN9tG7.js";function l(p,r,i={}){const{schema:s}=i,e=crypto.randomUUID();return new Promise((t,o)=>{if(!window.parent||window.parent===window){console.log("[MCP] No parent frame available. Would have sent message:",{type:p,messageId:e,payload:r}),o(new Error("No parent frame available"));return}window.parent.postMessage({type:p,messageId:e,payload:r},"*");function n(a){if(a.data.type!=="ui-message-response"||a.data.messageId!==e)return;window.removeEventListener("message",n);const{response:f,error:m}=a.data.payload;if(m)return o(m);if(!s)return t(f);const c=s.safeParse(f);return c.success?t(c.data):o(c.error)}window.addEventListener("message",n)})}const b=w(function({loaderData:r}){const i=u.useRef(null);u.useEffect(()=>{r.videoInfos?.finally(()=>{if(window.parent.postMessage({type:"ui-lifecycle-iframe-ready"},"*"),!i.current)return;const e=i.current.clientHeight,t=i.current.clientWidth;window.parent.postMessage({type:"ui-size-change",payload:{height:e,width:t}},"*")})},[r.videoInfos]);async function s(e){const t=e.target;if(!(t instanceof HTMLAnchorElement))return;const o=t.href;if(!o)return;e.preventDefault(),e.stopPropagation();const n=o.startsWith("http")?new URL(o):new URL(o,window.location.origin);n.host===window.location.host&&n.pathname==="/login"&&await l("tool",{toolName:"login",params:{workshopDirectory:ENV.EPICSHOP_CONTEXT_CWD}}),await l("link",{url:n.toString()})}return d.jsx("div",{ref:i,onClickCapture:s,children:d.jsx(g,{epicVideoInfosPromise:r.videoInfos,children:d.jsx(h,{url:r.videoUrl})})})});export{b as default};
//# sourceMappingURL=epic-video-8RM8jhE6.js.map
