import{w}from"./chunk-EPOLDU6W-BCLmut3y.js";import{j as m}from"./jsx-runtime-C5WNSv3b.js";import{r as u}from"./index-CqIc3cxq.js";import{E as g,D as h}from"./epic-video-BJW6MU1i.js";import"./use-event-source-BuD4_2SF.js";import"./index-DzdDahau.js";import"./index-vDCSPjrM.js";import"./index-CdzVFL-Z.js";import"./misc-W4055b-0.js";import"./tooltip-Tlsyx2YO.js";import"./root-loader-BOzEMapJ.js";import"./pe-CIZUOJMr.js";import"./schemas-Uj5SZtvt.js";import"./online-DiNLkgTC.js";import"./loading-CDNzW5oO.js";import"./format-CZ5n8p10.js";import"./user-BsPobzjB.js";import"./workshop-config-Zfc8zU0x.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:d,error:f}=a.data.payload;if(f)return o(f);if(!s)return t(d);const c=s.safeParse(d);return c.success?t(c.data):o(c.error)}window.addEventListener("message",n)})}const H=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 m.jsx("div",{ref:i,onClickCapture:s,children:m.jsx(g,{epicVideoInfosPromise:r.videoInfos,children:m.jsx(h,{url:r.videoUrl})})})});export{H as default};
//# sourceMappingURL=epic-video-jtxu_0bl.js.map
