/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/gbdk-emscripten@1.0.2/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var __awaiter=this&&this.__awaiter||function(e,r,n,t){return new(n||(n=Promise))((function(i,o){function s(e){try{c(t.next(e))}catch(e){o(e)}}function a(e){try{c(t.throw(e))}catch(e){o(e)}}function c(e){var r;e.done?i(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(s,a)}c((t=t.apply(e,r||[])).next())}))},__generator=this&&this.__generator||function(e,r){var n,t,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,t&&(i=2&o[0]?t.return:o[0]?t.throw||((i=t.return)&&i.call(t),0):t.next)&&!(i=i.call(t,o[1])).done)return i;switch(t=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,t=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=r.call(e,s)}catch(e){o=[6,e],t=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(exports,"__esModule",{value:!0});var child_process_1=require("child_process"),helpers_1=require("./lib/helpers"),preProcess=function(e,r,n){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return[2,new Promise((function(t,i){var o=child_process_1.fork(__dirname+"/lib/forked-child.js");o.on("message",(function(e){switch(e.type){case"SUCCESS":t(helpers_1.str2arr8(e.data));break;case"ERROR":i(e.error);break;default:i("Unknown msg type")}o.kill()})),o.send({type:"PRE-PROCESS",file:helpers_1.arr82str(e),filename:r,options:n})}))]}))}))},sdcc=function(e,r,n){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return[2,new Promise((function(t,i){var o=child_process_1.fork(__dirname+"/lib/forked-child.js");o.on("message",(function(e){switch(e.type){case"SUCCESS":t(helpers_1.str2arr8(e.data));break;case"ERROR":i(e.error);break;default:i("Unknown msg type")}o.kill()})),o.send({type:"SDCC",file:helpers_1.arr82str(e),filename:r,options:n})}))]}))}))},asgbz80=function(e,r){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(n){return[2,new Promise((function(n,t){var i=child_process_1.fork(__dirname+"/lib/forked-child.js");i.on("message",(function(e){switch(e.type){case"SUCCESS":n(helpers_1.str2arr8(e.data));break;case"ERROR":t(e.error);break;default:t("Unknown msg type")}i.kill()})),i.send({type:"ASGBZ80",file:helpers_1.arr82str(e),options:r})}))]}))}))},linkgbz80=function(e,r,n){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return[2,new Promise((function(t,i){var o=child_process_1.fork(__dirname+"/lib/forked-child.js");o.on("message",(function(e){switch(e.type){case"SUCCESS":t();break;case"ERROR":i(e.error);break;default:i("Unknown msg type")}o.kill()})),o.send({type:"LINKGBZ80",objPaths:e,romPath:r,options:n})}))]}))}))};exports.compile=function(e,r,n){return __awaiter(void 0,void 0,void 0,(function(){var t,i,o,s;return __generator(this,(function(a){switch(a.label){case 0:return[4,helpers_1.readFile(e)];case 1:return t=a.sent(),[4,preProcess(t,e,n)];case 2:return i=a.sent(),[4,sdcc(i,r+".i",n)];case 3:return o=a.sent(),[4,asgbz80(o,n)];case 4:return s=a.sent(),[4,helpers_1.writeFile(r,s)];case 5:return a.sent(),[2]}}))}))},exports.compileAsm=function(e,r,n){return __awaiter(void 0,void 0,void 0,(function(){var t,i;return __generator(this,(function(o){switch(o.label){case 0:return[4,helpers_1.readFile(e)];case 1:return t=o.sent(),[4,asgbz80(t,n)];case 2:return i=o.sent(),[4,helpers_1.writeFile(r,i)];case 3:return o.sent(),[2]}}))}))},exports.link=function(e,r,n){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:return[4,linkgbz80(e,r,n)];case 1:return t.sent(),[2]}}))}))};
//# sourceMappingURL=/sm/8c4492f924aaa9c00d014e794a7c807e94082982295125a3cf86cc58da2abde0.map