@triflare/fx 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +73 -2
  3. package/bin/fx.js +949 -0
  4. package/package.json +64 -4
  5. package/product.yml +28 -0
  6. package/src/brand.js +105 -0
  7. package/src/build.js +181 -0
  8. package/src/catalog.js +753 -0
  9. package/src/compiler.js +1658 -0
  10. package/src/config-edit.js +338 -0
  11. package/src/config.js +400 -0
  12. package/src/decompiler.js +504 -0
  13. package/src/dev.js +390 -0
  14. package/src/errors.js +56 -0
  15. package/src/extensions.js +707 -0
  16. package/src/index.js +31 -0
  17. package/src/language.js +12 -0
  18. package/src/lexer.js +202 -0
  19. package/src/log.js +70 -0
  20. package/src/package.js +202 -0
  21. package/src/packager.js +177 -0
  22. package/src/parser.js +608 -0
  23. package/src/product.js +27 -0
  24. package/src/project.js +156 -0
  25. package/src/sb3.js +340 -0
  26. package/src/sprite.js +81 -0
  27. package/vendor/pm-packager-dist/.fx-build.json +6 -0
  28. package/vendor/pm-packager-dist/LICENSE +202 -0
  29. package/vendor/pm-packager-dist/NOTICE +6 -0
  30. package/vendor/pm-packager-dist/dist/290e09e569a1cab8e61ba93b0d23863f.png +0 -0
  31. package/vendor/pm-packager-dist/dist/icns.js +1 -0
  32. package/vendor/pm-packager-dist/dist/packager.js +154 -0
  33. package/vendor/pm-packager-dist/dist/scaffolding/addons.js +2 -0
  34. package/vendor/pm-packager-dist/dist/scaffolding/extension worker.js +2 -0
  35. package/vendor/pm-packager-dist/dist/scaffolding/scaffolding-full.js +93 -0
  36. package/vendor/pm-packager-dist/dist/scaffolding/scaffolding-min.js +93 -0
  37. package/vendor/pm-packager-dist/dist/scaffolding/vendors~iframe-extension-worker.js +2 -0
  38. package/vendor/pm-packager-dist/dist/vendors~sha256.js +3 -0
  39. package/vendor/pm-packager-dist/package.json +3 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,6 @@
