"use strict";(()=>{var b=Object.defineProperty;var o=(e,t)=>b(e,"name",{value:t,configurable:!0});function k(){var t;return(t=new URLSearchParams(window.location.search).get("id"))!=null?t:null}o(k,"getId");function n(e){let t={...e,id:k()};parent==null||parent.postMessage(t,"https://replit.com"),parent==null||parent.postMessage(t,"https://staging.replit.com"),parent==null||parent.postMessage(t,"https://firewalledreplit.com/"),parent==null||parent.postMessage(t,"https://staging.firewalledreplit.com/"),parent==null||parent.postMessage(t,"http://localhost:3000")}o(n,"postMessageToWorkspace");var D=document.getElementById("iframe");function d(){try{return D.contentWindow.document.body,!0}catch{return!1}}o(d,"canAccessIframeWindow");var u="/devtools/devtools.js";var S="/devtools/devtools-react.js";function x(e){return`/__replco/static/${e.replace(/^\/+/,"")}`}o(x,"getStaticPath");function p(e){let t=document.createElement("script");return t.async=!1,t.src=x(e),t}o(p,"createScript");var v="__replit_devtools__",g=document.getElementById("iframe");function f(e){function t(){if(!d()){n({type:"page-navigation",payload:{isExternal:!0}});return}let a=new URL(e),c=a.pathname+a.search+a.hash;n({type:"page-navigation",payload:{isExternal:!1,path:a.pathname,relativeUrl:c}});let r=g.contentWindow.document;if(r.getElementById(v))return;let s=p(u);s.id=v,r.head.appendChild(s)}o(t,"onload"),g.addEventListener("load",t),g.src=e}o(f,"fallbackLoad");var i=document.getElementById("iframe");async function W(e){let a=i.contentWindow.location.href;for(let r=0;r<10&&(await new Promise(s=>setTimeout(s,0)),!(!d()||a!==i.contentWindow.location.href));r++);if(!d()){n({type:"page-navigation",payload:{isExternal:!0}});return}i.contentWindow.stop();let c;try{c=i.contentWindow.location.href}catch{n({type:"page-load-error"});return}try{i.setAttribute("srcdoc","
"),h(c)}catch{n({type:"page-load-error"})}}o(W,"unloadHandler");async function h(e){var L;let t=new URL(e,window.location.origin);if(t.origin!==window.location.origin){f(e);return}let a=t.pathname+t.search+t.hash,c=t.href,r=await fetch(c,{method:"GET",credentials:"same-origin"});if(!r.ok)if(r.status===404)n({type:"page-load-error",payload:{statusCode:r.status}});else throw new Error(`fetch-error: ${r.status} ${r.statusText}`);let s=await r.text(),l=new DOMParser().parseFromString(s,"text/html"),y=document.createElement("script");y.innerHTML=`history.pushState(null, null, ${JSON.stringify(a)});`;let w=l.createElement("base");w.href=c,l.head.prepend(w);let O=p(u),E=[y,O];(s.includes("import RefreshRuntime from")||s.includes(''))&&E.unshift(p(S)),l.head.prepend(...E);let m=i.contentDocument;m.open(),((L=l.doctype)==null?void 0:L.name)==="html"&&m.write(""),m.write(l.documentElement.outerHTML),m.close(),n({type:"page-navigation",payload:{isExternal:!1,path:t.pathname,relativeUrl:a}});function T(){i.contentWindow.removeEventListener("unload",W),i.contentWindow.addEventListener("unload",W)}o(T,"attachUnload"),i.addEventListener("load",T),T()}o(h,"fetchLoad");async function M(e){try{await h(e);return}catch(t){console.log("error fetchLoad failed"),console.error(t)}try{f(e)}catch{n({type:"page-load-error"})}}o(M,"tryLoad");var I=new URLSearchParams(window.location.search),_,P=(_=I.get("initialPath"))!=null?_:"/";M(P);window.addEventListener("message",e=>{e.origin===location.origin?n(e.data):document.getElementById("iframe").contentWindow.postMessage(e.data,location.origin)});})();