(function(){const d=document.location.search.match(/\bid=([\w-]+)/)[1],t=/platform=electron/.test(document.location.search),a=new class{constructor(){this.handlers=new Map,window.addEventListener("message",r=>{if(r.data&&(r.data.command==="onmessage"||r.data.command==="do-update-state")){this.postMessage(r.data.command,r.data.data);return}const s=r.data.channel,o=this.handlers.get(s);if(o)for(const n of o)n(r,r.data.args);else console.log("no handler for ",r)})}postMessage(r,s){window.parent.postMessage({target:d,channel:r,data:s},"*")}onMessage(r,s){let o=this.handlers.get(r);o||(o=[],this.handlers.set(r,o)),o.push(s)}};function c(e){console.error(`Webview fatal error: ${e}`),a.postMessage("fatal-error",{message:e})}const l=new Promise(async e=>{if(t)return e();if(!f())return c("Service Workers are not enabled in browser. Webviews will not work."),e();const r=1;navigator.serviceWorker.register("service-worker.js").then(async o=>{await navigator.serviceWorker.ready;const n=i=>{if(i.data.channel==="version")return navigator.serviceWorker.removeEventListener("message",n),i.data.version===r?e():o.update().then(()=>navigator.serviceWorker.ready).finally(e)};navigator.serviceWorker.addEventListener("message",n),o.active.postMessage({channel:"version"})},o=>{c(`Could not register service workers: ${o}.`),e()});const s=o=>{a.onMessage(o,n=>{navigator.serviceWorker.ready.then(i=>{i.active.postMessage({channel:o,data:n.data.args})})})};s("did-load-resource"),s("did-load-localhost"),navigator.serviceWorker.addEventListener("message",o=>{["load-resource","load-localhost"].includes(o.data.channel)&&a.postMessage(o.data.channel,o.data)})});function f(){try{return!!navigator.serviceWorker}catch(e){return!1}}const g=new class{constructor(){this.confirmBeforeClose="keyboardOnly",this.isModifierKeyDown=!1,a.onMessage("set-confirm-before-close",(e,r)=>{this.confirmBeforeClose=r}),a.onMessage("content",(e,r)=>{this.confirmBeforeClose=r.confirmBeforeClose}),window.addEventListener("beforeunload",e=>{if(!t)switch(this.confirmBeforeClose){case"always":return e.preventDefault(),e.returnValue="","";case"never":break;case"keyboardOnly":default:{if(this.isModifierKeyDown)return e.preventDefault(),e.returnValue="","";break}}})}onIframeLoaded(e){e.contentWindow.addEventListener("keydown",r=>{this.isModifierKeyDown=r.metaKey||r.ctrlKey||r.altKey}),e.contentWindow.addEventListener("keyup",()=>{this.isModifierKeyDown=!1})}},u={postMessage:a.postMessage.bind(a),onMessage:a.onMessage.bind(a),ready:l,fakeLoad:!t,onElectron:t,onIframeLoaded:e=>{g.onIframeLoaded(e)},rewriteCSP:t?e=>e.replace(/vscode-resource:(?=(\s|;|$))/g,"vscode-webview-resource:"):(e,r)=>{const s=new URL(r);return e.replace(/(vscode-webview-resource|vscode-resource):(?=(\s|;|$))/g,s.origin)}};window.createWebviewManager(u)})();

//# sourceMappingURL=https://ticino.blob.core.windows.net/sourcemaps/2b9aebd5354a3629c3aba0a5f5df49f43d6689f8/core/vs/workbench/contrib/webview/browser/pre/host.js.map