1
+ This directory contains the PenguinMod Packager.
2
+
3
+ Upstream: https://github.com/PenguinMod/PenguinMod-Packager#readme
4
+ Version: 1.9.2
5
+ Commit: 53f868b85ec21d2edab9ce00fd2d709da93da6d6
6
+ License: Apache-2.0 (see LICENSE)
@@ -0,0 +1 @@
1
+ exports.ids=[0],exports.modules={66:function(r,n,t){"use strict";t.r(n);var u=t(9);t.d(n,"Icns",(function(){return u}));var e=t(8);t.d(n,"Buffer",(function(){return e.Buffer}))}};
@@ -0,0 +1,154 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("cross-fetch"),require("@turbowarp/sbdl"),require("@fiahfy/icns"),require("jszip")):"function"==typeof define&&define.amd?define(["cross-fetch","@turbowarp/sbdl","@fiahfy/icns","jszip"],t):"object"==typeof exports?exports.packager=t(require("cross-fetch"),require("@turbowarp/sbdl"),require("@fiahfy/icns"),require("jszip")):e.packager=t(e["cross-fetch"],e["@turbowarp/sbdl"],e["@fiahfy/icns"],e.jszip)}(global,(function(e,t,n,s){return function(e){var t={},n={1:0};function s(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,s),o.l=!0,o.exports}return s.e=function(t){if(0!==n[t]){var s=require("./"+({0:"icns",2:"vendors~sha256"}[t]||t)+".js"),o=s.modules,r=s.ids;for(var i in o)e[i]=o[i];for(var a=0;a<r.length;a++)n[r[a]]=0}return Promise.all([])},s.m=e,s.c=t,s.d=function(e,t,n){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)s.d(n,o,function(t){return e[t]}.bind(null,o));return n},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s.oe=function(e){process.nextTick((function(){throw e}))},s(s.s=7)}([function(e,t){e.exports={APP_NAME:"PenguinMod Packager",WEBSITE:"https://studio.penguinmod.com/PenguinMod-Packager/",COPYRIGHT_NOTICE:'Copyright (C) 2021-2022 Thomas Weber\n\nLicensed under the Apache License, Version 2.0 (the "License");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an "AS IS" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.',ACCENT_COLOR:"#00c3ff",SOURCE_CODE:"https://github.com/PenguinMod/PenguinMod-Packager",FEEDBACK_PRIMARY:{name:"Discord",link:"https://discord.gg/NZ9MBMYTZh"},FEEDBACK_SECONDARY:{name:"GitHub",link:"https://github.com/PenguinMod/PenguinMod-Packager/issues"},DONATE:"https://penguinmod.com/donate",PRIVACY_POLICY:"https://turbowarp.org/privacy.html"}},function(e,t){e.exports=require("path")},function(e,t){e.exports=require("util")},function(e,t){e.exports=require("fs")},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e){e.exports=JSON.parse('{"a":"@penguinmod/packager"}')},function(e,t,n){"use strict";n.r(t),n.d(t,"Packager",(function(){return B})),n.d(t,"Image",(function(){return te})),n.d(t,"loadProject",(function(){return V}));class s{constructor(e,t){this.type=e,this.detail=t?t.detail:{}}}var o=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 n.e(2).then(n.t.bind(null,65,7))).default);return t.update(new Uint8Array(e)),t.digest("hex")};var r=e=>e.replace(/["'<>&]/g,e=>{switch(e){case'"':return"&quot;";case"'":return"&apos;";case"<":return"&lt;";case">":return"&gt;";case"&":return"&amp;"}});const i=e=>["https://packagerdata.turbowarp.org/"+e,"https://blobs.turbowarp.xyz/"+e],a=e=>"scaffolding/"+e;var c={"nwjs-win64":{src:i("nwjs-v0.68.1-win-x64.zip"),sha256:"82527d29f060bad7ec041f7c0536b1376f8bad5e5584adf7e3cf7205755a106c",estimatedSize:119821598},"nwjs-win32":{src:i("nwjs-v0.68.1-win-ia32.zip"),sha256:"7dd3104c2726082a8acd8973af2b2b223bc97960b722ec141b9bf07d84a0281b",estimatedSize:112613344},"nwjs-mac":{src:i("nwjs-v0.68.1-osx-x64.zip"),sha256:"4b1356302738a45f7ee212f6ecb997eb5d31403bfc45a7dd58429c968a1f581a",estimatedSize:119091132},"nwjs-linux-x64":{src:i("nwjs-v0.68.1-linux-x64.zip"),sha256:"5f597add1a2b6f13592117cc955111cea8211c13b21165e29c6616f385df5b94",estimatedSize:135854818},"electron-win32":{src:i("electron-v22.3.27-win32-ia32.zip"),sha256:"47bd498e5513529c5e141394fc9fd610cba1dcdea9e6dbb165edf929cbfd9af2",estimatedSize:90856612},"electron-win64":{src:i("electron-v22.3.27-win32-x64.zip"),sha256:"1a02c0f7af9664696f790dcce05948f0458a2f4f2d48c685f911d2eb99a4c9da",estimatedSize:96605498},"electron-win-arm":{src:i("electron-v22.3.27-win32-arm64.zip"),sha256:"0e4ad218018c0881ef4de363107a94dd2ced40367a0e18ca7d0dde1f40da0531",estimatedSize:94065344},"electron-mac":{src:i("electron-v22.3.27-macos-universal.zip"),sha256:"598b35f9030fe30f81b4041be048cd0374f675bd1bc0f172c26cf2808e80a3d9",estimatedSize:160882083},"electron-linux64":{src:i("electron-v22.3.27-linux-x64.zip"),sha256:"631d8eb08098c48ce2b29421e74c69ac0312b1e42f445d8a805414ba1242bf3a",estimatedSize:93426892},"electron-linux-arm32":{src:i("electron-v22.3.27-linux-armv7l.zip"),sha256:"9f8372606e5ede83cf1c73a3d8ff07047e4e3ef614aa89a76cd497dc06cf119d",estimatedSize:82722572},"electron-linux-arm64":{src:i("electron-v22.3.27-linux-arm64.zip"),sha256:"60279395a5ce4eaf3c08f1e717771b203830902d3fe3a7c311bc37deb1a0e15e",estimatedSize:93932512},"webview-mac":{src:i("WebView-macos-5.zip"),sha256:"b5636571cd9be2aae2f6dac1ab090fdf829c8fdfe91f462cc2feb2d324705f9f",estimatedSize:3425601},scaffolding:{src:a("scaffolding-full.js"),estimatedSize:4564032,useBuildId:!0},"scaffolding-min":{src:a("scaffolding-min.js"),estimatedSize:2530463,useBuildId:!0},addons:{src:a("addons.js"),estimatedSize:19931,useBuildId:!0}};Error;Error;class l extends Error{constructor(e){super(`Could not fetch ${e} for unknown reason.`),this.name="UnknownNetworkError",this.url=e}}class d extends Error{constructor(e){super(e),this.name="OutdatedPackagerError"}}class p extends Error{constructor(e,t){super(e),this.status=t,this.name="HTTPError"}}Error;const u=e=>Math.max(0,Math.min(1,e)),f=[400,404];var h=async e=>{const{type:t,progressCallback:n,timeout:s,estimatedSize:o,abortTarget:r}=e,i=e=>new Promise((i,a)=>{const c=new XMLHttpRequest;c.onload=()=>{d(),200===c.status?i(c.response):a(new p(`Couldn't fetch ${e}: status code ${c.status}`,c.status))},c.onerror=()=>{d(),a(new l(e))},n&&(c.onprogress=e=>{e.lengthComputable?n(u(e.loaded/e.total)):o&&n(u(e.loaded/o))}),c.responseType=t,c.open("GET",e),c.send();const d=()=>{f&&f(),h&&clearTimeout(h)};let f,h;if(r){const t=()=>{c.abort(),d(),a(new Error(`Couldn't fetch ${e}: aborted`))};r.addEventListener("abort",t),f=()=>{r.removeEventListener("abort",t)}}s&&(h=setTimeout(()=>{c.abort(),d(),a(new Error(`Couldn't fetch ${e}: timed out`))},s))}),a=Array.isArray(e.url)?e.url:[e.url];if(0===a.length)throw new Error("no URLs");let c;for(const e of a)try{return await i(e)}catch(e){if(e instanceof p&&f.includes(e.status))throw e;(!c||c instanceof l&&!(e instanceof l))&&(c=e)}throw c};const g=e=>new Promise((t,n)=>{const s=new FileReader;s.onload=()=>t(s.result),s.onerror=()=>n(new Error("Cannot read as array buffer: "+s.error)),s.readAsArrayBuffer(e)}),m=e=>new Promise((t,n)=>{e.toBlob(e=>{e?t(e):n(new Error("Could not read <canvas> as blob"))})});var w=async e=>{const{Icns:t,Buffer:s}=await n.e(0).then(n.bind(null,66)),o=new Blob([e],{type:"image/png"}),r=URL.createObjectURL(o),i=await(a=r,new Promise((e,t)=>{const n=new Image;n.onload=()=>e(n),n.onerror=()=>t(new Error("Could not load image: "+a)),n.src=a}));var a;const c=[{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||i.width>=e.size&&i.height>=e.size),l=document.createElement("canvas"),d=l.getContext("2d");if(!d)throw new Error("cannot get canvas rendering context");const p=new t.Icns;for(const e of c){const n=e.size;l.width=n,l.height=n,d.drawImage(i,0,0,n,n);const o=await m(l),r=await g(o),a=await t.IcnsImage.fromPNG(s.from(r),e.type);p.append(a)}return p.data};const b="d4717322ac8ca2bf1148dfb59dc94708ea2b21582c2e2dd1e8397545d363d2cb",y=e=>60===(e+=42)?40:62===e?41:e,v=e=>{const t=e.length;let n;if(t%4!=0){const s=new Uint8Array(4*Math.ceil(t/4));for(let n=0;n<t;n++)s[n]=e[n];n=new DataView(s.buffer)}else n=new DataView(e.buffer,e.byteOffset,e.byteLength);const s=new Uint8Array(5*Math.ceil(t/4));let o=0;for(let e=0;e<n.byteLength;e+=4){let t=n.getUint32(e,!0);s[o++]=y(t%85),t=Math.floor(t/85),s[o++]=y(t%85),t=Math.floor(t/85),s[o++]=y(t%85),t=Math.floor(t/85),s[o++]=y(t%85),t=Math.floor(t/85),s[o++]=y(t%85)}return(new TextDecoder).decode(s)},E=e=>{if("dict"===e.tagName){const t={};for(const n of e.children)"key"===n.tagName&&(t[n.textContent]=E(n.nextElementSibling));return t}return"array"===e.tagName?Array.from(e.children).map(E):"string"===e.tagName?e.textContent:"true"===e.tagName||"false"!==e.tagName&&(console.warn("unknown plist xml",e),null)},x=(e,t)=>{if(Array.isArray(t)){const n=e.createElement("array");for(const s of t)n.appendChild(x(e,s));return n}if("object"==typeof t){const n=e.createElement("dict");for(const[s,o]of Object.entries(t)){const t=e.createElement("key");t.textContent=s;const r=x(e,o);n.appendChild(t),n.appendChild(r)}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),x(e,""+t)};var S=n(0);const A=e=>{const t=(e=>{const t=e.red/255,n=e.green/255,s=e.blue/255,o=Math.min(Math.min(t,n),s),r=Math.max(Math.max(t,n),s);let i=0,a=0;if(o!==r){i=60*((t===o?3:n===o?5:1)-(t===o?n-s:n===o?s-t:t-n)/(r-o))%360,a=(r-o)/r}return{hue:i,saturation:a,value:r}})((e=>{const t=parseInt(e.substring(1),16);return{red:t>>16&255,green:t>>8&255,blue:255&t}})(e));t.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)),s=Math.max(0,Math.min(e.value,1)),o=Math.floor(t/60),r=t/60-o,i=s*(1-n),a=s*(1-n*r),c=s*(1-n*(1-r));let l,d,p;switch(o){default:case 0:l=s,d=c,p=i;break;case 1:l=a,d=s,p=i;break;case 2:l=i,d=s,p=c;break;case 3:l=i,d=a,p=s;break;case 4:l=c,d=i,p=s;break;case 5:l=s,d=i,p=a}return{red:Math.floor(255*l),green:Math.floor(255*d),blue:Math.floor(255*p)}})(t))};let I=null;const O=(e,t)=>{for(const n of t)e.push(n)},N=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)O(t,N(n));return t}throw new Error("Unknown value in encodeComponent: "+e)};var C=(e,...t)=>{const n=[];for(let s=0;s<e.length-1;s++)O(n,N(e[s])),O(n,N(t[s]));O(n,N(e[e.length-1]));let s=0;for(let e=0;e<n.length;e++)s+=n[e].byteLength;const o=new Uint8Array(s);for(let e=0,t=0;e<n.length;e++)o.set(n[e],t),t+=n[e].byteLength;return o};const T=async()=>(await Promise.resolve().then(n.t.bind(null,10,7))).default,M=(e,t,n)=>{e.files[t]=n},L={title:S.APP_NAME,homepage:S.WEBSITE,license:S.COPYRIGHT_NOTICE},R={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.'},k={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.'},j=`/*!\nParts of this script are from the ${S.APP_NAME} <${S.WEBSITE}>, licensed as follows:\n${L.license}\n\nParts of this script are from Scratch <https://scratch.mit.edu/>, licensed as follows:\n${R.license}\n*/\n`,P=e=>`<style>body { font-family: sans-serif; }</style>${`<h2>The following entries were added by the ${S.APP_NAME}</h2>`}${e.map(({title:e,license:t,homepage:n},s)=>`\n<div class="product">\n<span class="title">${r(e)}</span>\n<span class="homepage"><a href="${r(n)}">homepage</a></span>\n<input type="checkbox" hidden id="p4-${s}">\n<label class="show" for="p4-${s}" tabindex="0"></label>\n<div class="licence">\n<pre>${r(t)}</pre>\n</div>\n</div>\n`).join("\n")}`,$=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`,D=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 z extends class{constructor(){this._events={}}addEventListener(e,t){this._events[e]||(this._events[e]=[]),this._events[e].push(t)}removeEventListener(e,t){const n=this._events[e];n&&(this._events[e]=n.filter(e=>e!==t))}dispatchEvent(e){const t=this._events[e.type];if(t)for(const n of t)n(e)}}{constructor(){super(),this.project=null,this.options=z.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=c[e];if(!n)throw new Error("Invalid asset: "+e);if("undefined"!=typeof __ASSETS__&&__ASSETS__[n.src])return __ASSETS__[n.src];const r=t=>this.dispatchEvent(new s("large-asset-fetch",{detail:{asset:e,progress:t}}));let i;r(0);let a=!1;try{const e=await I.getCachedAsset(n);e&&(i=e,a=!0,r(.5))}catch(e){console.warn(e)}if(!i){let e=n.src;n.useBuildId&&(e+="?"+b),i=await h({url:e,type:t,estimatedSize:n.estimatedSize,progressCallback:e=>{r(e)},abortTarget:this})}if(n.useBuildId&&(l=b,(p=i).endsWith("=^..^=")&&!p.endsWith(l+" =^..^=")))throw new d("Build ID does not match.");var l,p;if(n.sha256){const t=await o(i);if(t!==n.sha256)throw new Error(`Hash mismatch for ${e}, found ${t} but expected ${n.sha256}`)}if(!a)try{await I.cacheAsset(n,i)}catch(e){console.warn(e)}return r(1),i}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=[j];this.project.analysis.usesMusic?e.push(await this.fetchLargeAsset("scaffolding","text")):e.push(await this.fetchLargeAsset("scaffolding-min","text")),this.options.removeDefaultFonts&&(e[1]=(e=>{const t=e.indexOf('{"Sans Serif":'),n=e.indexOf("}",t)+1,s=e.substring(t,n),o=/"([^"]+)"\s*:|([A-Za-z0-9_$]+)\s*:/g;let r=0;for(;o.exec(s);)r++;const i=e.substring(e.indexOf(",function(A,e)",n),e.length);let a=n;for(var c=0;c<r;c++){const t=i.indexOf("{",a)+(0===c?16:0),n=i.indexOf("}",a)+1;a=i.indexOf("}",n),e=e.replace(i.substring(t+1,a),"")}return e})(e[1])),this.options.optimizeCode&&(e[1]=((e,t)=>{const n=t.project.analysis.builtInExts,s="function(A,e,t){},",o=e.indexOf('+="let stuckCounter = 0;'),r=e.indexOf('("executeInCompatibilityLayer")&&!e.includes("const waitPromise")'),i=e.substring(o,r),a=i.replace(/\/\*[\s\S]*?\*\//g,"").replace(/[\r\n]+\s*/g,"").replace(/\s{2,}/g," ");if(e=e.replace(i,a),n.includes("translate")&&n.includes("text2speech")||(e=e.replace(/JSON\.parse\('(?:(?!'\)).)*?"menuMap".*?'\)/gs,"{menuMap:{}}")),n.includes("music")||(e=e.replace(/A\.exports\s*=\s*\{\s*"drums\/1-snare\.mp3"[\s\S]*?\}\s*,?/g,"")),!n.includes("fr3d")||!n.includes("jg3d")){const t=e.indexOf('function(A,e,t){"use strict";t.r(e),t.d(e,"ACESFilmicToneMapping"'),n=e.indexOf("window.__THREE__=");t>0&&n>0&&(e=e.substring(0,t)+e.substring(n+20,e.length));const o=e.indexOf('"deepCloneAttribute",(function(){'),r=e.indexOf("THREE.BufferGeometryUtils: mergeBufferAttributes() has been renamed to mergeAttributes()");o>0&&r>0&&(e=e.substring(0,o-42)+e.substring(r+98,e.length));const i=e.indexOf('t.r(e),t.d(e,"OBJLoader",(function(){')-29,a=e.indexOf('t.r(e),t.d(e,"GLTFLoader",(function(){')-29;i>0&&a>0&&(e=e.replace(e.substring(i,a),s));const c=e.indexOf('t.r(e),t.d(e,"GLTFLoader",(function(){')-29,l=e.indexOf("A.morphTargetsRelative=!0,A}))}")+54;c>0&&l>0&&(e=e.replace(e.substring(c,l),s));const d=e.indexOf('t.r(e),t.d(e,"FBXLoader",(function(){')-29,p=e.indexOf('console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ')+394;d>0&&p>0&&(e=e.replace(e.substring(d,p),s));const u=e.indexOf('t.r(e),t.d(e,"ConvexGeometry",(function(){')-29,f=/this\.setAttribute\("([^"]+)",\s*new\s+([a-zA-Z_$][\w$]*)\.Float32BufferAttribute\(\s*([a-zA-Z_$][\w$]*),\s*3\s*\)\)/.exec(e),h=(f?f.index:-999)+128;u>0&&h>0&&(e=e.replace(e.substring(u,h),s))}if(!n.includes("jwPsychic")){const t=e.indexOf("* matter-js")-35,n=e.indexOf(".addConstraint}])},A.exports=t()}).call(this,t(")+52;t>0&&n>0&&(e=e.replace(e.substring(t,n),"function(A,e,t){}"))}if(!n.includes("jwNum")){const t=e.indexOf('serializeMode:0,debug:0},o="[ExpantaNumError]')-66,n=/for\(var\s+([a-zA-Z_$][\w$]*)\s+in\s+([a-zA-Z_$][\w$]*)\.prototype=([a-zA-Z_$][\w$]*),\2\.JSON=0,\2\.STRING=1,\2\.NONE=0,\2\.NORMAL=1,\2\.ALL=2,\2\.clone=([a-zA-Z_$][\w$]*),\2\.config=\2\.set=/.exec(e),o=(n?n.index:-999)+378;t>0&&o>0&&(e=e.replace(e.substring(t,o),s))}const c=(t,n)=>{const s=e.indexOf(t),o=e.slice(0,s),r="oddMessage"===n?/},\s*function\s*\(\s*A\s*,\s*e\s*\)\s*{/g:/},\s*function\s*\(\s*A\s*,\s*e\s*,\s*t\s*\)\s*{/g;let i,a=-1;for(;null!==(i=r.exec(o));)i.index<s&&(a=i.index+1);if(-1===a)return t;const c=e.slice(s+t.length).indexOf("},");if(-1===c)return t;const l=s+t.length+c+2;let d=e.slice(a+1,l);return d.includes("function(A,e){A.exports=class{")?d=d.substring(0,d.indexOf("function(A,e){A.exports=class{")):d.includes("function(module,exports,__webpack_require__){")&&(d=d.substring(0,d.indexOf("function(module,exports,__webpack_require__){"))),d},l=(e=>{const t=[],n=/class(?:\s+[a-zA-Z0-9_]+)?\s*\{/g;let s;for(;null!==(s=n.exec(e));){const o=s.index;let r=1,i=n.lastIndex;for(;i<e.length&&r>0;)"{"===e[i]?r++:"}"===e[i]&&r--,i++;const a=e.slice(o,i);a.includes("getInfo(){")&&t.push(a)}return t})(e),d=/getInfo\s*\(\)\s*{[^}]*?\bid\s*:\s*["'`]([^"'`]+)["'`]/,p=[];for(var u=0;u<l.length;u++){const e=l[u].match(d);if(e){const t=e[1];t.includes(".")?p.push(t.split(".")[0]):p.push(t)}}for(u=0;u<l.length;u++){const t=p[u],o=l.find(e=>e.includes(`id:"${t}"`)||e.includes(`id:'${t}'`)||e.includes(`return'${t}'`)||e.includes(`return"${t}"`));if(o&&!n.includes(t)){const n=c(o,t);if(n.startsWith(s))continue;e=e.replace(n,s)}}const f=(e=(e=(e=e.replaceAll(/blockIconURI:"[^"]*"/g,'blockIconURI:""')).replaceAll(/menuIconURI:"[^"]*"/g,'menuIconURI:""')).replace("data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMjQgMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTIwLjc3MzU5NSA1LjcyODA1MTlhMS4zMDc3Nzc0IDEuMzA3Nzc3NCAwIDAgMC0xLjg1NzA0MyAwTDkuMTczNjEwNSAxNS40ODQwNzFsLTQuMDkzMzQzMi00LjEwNjQyYTEuMzM2NDQ2OCAxLjMzNjQ0NjggMCAxIDAtMS44NTcwNDM5IDEuOTIyNDMybDUuMDIxODY1MSA1LjAyMTg2NmExLjMwNzc3NzQgMS4zMDc3Nzc0IDAgMCAwIDEuODU3MDQ0NSAwTDIwLjc3MzU5NSA3LjY1MDQ4NDdhMS4zMDc3Nzc0IDEuMzA3Nzc3NCAwIDAgMCAwLTEuOTIyNDMyOHoiIGZpbGw9IiNmZmYiLz48L3N2Zz4=","data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZD0iTTIwLjc3NCA1LjcyOGExLjMxIDEuMzEgMCAwIDAtMS44NTcgMGwtOS43NDMgOS43NTYtNC4wOTQtNC4xMDZBMS4zMzYgMS4zMzYgMCAxIDAgMy4yMjMgMTMuM2w1LjAyMiA1LjAyMmExLjMxIDEuMzEgMCAwIDAgMS44NTcgMEwyMC43NzQgNy42NWExLjMxIDEuMzEgMCAwIDAgMC0xLjkyMiIgZmlsbD0iI2ZmZiIvPjwvc3ZnPg==").replace('<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><path fill="none" stroke="#fff" stroke-width="11.51815371" d="M24.457 7.707a18.41 18.41 0 0 0-.365 2.31c-.02.224 0 .507.06.852.061.405.092.689.092.851 0 .527-.345.79-1.034.79-.446 0-.74-.131-.881-.395-.02-.446-.01-1.054.03-1.824.04-.912.061-1.52.061-1.824-.02 0-.05-.02-.091-.06a98.522 98.522 0 0 0-5.32.364c-.04.264-.04.588 0 .973l.122 1.094c-.081.629-.122 1.56-.122 2.797.061.527.091 2.786.091 6.779v2.219c0 .344.051.587.152.73h1.885c.77-.102 1.155.222 1.155.972 0 .446-.213.76-.638.942-.264.102-.73.122-1.399.061-.405-.04-.881-.05-1.428-.03-.75.101-1.662.182-2.736.243-1.094.06-1.763-.091-2.006-.456-.162-.243-.162-.496 0-.76.283-.446 1.023-.669 2.219-.669.628 0 .942-.172.942-.516 0-.183-.01-.355-.03-.517 0-.507.01-.953.03-1.338.06-1.094.06-2.634 0-4.62-.081-2.878-.05-5.462.091-7.752l-.09-.09c-.63.04-1.805.03-3.527-.031-.081 0-.7.04-1.854.121.283 1.946.446 3.334.486 4.165l-.06.82c-.021.305-.274.457-.76.457-.386 0-.71-.73-.973-2.19-.122-.87-.244-1.752-.365-2.644 0-.142-.071-.385-.213-.73-.122-.364-.39-.97-.39-1.152 0-.641.593-.489 1.363-.61.06 0 .162.01.304.03.142.02.243.03.304.03H17.1a57.098 57.098 0 0 0 5.411-.486c.122-.06.304-.121.547-.182.426-.04.79.06 1.095.304.304.223.405.547.304.972z"/><path fill="none" stroke="#ff4c4c" stroke-width="5.75909785" d="M24.333 7.71q-.244 1.065-.365 2.311-.03.335.06.851.092.608.092.851 0 .79-1.034.79-.669 0-.881-.394-.03-.67.03-1.824.06-1.368.06-1.824-.03 0-.09-.061-2.827.122-5.32.365-.06.395 0 .973l.122 1.094q-.122.942-.122 2.796.091.79.091 6.78v2.218q0 .517.152.73h1.885q1.155-.152 1.155.973 0 .668-.638.942-.396.152-1.399.06-.608-.06-1.428-.03-1.125.152-2.736.243-1.642.092-2.006-.456-.244-.364 0-.76.425-.668 2.219-.668.942 0 .942-.517 0-.274-.03-.517 0-.76.03-1.337.091-1.642 0-4.62-.122-4.317.091-7.752l-.091-.091q-.942.06-3.526-.03-.122 0-1.854.12.425 2.919.486 4.165l-.06.821q-.031.456-.76.456-.578 0-.974-2.189-.182-1.307-.364-2.644 0-.213-.213-.73-.182-.547-.182-.82 0-.76 1.155-.943.09 0 .304.03.212.03.304.03h7.538q2.797-.12 5.411-.485.182-.092.547-.183.639-.06 1.095.304.456.335.304.973z"/><path fill="#fff" d="M24.31 7.714q-.243 1.064-.365 2.31-.03.335.061.852.091.608.091.85 0 .791-1.033.791-.67 0-.882-.395-.03-.669.03-1.824.061-1.368.061-1.824-.03 0-.09-.06-2.828.121-5.32.364-.061.396 0 .973l.121 1.094q-.121.943-.121 2.797.09.79.09 6.779v2.219q0 .517.153.73h1.884q1.156-.153 1.156.972 0 .669-.639.942-.395.152-1.398.061-.608-.06-1.429-.03-1.125.152-2.736.243-1.641.091-2.006-.456-.243-.365 0-.76.426-.669 2.22-.669.941 0 .941-.516 0-.274-.03-.517 0-.76.03-1.338.092-1.641 0-4.62-.121-4.317.092-7.752l-.092-.09q-.942.06-3.526-.031-.121 0-1.854.121.426 2.919.486 4.165l-.06.82q-.03.457-.76.457-.578 0-.973-2.19-.182-1.306-.365-2.644 0-.212-.213-.73-.182-.546-.182-.82 0-.76 1.155-.942.091 0 .304.03t.304.03h7.539q2.796-.121 5.41-.486.183-.091.548-.182.638-.061 1.094.304.456.334.304.972z"/></svg>',"")).match(/data:image\/[a-zA-Z0-9.+-]+;base64,[A-Za-z0-9+/=]+/g);if(f)for(u=1;u<f.length;u++)15!==u&&16!==u||n.includes("fr3d")?(u<15||u>16)&&(e=e.replace(f[u],"")):e=e.replace(f[u],"");return e=e.replace('c.has("livetests";',"false;").replace('String(window.location.href).startsWith("http://localhost:"),',"false,")})(e[1],this)),Object.values(this.getAddonOptions()).some(e=>e)&&e.push(await this.fetchLargeAsset("addons","text")),this.script=e.join("\n").replace(/<\/script>/g,"</scri'+'pt>")}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{CFBundleIdentifier:"org.turbowarp.packager.userland."+this.options.app.packageName,CFBundleName:this.options.app.windowTitle,CFBundleDisplayName:this.options.app.windowTitle,CFBundleExecutable:this.options.app.packageName,CFBundleVersion:this.options.app.version,CFBundleShortVersionString:this.options.app.version,LSApplicationCategoryType:"public.app-category.games"}}async updatePlist(e,t,n){const s=(e=>{const t=(new DOMParser).parseFromString(e,"text/xml").children[0].children[0];return E(t)})(await e.file(t).async("string"));Object.assign(s,n),e.file(t,(e=>{const t=document.implementation.createDocument(null,"plist"),n=t.documentElement;n.setAttribute("version","1.0"),n.appendChild(x(t,e));return'<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n'+(new XMLSerializer).serializeToString(t)})(s))}async addNwJS(e){const t=this.options.app.packageName;D(t);const n=await this.fetchLargeAsset(this.options.target,"arraybuffer"),s=await(await T()).loadAsync(n),o=this.options.target.startsWith("nwjs-win"),r="nwjs-mac"===this.options.target,i=this.options.target.startsWith("nwjs-linux"),a=Object.keys(s.files)[0].split("/")[0],c=new(await T());for(const e of Object.keys(s.files)){const n=s.files[e];let l=e.replace(a,t);o?l=l.replace("nw.exe",t+".exe"):r?l=l.replace("nwjs.app",t+".app"):i&&(l=l.replace(/nw$/,t)),M(c,l,n)}const l=await I.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:"icon.png"}};let p;if(o)p=t+"/";else if(r){c.file(`${t}/How to run ${t}.txt`,$(this.options));const e=await w(l);c.file(`${t}/${t}.app/Contents/Resources/app.icns`,e),p=`${t}/${t}.app/Contents/Resources/app.nw/`}else if(i){const e='#!/bin/bash\ncd "$(dirname "$0")"\n./'+t;c.file(t+"/start.sh",e,{unixPermissions:33261}),p=t+"/"}for(const t of Object.keys(e.files))M(c,p+t,e.files[t]);c.file(p+"icon.png",l),c.file(p+"package.json",JSON.stringify(d,null,4)),c.file(p+"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 u=t+"/credits.html",f=await c.file(u).async("string");return c.file(u,f+P([L,R])),c}async addElectron(e){const t=this.options.app.packageName;D(t);const n=await this.fetchLargeAsset(this.options.target,"arraybuffer"),s=await(await T()).loadAsync(n),o=this.options.target.includes("win"),r=this.options.target.includes("mac"),i=this.options.target.includes("linux"),a=new(await T());for(const e of Object.keys(s.files)){const n=s.files[e];let c;c=r?e:`${t}/${e}`,o?c=c.replace("electron.exe",t+".exe"):r?(c=c.replace("Electron.app",t+".app"),c=c.replace(/Electron$/,t)):i&&(c=c.replace(/electron$/,t)),M(a,c,n)}const c=r?"":t+"/",l=await a.file(c+"LICENSES.chromium.html").async("string");a.file(c+"licenses.html",l+P([L,R,k])),a.remove(c+"LICENSE.txt"),a.remove(c+"LICENSES.chromium.html"),a.remove(c+"LICENSE"),a.remove(c+"version"),a.remove(c+"resources/default_app.asar");const d=r?`${c}${t}.app/Contents/`:c,p=r?d+"Resources/app/":d+"resources/app/",u=await I.getAppIcon(this.options.app.icon);a.file(p+"icon.png",u);const f={name:t,main:"electron-main.js",version:this.options.app.version};a.file(p+"package.json",JSON.stringify(f,null,4));const h=`'use strict';\nconst {app, BrowserWindow, Menu, shell, screen, dialog} = 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("icon.png")}),\n useContentSize: true,\n webPreferences: {\n sandbox: true,\n contextIsolation: true,\n nodeIntegration: false,\n },\n show: true,\n width: 480,\n height: 360,\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\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: 'Renderer process crashed: ' + details.reason + ' (' + details.exitCode + ')'\n });\n});\n\napp.on('child-process-gone', (event, details) => {\n dialog.showMessageBoxSync({\n type: 'error',\n title: 'Error',\n message: details.type + ' child process crashed: ' + details.reason + ' (' + details.exitCode + ')'\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' && window.isFullScreen()) {\n window.setFullScreen(false);\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`;a.file(p+"electron-main.js",h);for(const[t,n]of Object.entries(e.files))M(a,`${p}${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");a.file(c+"README.txt",e)}else if(r){a.file(`How to run ${this.options.app.packageName}.txt`,$(this.options));const e=this.getPlistPropertiesForPrimaryExecutable();await this.updatePlist(a,d+"Info.plist",e);const t=["Electron Helper","Electron Helper (GPU)","Electron Helper (Renderer)","Electron Helper (Plugin)"];for(const n of t)await this.updatePlist(a,`${d}Frameworks/${n}.app/Contents/Info.plist`,{CFBundleIdentifier:e.CFBundleIdentifier+".helper",CFBundleDisplayName:n.replace("Electron",this.options.app.packageName),CFBundleVersion:this.options.app.version,CFBundleShortVersionString:this.options.app.version});const n=await w(u);a.file(d+"Resources/electron.icns",n)}else if(i){const e='#!/bin/bash\ncd "$(dirname "$0")"\n./'+t;a.file(c+"start.sh",e,{unixPermissions:33261})}return a}async addWebViewMac(e){D(this.options.app.packageName);const t=await this.fetchLargeAsset(this.options.target,"arraybuffer"),n=await(await T()).loadAsync(t),s=this.options.app.packageName+".app",o=s+"/Contents/",r=s+"/Contents/Resources/",i=new(await T());for(const[e,t]of Object.entries(n.files)){const n=e.replace("WebView.app",s).replace(/WebView$/,this.options.app.packageName);M(i,n,t)}for(const[t,n]of Object.entries(e.files))M(i,`${r}${t}`,n);const a=await I.getAppIcon(this.options.app.icon),c=await w(a);i.file(r+"AppIcon.icns",c),i.remove(r+"Assets.car");const l=parseInt(this.options.appearance.background.substr(1),16),d={title:this.options.app.windowTitle,background:[l>>16&255,l>>8&255,255&l,1],width:this.computeWindowSize().width,height:this.computeWindowSize().height};return i.file(r+"application_config.json",JSON.stringify(d)),await this.updatePlist(i,o+"Info.plist",this.getPlistPropertiesForPrimaryExecutable()),i.file(`How to run ${this.options.app.packageName}.txt`,$(this.options)),i}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 s=e[n];t+=`scaffolding.addCloudProviderOverride(${JSON.stringify(n)}, providers[${JSON.stringify(s)}] || null);\n`}return t+="}",t}generateFilename(e){return`${this.options.app.windowTitle}.${e}`}async generateGetProjectData(){const e=[];let t,n,s="",o=!1;if("html"===this.options.target){o="blob"!==this.project.type,t=.75,n=.98;const r=new Uint8Array(this.project.arrayBuffer);e.push(`\n <script>\n const getBase85DecodeValue = (code) => {\n if (code === 0x28) code = 0x3c;\n if (code === 0x29) code = 0x3e;\n return code - 0x2a;\n };\n const base85decode = (str, outBuffer, outOffset) => {\n const view = new DataView(outBuffer, outOffset, Math.floor(str.length / 5 * 4));\n for (let i = 0, j = 0; i < str.length; i += 5, j += 4) {\n view.setUint32(j, (\n getBase85DecodeValue(str.charCodeAt(i + 4)) * 85 * 85 * 85 * 85 +\n getBase85DecodeValue(str.charCodeAt(i + 3)) * 85 * 85 * 85 +\n getBase85DecodeValue(str.charCodeAt(i + 2)) * 85 * 85 +\n getBase85DecodeValue(str.charCodeAt(i + 1)) * 85 +\n getBase85DecodeValue(str.charCodeAt(i))\n ), true);\n }\n };\n let projectDecodeBuffer = new ArrayBuffer(${4*Math.ceil(r.length/4)});\n let projectDecodeIndex = 0;\n const decodeChunk = (size) => {\n try {\n base85decode(document.currentScript.getAttribute("data"), projectDecodeBuffer, projectDecodeIndex);\n document.currentScript.remove();\n projectDecodeIndex += size;\n setProgress(interpolate(0.1, 0.75, projectDecodeIndex / ${r.length}));\n } catch (e) {\n handleError(e);\n }\n };\n <\/script>`);const i=65536;for(let t=0;t<r.length;t+=i){const n=r.subarray(t,t+i),s=v(n);e.push(`<script data="${s}">decodeChunk(${n.length})<\/script>\n`)}s=`() => {\n const buffer = projectDecodeBuffer;\n projectDecodeBuffer = null; // Allow GC\n return Promise.resolve(new Uint8Array(buffer, 0, ${r.length}));\n }`}else{let e;"blob"===this.project.type||"zip-one-asset"===this.options.target?(o="blob"!==this.project.type,e="./project.zip",t=.75,n=.98):(e="./assets/project.json",t=.2,n=.98),s=`() => new Promise((resolve, reject) => {\n const xhr = new XMLHttpRequest();\n xhr.onload = () => {\n resolve(xhr.response);\n };\n xhr.onerror = () => {\n if (location.protocol === 'file:') {\n reject(new Error('Zip environment must be used from a website, not from a file URL.'));\n } else {\n reject(new Error('Request to load project data failed.'));\n }\n };\n xhr.onprogress = (e) => {\n if (e.lengthComputable) {\n setProgress(interpolate(0.1, ${t}, e.loaded / e.total));\n }\n };\n xhr.responseType = 'arraybuffer';\n xhr.open('GET', ${JSON.stringify(e)});\n xhr.send();\n })`}return e.push(`\n <script>\n const getProjectData = (function() {\n const storage = scaffolding.storage;\n storage.onprogress = (total, loaded) => {\n setProgress(interpolate(${t}, ${n}, loaded / total));\n };\n ${o?`\n let zip;\n // Allow zip to be GC'd after project loads\n vm.runtime.on('PROJECT_LOADED', () => (zip = null));\n const findFileInZip = (path) => zip.file(path) || zip.file(new RegExp("^([^/]*/)?" + path + "$"))[0];\n storage.addHelper({\n load: (assetType, assetId, dataFormat) => {\n if (!zip) {\n throw new Error('Zip is not loaded or has been closed');\n }\n const path = assetId + '.' + dataFormat;\n const file = findFileInZip(path);\n if (!file) {\n throw new Error('Asset is not in zip: ' + path)\n }\n return file\n .async('uint8array')\n .then((data) => storage.createAsset(assetType, dataFormat, data, assetId));\n }\n });\n return () => (${s})().then(async (data) => {\n zip = await Scaffolding.JSZip.loadAsync(data);\n const file = findFileInZip('project.json');\n if (!file) {\n throw new Error('project.json is not in zip');\n }\n return file.async('arraybuffer');\n });`:`\n storage.addWebStore(\n [\n storage.AssetType.ImageVector,\n storage.AssetType.ImageBitmap,\n storage.AssetType.Sound,\n storage.AssetType.Font\n ].filter(i => i),\n (asset) => new URL('./assets/' + asset.assetId + '.' + asset.dataFormat, location).href\n );\n return ${s};`}\n })();\n <\/script>`),e}async generateFavicon(){if(null===this.options.app.icon)return"";return`<link rel="icon" href="${await I.readAsURL(this.options.app.icon,"app icon")}">`}async generateCursor(){if("custom"!==this.options.cursor.type)return this.options.cursor.type;if(!this.options.cursor.custom)return"auto";return`url(${await I.readAsURL(this.options.cursor.custom,"custom cursor")}) ${this.options.cursor.center.x} ${this.options.cursor.center.y}, auto`}async generateExtensionURLs(){const e=e=>this.dispatchEvent(new s("fetch-extensions",{detail:{progress:e}})),t=e=>{if(!this.options.bakeExtensions)return!1;try{const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch(e){return!1}},n=this.options.extensions,o=n.filter(e=>!t(e)),r=n.filter(e=>t(e)),i=[...o];if(0!==r.length){for(let t=0;t<r.length;t++){e(t/r.length);const n=r[t];try{const e=`(function(Scratch) { ${await I.fetchExtensionScript(n)} })(Scratch);`,t="data:text/javascript;,"+encodeURIComponent(e);i.push(t)}catch(e){console.warn("Could not bake extension",n,e),i.push(n)}}e(1)}return i}async package(){if(!I)throw new Error("Missing adapter");if(this.used)throw new Error("Packager was already used");this.used=!0,this.ensureNotAborted(),await this.loadResources(),this.ensureNotAborted();const e=C`<!DOCTYPE html>
2
+ <!-- Created with ${S.WEBSITE} -->
3
+ <html>
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
7
+ <!-- We only include this to explicitly loosen the CSP of various packager environments. It does not provide any security. -->
8
+ <meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval' data: blob:">
9
+ <title>${r(this.options.app.windowTitle)}</title>
10
+ <style>
11
+ body {
12
+ color: ${this.options.appearance.foreground};
13
+ font-family: sans-serif;
14
+ overflow: hidden;
15
+ margin: 0;
16
+ padding: 0;
17
+ }
18
+ :root, body.is-fullscreen {
19
+ background-color: ${this.options.appearance.background};
20
+ }
21
+ [hidden] {
22
+ display: none !important;
23
+ }
24
+ h1 {
25
+ font-weight: normal;
26
+ }
27
+ a {
28
+ color: inherit;
29
+ text-decoration: underline;
30
+ cursor: pointer;
31
+ }
32
+
33
+ #app, #loading, #error, #launch {
34
+ position: absolute;
35
+ top: 0;
36
+ left: 0;
37
+ width: 100%;
38
+ height: 100%;
39
+ }
40
+ .screen {
41
+ display: flex;
42
+ flex-direction: column;
43
+ align-items: center;
44
+ justify-content: center;
45
+ text-align: center;
46
+ cursor: default;
47
+ user-select: none;
48
+ -webkit-user-select: none;
49
+ background-color: ${this.options.appearance.background};
50
+ }
51
+ #launch {
52
+ background-color: rgba(0, 0, 0, 0.7);
53
+ cursor: pointer;
54
+ }
55
+ ${this.options.controls.greenFlag.enabled||!this.options.autoplay?".green-flag {\n width: 80px;\n height: 80px;\n padding: 16px;\n border-radius: 100%;\n background: rgba(255, 255, 255, 0.75);\n border: 3px solid hsla(0, 100%, 100%, 1);\n display: flex;\n justify-content: center;\n align-items: center;\n box-sizing: border-box;\n }":""}
56
+ #loading {
57
+ ${this.options.loadingScreen.image&&"stretch"===this.options.loadingScreen.imageMode?`background-image: url(${await I.readAsURL(this.options.loadingScreen.image,"stretched loading screen")});\n background-repeat: no-repeat;\n background-size: contain;\n background-position: center;`:""}
58
+ }
59
+ .progress-bar-outer {
60
+ border: 1px solid currentColor;
61
+ height: 10px;
62
+ width: 200px;
63
+ max-width: 200px;
64
+ }
65
+ .progress-bar-inner {
66
+ height: 100%;
67
+ width: 0;
68
+ background-color: currentColor;
69
+ }
70
+ .loading-text, noscript {
71
+ font-weight: normal;
72
+ font-size: 36px;
73
+ margin: 0 0 16px;
74
+ }
75
+ .loading-image {
76
+ margin: 0 0 16px;
77
+ }
78
+ #error-message, #error-stack {
79
+ font-family: monospace;
80
+ max-width: 600px;
81
+ white-space: pre-wrap;
82
+ user-select: text;
83
+ -webkit-user-select: text;
84
+ }
85
+ #error-stack {
86
+ text-align: left;
87
+ max-height: 200px;
88
+ overflow: auto;
89
+ }
90
+ ${this.options.controls.greenFlag.enabled||this.options.controls.pause.enabled||this.options.controls.stopAll.enabled||this.options.controls.fullscreen.enabled?`.control-button {\n width: 2rem;\n height: 2rem;\n padding: 0.375rem;\n margin-top: 0.5rem;\n margin-bottom: 0.5rem;\n user-select: none;\n -webkit-user-select: none;\n cursor: pointer;\n border: 0;\n border-radius: 4px;\n }\n .control-button:hover {\n background: ${this.options.appearance.accent}26;\n }\n .control-button.active {\n background: ${this.options.appearance.accent}59;\n }`:""}
91
+ ${this.options.controls.fullscreen.enabled?".fullscreen-button {\n background: white !important;\n }\n .standalone-fullscreen-button {\n position: absolute;\n top: 0;\n right: 0;\n background-color: rgba(0, 0, 0, 0.5);\n border-radius: 0 0 0 4px;\n padding: 4px;\n cursor: pointer;\n }":""}
92
+ .sc-canvas {
93
+ cursor: ${await this.generateCursor()};
94
+ }
95
+ .sc-monitor-root[data-opcode^="data_"] .sc-monitor-value-color {
96
+ background-color: ${this.options.monitors.variableColor};
97
+ }
98
+ .sc-monitor-row-value-outer {
99
+ background-color: ${this.options.monitors.listColor};
100
+ }
101
+ .sc-monitor-row-value-editing .sc-monitor-row-value-outer {
102
+ background-color: ${A(this.options.monitors.listColor)};
103
+ }
104
+ ${this.options.custom.css}
105
+ </style>
106
+ <meta name="theme-color" content="${this.options.appearance.background}">
107
+ ${await this.generateFavicon()}
108
+ </head>
109
+ <body>
110
+ <div id="app"></div>
111
+
112
+ ${this.options.autoplay?"":'<div id="launch" class="screen" hidden title="Click to start">\n <div class="green-flag">\n <svg viewBox="0 0 16.63 17.5" width="42" height="44">\n <defs><style>.cls-1,.cls-2{fill:#007AF4;stroke:#003080;stroke-linecap:round;stroke-linejoin:round;}.cls-2{stroke-width:1.5px;}</style></defs>\n <path class="cls-1" d="M.75,2A6.44,6.44,0,0,1,8.44,2h0a6.44,6.44,0,0,0,7.69,0V12.4a6.44,6.44,0,0,1-7.69,0h0a6.44,6.44,0,0,0-7.69,0"/>\n <line class="cls-2" x1="0.75" y1="16.75" x2="0.75" y2="0.75"/>\n </svg>\n </div>\n </div>'}
113
+
114
+ <div id="loading" class="screen">
115
+ <noscript>Enable JavaScript</noscript>
116
+ ${this.options.loadingScreen.text?`<h1 class="loading-text">${r(this.options.loadingScreen.text)}</h1>`:""}
117
+ ${this.options.loadingScreen.image&&"normal"===this.options.loadingScreen.imageMode?`<div class="loading-image"><img src="${await I.readAsURL(this.options.loadingScreen.image,"loading-screen")}"></div>`:""}
118
+ ${this.options.loadingScreen.progressBar?'<div class="progress-bar-outer"><div class="progress-bar-inner" id="loading-inner"></div></div>':""}
119
+ </div>
120
+
121
+ <div id="error" class="screen" hidden>
122
+ <h1>Error</h1>
123
+ <details>
124
+ <summary id="error-message"></summary>
125
+ <p id="error-stack"></p>
126
+ </details>
127
+ </div>
128
+
129
+ ${"html"===this.options.target?`<script>${this.script}<\/script>`:'<script src="script.js"><\/script>'}
130
+ <script>${t=`\n const appElement = document.getElementById('app');\n const launchScreen = document.getElementById('launch');\n const loadingScreen = document.getElementById('loading');\n const loadingInner = document.getElementById('loading-inner');\n const errorScreen = document.getElementById('error');\n const errorScreenMessage = document.getElementById('error-message');\n const errorScreenStack = document.getElementById('error-stack');\n\n const handleError = (error) => {\n console.error(error);\n if (!errorScreen.hidden) return;\n errorScreen.hidden = false;\n errorScreenMessage.textContent = '' + error;\n let debug = error && error.stack || 'no stack';\n debug += '\\nUser agent: ' + navigator.userAgent;\n errorScreenStack.textContent = debug;\n };\n const setProgress = (progress) => {\n if (loadingInner) loadingInner.style.width = progress * 100 + '%';\n };\n const interpolate = (a, b, t) => a + t * (b - a);\n\n try {\n setProgress(0.1);\n\n const scaffolding = new Scaffolding.Scaffolding();\n scaffolding.width = ${this.options.stageWidth};\n scaffolding.height = ${this.options.stageHeight};\n scaffolding.resizeMode = ${JSON.stringify(this.options.resizeMode)};\n scaffolding.editableLists = ${this.options.monitors.editableLists};\n scaffolding.usePackagedRuntime = ${this.options.packagedRuntime};\n scaffolding.setup();\n scaffolding.appendTo(appElement);\n\n const vm = scaffolding.vm;\n window.scaffolding = scaffolding;\n window.vm = scaffolding.vm;\n window.Scratch = {\n vm,\n renderer: vm.renderer,\n audioEngine: vm.runtime.audioEngine,\n bitmapAdapter: vm.runtime.v2BitmapAdapter,\n videoProvider: vm.runtime.ioDevices.video.provider\n };\n\n vm.runtime.isPackagedProject = true;\n scaffolding.setUsername(${JSON.stringify(this.options.username)}.replace(/#/g, () => Math.floor(Math.random() * 10)));\n scaffolding.setAccentColor(${JSON.stringify(this.options.appearance.accent)});\n\n try {\n ${"ws"===this.options.cloudVariables.mode?`scaffolding.addCloudProvider(${this.makeWebSocketProvider()})`:"local"===this.options.cloudVariables.mode?`scaffolding.addCloudProvider(${this.makeLocalStorageProvider()})`:"custom"===this.options.cloudVariables.mode?this.makeCustomProvider():""};\n } catch (error) {\n console.error(error);\n }\n\n ${this.options.controls.greenFlag.enabled?'\n const greenFlagButton = document.createElement(\'img\');\n greenFlagButton.src = \'data:image/svg+xml,\' + encodeURIComponent(\'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16.63 17.5"><path d="M.75 2a6.44 6.44 0 017.69 0h0a6.44 6.44 0 007.69 0v10.4a6.44 6.44 0 01-7.69 0h0a6.44 6.44 0 00-7.69 0" fill="#007AF4" stroke="#003080" stroke-linecap="round" stroke-linejoin="round"/><path stroke-width="1.5" fill="#007AF4" stroke="#003080" stroke-linecap="round" stroke-linejoin="round" d="M.75 16.75v-16"/></svg>\');\n greenFlagButton.className = \'control-button green-flag-button\';\n greenFlagButton.draggable = false;\n greenFlagButton.addEventListener(\'click\', () => {\n scaffolding.greenFlag();\n });\n scaffolding.addEventListener(\'PROJECT_RUN_START\', () => {\n greenFlagButton.classList.add(\'active\');\n });\n scaffolding.addEventListener(\'PROJECT_RUN_STOP\', () => {\n greenFlagButton.classList.remove(\'active\');\n });\n scaffolding.addControlButton({\n element: greenFlagButton,\n where: \'top-left\'\n });':""}\n\n ${this.options.controls.pause.enabled?'\n const pauseButton = document.createElement(\'img\');\n pauseButton.className = \'control-button pause-button\';\n pauseButton.draggable = false;\n let isPaused = false;\n pauseButton.addEventListener(\'click\', () => {\n vm.setPaused(!isPaused);\n });\n const updatePause = (_isPaused) => {\n isPaused = _isPaused;\n if (isPaused) {\n pauseButton.src = \'data:image/svg+xml,\' + encodeURIComponent(\'<svg width="16" height="16" viewBox="0 0 4.2333332 4.2333335" xmlns="http://www.w3.org/2000/svg"><path d="m3.95163484 2.02835365-1.66643921.9621191-1.66643913.96211911V.10411543l1.66643922.9621191z" fill="#ffae00"/></svg>\');\n } else {\n pauseButton.src = \'data:image/svg+xml,\' + encodeURIComponent(\'<svg width="16" height="16" viewBox="0 0 4.2333332 4.2333335" xmlns="http://www.w3.org/2000/svg"><g fill="#ffae00"><path d="M.389.19239126h1.2631972v3.8485508H.389zM2.5810001.19239126h1.2631972v3.8485508H2.5810001z"/></g></svg>\');\n }\n }\n vm.on(\'P4_PAUSE\', updatePause);\n updatePause();\n scaffolding.addControlButton({\n element: pauseButton,\n where: \'top-left\'\n });':""}\n\n ${this.options.controls.stopAll.enabled?'\n const stopAllButton = document.createElement(\'img\');\n stopAllButton.src = \'data:image/svg+xml,\' + encodeURIComponent(\'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14"><path fill="#ec5959" stroke="#b84848" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="M4.3.5h5.4l3.8 3.8v5.4l-3.8 3.8H4.3L.5 9.7V4.3z"/></svg>\');\n stopAllButton.className = \'control-button stop-all-button\';\n stopAllButton.draggable = false;\n stopAllButton.addEventListener(\'click\', () => {\n scaffolding.stopAll();\n });\n scaffolding.addControlButton({\n element: stopAllButton,\n where: \'top-left\'\n });':""}\n\n ${this.options.controls.fullscreen.enabled?`\n if (document.fullscreenEnabled || document.webkitFullscreenEnabled) {\n let isFullScreen = !!(document.fullscreenElement || document.webkitFullscreenElement);\n const fullscreenButton = document.createElement('img');\n fullscreenButton.draggable = false;\n fullscreenButton.className = 'control-button fullscreen-button';\n fullscreenButton.addEventListener('click', () => {\n if (isFullScreen) {\n if (document.exitFullscreen) {\n document.exitFullscreen();\n } else if (document.webkitExitFullscreen) {\n document.webkitExitFullscreen();\n }\n } else {\n if (document.body.requestFullscreen) {\n document.body.requestFullscreen();\n } else if (document.body.webkitRequestFullscreen) {\n document.body.webkitRequestFullscreen();\n }\n }\n });\n const otherControlsExist = ${this.options.controls.greenFlag.enabled||this.options.controls.stopAll.enabled};\n const fillColor = otherControlsExist ? '#575E75' : '${this.options.appearance.foreground}';\n const updateFullScreen = () => {\n isFullScreen = !!(document.fullscreenElement || document.webkitFullscreenElement);\n document.body.classList.toggle('is-fullscreen', isFullScreen);\n if (isFullScreen) {\n fullscreenButton.src = 'data:image/svg+xml,' + encodeURIComponent('<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg"><g fill="' + fillColor + '" fill-rule="evenodd"><path d="M12.662 3.65l.89.891 3.133-2.374a.815.815 0 011.15.165.819.819 0 010 .986L15.467 6.46l.867.871c.25.25.072.664-.269.664L12.388 8A.397.397 0 0112 7.611V3.92c0-.341.418-.514.662-.27M7.338 16.35l-.89-.89-3.133 2.374a.817.817 0 01-1.15-.166.819.819 0 010-.985l2.37-3.143-.87-.871a.387.387 0 01.27-.664L7.612 12a.397.397 0 01.388.389v3.692a.387.387 0 01-.662.27M7.338 3.65l-.89.891-3.133-2.374a.815.815 0 00-1.15.165.819.819 0 000 .986l2.37 3.142-.87.871a.387.387 0 00.27.664L7.612 8A.397.397 0 008 7.611V3.92a.387.387 0 00-.662-.27M12.662 16.35l.89-.89 3.133 2.374a.817.817 0 001.15-.166.819.819 0 000-.985l-2.368-3.143.867-.871a.387.387 0 00-.269-.664L12.388 12a.397.397 0 00-.388.389v3.692c0 .342.418.514.662.27"/></g></svg>');\n } else {\n fullscreenButton.src = 'data:image/svg+xml,' + encodeURIComponent('<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg"><g fill="' + fillColor + '" fill-rule="evenodd"><path d="M16.338 7.35l-.89-.891-3.133 2.374a.815.815 0 01-1.15-.165.819.819 0 010-.986l2.368-3.142-.867-.871a.387.387 0 01.269-.664L16.612 3a.397.397 0 01.388.389V7.08a.387.387 0 01-.662.27M3.662 12.65l.89.89 3.133-2.374a.817.817 0 011.15.166.819.819 0 010 .985l-2.37 3.143.87.871c.248.25.071.664-.27.664L3.388 17A.397.397 0 013 16.611V12.92c0-.342.418-.514.662-.27M3.662 7.35l.89-.891 3.133 2.374a.815.815 0 001.15-.165.819.819 0 000-.986L6.465 4.54l.87-.871a.387.387 0 00-.27-.664L3.388 3A.397.397 0 003 3.389V7.08c0 .341.418.514.662.27M16.338 12.65l-.89.89-3.133-2.374a.817.817 0 00-1.15.166.819.819 0 000 .985l2.368 3.143-.867.871a.387.387 0 00.269.664l3.677.005a.397.397 0 00.388-.389V12.92a.387.387 0 00-.662-.27"/></g></svg>');\n }\n };\n updateFullScreen();\n document.addEventListener('fullscreenchange', updateFullScreen);\n document.addEventListener('webkitfullscreenchange', updateFullScreen);\n if (otherControlsExist) {\n fullscreenButton.className = 'control-button fullscreen-button';\n scaffolding.addControlButton({\n element: fullscreenButton,\n where: 'top-right'\n });\n } else {\n fullscreenButton.className = 'standalone-fullscreen-button';\n document.body.appendChild(fullscreenButton);\n }\n }`:""}\n\n vm.setTurboMode(${this.options.turbo});\n if (vm.setInterpolation) vm.setInterpolation(${this.options.interpolation});\n if (vm.setFramerate) vm.setFramerate(${this.options.framerate});\n if (vm.renderer.setUseHighQualityRender) vm.renderer.setUseHighQualityRender(${this.options.highQualityPen});\n if (vm.setRuntimeOptions) vm.setRuntimeOptions({\n fencing: ${this.options.fencing},\n miscLimits: ${this.options.miscLimits},\n maxClones: ${this.options.maxClones},\n dangerousOptimizations: ${this.options.dangerousOptimizations}\n });\n if (vm.setCompilerOptions) vm.setCompilerOptions({\n enabled: true,\n warpTimer: ${this.options.compiler.warpTimer}\n });\n if (vm.renderer.setMaxTextureDimension) vm.renderer.setMaxTextureDimension(${this.options.maxTextureDimension});\n\n if (typeof ScaffoldingAddons !== 'undefined') {\n ScaffoldingAddons.run(scaffolding, ${JSON.stringify(this.getAddonOptions())});\n }\n\n scaffolding.setExtensionSecurityManager({\n getSandboxMode: () => 'unsandboxed',\n canLoadExtensionFromProject: () => true\n });\n for (const extension of ${JSON.stringify(await this.generateExtensionURLs())}) {\n vm.extensionManager.loadExtensionURL(extension);\n }\n\n ${this.options.closeWhenStopped?"\n vm.runtime.on('PROJECT_RUN_STOP', () => {\n if (!vm.isPaused || !vm.isPaused()) {\n window.close();\n }\n });":""}\n ${this.options.penguinmod.permissionManager.enabled?"vm.runtime.isProjectPermissionManagerDisabled = false;":"vm.runtime.isProjectPermissionManagerDisabled = true;"}\n ${this.options.penguinmod.permissionManager.unsandboxedJavascript?"vm.runtime.extensionRuntimeOptions.javascriptUnsandboxed = true;":""}\n\n ${this.options.target.startsWith("nwjs-")?"\n if (typeof nw !== 'undefined') {\n const win = nw.Window.get();\n win.on('new-win-policy', (frame, url, policy) => {\n policy.ignore();\n nw.Shell.openExternal(url);\n });\n win.on('navigation', (frame, url, policy) => {\n policy.ignore();\n nw.Shell.openExternal(url);\n });\n document.addEventListener('keydown', (e) => {\n if (e.key === 'Escape' && document.fullscreenElement) {\n document.exitFullscreen();\n }\n });\n }":""}\n } catch (e) {\n handleError(e);\n }\n `,t.split("\n").filter((e,t,n)=>0===t||t===n.length-1||0!==e.trim().length||0!==n[t-1].trim().length).join("\n")}</script>
131
+ ${this.options.custom.js?`<script>\n try {\n ${this.options.custom.js}\n } catch (e) {\n handleError(e);\n }\n <\/script>`:""}
132
+ ${await this.generateGetProjectData()}
133
+ <script>
134
+ const run = async () => {
135
+ const projectData = await getProjectData();
136
+ await scaffolding.loadProject(projectData);
137
+ setProgress(1);
138
+ loadingScreen.hidden = true;
139
+ if (${this.options.autoplay}) {
140
+ scaffolding.start();
141
+ } else {
142
+ launchScreen.hidden = false;
143
+ launchScreen.addEventListener('click', () => {
144
+ launchScreen.hidden = true;
145
+ scaffolding.start();
146
+ });
147
+ launchScreen.focus();
148
+ }
149
+ };
150
+ run().catch(handleError);
151
+ </script>
152
+ </body>
153
+ </html>
154
+ `;var t;if(this.ensureNotAborted(),"html"!==this.options.target){let t;if("sb3"===this.project.type||"pm"===this.project.type&&"zip-one-asset"!==this.options.target){t=await(await T()).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 T()),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 s("zip-progress",{detail:{progress:e.percent/100}}))}),type:"application/zip",filename:this.generateFilename("zip")}}return{data:e,type:"text/html",filename:this.generateFilename("html")}}}z.getDefaultPackageNameFromFileName=e=>(e=(e=(e=(e=e.split(".")[0]).replace(/[^\-a-z ]/gi,"")).trim()).replace(/ /g,"-")).toLowerCase()||"packaged-project",z.getWindowTitleFromFileName=e=>{const t=e.split(".");return t.length>1&&t.pop(),(e=t.join(".").trim())||"Packaged Project"},z.usesUnsafeOptions=e=>{const t=z.DEFAULT_OPTIONS(),n=e=>[e.custom,e.extensions,e.cloudVariables.unsafeCloudBehaviors];return JSON.stringify(n(t))!==JSON.stringify(n(e))},z.DEFAULT_OPTIONS=()=>({turbo:!1,interpolation:!1,framerate:30,highQualityPen:!1,maxClones:300,fencing:!0,miscLimits:!0,dangerousOptimizations:!1,stageWidth:480,stageHeight:360,resizeMode:"preserve-ratio",autoplay:!1,username:"player####",closeWhenStopped:!1,projectId:"",custom:{css:"",js:""},appearance:{background:"#000000",foreground:"#ffffff",accent:S.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"},penguinmod:{permissionManager:{enabled:!1,unsandboxedJavascript:!1}},compiler:{enabled:!0,warpTimer:!1},packagedRuntime:!0,optimizeCode:!1,removeDefaultFonts:!1,target:"html",app:{icon:null,packageName:z.getDefaultPackageNameFromFileName(""),windowTitle:z.getWindowTitleFromFileName(""),windowMode:"window",version:"1.0.0"},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}},extensions:[],bakeExtensions:!0,maxTextureDimension:2048});var B=z;const F="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#%()*+,-./:;=?@[]^_`{|}~",U=e=>{let t="";for(;e>=0;)t=F[e%F.length]+t,e=Math.floor(e/F.length)-1;return t};class _{constructor(){this.generatedIds=new Map,this.references=new Map,this.skippedIds=new Set,this.skippedIds.add("of")}skip(e){this.skippedIds.add(e)}addReference(e){const t=this.references.get(e)||0;this.references.set(e,t+1)}generateNewIds(){const e=Array.from(this.references.entries());e.sort((e,t)=>t[1]-e[1]);let t=0;for(const n of e){const e=n[0];let s=U(t);for(;this.skippedIds.has(s);)t++,s=U(t);this.generatedIds.set(e,s),t++}}getNewId(e){return this.generatedIds.has(e)?this.generatedIds.get(e):e}}var W=e=>{const t=new _;for(const n of e.targets)for(const[e,s]of Object.entries(n.blocks))if(t.addReference(e),!Array.isArray(s)){s.parent&&t.addReference(s.parent),s.next&&t.addReference(s.next);for(const e of Object.values(s.inputs))for(let n=1;n<e.length;n++){const s=e[n];"string"==typeof s&&t.addReference(s)}}if(t.generateNewIds(),e.monitors)for(const t of e.monitors)t.value=Array.isArray(t.value)?[]:0;for(const n of e.targets){const e={},s={};for(const[s,o]of Object.entries(n.blocks))if(e[t.getNewId(s)]=o,!Array.isArray(o)){o.parent&&(o.parent=t.getNewId(o.parent)),o.next&&(o.next=t.getNewId(o.next));for(const e of Object.values(o.inputs))for(let n=1;n<e.length;n++){const s=e[n];"string"==typeof s&&(e[n]=t.getNewId(s))}o.shadow||delete o.shadow,o.topLevel||delete o.topLevel,delete o.x,delete o.y,delete o.comment}for(const[e,t]of Object.entries(n.comments)){const n=t.text;(n.includes(" // _twconfig_")||n.includes(" // _gamepad_"))&&(s[e]=t)}n.blocks=e,n.comments=s}return e.meta&&(delete e.meta.agent,delete e.meta.vm),e},H=n(5);const V=async(e,t=(()=>{}),n,s=0)=>{let o={stageVariables:[],stageComments:[],usesMusic:!0,extensions:[],builtInExts:[]};const r={signal:n,assetHost:`https://asset-cdn.penguinmod.com/file/penguinmod-warm-tier-s2-cf/${s}_$id`,onProgress(e,n,s){t(e,n,s)},processJSON(e,t){if("sb3"===e||"pm"===e||"pmp"===e)return(e=>{(e=>{const t=e.targets.find(e=>e.isStage);if(t)for(const e of Object.values(t.variables)){e[0].startsWith("☁")&&(e[2]=!0)}})(e),(e=>{const t=["☁ potential reporters"],n=e.targets.find(e=>e.isStage);if(n)for(const e of Object.values(n.variables))e[2]&&t.includes(e[0])&&(e[2]=!1)})(e),W(e)})(t),o=(e=>{const t=e.targets[0];if(!t||!t.isStage)throw new Error("Project does not have stage");return{stageVariables:[],stageComments:[],usesMusic:!0,extensions:[],builtInExts:[],stageVariables:Object.values(t.variables).map(([e,t,n])=>({name:e,isCloud:!!n})),stageComments:Object.values(t.comments).map(e=>e.text),usesMusic:e.extensions&&e.extensions.includes("music"),extensions:e.extensionURLs?Object.values(e.extensionURLs):[],builtInExts:e.extensions}})(t),t;"sb2"===e&&(o=(e=>{const t=(e.variables||[]).map(({name:e,isPersistent:t})=>({name:e,isCloud:t})),n=JSON.stringify(e);return{stageVariables:[],stageComments:[],usesMusic:!0,extensions:[],builtInExts:[],stageVariables:t,usesMusic:n.includes("drum:duration:elapsed:from:")||n.includes("playDrum")||n.includes("noteOn:duration:elapsed:from:")}})(t))}},i=await Object(H.downloadProjectFromBuffer)(e,r);return"sb3"===i.type&&"pm"!==i.type||(i.type="blob"),i.analysis=o,i};var q=n(3),G=n.n(q),Y=n(1),J=n.n(Y),Z=n(2),Q=n(4),X=n.n(Q),K=n(6),ee=n.p+"290e09e569a1cab8e61ba93b0d23863f.png";var te=class{constructor(e,t){this.mimeType=e,this.buffer=Buffer.from(t)}readAsURL(){return`data:${this.mimeType};base64,${this.buffer.toString("base64")}`}readAsBuffer(){return this.buffer}};const ne=Object(Z.promisify)(G.a.readFile),se=Object(Z.promisify)(G.a.writeFile),oe=Object(Z.promisify)(G.a.mkdir),re=(e,t)=>{e=J.a.join(e,"/");const n=J.a.join(e,t);return n.startsWith(e)?n:null},ie=J.a.join(__dirname,"..",".packager-cache");var ae;ae=new class{async getCachedAsset(e){const t=e.src,n=Array.isArray(t)?t[0]:t;if(n.startsWith("scaffolding/")){const e=re(__dirname,n);if(e)return ne(e,"utf-8")}if(n.startsWith("https:")){const t=await(async e=>{if(!e.sha256)return null;const t=re(ie,e.sha256);return t?(await oe(ie,{recursive:!0}),t):null})(e);if(t)try{return(s=await ne(t)).buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}catch(e){}console.log(`[${K.a}]: downloading large asset ${n}; this may take a while`);const o=await X()(n);if(!o.ok)throw new Error("Unexpected status code: "+o.status);const r=await o.arrayBuffer();return t&&await se(t,(e=>Buffer.from(e))(r)),r}var s}async cacheAsset(e,t){}async getAppIcon(e){if(!e){const e=await ne(J.a.join(__dirname,ee));return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(e instanceof te){if("image/png"===e.mimeType)return e.readAsBuffer();throw new Error("icon must be of type image/png but found "+e.mimeType+" instead.")}throw new Error("file must be an instance of Packager.Image or null but found "+e+" instead.")}readAsURL(e){if(!(e instanceof te))throw new Error("file must be an instance of Packager.Image but found "+e+" instead.");return e.readAsURL()}fetchExtensionScript(e){return X()(e).then(e=>{if(e.ok)return e.text();throw new Error("Unexpected status code: "+e.status)})}},I=ae},function(e,t){e.exports=require("buffer")},function(e,t){e.exports=n},function(e,t){e.exports=s}])}));
@@ -0,0 +1,2 @@
1
+ !function(e){var t={};function n(s){if(t[s])return t[s].exports;var r=t[s]={i:s,l:!1,exports:{}};return e[s].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(s,r,function(t){return e[t]}.bind(null,r));return s},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=561)}({153:function(e,t){e.exports='.sa-gamepad-container {\n margin-right: 0.2rem;\n}\n\n.sa-gamepad-spacer {\n display: flex;\n width: 100%;\n justify-content: flex-end;\n}\n\n.sa-gamepad-popup-outer {\n /* above fullscreen */\n z-index: 99999;\n}\n.sa-gamepad-popup {\n box-sizing: border-box;\n width: 700px;\n max-height: min(800px, 85vh);\n height: 100%;\n max-width: 85%;\n margin: 50px auto;\n display: flex;\n flex-direction: column;\n}\n.sa-gamepad-popup-content {\n background-color: white;\n padding: 1.5rem 2.25rem;\n height: 100%;\n overflow-y: auto;\n}\n\n.sa-gamepad-popup [class*="modal_header-item-title"] {\n margin: 0 -20rem 0 0;\n}\n\n.sa-gamepad-cursor {\n position: absolute;\n top: 0;\n left: 0;\n z-index: 9999;\n user-select: none;\n pointer-events: none;\n will-change: transform;\n image-rendering: optimizeSpeed;\n image-rendering: crisp-edges;\n image-rendering: pixelated;\n}\n.sa-gamepad-cursor-down {\n filter: invert(100%);\n}\n\n.sa-gamepad-small .sa-gamepad-container[data-editor-mode="editor"] {\n display: none !important;\n}\n\n.sa-gamepad-hide-cursor {\n cursor: none;\n}\n\n.sa-gamepad-browser-support-warning {\n font-weight: bold;\n margin-bottom: 10px;\n}\n\n.sa-gamepad-store-settings {\n display: none;\n}\n.sa-gamepad-store-settings > input {\n margin-right: 4px;\n}\n.sa-gamepad-has-controller .sa-gamepad-store-settings {\n display: block;\n}\n'},154:function(module,__webpack_exports__,__webpack_require__){"use strict";const isPromise=e=>!!e&&"function"==typeof e.then,jsValueToScratchValue=e=>"boolean"==typeof e||"number"==typeof e||"string"==typeof e?e:""+e;class UnsafeCloudBehaviorsProvider{enable(){}setEvalValue(e){this.manager.setVariable(this,"☁ eval output",jsValueToScratchValue(e))}setEvalError(e){console.error("Error evaluating ☁ eval",e),this.manager.setVariable(this,"☁ eval error",jsValueToScratchValue(e))}evaluateAsync(js){try{const value=eval(js);isPromise(value)?value.then(e=>this.setEvalValue(e)).catch(e=>this.setEvalError(e)):this.setEvalValue(value)}catch(e){this.setEvalError(e)}}handleUpdateVariable(e,t){"☁ eval"===e&&this.evaluateAsync(t)}}__webpack_exports__.a=function(e){let t=e.scaffolding;const n=new UnsafeCloudBehaviorsProvider;t.addCloudProvider(n),t.addCloudProviderOverride("☁ eval",n),t.addCloudProviderOverride("☁ eval output",n),t.addCloudProviderOverride("☁ eval error",n)}},17:function(e,t,n){"use strict";n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return r}));class s{constructor(){this._events={}}addEventListener(e,t){this._events[e]||(this._events[e]=[]),this._events[e].push(t)}removeEventListener(e,t){const n=this._events[e];n&&(this._events[e]=n.filter(e=>e!==t))}dispatchEvent(e){const t=this._events[e.type];if(t)for(const n of t)n(e)}}class r{constructor(e,t){this.type=e,this.detail=t?t.detail:{}}}},561:function(e,t,n){"use strict";n.r(t);var s=n(17);let r=window.console;const i=[{type:"key",high:"ArrowRight",low:"ArrowLeft",deadZone:.5},{type:"key",high:"ArrowDown",low:"ArrowUp",deadZone:.5}],o=[{type:"key",high:"d",low:"a",deadZone:.5},{type:"key",high:"s",low:"w",deadZone:.5}],a=[{type:"virtual_cursor",high:"+x",low:"-x",sensitivity:.6,deadZone:.2},{type:"virtual_cursor",high:"-y",low:"+y",sensitivity:.6,deadZone:.2}],d=e=>{if("object"!=typeof e||!e)return r.warn("invalid mapping",e),{type:"key",high:null,low:null};const t=Object.assign({},e);if("key"===t.type)void 0===t.deadZone&&(t.deadZone=.5),void 0===t.high&&(t.high=""),void 0===t.low&&(t.low="");else if("mousedown"===t.type)void 0===t.deadZone&&(t.deadZone=.5),void 0===t.button&&(t.button=0);else{if("virtual_cursor"!==t.type)return r.warn("unknown mapping type",t.type),{type:"key",high:null,low:null};void 0===t.high&&(t.high=""),void 0===t.low&&(t.low=""),void 0===t.sensitivity&&(t.sensitivity=10),void 0===t.deadZone&&(t.deadZone=.5)}return t},u=(e,t)=>{for(;e.length<t;)e.push({type:"key",high:null,low:null});return e.length=t,e},l=e=>u([],e),c=e=>({usesArrows:e.has("ArrowUp")||e.has("ArrowDown")||e.has("ArrowRight")||e.has("ArrowLeft"),usesWASD:e.has("w")&&e.has("s")||e.has("a")&&e.has("d")}),h=e=>"".concat(e.id," (").concat(e.index,")");class p{constructor(e,t){this.gamepad=e,this.gamepadLib=t,this.resetMappings()}resetMappings(){this.hints=this.gamepadLib.getHints(),this.buttonMappings=this.getDefaultButtonMappings().map(d),this.axesMappings=this.getDefaultAxisMappings().map(d)}clearMappings(){this.buttonMappings=l(this.gamepad.buttons.length),this.axesMappings=l(this.gamepad.axes.length)}getDefaultButtonMappings(){let e;if(this.hints.importedSettings)e=this.hints.importedSettings.buttons;else{const t=this.hints.usedKeys,n=new Set,s=c(t),r=s.usesArrows,i=s.usesWASD;i&&(n.add("w"),n.add("a"),n.add("s"),n.add("d"));const o=["p","q","r"],a=[" ","Enter","e","f","z","x","c",...Array.from(t).filter(e=>1===e.length&&!o.includes(e))],d=e=>{for(const s of e)if(t.has(s)&&!n.has(s))return n.add(s),s;return null},u=()=>d(a),l=()=>d(o),h=()=>r||!i?"ArrowUp":"w",p=()=>r||!i?"ArrowDown":"s",m=()=>r||!i?"ArrowRight":"d",g=()=>r||!i?"ArrowLeft":"a",v=(()=>r&&t.has("ArrowUp")?"ArrowUp":i&&t.has("w")?"w":d(a))();let f=u(),y=u(),w=u();!v||f||y||w||(f=v,y=v,w=v),v&&f&&!y&&!w&&(y=v,w=f),e=[],e[0]={type:"key",high:v},e[1]={type:"key",high:f},e[2]={type:"key",high:y},e[3]={type:"key",high:w},e[4]={type:"mousedown"},e[5]={type:"mousedown"},e[6]={type:"mousedown"},e[7]={type:"mousedown"},e[9]={type:"key",high:l()},e[8]={type:"key",high:l()},e[10]={type:"key",high:null,low:null},e[11]={type:"key",high:null,low:null},e[12]={type:"key",high:h()},e[13]={type:"key",high:p()},e[14]={type:"key",high:g()},e[15]={type:"key",high:m()}}return u(e,this.gamepad.buttons.length)}getDefaultAxisMappings(){let e=[];if(this.hints.importedSettings)e=this.hints.importedSettings.axes;else if(4===this.gamepad.axes.length){const t=this.hints.usedKeys,n=c(t),s=n.usesArrows;n.usesWASD?(e.push(o[0]),e.push(o[1])):s?(e.push(i[0]),e.push(i[1])):(e.push(a[0]),e.push(a[1])),e.push(a[0]),e.push(a[1])}return u(e,this.gamepad.axes.length)}}class m extends s.b{constructor(){super(),this.gamepads=new Map,this.handleConnect=this.handleConnect.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.update=this.update.bind(this),this.animationFrame=null,this.currentTime=null,this.deltaTime=0,this.virtualCursor={x:0,y:0,maxX:1/0,minX:-1/0,maxY:1/0,minY:-1/0,modified:!1},this._editor=null,this.connectCallbacks=[],this.keysPressedThisFrame=new Set,this.oldKeysPressed=new Set,this.mouseButtonsPressedThisFrame=new Set,this.oldMouseDown=new Set,this.addEventHandlers()}addEventHandlers(){window.addEventListener("gamepadconnected",this.handleConnect),window.addEventListener("gamepaddisconnected",this.handleDisconnect)}removeEventHandlers(){window.removeEventListener("gamepadconnected",this.handleConnect),window.removeEventListener("gamepaddisconnected",this.handleDisconnect)}gamepadConnected(){return this.gamepads.size>0?Promise.resolve():new Promise(e=>{this.connectCallbacks.push(e)})}getHints(){return Object.assign({usedKeys:new Set,importedSettings:null,generated:!1},this.getUserHints())}getUserHints(){return{}}resetControls(){for(const e of this.gamepads.values())e.resetMappings()}clearControls(){for(const e of this.gamepads.values())e.clearMappings()}handleConnect(e){for(const e of this.connectCallbacks)e();this.connectCallbacks=[];const t=e.gamepad,n=h(t);r.log("connected",t);const i=new p(t,this);this.gamepads.set(n,i),null===this.animationFrame&&(this.animationFrame=requestAnimationFrame(this.update)),this.dispatchEvent(new s.a("gamepadconnected",{detail:i}))}handleDisconnect(e){const t=e.gamepad,n=h(t);r.log("disconnected",t);const i=this.gamepads.get(n);this.gamepads.delete(n),this.dispatchEvent(new s.a("gamepaddisconnected",{detail:i})),0===this.gamepads.size&&(cancelAnimationFrame(this.animationFrame),this.animationFrame=null,this.currentTime=null)}dispatchKey(e,t){t?this.dispatchEvent(new s.a("keydown",{detail:e})):this.dispatchEvent(new s.a("keyup",{detail:e}))}dispatchMouse(e,t){t?this.dispatchEvent(new s.a("mousedown",{detail:e})):this.dispatchEvent(new s.a("mouseup",{detail:e}))}dispatchMouseMove(e,t){this.dispatchEvent(new s.a("mousemove",{detail:{x:e,y:t}}))}updateButton(e,t){if("key"===t.type)e>=t.deadZone?t.high&&this.keysPressedThisFrame.add(t.high):e<=-t.deadZone&&t.low&&this.keysPressedThisFrame.add(t.low);else if("mousedown"===t.type){Math.abs(e)>=t.deadZone&&this.mouseButtonsPressedThisFrame.add(t.button)}else if("virtual_cursor"===t.type){const n=t.deadZone;let s;if(e>=n&&(s=t.high),e<=-n&&(s=t.low),s){const r=(Math.abs(e)-n)/(1-n),i=r*r*t.sensitivity*this.deltaTime;"+x"===s?this.virtualCursor.x+=i:"-x"===s?this.virtualCursor.x-=i:"+y"===s?this.virtualCursor.y+=i:"-y"===s&&(this.virtualCursor.y-=i),this.virtualCursor.modified=!0}}}update(e){this.oldKeysPressed=this.keysPressedThisFrame,this.oldMouseButtonsPressed=this.mouseButtonsPressedThisFrame,this.keysPressedThisFrame=new Set,this.mouseButtonsPressedThisFrame=new Set,null===this.currentTime?this.deltaTime=0:this.deltaTime=e-this.currentTime,this.deltaTime=Math.max(Math.min(this.deltaTime,1e3),0),this.currentTime=e,this.animationFrame=requestAnimationFrame(this.update);const t=navigator.getGamepads();for(const e of t){if(null===e)continue;const t=h(e),n=this.gamepads.get(t);for(let t=0;t<e.buttons.length;t++){const s=e.buttons[t].value,r=n.buttonMappings[t];this.updateButton(s,r)}for(let t=0;t<e.axes.length;t++){const s=e.axes[t],r=n.axesMappings[t];this.updateButton(s,r)}}this._editor&&this._editor.update(t);for(const e of this.keysPressedThisFrame)this.oldKeysPressed.has(e)||this.dispatchKey(e,!0);for(const e of this.oldKeysPressed)this.keysPressedThisFrame.has(e)||this.dispatchKey(e,!1);for(const e of this.mouseButtonsPressedThisFrame)this.oldMouseButtonsPressed.has(e)||this.dispatchMouse(e,!0);for(const e of this.oldMouseButtonsPressed)this.mouseButtonsPressedThisFrame.has(e)||this.dispatchMouse(e,!1);this.virtualCursor.modified&&(this.virtualCursor.modified=!1,this.virtualCursor.x>this.virtualCursor.maxX&&(this.virtualCursor.x=this.virtualCursor.maxX),this.virtualCursor.x<this.virtualCursor.minX&&(this.virtualCursor.x=this.virtualCursor.minX),this.virtualCursor.y>this.virtualCursor.maxY&&(this.virtualCursor.y=this.virtualCursor.maxY),this.virtualCursor.y<this.virtualCursor.minY&&(this.virtualCursor.y=this.virtualCursor.minY),this.dispatchMouseMove(this.virtualCursor.x,this.virtualCursor.y))}}m.browserHasBrokenGamepadAPI=()=>!navigator.getGamepads||(!(!navigator.userAgent.includes("Firefox")||!navigator.userAgent.includes("Linux"))||!(!navigator.userAgent.includes("Firefox")||!navigator.userAgent.includes("Mac OS"))),m.setConsole=e=>r=e;var g=m;function v(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?v(Object(n),!0).forEach((function(t){y(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function y(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var s,r,i,o,a=[],d=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;d=!1}else for(;!(d=(s=i.call(n)).done)&&(a.push(s.value),a.length!==t);d=!0);}catch(e){u=!0,r=e}finally{try{if(!d&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return A(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?A(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,s=Array(t);n<t;n++)s[n]=e[n];return s}var b=async function(e,t){const n=e.vm;await new Promise(e=>{if(n.editingTarget)return e();n.runtime.once("PROJECT_LOADED",e)});const s=()=>null!==n.runtime._steppingInterval,r=e=>{switch(e){case"right arrow":return"ArrowRight";case"up arrow":return"ArrowUp";case"left arrow":return"ArrowLeft";case"down arrow":return"ArrowDown";case"enter":return"Enter";case"space":return" "}return e.toLowerCase().charAt(0)},i=()=>{const e=[n.runtime.getTargetForStage(),...n.runtime.targets].filter(e=>e.isOriginal).map(e=>e.blocks),t=new Set;for(const n of e)for(const e of Object.values(n._blocks))if("event_whenkeypressed"===e.opcode||"event_whenkeyhit"===e.opcode||"sensing_keyoptions"===e.opcode){if("sensing_keyoptions"===e.opcode&&!e.parent)continue;const n=e.fields.KEY_OPTION.value;t.add(r(n))}return t};g.setConsole(console);const o=new g,a=(()=>{const e=(()=>{const e=n.runtime.getTargetForStage().comments;for(const t of Object.values(e))if(t.text.includes(" // _gamepad_"))return t;return null})();if(!e)return null;const t=e.text.split("\n").find(e=>e.endsWith(" // _gamepad_"));if(!t)return console.warn("Gamepad comment does not contain valid line"),null;const s=t.substr(0,t.length-" // _gamepad_".length);let r;try{if(r=JSON.parse(s),!r||"object"!=typeof r||!Array.isArray(r.buttons)||!Array.isArray(r.axes))throw new Error("Invalid data")}catch(e){return console.warn("Gamepad comment has invalid JSON",e),null}return r})();o.getUserHints=()=>a?{importedSettings:a}:{usedKeys:i()};const d=n.runtime.renderer,u=d._xRight-d._xLeft,l=d._yTop-d._yBottom,c=d.canvas,h=document.createElement("img");let p;h.hidden=!0,h.className="sa-gamepad-cursor",h.src=(e=>{if("/active.png"===e)return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAIAAABvrngfAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAAgSURBVBhXY/z//z8DKmCC0kgAKsQIBhA2FlXEmMXAAAC+2gYLeDM0CAAAAABJRU5ErkJggg==";if("/close.svg"===e)return"data:image/svg+xml;base64,PHN2ZyBkYXRhLW5hbWU9IkxheWVyIDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDcuNDggNy40OCI+PHBhdGggZD0iTTMuNzQgNi40OFYxTTEgMy43NGg1LjQ4IiBzdHlsZT0iZmlsbDpub25lO3N0cm9rZTojZmZmO3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2Utd2lkdGg6MnB4Ii8+PC9zdmc+Cg==";if("/cursor.png"===e)return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAIAAABvrngfAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAAVSURBVBhXYyAF/AcDCJsJQpEKGBgAjmQF/WBrfi0AAAAASUVORK5CYII=";if("/dot.svg"===e)return"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI4IiBoZWlnaHQ9IjgiIHZpZXdCb3g9IjAgMCAyLjExNyAyLjExNyI+PGNpcmNsZSBjeD0iMS4wNTgiIGN5PSIxLjA1OCIgcj0iMS4wNTgiIGZpbGw9InJlZCIvPjwvc3ZnPgo=";throw new Error("Unknown asset: ".concat(e))})("/cursor.png");const m=e=>{h.hidden=!e,clearTimeout(p),e&&(document.body.classList.add("sa-gamepad-hide-cursor"),p=setTimeout(v,8e3))},v=()=>{m(!1)},y=e=>{m(!0),h.classList.toggle("sa-gamepad-cursor-down",e)};let A;if(document.addEventListener("mousemove",()=>{m(!1),document.body.classList.remove("sa-gamepad-hide-cursor")}),window.ResizeObserver){let e=u,t=l;new ResizeObserver(n=>{for(const s of n)e=s.contentRect.width,t=s.contentRect.height}).observe(c),A=()=>[e,t]}else A=()=>{const e=c.getBoundingClientRect();return[e.width,e.height]};let b=0,C=0;const x=e=>{if(!s())return;const t=w(A(),2),r=t[0],i=t[1];n.postIOData("mouse",f(f({},e),{},{canvasWidth:r,canvasHeight:i,x:(b+u/2)*(r/u),y:i/l*(l/2-C)}))},P=(e,t)=>{s()&&n.postIOData("keyboard",{key:e,isDown:t})};t||(o.virtualCursor.maxX=d._xRight,o.virtualCursor.minX=d._xLeft,o.virtualCursor.maxY=d._yTop,o.virtualCursor.minY=d._yBottom),o.addEventListener("keydown",e=>P(e.detail,!0)),o.addEventListener("keyup",e=>P(e.detail,!1)),o.addEventListener("mousedown",e=>{y(!0),x({isDown:!0,button:e.detail})}),o.addEventListener("mouseup",e=>{y(!1),x({isDown:!1,button:e.detail})}),o.addEventListener("mousemove",s=>{const r=s.detail,i=r.x,o=r.y;if(t){const t=i-b,s=-(o-C);b=i,C=o;const r=4,a=e.layersRect.width/n.runtime.stageWidth,d=e.layersRect.height/n.runtime.stageHeight;n.pointerLockMove(t*r*a,s*r*d)}else b=i,C=o,((e,t)=>{m(!0);const n=u/2+e-3,s=l/2-t-3;h.style.transform="translate(".concat(n,"px, ").concat(s,"px)")})(b,C),x({})}),t||e._overlays.appendChild(h)},C=n(153),x=n.n(C);var P=e=>{let t=e.scaffolding,n=e.options;b(t,n.pointerlock),(e=>{const t=document.createElement("style");t.textContent=e,document.head.appendChild(t)})(x.a)};var k=e=>{let t=e.scaffolding;const n=t._canvas,s=t.vm,r=s.runtime.ioDevices.mouse;let i=!1;const o=(e,n)=>{const i=e.movementX,o=e.movementY,a=t.layersRect,d=a.width,u=a.height,l=r._clientX+i,c=r._clientY-o;if(r._clientX=l,r._scratchX=r.runtime.stageWidth*(l/d-.5),r._clientY=c,r._scratchY=r.runtime.stageWidth*(c/u-.5),"boolean"==typeof n){const t={button:e.button,isDown:n};s.postIOData("mouse",t)}};document.addEventListener("mousedown",e=>{n.contains(e.target)&&(e.stopPropagation(),i?o(e,!0):n.requestPointerLock())},!0),document.addEventListener("mouseup",e=>{e.stopPropagation(),i?o(e,!1):n.contains(e.target)&&n.requestPointerLock()},!0),document.addEventListener("mousemove",e=>{e.stopPropagation(),i&&o(e)},!0),t.addEventListener("PROJECT_RUN_START",()=>{i||n.requestPointerLock()}),document.addEventListener("pointerlockchange",()=>{i=document.pointerLockElement===n}),document.addEventListener("pointerlockerror",e=>{console.error("Pointer lock error",e)}),s.pointerLockMove=(e,t)=>{o({movementX:e,movementY:t})};const a=s.runtime._step;s.runtime._step=function(){for(var e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];const i=a.call(this,...n),o=t.layersRect,d=o.width,u=o.height;return r._clientX=d/2,r._clientY=u/2,r._scratchX=0,r._scratchY=0,i}};const _=["http:","https:","data:","file:","mailto:"],E=e=>{try{const t=new URL(e,location.href);return _.includes(t.protocol)}catch(e){return!1}},O=e=>{window.open(e)},S=e=>{location.href=e};class T{enable(){this.manager.setVariable(this,"☁ url",location.href),document.addEventListener("paste",e=>{const t=(e.clipboardData||window.clipboardData).getData("text");this.manager.setVariable(this,"☁ pasted",t)}),this.webSocketProvider=this.manager.providers.find(e=>"function"==typeof e.setProjectId),this.initialProjectId=this.webSocketProvider?this.webSocketProvider.projectId:null}handleUpdateVariable(e,t){if("☁ redirect"===e)E(t)&&((e=>{try{return"data:"===new URL(e,location.href).protocol}catch(e){return!1}})(t)?O(t):S(t));else if("☁ open link"===e)E(t)&&((e=>{try{return"mailto:"===new URL(e,location.href).protocol}catch(e){return!1}})(t)?S(t):O(t));else if("☁ username"===e)this.manager.parent.setUsername(t);else if("☁ set clipboard"===e)navigator.clipboard.writeText(t);else if("☁ room id"===e&&this.webSocketProvider){const e=this.initialProjectId+(t?"-".concat(t):"");this.webSocketProvider.setProjectId(e)}}}var j=n(154);window.ScaffoldingAddons={run:(e,t)=>{const n={scaffolding:e,options:t};t.gamepad&&P(n),t.pointerlock&&k(n),t.specialCloudBehaviors&&function(e){let t=e.scaffolding;const n=new T;t.addCloudProvider(n),t.addCloudProviderOverride("☁ url",n),t.addCloudProviderOverride("☁ redirect",n),t.addCloudProviderOverride("☁ open link",n),t.addCloudProviderOverride("☁ username",n),t.addCloudProviderOverride("☁ set clipboard",n),t.addCloudProviderOverride("☁ pasted",n),t.addCloudProviderOverride("☁ room id",n)}(n),t.unsafeCloudBehaviors&&Object(j.a)(n),t.pause&&function(e){let t=e.scaffolding;const n=t.vm;let s=!1,r=new WeakMap,i=Promise.resolve();const o=e=>{if(s=e,s){i=i.then(()=>n.runtime.audioEngine.audioContext.suspend()),n.runtime.ioDevices.clock._paused||n.runtime.ioDevices.clock.pause();for(const e of n.runtime.threads)if(!e.updateMonitor&&!r.has(e)){const t={pauseTime:n.runtime.currentMSecs,status:e.status};r.set(e,t),e.status=1}n.runtime.emit("PROJECT_RUN_STOP")}else{i=i.then(()=>n.runtime.audioEngine.audioContext.resume()),n.runtime.ioDevices.clock.resume();const e=Date.now();for(const t of n.runtime.threads){const n=r.get(t);if(n){const s=t.peekStackFrame();if(s&&s.executionContext&&s.executionContext.timer){const t=e-n.pauseTime;s.executionContext.timer.startTime+=t}if(t.timer){const s=e-n.pauseTime;t.timer.startTime+=s}t.status=n.status}}r=new WeakMap}n.emit("P4_PAUSE",s)},a=e=>{if(4===e.status)return;const t=r.get(e);t&&1!==e.status&&(t.status=e.status,e.status=1)},d=n.runtime.sequencer.stepThreads;n.runtime.sequencer.stepThreads=function(){if(s)for(const e of this.runtime.threads)a(e);return d.call(this)};const u=n.runtime.greenFlag;n.runtime.greenFlag=function(){return o(!1),u.call(this)};const l=n.runtime.startHats;n.runtime.startHats=function(){if(s)return[];for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return l.apply(this,t)};const c=n.runtime._getMonitorThreadCount;n.runtime._getMonitorThreadCount=function(e){let t=c.call(this,e);if(s)for(const n of e)r.has(n)&&t++;return t},n.setPaused=o,n.isPaused=()=>s}(n)}}}});
2
+ // d4717322ac8ca2bf1148dfb59dc94708ea2b21582c2e2dd1e8397545d363d2cb =^..^=