"use strict";(self.webpackChunkpyesasky=self.webpackChunkpyesasky||[]).push([[199],{199:(e,t,s)=>{s.r(t),s.d(t,{default:()=>d});var i=s(454);class o extends i.DOMWidgetModel{defaults(){return{...super.defaults(),_model_name:"IFrameModel",_view_name:"IFrameView",_model_module:"pyesasky",_view_module:"pyesasky",view_module_ids:[]}}}class n extends i.DOMWidgetView{constructor(){super(...arguments),this.modelId="",this.prevMsgId="",this.prevMsgIdToFront="",this.baseUrl="https://sky.esa.int",this.hideWelcome=!0,this.hideSciSwitch=!0,this.sci=!0,this.hideBannerInfo=!0}render(){this.modelId="esaskyFrame"+Math.random().toString(36).substring(2,10);const e=new URLSearchParams({hide_welcome:this.hideWelcome.toString(),hide_sci_switch:this.hideSciSwitch.toString(),sci:this.sci.toString(),hide_banner_info:this.hideBannerInfo.toString()}),t=`${this.baseUrl}?${e.toString()}`;this.model.set("_view_module_ids",[...this.model.get("_view_module_ids"),this.modelId]);const s=document.createElement("div"),i=document.createElement("iframe");i.setAttribute("id",this.modelId.toString()),i.setAttribute("width","100%"),i.setAttribute("height","800px"),i.setAttribute("style","border: none"),i.setAttribute("src",t),i.onload=()=>{i.contentWindow&&(i.contentWindow.postMessage({event:"initTest",origin:"pyesasky"},this.baseUrl),console.log("Init message sent"))},s.appendChild(i),this.el.appendChild(s),new MutationObserver((()=>{this.el.style.height="auto"})).observe(this.el,{attributes:!0,childList:!0}),this.model.on("msg:custom",this.handle_custom_message,this),this.listenTo(this.model,"change:view_height",this.height_changed),window.addEventListener("message",(e=>{const t=e.data;console.log("Recieved message from iFrame"),console.log("Sending message to backend"),this.prevMsgId!==t.msgId&&(this.prevMsgId=t.msgId,this.model.send(t))}))}height_changed(){console.log("Changing view height");const e=this.model.get("view_height"),t=this.model.get("_view_module_ids");for(const s of t.reverse()){const t=document.getElementById(s);if(t){t.style.height=e;break}}}handle_custom_message(e){const t=this.model.get("_view_module_ids").find((e=>null!==document.getElementById(e)));if(t&&this.prevMsgIdToFront!==e.msgId&&this.modelId===t){console.log("Sending message to iFrame");const t=document.getElementById(this.modelId);(null==t?void 0:t.contentWindow)&&(this.prevMsgIdToFront=e.msgId,t.contentWindow.postMessage(e,this.baseUrl))}}}const d={id:"pyesasky:plugin",requires:[i.IJupyterWidgetRegistry],description:"ESASky Python wrapper",autoStart:!0,activate:(e,t)=>{console.log("JupyterLab extension pyesasky is activated!"),t.registerWidget({name:"pyesasky",version:"2.0.0",exports:{IFrameModel:o,IFrameView:n}})}}}}]);