(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{156:function(e,t,n){"use strict";n.r(t);var c=n(0),o=n(5),s=n(4),a=n(12),i=n(6),r=n(9),l=n(15);function b(e){Object(c.e)(e,"svelte-vgthxo",'.container.svelte-vgthxo.svelte-vgthxo{background:transparent;color:#555;width:100%;box-sizing:border-box;border:3px dashed currentColor;transition:.2s border-color, .2s color;border-radius:20px;min-height:90px;font:inherit;display:flex;align-items:center;justify-content:center;text-align:center;overflow:hidden;position:relative;cursor:pointer;padding:4px}[theme="dark"] .container.svelte-vgthxo.svelte-vgthxo{color:#aaa}.dropping.svelte-vgthxo.svelte-vgthxo,.container.svelte-vgthxo.svelte-vgthxo:focus-visible,.container.svelte-vgthxo.svelte-vgthxo:active{color:rgb(79, 123, 211)}[theme="dark"] .dropping.svelte-vgthxo.svelte-vgthxo,[theme="dark"] .container.svelte-vgthxo.svelte-vgthxo:focus-visible,[theme="dark"] .container.svelte-vgthxo.svelte-vgthxo:active{color:rgb(178, 195, 228)}.placeholder.svelte-vgthxo.svelte-vgthxo{font-size:1.5em}.selected.svelte-vgthxo.svelte-vgthxo{display:flex;align-items:center;justify-content:center;flex-wrap:wrap}.selected.svelte-vgthxo>.svelte-vgthxo:not(:last-child){margin-right:12px}')}function d(e,t,n){const c=e.slice();return c[10]=t[n],c}function O(e){let t,n,o=e[4]("fileInput.select")+"";return{c(){t=Object(c.v)("div"),n=Object(c.Y)(o),Object(c.g)(t,"class","placeholder svelte-vgthxo")},m(e,o){Object(c.E)(e,t,o),Object(c.d)(t,n)},p(e,t){16&t&&o!==(o=e[4]("fileInput.select")+"")&&Object(c.Q)(n,o)},d(e){e&&Object(c.u)(t)}}}function p(e){let t,n,o,s,a,i,r,l,b,O=e[4]("fileInput.selected").replace("{file}",e[0].name)+"",p=e[4]("fileInput.clear")+"",u=e[1],g=[];for(let t=0;tObject(c.h)(t,"dropping",s))),t.$on("drop",e[7]),{c(){Object(c.o)(t.$$.fragment)},m(e,n){Object(c.H)(t,e,n),o=!0},p(e,[o]){const s={};8223&o&&(s.$$scope={dirty:o,ctx:e}),!n&&8&o&&(n=!0,s.dropping=e[3],Object(c.b)((()=>n=!1))),t.$set(s)},i(e){o||(Object(c.cb)(t.$$.fragment,e),o=!0)},o(e){Object(c.db)(t.$$.fragment,e),o=!1},d(e){Object(c.s)(t,e)}}}function h(e,t,n){let o;Object(c.l)(e,s.a,(e=>n(4,o=e)));const a=[".png",".jpg",".jpeg",".bmp",".svg",".ico",".gif"];let i,r,{file:l}=t,{previewSizes:b}=t;return e.$$set=e=>{"file"in e&&n(0,l=e.file),"previewSizes"in e&&n(1,b=e.previewSizes)},e.$$.update=()=>{5&e.$$.dirty&&(l?(r&&URL.revokeObjectURL(r),n(2,r=URL.createObjectURL(l))):r&&(URL.revokeObjectURL(r),n(2,r=null)))},[l,b,r,i,o,e=>{e.stopPropagation(),n(0,l=null)},()=>{const e=document.createElement("input");e.type="file",e.accept=a.join(","),e.addEventListener("change",(e=>{const t=e.target.files;t.length?n(0,l=t[0]):n(0,l=null)})),document.body.appendChild(e),e.click(),e.remove()},({detail:e})=>{const t=e.files[0];a.some((e=>t.name.endsWith(e)))&&n(0,l=t)},function(e){i=e,n(3,i)}]}class m extends c.a{constructor(e){super(),Object(c.C)(this,e,h,g,c.M,{file:0,previewSizes:1},b)}}var v=m;function f(e){Object(c.e)(e,"svelte-1vgg5z0","textarea.svelte-1vgg5z0{box-sizing:border-box;width:100%;min-width:100%;height:100px}")}function y(e){let t,n,o,s;return{c(){t=Object(c.v)("textarea"),t.value=n=e[0].join("\n"),Object(c.g)(t,"class","svelte-1vgg5z0")},m(n,a){Object(c.E)(n,t,a),o||(s=Object(c.G)(t,"change",e[1]),o=!0)},p(e,[c]){1&c&&n!==(n=e[0].join("\n"))&&(t.value=n)},i:c.I,o:c.I,d(e){e&&Object(c.u)(t),o=!1,s()}}}function w(e,t,n){let{extensions:c}=t;return e.$$set=e=>{"extensions"in e&&n(0,c=e.extensions)},[c,e=>{n(0,c=e.target.value.split("\n").filter((e=>e)))}]}class $ extends c.a{constructor(e){super(),Object(c.C)(this,e,w,y,c.M,{extensions:0},f)}}var x=$;function k(e){Object(c.e)(e,"svelte-fiwpjx","a.svelte-fiwpjx{text-decoration:none}a.svelte-fiwpjx:hover{text-decoration:underline}")}function E(e){let t,n,o;return{c(){t=Object(c.v)("a"),n=Object(c.Y)("(?)"),Object(c.g)(t,"href",e[1]),Object(c.g)(t,"title",o=e[0]("options.learnMore")),Object(c.g)(t,"target","_blank"),Object(c.g)(t,"rel","noopener noreferrer"),Object(c.g)(t,"class","svelte-fiwpjx")},m(e,o){Object(c.E)(e,t,o),Object(c.d)(t,n)},p(e,[n]){1&n&&o!==(o=e[0]("options.learnMore"))&&Object(c.g)(t,"title",o)},i:c.I,o:c.I,d(e){e&&Object(c.u)(t)}}}function S(e,t,n){let o;Object(c.l)(e,s.a,(e=>n(0,o=e)));let{slug:a}=t,{href:i}=t;const r=a?`https://docs.turbowarp.org/${a}`:i;return e.$$set=e=>{"slug"in e&&n(2,a=e.slug),"href"in e&&n(3,i=e.href)},[o,r,a,i]}class z extends c.a{constructor(e){super(),Object(c.C)(this,e,S,E,c.M,{slug:2,href:3},k)}}var _=z;function U(e){let t,n,o;return{c(){t=Object(c.v)("input"),Object(c.g)(t,"type","color")},m(s,a){Object(c.E)(s,t,a),Object(c.R)(t,e[0]),n||(o=Object(c.G)(t,"input",e[1]),n=!0)},p(e,[n]){1&n&&Object(c.R)(t,e[0])},i:c.I,o:c.I,d(e){e&&Object(c.u)(t),n=!1,o()}}}function C(e,t,n){let{value:c}=t;return e.$$set=e=>{"value"in e&&n(0,c=e.value)},[c,function(){c=this.value,n(0,c)}]}class I extends c.a{constructor(e){super(),Object(c.C)(this,e,C,U,c.M,{value:0})}}var R=I,q=n(19);var T=async e=>{if("object"==typeof crypto&&crypto.subtle&&crypto.subtle.digest){const t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map((e=>e.toString(16).padStart(2,"0"))).join("")}const t=new(0,(await Promise.all([n.e(0),n.e(6)]).then(n.t.bind(null,154,7))).default);return t.update(new Uint8Array(e)),t.digest("hex")};var A=e=>e.replace(/["'<>&]/g,(e=>{switch(e){case'"':return""";case"'":return"'";case"<":return"<";case">":return">";case"&":return"&"}}));const N=e=>[`https://packagerdata.turbowarp.org/${e}`,`https://blobs.turbowarp.xyz/${e}`],L=e=>`scaffolding/${e}`;var P={"nwjs-win64":{src:N("nwjs-v0.68.1-win-x64.zip"),sha256:"82527d29f060bad7ec041f7c0536b1376f8bad5e5584adf7e3cf7205755a106c",estimatedSize:119821598},"nwjs-win32":{src:N("nwjs-v0.68.1-win-ia32.zip"),sha256:"7dd3104c2726082a8acd8973af2b2b223bc97960b722ec141b9bf07d84a0281b",estimatedSize:112613344},"nwjs-mac":{src:N("nwjs-v0.68.1-osx-x64.zip"),sha256:"4b1356302738a45f7ee212f6ecb997eb5d31403bfc45a7dd58429c968a1f581a",estimatedSize:119091132},"nwjs-linux-x64":{src:N("nwjs-v0.68.1-linux-x64.zip"),sha256:"5f597add1a2b6f13592117cc955111cea8211c13b21165e29c6616f385df5b94",estimatedSize:135854818},"electron-win32":{src:N("electron-v22.3.27-win32-ia32.zip"),sha256:"47bd498e5513529c5e141394fc9fd610cba1dcdea9e6dbb165edf929cbfd9af2",estimatedSize:90856612},"electron-win64":{src:N("electron-v22.3.27-win32-x64.zip"),sha256:"1a02c0f7af9664696f790dcce05948f0458a2f4f2d48c685f911d2eb99a4c9da",estimatedSize:96605498},"electron-win-arm":{src:N("electron-v22.3.27-win32-arm64.zip"),sha256:"0e4ad218018c0881ef4de363107a94dd2ced40367a0e18ca7d0dde1f40da0531",estimatedSize:94065344},"electron-mac":{src:N("electron-v22.3.27-macos-universal.zip"),sha256:"598b35f9030fe30f81b4041be048cd0374f675bd1bc0f172c26cf2808e80a3d9",estimatedSize:160882083},"electron-linux64":{src:N("electron-v22.3.27-linux-x64.zip"),sha256:"631d8eb08098c48ce2b29421e74c69ac0312b1e42f445d8a805414ba1242bf3a",estimatedSize:93426892},"electron-linux-arm32":{src:N("electron-v22.3.27-linux-armv7l.zip"),sha256:"9f8372606e5ede83cf1c73a3d8ff07047e4e3ef614aa89a76cd497dc06cf119d",estimatedSize:82722572},"electron-linux-arm64":{src:N("electron-v22.3.27-linux-arm64.zip"),sha256:"60279395a5ce4eaf3c08f1e717771b203830902d3fe3a7c311bc37deb1a0e15e",estimatedSize:93932512},"webview-mac":{src:N("WebView-macos-5.zip"),sha256:"b5636571cd9be2aae2f6dac1ab090fdf829c8fdfe91f462cc2feb2d324705f9f",estimatedSize:3425601},"steamworks.js":{src:N("steamworks.js-0.3.2.zip"),sha256:"fd8bc80a97cd880d71113dfc5f81b124b6e212335393db73e3df168c5c546fbc",estimatedSize:3279554},scaffolding:{src:L("scaffolding-full.js"),estimatedSize:4564032,useBuildId:!0},"scaffolding-min":{src:L("scaffolding-min.js"),estimatedSize:2530463,useBuildId:!0},addons:{src:L("addons.js"),estimatedSize:19931,useBuildId:!0}},B=n(11),Y=n(14);const M=e=>new Promise(((t,n)=>{e.toBlob((e=>{e?t(e):n(new Error("Could not read as blob"))}))}));var H=async e=>{const{Icns:t,Buffer:c}=await Promise.all([n.e(0),n.e(2)]).then(n.bind(null,155)),o=new Blob([e],{type:"image/png"}),s=URL.createObjectURL(o),a=await(i=s,new Promise(((e,t)=>{const n=new Image;n.onload=()=>e(n),n.onerror=()=>t(new Error(`Could not load image: ${i}`)),n.src=i})));var i;const r=[{type:"ic04",size:16},{type:"ic07",size:128},{type:"ic08",size:256},{type:"ic09",size:512},{type:"ic10",size:1024},{type:"ic11",size:32},{type:"ic12",size:64},{type:"ic13",size:256},{type:"ic14",size:512}].filter((e=>16===e.size||a.width>=e.size&&a.height>=e.size)),l=document.createElement("canvas"),b=l.getContext("2d");if(!b)throw new Error("cannot get canvas rendering context");const d=new t.Icns;for(const e of r){const n=e.size;l.width=n,l.height=n,b.drawImage(a,0,0,n,n);const o=await M(l),s=await Object(Y.a)(o),i=await t.IcnsImage.fromPNG(c.from(s),e.type);d.append(i)}return d.data};const W="5d7dd676348dd3aeff5976898cb41e20871e3cee6db54f6574e1fb66c0deae1a",Q=e=>60===(e+=42)?40:62===e?41:e,F=e=>{const t=e.length;let n;if(t%4!=0){const c=new Uint8Array(4*Math.ceil(t/4));for(let n=0;n{if("dict"===e.tagName){const t={};for(const n of e.children)"key"===n.tagName&&(t[n.textContent]=D(n.nextElementSibling));return t}return"array"===e.tagName?Array.from(e.children).map(D):"string"===e.tagName?e.textContent:"true"===e.tagName||"false"!==e.tagName&&(console.warn("unknown plist xml",e),null)},V=(e,t)=>{if(Array.isArray(t)){const n=e.createElement("array");for(const c of t)n.appendChild(V(e,c));return n}if("object"==typeof t){const n=e.createElement("dict");for(const[c,o]of Object.entries(t)){const t=e.createElement("key");t.textContent=c;const s=V(e,o);n.appendChild(t),n.appendChild(s)}return n}if("string"==typeof t){const n=e.createElement("string");return n.textContent=t,n}if("boolean"==typeof t){return e.createElement(t.toString())}return console.warn("unknown plist value",t),V(e,`${t}`)};var G=n(1),J=n(3);const Z=e=>{const t=(e=>{const t=parseInt(e.substring(1),16);return{red:t>>16&255,green:t>>8&255,blue:255&t}})(e),n=(e=>{const t=e.red/255,n=e.green/255,c=e.blue/255,o=Math.min(Math.min(t,n),c),s=Math.max(Math.max(t,n),c);let a=0,i=0;o!==s&&(a=60*((t===o?3:n===o?5:1)-(t===o?n-c:n===o?c-t:t-n)/(s-o))%360,i=(s-o)/s);return{hue:a,saturation:i,value:s}})(t);n.value-=.1;return(e=>{const t=e=>e.toString(16).padStart(2,"0");return`#${t(e.red)}${t(e.green)}${t(e.blue)}`})((e=>{let t=e.hue%360;t<0&&(t+=360);const n=Math.max(0,Math.min(e.saturation,1)),c=Math.max(0,Math.min(e.value,1)),o=Math.floor(t/60),s=t/60-o,a=c*(1-n),i=c*(1-n*s),r=c*(1-n*(1-s));let l,b,d;switch(o){default:case 0:l=c,b=r,d=a;break;case 1:l=i,b=c,d=a;break;case 2:l=a,b=c,d=r;break;case 3:l=a,b=i,d=c;break;case 4:l=r,b=a,d=c;break;case 5:l=c,b=a,d=i}return{red:Math.floor(255*l),green:Math.floor(255*b),blue:Math.floor(255*d)}})(n))};let K=null;const X=(e,t)=>{for(const n of t)e.push(n)},ee=e=>{if("string"==typeof e)return[(new TextEncoder).encode(e)];if("number"==typeof e||"boolean"==typeof e||null==e)return[(new TextEncoder).encode(String(e))];if(Array.isArray(e)){const t=[];for(const n of e)X(t,ee(n));return t}throw new Error(`Unknown value in encodeComponent: ${e}`)};var te=(e,...t)=>{const n=[];for(let c=0;c(await Promise.all([n.e(0),n.e(3)]).then(n.t.bind(null,153,7))).default,oe=(e,t,n)=>{e.files[t]=n},se={title:G.APP_NAME,homepage:G.WEBSITE,license:G.COPYRIGHT_NOTICE},ae={title:"Scratch",homepage:"https://scratch.mit.edu/",license:'Copyright (c) 2016, Massachusetts Institute of Technology\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\n3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.'},ie={title:"Electron",homepage:"https://www.electronjs.org/",license:'Copyright (c) Electron contributors\nCopyright (c) 2013-2020 GitHub Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n"Software"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.'},re=`/*!\nParts of this script are from the ${G.APP_NAME} <${G.WEBSITE}>, licensed as follows:\n${se.license}\n\nParts of this script are from Scratch , licensed as follows:\n${ae.license}\n*/\n`,le=e=>`${`

The following entries were added by the ${G.APP_NAME}

`}${e.map((({title:e,license:t,homepage:n},c)=>`\n
\n${A(e)}\nhomepage\n\n\n
\n
${A(t)}
\n
\n
\n`)).join("\n")}`,be="CFBundleIdentifier",de="CFBundleName",Oe="CFBundleDisplayName",pe="CFBundleExecutable",je="CFBundleVersion",ue="CFBundleShortVersionString",ge="LSApplicationCategoryType",he=e=>`When you try to double click on the app to run it, you will probably see this warning:\n"${e.app.packageName} cannot be opened because the developer cannot be verified."\nThis is normal. Press cancel.\n\nTo run the app:\n1) Control+click on the app file (${e.app.packageName} in the same folder as this document) and select "Open".\n2) If a warning appears, select "Open" if it's an option.\n3) If a warning appears but "Open" isn't an option, press "Cancel" and repeat from step 1.\n The open button will appear the second time the warning appears.\n\nAfter completing these steps, the app should run without any further warnings.\n\nFeel free to drag the app into your Applications folder.\n`,me=e=>{const t=["/","\\",":","*","?","<",">","|"];if(t.some((t=>e.includes(t))))throw new Error(`Invalid package name: ${e}. It must not use the characters: ${t.join(" ")}`)};class ve extends q.b{constructor(){super(),this.project=null,this.options=ve.DEFAULT_OPTIONS(),this.aborted=!1,this.used=!1}abort(){this.aborted||(this.aborted=!0,this.dispatchEvent(new Event("abort")))}ensureNotAborted(){if(this.aborted)throw new Error("Aborted")}async fetchLargeAsset(e,t){this.ensureNotAborted();const n=P[e];if(!n)throw new Error(`Invalid asset: ${e}`);if("undefined"!=typeof __ASSETS__&&__ASSETS__[n.src])return __ASSETS__[n.src];const c=t=>this.dispatchEvent(new q.a("large-asset-fetch",{detail:{asset:e,progress:t}}));let o;c(0);let s=!1;try{const e=await K.getCachedAsset(n);e&&(o=e,s=!0,c(.5))}catch(e){console.warn(e)}if(!o){let e=n.src;n.useBuildId&&(e+=`?${W}`),o=await Object(B.a)({url:e,type:t,estimatedSize:n.estimatedSize,progressCallback:e=>{c(e)},abortTarget:this})}if(n.useBuildId&&(a=W,(i=o).endsWith("=^..^=")&&!i.endsWith(`${a} =^..^=`)))throw new J.d("Build ID does not match.");var a,i;if(n.sha256){const t=await T(o);if(t!==n.sha256)throw new Error(`Hash mismatch for ${e}, found ${t} but expected ${n.sha256}`)}if(!s)try{await K.cacheAsset(n,o)}catch(e){console.warn(e)}return c(1),o}getAddonOptions(){return{...this.options.chunks,specialCloudBehaviors:this.options.cloudVariables.specialCloudBehaviors,unsafeCloudBehaviors:this.options.cloudVariables.unsafeCloudBehaviors,pause:this.options.controls.pause.enabled}}async loadResources(){const e=[re];this.project.analysis.usesMusic?e.push(await this.fetchLargeAsset("scaffolding","text")):e.push(await this.fetchLargeAsset("scaffolding-min","text")),Object.values(this.getAddonOptions()).some((e=>e))&&e.push(await this.fetchLargeAsset("addons","text")),this.script=e.join("\n").replace(/<\/script>/g,"")}computeWindowSize(){let e=this.options.stageWidth,t=this.options.stageHeight;return(this.options.controls.greenFlag.enabled||this.options.controls.stopAll.enabled||this.options.controls.pause.enabled)&&(t+=48),{width:e,height:t}}getPlistPropertiesForPrimaryExecutable(){return{[be]:`org.turbowarp.packager.userland.${this.options.app.packageName}`,[de]:this.options.app.windowTitle,[Oe]:this.options.app.windowTitle,[pe]:this.options.app.packageName,[je]:this.options.app.version,[ue]:this.options.app.version,[ge]:"public.app-category.games"}}async updatePlist(e,t,n){const c=(e=>{const t=(new DOMParser).parseFromString(e,"text/xml").children[0].children[0];return D(t)})(await e.file(t).async("string"));Object.assign(c,n),e.file(t,(e=>{const t=document.implementation.createDocument(null,"plist"),n=t.documentElement;return n.setAttribute("version","1.0"),n.appendChild(V(t,e)),`\n\n${(new XMLSerializer).serializeToString(t)}`})(c))}async addNwJS(e){const t=this.options.app.packageName;me(t);const n=await this.fetchLargeAsset(this.options.target,"arraybuffer"),c=await(await ce()).loadAsync(n),o=this.options.target.startsWith("nwjs-win"),s="nwjs-mac"===this.options.target,a=this.options.target.startsWith("nwjs-linux"),i=Object.keys(c.files)[0].split("/")[0],r=new(await ce());for(const e of Object.keys(c.files)){const n=c.files[e];let l=e.replace(i,t);o?l=l.replace("nw.exe",`${t}.exe`):s?l=l.replace("nwjs.app",`${t}.app`):a&&(l=l.replace(/nw$/,t)),oe(r,l,n)}const l="icon.png",b=await K.getAppIcon(this.options.app.icon),d={name:t,main:"main.js",version:this.options.app.version,window:{width:this.computeWindowSize().width,height:this.computeWindowSize().height,icon:l}};let O;if(o)O=`${t}/`;else if(s){r.file(`${t}/How to run ${t}.txt`,he(this.options));const e=await H(b);r.file(`${t}/${t}.app/Contents/Resources/app.icns`,e),O=`${t}/${t}.app/Contents/Resources/app.nw/`}else if(a){const e=`#!/bin/bash\ncd "$(dirname "$0")"\n./${t}`;r.file(`${t}/start.sh`,e,{unixPermissions:33261}),O=`${t}/`}for(const t of Object.keys(e.files))oe(r,O+t,e.files[t]);r.file(O+l,b),r.file(O+"package.json",JSON.stringify(d,null,4)),r.file(O+"main.js","\n const start = () => nw.Window.open('index.html', {\n position: 'center',\n new_instance: true\n });\n nw.App.on('open', start);\n start();");const p=`${t}/credits.html`,j=await r.file(p).async("string");return r.file(p,j+le([se,ae])),r}async addElectron(e){const t=this.options.app.packageName;me(t);const n=await this.fetchLargeAsset(this.options.target,"arraybuffer"),c=await(await ce()).loadAsync(n),o=this.options.target.includes("win"),s=this.options.target.includes("mac"),a=this.options.target.includes("linux"),i=new(await ce());for(const e of Object.keys(c.files)){const n=c.files[e];let r;r=s?e:`${t}/${e}`,o?r=r.replace("electron.exe",`${t}.exe`):s?(r=r.replace("Electron.app",`${t}.app`),r=r.replace(/Electron$/,t)):a&&(r=r.replace(/electron$/,t)),oe(i,r,n)}const r=s?"":`${t}/`,l=await i.file(`${r}LICENSES.chromium.html`).async("string");i.file(`${r}licenses.html`,l+le([se,ae,ie])),i.remove(`${r}LICENSE.txt`),i.remove(`${r}LICENSES.chromium.html`),i.remove(`${r}LICENSE`),i.remove(`${r}version`),i.remove(`${r}resources/default_app.asar`);const b=s?`${r}${t}.app/Contents/`:r,d=s?`${b}Resources/app/`:`${b}resources/app/`,O="electron-main.js",p="electron-preload.js",j="icon.png",u=await K.getAppIcon(this.options.app.icon);i.file(`${d}${j}`,u);const g={name:t,main:O,version:this.options.app.version};i.file(`${d}package.json`,JSON.stringify(g,null,4));let h=`'use strict';\nconst {app, BrowserWindow, Menu, shell, screen, dialog, ipcMain} = require('electron');\nconst path = require('path');\n\nconst isWindows = process.platform === 'win32';\nconst isMac = process.platform === 'darwin';\nconst isLinux = process.platform === 'linux';\n\nif (isMac) {\n Menu.setApplicationMenu(Menu.buildFromTemplate([\n { role: 'appMenu' },\n { role: 'fileMenu' },\n { role: 'editMenu' },\n { role: 'windowMenu' },\n { role: 'help' }\n ]));\n} else {\n Menu.setApplicationMenu(null);\n}\n\nconst resourcesURL = Object.assign(new URL('file://'), {\n pathname: path.join(__dirname, '/')\n}).href;\nconst defaultProjectURL = new URL('./index.html', resourcesURL).href;\n\nconst createWindow = (windowOptions) => {\n const options = {\n title: ${JSON.stringify(this.options.app.windowTitle)},\n icon: path.resolve(__dirname, ${JSON.stringify(j)}),\n useContentSize: true,\n webPreferences: {\n sandbox: true,\n contextIsolation: true,\n nodeIntegration: false,\n preload: path.resolve(__dirname, ${JSON.stringify(p)}),\n },\n frame: ${"frameless"!==this.options.app.windowControls},\n show: true,\n width: ${this.options.stageWidth},\n height: ${this.options.stageHeight},\n ...windowOptions,\n };\n\n const activeScreen = screen.getDisplayNearestPoint(screen.getCursorScreenPoint());\n const bounds = activeScreen.workArea;\n options.x = bounds.x + ((bounds.width - options.width) / 2);\n options.y = bounds.y + ((bounds.height - options.height) / 2);\n\n const window = new BrowserWindow(options);\n return window;\n};\n\nconst createProjectWindow = (url) => {\n const windowMode = ${JSON.stringify(this.options.app.windowMode)};\n const options = {\n show: false,\n backgroundColor: ${JSON.stringify(this.options.appearance.background)},\n width: ${this.computeWindowSize().width},\n height: ${this.computeWindowSize().height},\n minWidth: 50,\n minHeight: 50,\n };\n // fullscreen === false disables fullscreen on macOS so only set this property when it's true\n if (windowMode === 'fullscreen') {\n options.fullscreen = true;\n }\n const window = createWindow(options);\n if (windowMode === 'maximize') {\n window.maximize();\n }\n window.loadURL(url);\n window.show();\n};\n\nconst createDataWindow = (dataURI) => {\n const window = createWindow({});\n window.loadURL(dataURI);\n};\n\nconst isResourceURL = (url) => {\n try {\n const parsedUrl = new URL(url);\n return parsedUrl.protocol === 'file:' && parsedUrl.href.startsWith(resourcesURL);\n } catch (e) {\n // ignore\n }\n return false;\n};\n\nconst SAFE_PROTOCOLS = [\n 'https:',\n 'http:',\n 'mailto:',\n];\n\nconst isSafeOpenExternal = (url) => {\n try {\n const parsedUrl = new URL(url);\n return SAFE_PROTOCOLS.includes(parsedUrl.protocol);\n } catch (e) {\n // ignore\n }\n return false;\n};\n\nconst isDataURL = (url) => {\n try {\n const parsedUrl = new URL(url);\n return parsedUrl.protocol === 'data:';\n } catch (e) {\n // ignore\n }\n return false;\n};\n\nconst openLink = (url) => {\n if (isDataURL(url)) {\n createDataWindow(url);\n } else if (isResourceURL(url)) {\n createProjectWindow(url);\n } else if (isSafeOpenExternal(url)) {\n shell.openExternal(url);\n }\n};\n\nconst createProcessCrashMessage = (details) => {\n let message = details.type ? details.type + ' child process' : 'Renderer process';\n message += ' crashed: ' + details.reason + ' (' + details.exitCode + ')\\n\\n';\n if (process.arch === 'ia32') {\n message += 'Usually this means the project was too big for the 32-bit Electron environment or your computer is out of memory. Ask the creator to use the 64-bit environment instead.';\n } else {\n message += 'Usually this means your computer is out of memory.';\n }\n return message;\n};\n\napp.on('render-process-gone', (event, webContents, details) => {\n const window = BrowserWindow.fromWebContents(webContents);\n dialog.showMessageBoxSync(window, {\n type: 'error',\n title: 'Error',\n message: createProcessCrashMessage(details)\n });\n});\n\napp.on('child-process-gone', (event, details) => {\n dialog.showMessageBoxSync({\n type: 'error',\n title: 'Error',\n message: createProcessCrashMessage(details)\n });\n});\n\napp.on('web-contents-created', (event, contents) => {\n contents.setWindowOpenHandler((details) => {\n setImmediate(() => {\n openLink(details.url);\n });\n return {action: 'deny'};\n });\n contents.on('will-navigate', (e, url) => {\n if (!isResourceURL(url)) {\n e.preventDefault();\n openLink(url);\n }\n });\n contents.on('before-input-event', (e, input) => {\n const window = BrowserWindow.fromWebContents(contents);\n if (!window || input.type !== "keyDown") return;\n if (input.key === 'F11' || (input.key === 'Enter' && input.alt)) {\n window.setFullScreen(!window.isFullScreen());\n } else if (input.key === 'Escape') {\n const behavior = ${JSON.stringify(this.options.app.escapeBehavior)};\n if (window.isFullScreen() && (behavior === 'unfullscreen-only' || behavior === 'unfullscreen-or-exit')) {\n window.setFullScreen(false);\n } else if (behavior === 'unfullscreen-or-exit' || behavior === 'exit-only') {\n window.close();\n }\n }\n });\n});\n\napp.on('session-created', (session) => {\n session.webRequest.onBeforeRequest({\n urls: ["file://*"]\n }, (details, callback) => {\n callback({\n cancel: !details.url.startsWith(resourcesURL)\n });\n });\n});\n\napp.on('window-all-closed', () => {\n app.quit();\n});\n\napp.whenReady().then(() => {\n createProjectWindow(defaultProjectURL);\n});\n`,m="'use strict';\nconst {contextBridge, ipcRenderer} = require('electron');\n";if(this.project.analysis.usesSteamworks&&["electron-win64","electron-linux64","electron-mac"].includes(this.options.target)){h+=`\n const enableSteamworks = () => {\n const APP_ID = +${JSON.stringify(this.options.steamworks.appId)};\n const steamworks = require('./steamworks.js/');\n\n const client = steamworks.init(APP_ID);\n\n const async = (event, callback) => ipcMain.handle(event, (e, ...args) => {\n return callback(...args);\n });\n const sync = (event, callback) => ipcMain.on(event, (e, ...args) => {\n e.returnValue = callback(...args);\n });\n\n async('Steamworks.achievement.activate', (achievement) => client.achievement.activate(achievement));\n async('Steamworks.achievement.clear', (achievement) => client.achievement.clear(achievement));\n sync('Steamworks.achievement.isActivated', (achievement) => client.achievement.isActivated(achievement));\n sync('Steamworks.apps.isDlcInstalled', (dlc) => client.apps.isDlcInstalled(dlc));\n sync('Steamworks.localplayer.getName', () => client.localplayer.getName());\n sync('Steamworks.localplayer.getLevel', () => client.localplayer.getLevel());\n sync('Steamworks.localplayer.getIpCountry', () => client.localplayer.getIpCountry());\n sync('Steamworks.localplayer.getSteamId', () => client.localplayer.getSteamId());\n async('Steamworks.overlay.activateToWebPage', (url) => client.overlay.activateToWebPage(url));\n\n steamworks.electronEnableSteamOverlay();\n sync('Steamworks.ok', () => true);\n };\n\n try {\n enableSteamworks();\n } catch (e) {\n console.error(e);\n ipcMain.on('Steamworks.ok', (e) => {\n e.returnValue = false;\n });\n app.whenReady().then(() => {\n const ON_ERROR = ${JSON.stringify(this.options.steamworks.onError)};\n const window = BrowserWindow.getAllWindows()[0];\n if (ON_ERROR === 'warning') {\n dialog.showMessageBox(window, {\n type: 'error',\n message: 'Error initializing Steamworks: ' + e,\n });\n } else if (ON_ERROR === 'error') {\n dialog.showMessageBoxSync(window, {\n type: 'error',\n message: 'Error initializing Steamworks: ' + e,\n });\n app.quit();\n }\n });\n }`,m+="\n const enableSteamworks = () => {\n const sync = (event) => (...args) => ipcRenderer.sendSync(event, ...args);\n const async = (event) => (...args) => ipcRenderer.invoke(event, ...args);\n\n contextBridge.exposeInMainWorld('Steamworks', {\n ok: sync('Steamworks.ok'),\n achievement: {\n activate: async('Steamworks.achievement.activate'),\n clear: async('Steamworks.achievement.clear'),\n isActivated: sync('Steamworks.achievement.isActivated'),\n },\n apps: {\n isDlcInstalled: sync('Steamworks.apps.isDlcInstalled'),\n },\n leaderboard: {\n uploadScore: async('Steamworks.leaderboard.uploadScore'),\n },\n localplayer: {\n getName: sync('Steamworks.localplayer.getName'),\n getLevel: sync('Steamworks.localplayer.getLevel'),\n getIpCountry: sync('Steamworks.localplayer.getIpCountry'),\n getSteamId: sync('Steamworks.localplayer.getSteamId'),\n },\n overlay: {\n activateToWebPage: async('Steamworks.overlay.activateToWebPage'),\n },\n });\n };\n enableSteamworks();";const e=await this.fetchLargeAsset("steamworks.js","arraybuffer"),t=await(await ce()).loadAsync(e);for(const[e,n]of Object.entries(t.files)){const t=e.replace(/^package\//,"steamworks.js/");oe(i,`${d}${t}`,n)}}i.file(`${d}${O}`,h),i.file(`${d}${p}`,m);for(const[t,n]of Object.entries(e.files))oe(i,`${d}${t}`,n);if(o){const e=["1) Extract the whole zip",`2) Open "${t}.exe" to start the app.`,'Open "licenses.html" for information regarding open source software used by the app.'].join("\n\n");i.file(`${r}README.txt`,e)}else if(s){i.file(`How to run ${this.options.app.packageName}.txt`,he(this.options));const e=this.getPlistPropertiesForPrimaryExecutable();await this.updatePlist(i,`${b}Info.plist`,e);const t=["Electron Helper","Electron Helper (GPU)","Electron Helper (Renderer)","Electron Helper (Plugin)"];for(const n of t)await this.updatePlist(i,`${b}Frameworks/${n}.app/Contents/Info.plist`,{[be]:`${e[be]}.helper`,[Oe]:n.replace("Electron",this.options.app.packageName),[je]:this.options.app.version,[ue]:this.options.app.version});const n=await H(u);i.file(`${b}Resources/electron.icns`,n)}else if(a){const e=`#!/bin/bash\ncd "$(dirname "$0")"\n./${t}`;i.file(`${r}start.sh`,e,{unixPermissions:33261})}return i}async addWebViewMac(e){me(this.options.app.packageName);const t=await this.fetchLargeAsset(this.options.target,"arraybuffer"),n=await(await ce()).loadAsync(t),c=`${this.options.app.packageName}.app`,o=`${c}/Contents/`,s=`${c}/Contents/Resources/`,a=new(await ce());for(const[e,t]of Object.entries(n.files)){const n=e.replace("WebView.app",c).replace(/WebView$/,this.options.app.packageName);oe(a,n,t)}for(const[t,n]of Object.entries(e.files))oe(a,`${s}${t}`,n);const i=await K.getAppIcon(this.options.app.icon),r=await H(i);a.file(`${s}AppIcon.icns`,r),a.remove(`${s}Assets.car`);const l=parseInt(this.options.appearance.background.substr(1),16),b={title:this.options.app.windowTitle,background:[l>>16&255,l>>8&255,255&l,1],width:this.computeWindowSize().width,height:this.computeWindowSize().height};return a.file(`${s}application_config.json`,JSON.stringify(b)),await this.updatePlist(a,`${o}Info.plist`,this.getPlistPropertiesForPrimaryExecutable()),a.file(`How to run ${this.options.app.packageName}.txt`,he(this.options)),a}makeWebSocketProvider(){const e="wss://clouddata.turbowarp.org"===this.options.cloudVariables.cloudHost?["wss://clouddata.turbowarp.org","wss://clouddata.turbowarp.xyz"]:this.options.cloudVariables.cloudHost;return`new Scaffolding.Cloud.WebSocketProvider(${JSON.stringify(e)}, ${JSON.stringify(this.options.projectId)})`}makeLocalStorageProvider(){return`new Scaffolding.Cloud.LocalStorageProvider(${JSON.stringify(`cloudvariables:${this.options.projectId}`)})`}makeCustomProvider(){const e=this.options.cloudVariables.custom;let t="{const providers = {};\n";for(const n of new Set(Object.values(e)))"ws"===n?t+=`providers.ws = ${this.makeWebSocketProvider()};\n`:"local"===n&&(t+=`providers.local = ${this.makeLocalStorageProvider()};\n`);t+="for (const provider of Object.values(providers)) scaffolding.addCloudProvider(provider);\n";for(const n of Object.keys(e)){const c=e[n];t+=`scaffolding.addCloudProviderOverride(${JSON.stringify(n)}, providers[${JSON.stringify(c)}] || null);\n`}return t+="}",t}generateFilename(e){return`${this.options.app.windowTitle}.${e}`}async generateGetProjectData(){const e=[];let t,n,c="",o=!1;if("html"===this.options.target){o="blob"!==this.project.type,t=ne,n=.98;const s=new Uint8Array(this.project.arrayBuffer);e.push(`\n ${this.options.custom.js?` `;var t;if(this.ensureNotAborted(),"html"!==this.options.target){let t;if("sb3"===this.project.type&&"zip-one-asset"!==this.options.target){t=await(await ce()).loadAsync(this.project.arrayBuffer);for(const e of Object.keys(t.files))t.files[`assets/${e}`]=t.files[e],delete t.files[e]}else t=new(await ce()),t.file("project.zip",this.project.arrayBuffer);return t.file("index.html",e),t.file("script.js",this.script),this.options.target.startsWith("nwjs-")?t=await this.addNwJS(t):this.options.target.startsWith("electron-")?t=await this.addElectron(t):"webview-mac"===this.options.target&&(t=await this.addWebViewMac(t)),this.ensureNotAborted(),{data:await t.generateAsync({type:"uint8array",compression:"DEFLATE",platform:"UNIX"},(e=>{this.dispatchEvent(new q.a("zip-progress",{detail:{progress:e.percent/100}}))})),type:"application/zip",filename:this.generateFilename("zip")}}return{data:e,type:"text/html",filename:this.generateFilename("html")}}}ve.getDefaultPackageNameFromFileName=e=>(e=(e=(e=(e=e.split(".")[0]).replace(/[^\-a-z ]/gi,"")).trim()).replace(/ /g,"-")).toLowerCase()||"packaged-project",ve.getWindowTitleFromFileName=e=>{const t=e.split(".");return t.length>1&&t.pop(),(e=t.join(".").trim())||"Packaged Project"},ve.usesUnsafeOptions=e=>{const t=ve.DEFAULT_OPTIONS(),n=e=>[e.custom,e.extensions,e.cloudVariables.unsafeCloudBehaviors];return JSON.stringify(n(t))!==JSON.stringify(n(e))},ve.DEFAULT_OPTIONS=()=>({turbo:!1,interpolation:!1,framerate:30,highQualityPen:!1,maxClones:300,fencing:!0,miscLimits:!0,stageWidth:480,stageHeight:360,resizeMode:"preserve-ratio",autoplay:!1,username:"player####",closeWhenStopped:!1,projectId:"",custom:{css:"",js:""},appearance:{background:"#000000",foreground:"#ffffff",accent:G.ACCENT_COLOR},loadingScreen:{progressBar:!0,text:"",imageMode:"normal",image:null},controls:{greenFlag:{enabled:!1},stopAll:{enabled:!1},fullscreen:{enabled:!1},pause:{enabled:!1}},monitors:{editableLists:!1,variableColor:"#ff8c1a",listColor:"#fc662c"},compiler:{enabled:!0,warpTimer:!1},packagedRuntime:!0,target:"html",app:{icon:null,packageName:ve.getDefaultPackageNameFromFileName(""),windowTitle:ve.getWindowTitleFromFileName(""),windowMode:"window",version:"1.0.0",escapeBehavior:"unfullscreen-only",windowControls:"default"},chunks:{gamepad:!1,pointerlock:!1},cloudVariables:{mode:"ws",cloudHost:"wss://clouddata.turbowarp.org",custom:{},specialCloudBehaviors:!1,unsafeCloudBehaviors:!1},cursor:{type:"auto",custom:null,center:{x:0,y:0}},steamworks:{appId:"480",onError:"warning"},extensions:[],bakeExtensions:!0,maxTextureDimension:2048});var fe=ve;var ye=(e,t)=>{const n=document.createElement("a");n.download=e,n.href=t,document.body.appendChild(n),n.click(),n.remove()},we=n(7);function $e(e){Object(c.e)(e,"svelte-1u9hge",".alternative.svelte-1u9hge{font-size:smaller}")}function xe(e){let t,n,o,s,a,i=e[4]("downloads.useWorkaround")+"";return{c(){t=Object(c.v)("p"),n=Object(c.v)("button"),o=Object(c.Y)(i),n.disabled=e[3],Object(c.g)(t,"class","alternative svelte-1u9hge")},m(i,r){Object(c.E)(i,t,r),Object(c.d)(t,n),Object(c.d)(n,o),s||(a=Object(c.G)(n,"click",e[5]),s=!0)},p(e,t){16&t&&i!==(i=e[4]("downloads.useWorkaround")+"")&&Object(c.Q)(o,i),8&t&&(n.disabled=e[3])},d(e){e&&Object(c.u)(t),s=!1,a()}}}function ke(e){let t,n,o,s,a,i=e[4]("downloads.link").replace("{size}",`${(e[2].size/1e3/1e3).toFixed(2)}MB`).replace("{filename}",e[0])+"",r=we.a&&e[0].endsWith(".html"),l=r&&xe(e);return{c(){t=Object(c.v)("div"),n=Object(c.v)("p"),o=Object(c.v)("a"),s=Object(c.Y)(i),a=Object(c.U)(),l&&l.c(),Object(c.g)(o,"href",e[1]),Object(c.g)(o,"download",e[0])},m(e,i){Object(c.E)(e,t,i),Object(c.d)(t,n),Object(c.d)(n,o),Object(c.d)(o,s),Object(c.d)(t,a),l&&l.m(t,null)},p(e,n){21&n&&i!==(i=e[4]("downloads.link").replace("{size}",`${(e[2].size/1e3/1e3).toFixed(2)}MB`).replace("{filename}",e[0])+"")&&Object(c.Q)(s,i),2&n&&Object(c.g)(o,"href",e[1]),1&n&&Object(c.g)(o,"download",e[0]),1&n&&(r=we.a&&e[0].endsWith(".html")),r?l?l.p(e,n):(l=xe(e),l.c(),l.m(t,null)):l&&(l.d(1),l=null)},d(e){e&&Object(c.u)(t),l&&l.d()}}}function Ee(e){let t,n;return t=new i.a({props:{center:!0,$$slots:{default:[ke]},$$scope:{ctx:e}}}),{c(){Object(c.o)(t.$$.fragment)},m(e,o){Object(c.H)(t,e,o),n=!0},p(e,[n]){const c={};95&n&&(c.$$scope={dirty:n,ctx:e}),t.$set(c)},i(e){n||(Object(c.cb)(t.$$.fragment,e),n=!0)},o(e){Object(c.db)(t.$$.fragment,e),n=!1},d(e){Object(c.s)(t,e)}}}function Se(e,t,n){let o;Object(c.l)(e,s.a,(e=>n(4,o=e)));let a,{name:i}=t,{url:r}=t,{blob:l}=t;return e.$$set=e=>{"name"in e&&n(0,i=e.name),"url"in e&&n(1,r=e.url),"blob"in e&&n(2,l=e.blob)},[i,r,l,a,o,async()=>{n(3,a=!0);try{const e=new(await ce());e.file(i,l);const t=await e.generateAsync({type:"blob",compression:"DEFLATE"}),n=i.replace(/\.html$/,".zip"),c=URL.createObjectURL(t);ye(n,c),URL.revokeObjectURL(c)}catch(e){console.error(e)}n(3,a=!1)}]}class ze extends c.a{constructor(e){super(),Object(c.C)(this,e,Se,Ee,c.M,{name:0,url:1,blob:2},$e)}}var _e=ze,Ue=n(10),Ce=n(8);const Ie=[];class Re{constructor(e,t,n){this.name=e,this.version=t,this.storeName=n,this.db=null,this.dbPromise=null,Ie.push(this)}open(){if(this.db)return this.db;if(this.dbPromise)return this.dbPromise;if("undefined"==typeof indexedDB)throw new Error("indexedDB is not supported");return this.dbPromise=(()=>{if(navigator.userAgentData||!/Safari\//.test(navigator.userAgent)||/Chrom(e|ium)\//.test(navigator.userAgent)||!indexedDB.databases)return Promise.resolve();let e;return new Promise((t=>{const n=()=>indexedDB.databases().finally(t);e=setInterval(n,100),n()})).finally((()=>clearInterval(e)))})().then((()=>new Promise(((e,t)=>{const n=indexedDB.open(this.name,this.version);n.onupgradeneeded=e=>{e.target.result.createObjectStore(this.storeName,{keyPath:"id"})},n.onsuccess=t=>{const n=t.target.result;e(n)},n.onerror=e=>{t(new Error(`IDB Error ${e.target.error}`))}})))).then((e=>(this.dbPromise=null,this.db=e,e))).catch((e=>{throw this.dbPromise=null,e})),this.dbPromise}close(){this.db&&(this.db.close(),this.db=null),this.dbPromise&&(this.dbPromise.then((e=>{e.close()})),this.dbPromise=null)}async createTransaction(e){const t=await this.open(),n=t.transaction(this.storeName,e),c=n.objectStore(this.storeName);return{db:t,transaction:n,store:c}}async deleteEverything(){const{transaction:e,store:t}=await this.createTransaction("readwrite");return new Promise(((n,c)=>{Re.setTransactionErrorHandler(e,c);t.clear().onsuccess=()=>{n()}}))}}Re.setTransactionErrorHandler=(e,t)=>{e.onerror=()=>{t(new Error(`Transaction error: ${e.error}`))},e.onabort=()=>{t(new Error(`Transaction aborted: ${e.error}`))}};window.addEventListener("pagehide",(()=>{for(const e of Ie)e.close()}));var qe=Re;const Te=new qe("p4-local-settings",1,"blobs"),Ae=(e,t,n)=>{const c=new Blob([e],{type:t});return c.name=n,c},Ne=async e=>{const{transaction:t,store:n}=await Te.createTransaction("readonly");return new Promise(((c,o)=>{qe.setTransactionErrorHandler(t,o);n.get(e).onsuccess=e=>{const t=e.target.result;if(t){const e=t.data;e instanceof Blob?c((async e=>{const t=await Object(Y.a)(e);return Ae(t,e.type,e.name)})(e)):c(Ae(e,t.type,t.name))}else c(null)}}))};var Le=e=>{let t=!1;const n=Object(Ce.b)(null,(()=>{const c=n.subscribe((n=>{t&&(async(e,t)=>{const n=t?await Object(Y.a)(t):null,{transaction:c,store:o}=await Te.createTransaction("readwrite");return new Promise(((s,a)=>{qe.setTransactionErrorHandler(c,a),(t?o.put({id:e,data:n,type:t.type,name:t.name}):o.delete(e)).onsuccess=()=>{s()}}))})(e,n).catch((e=>{console.warn(e)}))}));return c}));return Ne(e).then((e=>{t=!0,e&&n.set(e)})),n},Pe=n(2);const Be=we.c?"*":location.origin,Ye=new WeakMap;window.addEventListener("message",(e=>{if("*"!==Be&&e.origin!==location.origin)return;const t=e.data;if(t&&"hello"===t.preview){const t=e.source,n=Ye.get(t);n&&t.postMessage({blob:n},Be)}}));var Me=class{constructor(){const e=`\n\n\n ${A(s.a.translate("preview.loading"))}\n \n \n \n\n\n
\n \n
\n
\n \n