(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[803],{96597:function(t,e,a){Promise.resolve().then(a.bind(a,7840))},7840:function(t,e,a){"use strict";a.r(e),a.d(e,{default:function(){return f}});var r=a(57437),i=a(2265),n=a(14735),s=a(6877),l=a(59511),o=a(50386);function c(t){let{initialProjectState:e}=t,[a,c]=i.useState((0,n.fV)()),[d,u]=i.useState(e),[h,p]=i.useState({python:d.python,requirements:d.requirements}),{fsWorkerComm:f,fsReady:m}=(0,l.VC)({pageId:a}),[j,g]=i.useState(!1);return i.useEffect(()=>{let t=!1,e=async()=>{let e=d.code,a=d.requirements,r={...d};if(e.startsWith("http://")||e.startsWith("https://")){let t=await fetch("/i/request_proxy?uri=".concat(e));e=await t.text(),r={...r,code:e}}if((a.startsWith("http://")||a.startsWith("https://"))&&a.endsWith(".txt")){let t=await fetch("/i/request_proxy?uri=".concat(a));a=await t.text(),r={...r,requirements:a}}await (0,o._R)({projectState:r,fsWorkerComm:f}),t||(p({...h,requirements:d.requirements}),u(r),g(!0))};return m&&e(),()=>{t=!0}},[m,a]),(0,r.jsx)(r.Fragment,{children:j?(0,r.jsx)(s.Z,{type:d.type,start:"",pageId:a,python:h.python},"python-".concat(a)):(0,r.jsx)("div",{children:"Loading filesystem"})})}var d=a(93646),u=a(7032),h=a(91929),p=a(38615);function f(){let t=i.useMemo(()=>window.location.search.includes("iframe"),[]),[e,a]=i.useState(null),[n,s]=i.useState(null),[l,o]=i.useState(null);return(i.useEffect(()=>{console.info("listening for messages"),window.parent.postMessage("ready","*");let t=new p.C,e=async e=>{if(t.handleEvent(e),"loadProject"===e.data.type){let e=t.getProjectDataOnce(),a=e.signatureJwt;if(null===a){s(e.projectState),o("trial");return}await (0,d.gW)(e.projectState,a)?(s(e.projectState),o("valid")):o("invalid")}};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[]),e)?(0,r.jsx)("h2",{children:e}):null!==n?(0,r.jsxs)(r.Fragment,{children:["invalid"===l&&(0,r.jsx)("h1",{children:"Error: Invalid signature"}),"trial"===l&&u.Xd.isPublic&&(0,r.jsxs)("h3",{style:{textAlign:"center",backgroundColor:"var(--color-primary)",padding:"1em 0",margin:"0"},children:["Trial version, if you would like to remove this message, please contact us at"," ",(0,r.jsx)("a",{href:"https://py.cafe/contact",target:"_blank",children:"PyCafe"}),(0,r.jsx)(h.Z,{style:{marginLeft:"0.4em",verticalAlign:"text-bottom"},children:"keyboard_double_arrow_right"})]}),"trial"===l&&!u.Xd.isPublic&&(0,r.jsxs)("h3",{style:{textAlign:"center",backgroundColor:"var(--color-primary)",padding:"1em 0",margin:"0"},children:["This file was created with a trial account, please obtain a license key at"," ",(0,r.jsx)("a",{href:"https://py.cafe/contact",target:"_blank",children:"PyCafe"}),(0,r.jsx)(h.Z,{style:{marginLeft:"0.4em",verticalAlign:"text-bottom"},children:"keyboard_double_arrow_right"})]}),(0,r.jsx)("div",{id:"iframe-parent",style:{display:"flex",flexDirection:"column",alignItems:"stretch",height:"trial"===l&&u.Xd.isPublic?"calc(100dvh - 66px)":"100dvh",background:"none",backgroundColor:"var(--color-material-background)"},children:(0,r.jsx)("div",{style:{flex:"1 0 0"},children:(0,r.jsx)(c,{initialProjectState:n})})})]}):t?(0,r.jsx)("h1",{children:"Loading project..."}):(0,r.jsx)("h1",{children:"Error - No project opened."})}},38615:function(t,e,a){"use strict";a.d(e,{C:function(){return r}});class r{handleEvent(t){if("loadProject-file-part"===t.data.type){let e=t.data.name,a=t.data.part;this.fileParts[e]=(this.fileParts[e]||"")+a}"loadProject"===t.data.type&&(this.projectData=t.data.projectData,this.projectData.projectState.files=this.projectData.projectState.files.map(t=>{let e=this.fileParts[t.name];return this.fileParts[t.name]="",e&&(t.content=e),t}))}getProjectDataOnce(){let t=this.projectData;return this.projectData=null,t}constructor(){this.fileParts={},this.projectData=null}}}},function(t){t.O(0,[436,72,218,155,50,182,36,543,5,386,971,117,744],function(){return t(t.s=96597)}),_N_E=t.O()}]);