!function(){const e=document.location.search.match(/\bid=([\w-]+)/)[1],a=new class{constructor(){this.handlers=new Map,window.addEventListener("message",(e=>{const a=e.source===window.parent;let r=!1;for(let a=0;a<window.frames.length;a++){const n=window.frames[a];if(e.origin===n.origin){r=!0;break}}if(r&&e.data&&("onmessage"===e.data.command||"do-update-state"===e.data.command||"onconsole"===e.data.command))this.postMessage(e.data.command,e.data.data);else if(r||a){const a=e.data.channel,r=this.handlers.get(a);r?r(e,e.data.args):console.error("no handler for ",e)}}))}postMessage(a,r){window.parent.postMessage({target:e,channel:a,data:r},"*");let n=window;for(;n.parent!==n;)n=n.parent,n.opener&&n.opener.postMessage({target:e,channel:a,data:r,fromSecondary:!0},"*")}onMessage(e,a){this.handlers.set(e,a)}},r=new Promise((async e=>{if(!function(){try{return!!navigator.serviceWorker}catch(e){return!1}}())return console.error("Service Workers are not enabled. Webviews will not work properly"),e();navigator.serviceWorker.register("service-worker.js").then((async a=>{await navigator.serviceWorker.ready;const r=n=>{if("version"===n.data.channel)return navigator.serviceWorker.removeEventListener("message",r),1===n.data.version?e():a.update().then((()=>navigator.serviceWorker.ready)).finally(e)};navigator.serviceWorker.addEventListener("message",r),a.active.postMessage({channel:"version"})}));const r=e=>{a.onMessage(e,(a=>{navigator.serviceWorker.ready.then((r=>{r.active.postMessage({channel:e,data:a.data.args})}))}))};r("did-load-resource"),r("did-load-localhost"),navigator.serviceWorker.addEventListener("message",(e=>{["load-resource","load-localhost"].includes(e.data.channel)&&a.postMessage(e.data.channel,e.data)}))}));window.createWebviewManager({postMessage:a.postMessage.bind(a),onMessage:a.onMessage.bind(a),ready:r,fakeLoad:!0})}();