PageSourceSearch

https://uma.xyz/_next/static/chunks/309.d212e640ced7c989.js

js uma.xyz collected 2026-10-03 20:56:20 UTC 48,383 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[309],{8741:function(t,e,r){r.d(e,{S:function(){return a}});var n=r(501),a=function(){function t(t,e,r){void 0===r&&(r={}),this.status="idle",this.options=r,this.sandboxSetup=e,this.iframeSelector=t}return t.prototype.updateOptions=function(t){(0,n.J)(this.options,t)||(this.options=t,this.updateSandbox())},t.prototype.updateSandbox=function(t,e){throw void 0===t&&(t=this.sandboxSetup),Error("Method not implemented")},t.prototype.destroy=function(){throw Error("Method not implemented")},t.prototype.dispatch=function(t){throw Error("Method not implemented")},t.prototype.listen=function(t){throw Error("Method not implemented")},t}()},7564:function(t,e,r){r.d(e,{E:function(){return s},a:function(){return w},b:function(){return g},f:function(){return y},g:function(){return p},r:function(){return v},w:function(){return m}});var n,a,i=r(792),o=r(8693),s=function(){function t(){this.listeners={},this.listenersCount=0,this.channelId=Math.floor(1e6*Math.random()),this.listeners=[]}return t.prototype.cleanup=function(){this.listeners={},this.listenersCount=0},t.prototype.dispatch=function(t){Object.values(this.listeners).forEach(function(e){return e(t)})},t.prototype.listener=function(t){var e=this;if("function"!=typeof t)return function(){};var r=this.listenersCount;return this.listeners[r]=t,this.listenersCount++,function(){delete e.listeners[r]}},t}();function u(t){return/[a-zA-Z.]/.test(t)}function c(t){return/[a-zA-Z]/.test(t)}function l(t){return/[&|]/.test(t)}function d(t){return c(t)&&t===t.toUpperCase()}(n=a||(a={})).OR="OR",n.AND="AND",n.PIPE="PIPE",n.Command="Command",n.Argument="Argument",n.String="String",n.EnvVar="EnvVar";var f=new Map([["&&",{type:a.AND}],["||",{type:a.OR}],["|",{type:a.PIPE}],["-",{type:a.Argument}]]),h=0;function p(){return(+(""+Date.now()+Math.round(1e4*Math.random())+(h+=1))).toString(16)}var m=function(t){return"string"==typeof t?new TextEncoder().encode(t):t},v=function(t){return"string"==typeof t?t:new TextDecoder().decode(t)},y=function(t){return Object.entries(t).reduce(function(t,e){var r=e[0],n=e[1];return t[r]=m(n.code),t},{})},g=function(t){var e={},r=["dev","start"];try{e=JSON.parse(t).scripts}catch(t){throw(0,o.c)("Could not parse package.json file: "+t.message)}(0,i.kG)(e,"Failed to start. Please provide a `start` or `dev` script on the package.json");for(var n=0;n<r.length;n++){var s=function(t){if(r[t]in e){var n=e[r[t]],i={},o="",s=[];return(function(t){for(var e=0,r=[];e<t.length;){var n=t[e];if(/\s/.test(n)){e++;continue}switch(!0){case d(n):r.push(function(){for(var r={};d(t[e])&&e<t.length;)(function(){for(var n="",a="";"="!==t[e]&&e<t.length;)n+=t[e],e++;for("="===t[e]&&e++;" "!==t[e]&&e<t.length;)a+=t[e],e++;r[n]=a})(),e++;return{type:a.EnvVar,value:r}}());break;case u(n):r.push(function(){for(var r="";u(t[e])&&e<t.length;)r+=t[e],e++;return{type:a.Command,value:r}}());break;case l(n):r.push(function(){for(var r="";l(t[e])&&e<t.length;)r+=t[e],e++;return f.get(r)}());break;case/-/.test(n):r.push(function(){for(var r,n="";r=t[e],(/-/.test(r)||c(t[e]))&&e<t.length;)n+=t[e],e++;return{type:a.Argument,value:n}}());break;case/["']/.test(n):r.push(function(){var r=t[e],n=t[e];for(e++;t[e]!==r&&e<t.length;)n+=t[e],e++;return n+=t[e],e++,{type:a.String,value:n}}());break;default:throw Error("Unknown character: "+n)}}return r})(n).forEach(function(t){var e=""===o;t.type===a.EnvVar&&(i=t.value),t.type===a.Command&&e&&(o=t.value),t.type!==a.Argument&&(e||t.type!==a.Command)||s.push(t.value)}),{value:[o,s,{env:i}]}}}(n);if("object"==typeof s)return s.value}throw(0,o.c)("Failed to start. Please provide a `start` or `dev` script on the package.json")},w=function(t){return"string"==typeof t?t:"object"==typeof t&&"message"in t?t.message:(0,o.c)("The server could not be reached. Make sure that the node script is running and that a port has been started.")}},8309:function(t,e,r){r.r(e),r.d(e,{SandpackNode:function(){return ts}});var n=r(8693);function a(t,e,r){if(!e.has(t))throw TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}function i(t,e){var r=a(t,e,"get");return r.get?r.get.call(t):r.value}function o(t,e){if(e.has(t))throw TypeError("Cannot initialize the same private elements twice on an object")}function s(t,e,r){if(!e.has(t))throw TypeError("attempted to get private field on non-instance");return r}var u=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,f=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty,p=(t,e,r)=>e in t?c(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,m=(t,e)=>function(){return e||(0,t[d(t)[0]])((e={exports:{}}).exports,e),e.exports},v=(t,e,r,n)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let a of d(e))h.call(t,a)||a===r||c(t,a,{get:()=>e[a],enumerable:!(n=l(e,a))||n.enumerable});return t},y=(t,e,r)=>(r=null!=t?u(f(t)):{},v(!e&&t&&t.__esModule?r:c(r,"default",{value:t,enumerable:!0}),t)),g=(t,e,r)=>
1(p(t,"symbol"!=typeof e?e+"":e,r),r),w=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},b=(t,e,r)=>(w(t,e,"read from private field"),r?r.call(t):e.get(t)),_=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},E=(t,e,r,n)=>(w(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),S=(t,e,r)=>(w(t,e,"access private method"),r),M=m({"../../node_modules/.pnpm/[email protected]/node_modules/cuid/lib/pad.js"(t,e){e.exports=function(t,e){var r="000000000"+t;return r.substr(r.length-e)}}}),j=m({"../../node_modules/.pnpm/[email protected]/node_modules/cuid/lib/fingerprint.browser.js"(t,e){var r=M(),n=Object.keys(window).length,a=r(((navigator.mimeTypes?navigator.mimeTypes.length:0)+navigator.userAgent.length).toString(36)+n.toString(36),4);e.exports=function(){return a}}}),P=m({"../../node_modules/.pnpm/[email protected]/node_modules/cuid/lib/getRandomValue.browser.js"(t,e){var r=window.crypto||window.msCrypto||"undefined"!=typeof self&&self.crypto;e.exports=r?function(){return Math.abs(r.getRandomValues(new Uint32Array(1))[0]/4294967295)}:Math.random}}),k=m({"../../node_modules/.pnpm/[email protected]/node_modules/cuid/index.js"(t,e){var r=j(),n=M(),a=P(),i=0;function o(){return n((1679616*a()<<0).toString(36),4)}function s(){return i=i<1679616?i:0,++i-1}function u(){return"c"+new Date().getTime().toString(36)+n(s().toString(36),4)+r()+(o()+o())}u.slug=function(){var t=new Date().getTime().toString(36),e=s().toString(36).slice(-4),n=r().slice(0,1)+r().slice(-1),a=o().slice(-2);return t.slice(-2)+e+n+a},u.isCuid=function(t){return"string"==typeof t&&!!t.startsWith("c")},u.isSlug=function(t){if("string"!=typeof t)return!1;var e=t.length;return e>=7&&e<=10},u.fingerprint=r,e.exports=u}}),O=m({"../../node_modules/.pnpm/@[email protected]/node_modules/@open-draft/deferred-promise/build/createDeferredExecutor.js"(t){Object.defineProperty(t,"__esModule",{value:!0}),t.createDeferredExecutor=void 0,t.createDeferredExecutor=function(){let t=(e,r)=>{t.state="pending",t.resolve=r=>"pending"!==t.state?void 0:(t.result=r,e(r instanceof Promise?r:Promise.resolve(r).then(e=>(t.state="fulfilled",e)))),t.reject=e=>{if("pending"===t.state)return queueMicrotask(()=>{t.state="rejected"}),r(t.rejectionReason=e)}};return t}}}),T=m({"../../node_modules/.pnpm/@[email protected]/node_modules/@open-draft/deferred-promise/build/DeferredPromise.js"(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DeferredPromise=void 0;var e,r,n=O(),u=(e=new WeakMap,r=new WeakSet,class extends Promise{get state(){return i(this,e).state}get rejectionReason(){return i(this,e).rejectionReason}then(t,e){return s(this,r,c).call(this,super.then(t,e))}catch(t){return s(this,r,c).call(this,super.catch(t))}finally(t){return s(this,r,c).call(this,super.finally(t))}constructor(t=null){let s=(0,n.createDeferredExecutor)();super((e,r)=>{s(e,r),null==t||t(s.resolve,s.reject)}),o(this,r),r.add(this),o(this,e),e.set(this,{writable:!0,value:void 0}),function(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw TypeError("attempted to set read only private field");e.value=r}}(this,a(this,e,"set"),s),this.resolve=i(this,e).resolve,this.reject=i(this,e).reject}});function c(t){return Object.defineProperties(t,{resolve:{configurable:!0,value:this.resolve},reject:{configurable:!0,value:this.reject}})}t.DeferredPromise=u}}),C=m({"../../node_modules/.pnpm/@[email protected]/node_modules/@open-draft/deferred-promise/build/index.js"(t){var e=t&&t.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,a)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),r=t&&t.__exportStar||function(t,r){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||e(r,t,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(O(),t),r(T(),t)}}),A=m({"../../node_modules/.pnpm/[email protected]/node_modules/strict-event-emitter/lib/MemoryLeakError.js"(t){Object.defineProperty(t,"__esMo
1dule",{value:!0}),t.MemoryLeakError=void 0,t.MemoryLeakError=class extends Error{constructor(t,e,r){super("Possible EventEmitter memory leak detected. ".concat(r," ").concat(e.toString()," listeners added. Use emitter.setMaxListeners() to increase limit")),this.emitter=t,this.type=e,this.count=r,this.name="MaxListenersExceededWarning"}}}}),I=m({"../../node_modules/.pnpm/[email protected]/node_modules/strict-event-emitter/lib/Emitter.js"(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Emitter=void 0;var e,r,n,a,i,o,s,u,c,l,d,f=A(),h=class{static listenerCount(t,e){return t.listenerCount(e)}setMaxListeners(t){return E(this,r,t),this}getMaxListeners(){return b(this,r)}eventNames(){return Array.from(b(this,e).keys())}emit(t){for(var e=arguments.length,r=Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];let o=S(this,a,i).call(this,t);return o.forEach(t=>{t.apply(this,r)}),o.length>0}addListener(t,o){S(this,l,d).call(this,"newListener",t,o);let s=S(this,a,i).call(this,t).concat(o);return b(this,e).set(t,s),b(this,r)>0&&this.listenerCount(t)>b(this,r)&&!b(this,n)&&(E(this,n,!0),console.warn(new f.MemoryLeakError(this,t,this.listenerCount(t)))),this}on(t,e){return this.addListener(t,e)}once(t,e){return this.addListener(t,S(this,u,c).call(this,t,e))}prependListener(t,r){let n=S(this,a,i).call(this,t);if(n.length>0){let a=[r].concat(n);b(this,e).set(t,a)}else b(this,e).set(t,n.concat(r));return this}prependOnceListener(t,e){return this.prependListener(t,S(this,u,c).call(this,t,e))}removeListener(t,r){let n=S(this,a,i).call(this,t);return n.length>0&&(S(this,o,s).call(this,n,r),b(this,e).set(t,n),S(this,l,d).call(this,"removeListener",t,r)),this}off(t,e){return this.removeListener(t,e)}removeAllListeners(t){return t?b(this,e).delete(t):b(this,e).clear(),this}listeners(t){return Array.from(S(this,a,i).call(this,t))}listenerCount(t){return S(this,a,i).call(this,t).length}rawListeners(t){return this.listeners(t)}constructor(){_(this,a),_(this,o),_(this,u),_(this,l),_(this,e,void 0),_(this,r,void 0),_(this,n,void 0),E(this,e,new Map),E(this,r,h.defaultMaxListeners),E(this,n,!1)}};e=new WeakMap,r=new WeakMap,n=new WeakMap,a=new WeakSet,i=function(t){return b(this,e).get(t)||[]},o=new WeakSet,s=function(t,e){let r=t.indexOf(e);return r>-1&&t.splice(r,1),[]},u=new WeakSet,c=function(t,e){var r=this;let n=function(){for(var a=arguments.length,i=Array(a),o=0;o<a;o++)i[o]=arguments[o];r.removeListener(t,n),e.apply(r,i)};return n},l=new WeakSet,d=function(t,e,r){this.emit(t,...[e,r])},g(h,"defaultMaxListeners",10),t.Emitter=h}}),x=m({"../../node_modules/.pnpm/[email protected]/node_modules/strict-event-emitter/lib/index.js"(t){var e=t&&t.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,a)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),r=t&&t.__exportStar||function(t,r){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||e(r,t,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(I(),t),r(A(),t)}}),L=y(k()),D=/(%?)(%([sdjo]))/g;function F(t){for(var e=arguments.length,r=Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];if(0===r.length)return t;let a=0,i=t.replace(D,(t,e,n,i)=>{let o=function(t,e){switch(e){case"s":return t;case"d":case"i":return Number(t);case"j":return JSON.stringify(t);case"o":{if("string"==typeof t)return t;let e=JSON.stringify(t);if("{}"===e||"[]"===e||/^\[object .+?\]$/.test(e))return t;return e}}}(r[a],i);return e?t:(a++,o)});return a<r.length&&(i+=" ".concat(r.slice(a).join(" "))),i=i.replace(/%{2,2}/g,"%")}var N=class extends Error{constructor(t,...e){super(t),this.message=t,this.name="Invariant Violation",this.message=F(t,...e),function(t){if(!t.stack)return;let e=t.stack.split("\n");e.splice(1,2),t.stack=e.join("\n")}(this)}},R=function(t,e){for(var r=arguments.length,n=Array(r>2?r-2:0),a=2;a<r;a++)n[a-2]=arguments[a];if(!t)throw new N(e,...n)};R.as=function(t,e,r){for(var n=arguments.length,a=Array(n>3?n-3:0),i=3;i<n;i++)a[i-3]=arguments[i];if(!e)throw null!=t.prototype.name?new t(F(r,a)):t(F(r,a))};var z=y(C()),U=window.localStorage.CSB_EMULATOR_DEBUG,V="\x1b[36;1m",W={preview:"\x1b[33;1m",emulator:"\x1b[35;1m",runtime:V,bridge:"\x1b[34m","runtime:worker":V};function B(t){return function(e){for(var r=arguments.length,n=Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];if("true"===U){let r=e.replace(/\[.+\]:/,"");
1console.debug("".concat(W[t]).concat(t,":").concat(e.includes("sender")?"".concat("\x1b[32;1m","sender"):e.includes("receiver")?"".concat("\x1b[31m","receiver"):"").concat("\x1b[0m",":").concat(r),...n)}}}var H=B("emulator"),J=class{async handshake(){let t=new z.DeferredPromise;await this.receiverReadyPromise,H("[message-sender]: sending handshake"),this.target.postMessage({type:"internal/handshake"},"*",[this.channel.port2]),this.on("internal/handshake/done",()=>{t.resolve(),clearTimeout(e)});let e=setTimeout(()=>{t.reject(Error("MessageSender: Handshake timeout"))},5e3);return t}on(t,e,r){H('[message-sender]: add listener "%s"',t),this.emitter.addEventListener(t,t=>{t instanceof MessageEvent&&e(t)},r)}off(t,e,r){this.emitter.removeEventListener(t,e,r)}async send(t){for(var e=arguments.length,r=Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];let a=new z.DeferredPromise,i=(0,L.default)(),o=r[0]||{};H('[message-sender]: send "%s" (%s)',t,i,o),this.receiverPort.postMessage({type:t,payload:{operationId:i,payload:o}}),H('[message-sender]: adding done listener for "%s" (%s)',t,i);let s=e=>{let{data:r}=e;if(r.operationId===i){let e=r.listenerPayload||{};H('[message-sender]: resolving "%s (%s) promise!',t,i),a.resolve({...e,operationId:r.operationId})}},u=e=>{let{data:r}=e;r.operationId===i&&(H('[message-sender]: rejecting "%s (%s) promise!',t,i),a.reject(r.error))};return this.on("internal/operation/done",s),this.on("internal/operation/failed",u),a.finally(()=>{this.emitter.removeEventListener("internal/operation/done",s),this.emitter.removeEventListener("internal/operation/failed",u)})}constructor(t){this.target=t,this.emitter=new EventTarget,this.channel=new MessageChannel,this.receiverPort=this.channel.port1;let e=new z.DeferredPromise,r=t=>{"internal/ready"===t.data.type&&(H("[message-sender]: runtime is ready"),e.resolve())};window.addEventListener("message",r),e.then(()=>{window.removeEventListener("message",r)}),this.receiverReadyPromise=e,this.receiverPort.onmessage=t=>{let e=t.data;null!=e.type&&(H('[message-sender]: emitting "%s" event...',e.type,e.payload),this.emitter.dispatchEvent(new MessageEvent(e.type,{data:e.payload})))}}},Z=y(C()),q=y(k()),G=class{async init(t){await this.channel.send("fs/init",{files:t})}async readFile(t,e){let r=await this.channel.send("fs/readFile",{path:t,encoding:e}).catch(e=>{throw Error(F('Failed to read file at path "%s"',t),{cause:e})});if(!r)throw Error("File not found");return r.data}async writeFile(t,e,r){let n;let a=!1;"object"==typeof r?(n=r.encoding,a=!!r.recursive):"string"==typeof r&&(n=r),await this.channel.send("fs/writeFile",{path:t,content:e,encoding:n,recursive:a}).catch(e=>{throw Error(F('Failed to write file at path "%s"',t),{cause:e})})}async readdir(t){let e=await this.channel.send("fs/readdir",{path:t}).catch(e=>{throw Error(F('Failed to read directory at path "%s"',t),{cause:e})});if(!e)throw Error("Directory not found");return e.data}async mkdir(t,e){let r=!!(null==e?void 0:e.recursive);await this.channel.send("fs/mkdir",{path:t,recursive:r}).catch(e=>{throw Error(F('Failed to make directory at path "%s"',t),{cause:e})})}async stat(t){let e=await this.channel.send("fs/stat",{path:t}).catch(e=>{throw Error(F('Failed to stat file at path "%s"',t),{cause:e})});if(!e)throw Error("File not found");return e.data}async rm(t,e){let{force:r,recursive:n}=e||{};await this.channel.send("fs/rm",{path:t,force:r,recursive:n}).catch(e=>{throw Error(F('Failed to remove file at path "%s"',t),{cause:e})})}async watch(t,e,r){let n=(0,q.default)();return await this.channel.send("fs/watch",{watcherId:n,includes:t,excludes:e}),this.channel.on("fs/watch-event",t=>{let{data:e}=t;if(e.watcherId===n&&r){let t={...e};delete t.watcherId,r(t)}}),{dispose:()=>this.channel.send("fs/unwatch",{watcherId:n})}}constructor(t){this.channel=t}},$=y(x()),K=class{create(){return new Q(this.channel)}constructor(t){this.channel=t}},Q=class{forwardStdEvents(){this.channel.on("worker/tty",t=>{let{data:e}=t;if(e.workerId===this.id)switch(e.payload.type){case"out":this.stdout.emit("data",e.payload.data);break;case"err":this.stderr.emit("data",e.payload.data)}})}async runCommand(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};R(!this.id,'Failed to run "runCommand" on a ShellProcess: there is already a process running.');let n=await this.channel.send("shell/runCommand",{command:t,args:e,options:r});return R(n,'Failed to run "runCommand" on a ShellProcess: was not able to retrieve a running process.'),this.id=n.id,this.state="running",n}async on(t,e){switch(t){case"progress":this.channel.on("worker/progress",t=>{let{data:r}=t;e(r.status)});return;case"exit":this.channel.on("worker/exit",t=>{let{data:r}=t;r.workerId===this.id&&e(r.exitCode,r.error)});return}}async kill(){R(this.id,'Failed to run "kill" on a ShellProcess: there is no process running. Did you forget to run it?'),this.state="idle",await this.channel.send("shell/exit",{id:this.id}).catch(t=>{throw Error(F('Failed to kill shell with ID "%s"',this.id),{cause:t})}),this.id=void 0}constructor(t){this.channel=t,this.state="running",this.stdout=new $.Emitter,this.stderr=new $.Emitter,this.stdin={write:t=>{if(!this.id)throw Error("Failed to write to stdin, no process is currently running");return this.channel.send("shell/stdin",{data:t,workerId:this.id})}},this.forwardStdEvents()}},X=y(C()),Y=class{async waitFor(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2e4,n=new X.DeferredPromise,a=setTimeout(()=>{n.reject()},r),i=await this.channel.send("preview/get/info",t).catch(e=>{n.reject(Error(F('Failed to look up preview information for shell ID "%s" (port: %d)',t.sourceShellId,t.port)))}),o=i&&e(i);return o&&n.resolve({url:i.url,port:i.port,sourceShellId:i.sourceShellId}),this.channel.on("preview/port/ready",t=>{let{data:r}=t;!o&&e(r)&&n.resolve({url:r.url,port:r.port,sourceShellId:r.sourceShellId})}),n.finally(()=>{clearTimeout(a)})}async getByShellId(t,e){return this.waitFor({sourceShellId:t},e=>e.sourceShellId===t,e).catch(e=>{throw Error(F('Failed to get shell by ID "%s"',t),{cause:e})})}async waitForPort(t,e){return this.waitFor({port:t},e=>e.port===t,e).catch(e=>{throw Error(F("Failed to await port %d",t),{cause:e})})}constructor(t){this.channel=t}},tt=B("emulator"),te=class{async connect(){let{iframe:t,cdnUrl:e}=this.options;tt("[message-sender]: Connecting to node emulator...");let r=new Z.DeferredPromise;this.url||r.reject(Error("Nodebox URL is missing. Did you forget to provide it when creating this Nodebox instance?")),R(t.contentWindow,"Failed to create a MessageChannel with the Nodebox iframe: no content window found"),this.channel=new J(t.contentWindow);let n=new Z.DeferredPromise;return t.setAttribute("src",this.url),t.addEventListener("load",()=>{n.resolve()},{once:!0}),t.addEventListener("error",t=>{n.reject(t.error)},{once:!0}),await n,tt("[message-sender]: IFrame loaded..."),await this.channel.handshake(),tt("[message-sender]: Handshake completed..."),this.channel.send("connect",{cdnUrl:e}),this.channel.on("runtime/ready",()=>{r.resolve()}),r.then(()=>{tt("[message-sender]: Connected to runtime..."),this.isConnected=!0})}get fs(){return R(this.isConnected,'Failed to access the File System API: consumer is not connected. Did you forget to run "connect()"?'),this.fileSystemApi||(this.fileSystemApi=new G(this.channel)),this.fileSystemApi}get shell(){return R(this.isConnected,'Failed to access the Shell API: consumer is not connected. Did you forget to run "connect()"?'),this.shellApi||(this.shellApi=new K(this.channel)),this.shellApi}get preview(){return R(this.isConnected,'Failed to access the Preview API: consumer is not connected. Did you forget to run "connect()"?'),this.previewApi||(this.previewApi=new Y(this.channel)),this.previewApi}constructor(t){this.channel=null,this.fileSystemApi=null,this.shellApi=null,this.previewApi=null,this.options=t,R(this.options.iframe,'Failed to create a Nodebox: expected "iframe" argument to be a reference to an <iframe> element but got %j',this.options.iframe),this.url=this.options.runtimeUrl||"https://nodebox-runtime.codesandbox.io",this.isConnected=!1}},tr=r(8741),tn=r(7564);r(792),r(501);var ta=function(t,e){t.style.border="0",t.style.width=e.width||"100%",t.style.height=e.height||"100%",t.style.overflow="hidden",t.allow="cross-origin-isolated"},ti=[{code:(function(t){var e=t.scope,r=window.history.__proto__,n=[],a=0,i=function(t){parent.postMessage({type:"urlchange",url:t,back:a>0,forward:a<n.length-1,channelId:e.channelId},"*")};Object.assign(window.history,{go:function(t){var e=a+t;if(e>=0&&e<=n.length-1){var o=n[a=e],s=o.url,u=o.state;r.replaceState.call(window.history,u,"",s),i(document.location.href),window.dispatchEvent(new PopStateEvent("popstate",{state:u}))}},back:function(){window.history.go(-1)},forward:function(){window.history.go(1)},pushState:function(t,e,o){r.replaceState.call(window.history,t,e,o),n.splice(a+1),n.push({url:o,state:t}),a=n.length-1,i(document.location.href)},replaceState:function(t,e,o){r.replaceState.call(window.history,t,e,o),n[a]={state:t,url:o},i(document.location.href)}}),window.addEventListener("message",function(t){var e=t.data;"urlback"===e.type?history.back():"urlforward"===e.type?history.forward():"refresh"===e.type&&document.location.reload()})}).toString(),id:"historyListener"},{code:'function consoleHook({ scope }) {var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e={},n={};!function(t){t.__esModule=!0,t.default=["log","debug","info","warn","error","table","clear","time","timeEnd","count","assert","command","result"]}(n);var a,o={},i={};(a=i).__esModule=!0,a.default=function(){var t=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};
1return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+"-"+Date.now()};var u={},s={__esModule:!0};s.update=s.state=void 0,s.update=function(t){s.state=t};var f={},c={};!function(r){var e=t&&t.__assign||function(){return e=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var a in r=arguments[e])Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a]);return t},e.apply(this,arguments)};r.__esModule=!0,r.initialState=void 0,r.initialState={timings:{},count:{}};var n=function(){return"undefined"!=typeof performance&&performance.now?performance.now():Date.now()};r.default=function(t,a){var o,i,u;switch(void 0===t&&(t=r.initialState),a.type){case"COUNT":var s=t.count[a.name]||0;return e(e({},t),{count:e(e({},t.count),(o={},o[a.name]=s+1,o))});case"TIME_START":return e(e({},t),{timings:e(e({},t.timings),(i={},i[a.name]={start:n()},i))});case"TIME_END":var f=t.timings[a.name],c=n(),l=c-f.start;return e(e({},t),{timings:e(e({},t.timings),(u={},u[a.name]=e(e({},f),{end:c,time:l}),u))});default:return t}}}(c),function(r){var e=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};r.__esModule=!0;var n=e(c),a=s;r.default=function(t){a.update(n.default(a.state,t))}}(f);var l={__esModule:!0};l.timeEnd=l.timeStart=l.count=void 0,l.count=function(t){return{type:"COUNT",name:t}},l.timeStart=function(t){return{type:"TIME_START",name:t}},l.timeEnd=function(t){return{type:"TIME_END",name:t}};var d=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};u.__esModule=!0,u.stop=u.start=void 0;var p=s,h=d(f),m=l;u.start=function(t){h.default(m.timeStart(t))},u.stop=function(t){var r=null===p.state||void 0===p.state?void 0:p.state.timings[t];return r&&!r.end?(h.default(m.timeEnd(t)),{method:"log",data:[t+": "+p.state.timings[t].time+"ms"]}):{method:"warn",data:["Timer \'"+t+"\' does not exist"]}};var y={},v=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};y.__esModule=!0,y.increment=void 0;var _=s,b=v(f),g=l;y.increment=function(t){return b.default(g.count(t)),{method:"log",data:[t+": "+_.state.count[t]]}};var M={},T=t&&t.__spreadArrays||function(){for(var t=0,r=0,e=arguments.length;r<e;r++)t+=arguments[r].length;var n=Array(t),a=0;for(r=0;r<e;r++)for(var o=arguments[r],i=0,u=o.length;i<u;i++,a++)n[a]=o[i];return n};M.__esModule=!0,M.test=void 0,M.test=function(t){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return!t&&(0===r.length&&r.push("console.assert"),{method:"error",data:T(["Assertion failed:"],r)})},function(r){var e=t&&t.__assign||function(){return e=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var a in r=arguments[e])Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a]);return t},e.apply(this,arguments)},n=t&&t.__createBinding||(Object.create?function(t,r,e,n){void 0===n&&(n=e),Object.defineProperty(t,n,{enumerable:!0,get:function(){return r[e]}})}:function(t,r,e,n){void 0===n&&(n=e),t[n]=r[e]}),a=t&&t.__setModuleDefault||(Object.create?function(t,r){Object.defineProperty(t,"default",{enumerable:!0,value:r})}:function(t,r){t.default=r}),o=t&&t.__importStar||function(t){if(t&&t.__esModule)return t;var r={};if(null!=t)for(var e in t)"default"!==e&&Object.prototype.hasOwnProperty.call(t,e)&&n(r,t,e);return a(r,t),r},s=t&&t.__spreadArrays||function(){for(var t=0,r=0,e=arguments.length;r<e;r++)t+=arguments[r].length;var n=Array(t),a=0;for(r=0;r<e;r++)for(var o=arguments[r],i=0,u=o.length;i<u;i++,a++)n[a]=o[i];return n},f=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};r.__esModule=!0;var c=f(i),l=o(u),d=o(y),p=o(M);r.default=function(t,r,n){var a=n||c.default();switch(t){case"clear":return{method:t,id:a};case"count":return!!(o="string"==typeof r[0]?r[0]:"default")&&e(e({},d.increment(o)),{id:a});case"time":case"timeEnd":var o;return!!(o="string"==typeof r[0]?r[0]:"default")&&("time"===t?(l.start(o),!1):e(e({},l.stop(o)),{id:a}));case"assert":if(0!==r.length){var i=p.test.apply(p,s([r[0]],r.slice(1)));if(i)return e(e({},i),{id:a})}return!1;case"error":return{method:t,id:a,data:r.map((function(t){try{return t.stack||t}catch(r){return t}}))};default:return{method:t,id:a,data:r}}}}(o);var S={},O={};!function(t){var r;t.__esModule=!0,function(t){t[t.infinity=0]="infinity",t[t.minusInfinity=1]="minusInfinity",t[t.minusZero=2]="minusZero"}(r||(r={})),t.default={type:"Arithmetic",lookup:Number,shouldTransform:function(t,r){return"number"===t&&(r===1/0||r===-1/0||function(t){return 1/t==-1/0}(r))},toSerializable:function(t){return t===1/0?r.infinity:t===-1/0?r.minu
1sInfinity:r.minusZero},fromSerializable:function(t){return t===r.infinity?1/0:t===r.minusInfinity?-1/0:t===r.minusZero?-0:t}}}(O);var w={};!function(t){t.__esModule=!0,t.default={type:"Function",lookup:Function,shouldTransform:function(t,r){return"function"==typeof r},toSerializable:function(t){var r="";try{r=t.toString().substring(r.indexOf("{")+1,r.lastIndexOf("}"))}catch(t){}return{name:t.name,body:r,proto:Object.getPrototypeOf(t).constructor.name}},fromSerializable:function(t){try{var r=function(){};return"string"==typeof t.name&&Object.defineProperty(r,"name",{value:t.name,writable:!1}),"string"==typeof t.body&&Object.defineProperty(r,"body",{value:t.body,writable:!1}),"string"==typeof t.proto&&(r.constructor={name:t.proto}),r}catch(r){return t}}}}(w);var A={};!function(t){var r;function e(t){for(var r={},e=0,n=t.attributes;e<n.length;e++){var a=n[e];r[a.name]=a.value}return r}t.__esModule=!0,t.default={type:"HTMLElement",shouldTransform:function(t,r){return r&&r.children&&"string"==typeof r.innerHTML&&"string"==typeof r.tagName},toSerializable:function(t){return{tagName:t.tagName.toLowerCase(),attributes:e(t),innerHTML:t.innerHTML}},fromSerializable:function(t){try{var e=(r||(r=document.implementation.createHTMLDocument("sandbox"))).createElement(t.tagName);e.innerHTML=t.innerHTML;for(var n=0,a=Object.keys(t.attributes);n<a.length;n++){var o=a[n];try{e.setAttribute(o,t.attributes[o])}catch(t){}}return e}catch(r){return t}}}}(A);var j={};!function(r){var e=t&&t.__assign||function(){return e=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var a in r=arguments[e])Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a]);return t},e.apply(this,arguments)};r.__esModule=!0,r.default={type:"Map",shouldTransform:function(t,r){return r&&r.constructor&&"Map"===r.constructor.name},toSerializable:function(t){var r={};return t.forEach((function(t,e){var n="object"==typeof e?JSON.stringify(e):e;r[n]=t})),{name:"Map",body:r,proto:Object.getPrototypeOf(t).constructor.name}},fromSerializable:function(t){var r=t.body,n=e({},r);return"string"==typeof t.proto&&(n.constructor={name:t.proto}),n}}}(j);var z={};!function(t){t.__esModule=!0;var r="@t",e=/^#*@(t|r)$/,n=(0,eval)("this"),a="function"==typeof ArrayBuffer,o="function"==typeof Map,i="function"==typeof Set,u=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array"],s=Array.prototype.slice,f={serialize:function(t){return JSON.stringify(t)},deserialize:function(t){return JSON.parse(t)}},c=function(){function t(t,r){this.references=t,this.transforms=r,this.transformsMap=this._makeTransformsMap(),this.circularCandidates=[],this.circularCandidatesDescrs=[],this.circularRefCount=0}return t._createRefMark=function(t){var r=Object.create(null);return r["@r"]=t,r},t.prototype._createCircularCandidate=function(t,r,e){this.circularCandidates.push(t),this.circularCandidatesDescrs.push({parent:r,key:e,refIdx:-1})},t.prototype._applyTransform=function(t,e,n,a){var o=Object.create(null),i=a.toSerializable(t);return"object"==typeof i&&this._createCircularCandidate(t,e,n),o[r]=a.type,o.data=this._handleValue((function(){return i}),e,n),o},t.prototype._handleArray=function(t){for(var r=[],e=function(e){r[e]=n._handleValue((function(){return t[e]}),r,e)},n=this,a=0;a<t.length;a++)e(a);return r},t.prototype._handlePlainObject=function(t){var r,n,a=Object.create(null),o=function(r){if(Reflect.has(t,r)){var n=e.test(r)?"#"+r:r;a[n]=i._handleValue((function(){return t[r]}),a,n)}},i=this;for(var u in t)o(u);var s=null===(n=null===(r=null==t?void 0:t.__proto__)||void 0===r?void 0:r.constructor)||void 0===n?void 0:n.name;return s&&"Object"!==s&&(a.constructor={name:s}),a},t.prototype._handleObject=function(t,r,e){return this._createCircularCandidate(t,r,e),Array.isArray(t)?this._handleArray(t):this._handlePlainObject(t)},t.prototype._ensureCircularReference=function(r){var e=this.circularCandidates.indexOf(r);if(e>-1){var n=this.circularCandidatesDescrs[e];return-1===n.refIdx&&(n.refIdx=n.parent?++this.circularRefCount:0),t._createRefMark(n.refIdx)}return null},t.prototype._handleValue=function(t,r,e){try{var n=t(),a=typeof n,o="object"===a&&null!==n;if(o){var i=this._ensureCircularReference(n);if(i)return i}var u=this._findTransform(a,n);return u?this._applyTransform(n,r,e,u):o?this._handleObject(n,r,e):n}catch(t){try{return this._handleValue((function(){return t instanceof Error?t:new Error(t)}),r,e)}catch(t){return null}}},t.prototype._makeTransformsMap=function(){if(o){var t=new Map;
1return this.transforms.forEach((function(r){r.lookup&&t.set(r.lookup,r)})),t}},t.prototype._findTransform=function(t,r){if(o&&r&&r.constructor&&(null==(a=this.transformsMap.get(r.constructor))?void 0:a.shouldTransform(t,r)))return a;for(var e=0,n=this.transforms;e<n.length;e++){var a;if((a=n[e]).shouldTransform(t,r))return a}},t.prototype.transform=function(){for(var r=this,e=[this._handleValue((function(){return r.references}),null,null)],n=0,a=this.circularCandidatesDescrs;n<a.length;n++){var o=a[n];o.refIdx>0&&(e[o.refIdx]=o.parent[o.key],o.parent[o.key]=t._createRefMark(o.refIdx))}return e},t}(),l=function(){function t(t,r){this.activeTransformsStack=[],this.visitedRefs=Object.create(null),this.references=t,this.transformMap=r}return t.prototype._handlePlainObject=function(t){var r=Object.create(null);for(var n in"constructor"in t&&(t.constructor&&"string"==typeof t.constructor.name||(t.constructor={name:"Object"})),t)t.hasOwnProperty(n)&&(this._handleValue(t[n],t,n),e.test(n)&&(r[n.substring(1)]=t[n],delete t[n]));for(var a in r)t[a]=r[a]},t.prototype._handleTransformedObject=function(t,e,n){var a=t[r],o=this.transformMap[a];if(!o)throw new Error("Can\'t find transform for \\""+a+\'" type.\');this.activeTransformsStack.push(t),this._handleValue(t.data,t,"data"),this.activeTransformsStack.pop(),e[n]=o.fromSerializable(t.data)},t.prototype._handleCircularSelfRefDuringTransform=function(t,r,e){var n=this.references;Object.defineProperty(r,e,{val:void 0,configurable:!0,enumerable:!0,get:function(){return void 0===this.val&&(this.val=n[t]),this.val},set:function(t){this.val=t}})},t.prototype._handleCircularRef=function(t,r,e){this.activeTransformsStack.includes(this.references[t])?this._handleCircularSelfRefDuringTransform(t,r,e):(this.visitedRefs[t]||(this.visitedRefs[t]=!0,this._handleValue(this.references[t],this.references,t)),r[e]=this.references[t])},t.prototype._handleValue=function(t,e,n){if("object"==typeof t&&null!==t){var a=t["@r"];if(void 0!==a)this._handleCircularRef(a,e,n);else if(t[r])this._handleTransformedObject(t,e,n);else if(Array.isArray(t))for(var o=0;o<t.length;o++)this._handleValue(t[o],t,o);else this._handlePlainObject(t)}},t.prototype.transform=function(){return this.visitedRefs[0]=!0,this._handleValue(this.references[0],this.references,0),this.references[0]},t}(),d=[{type:"[[NaN]]",shouldTransform:function(t,r){return"number"===t&&isNaN(r)},toSerializable:function(){return""},fromSerializable:function(){return NaN}},{type:"[[undefined]]",shouldTransform:function(t){return"undefined"===t},toSerializable:function(){return""},fromSerializable:function(){}},{type:"[[Date]]",lookup:Date,shouldTransform:function(t,r){return r instanceof Date},toSerializable:function(t){return t.getTime()},fromSerializable:function(t){var r=new Date;return r.setTime(t),r}},{type:"[[RegExp]]",lookup:RegExp,shouldTransform:function(t,r){return r instanceof RegExp},toSerializable:function(t){var r={src:t.source,flags:""};return t.globalThis&&(r.flags+="g"),t.ignoreCase&&(r.flags+="i"),t.multiline&&(r.flags+="m"),r},fromSerializable:function(t){return new RegExp(t.src,t.flags)}},{type:"[[Error]]",lookup:Error,shouldTransform:function(t,r){return r instanceof Error},toSerializable:function(t){var r,e;return t.stack||null===(e=(r=Error).captureStackTrace)||void 0===e||e.call(r,t),{name:t.name,message:t.message,stack:t.stack}},fromSerializable:function(t){var r=new(n[t.name]||Error)(t.message);return r.stack=t.stack,r}},{type:"[[ArrayBuffer]]",lookup:a&&ArrayBuffer,shouldTransform:function(t,r){return a&&r instanceof ArrayBuffer},toSerializable:function(t){var r=new Int8Array(t);return s.call(r)},fromSerializable:function(t){if(a){var r=new ArrayBuffer(t.length);return new Int8Array(r).set(t),r}return t}},{type:"[[TypedArray]]",shouldTransform:function(t,r){if(a)return ArrayBuffer.isView(r)&&!(r instanceof DataView);for(var e=0,o=u;e<o.length;e++){var i=o[e];if("function"==typeof n[i]&&r instanceof n[i])return!0}return!1},toSerializable:function(t){return{ctorName:t.constructor.name,arr:s.call(t)}},fromSerializable:function(t){return"function"==typeof n[t.ctorName]?new n[t.ctorName](t.arr):t.arr}},{type:"[[Map]]",lookup:o&&Map,shouldTransform:function(t,r){return o&&r instanceof Map},toSerializable:function(t){var r=[];return t.forEach((function(t,e){r.push(e),r.push(t)})),r},fromSerializable:function(t){if(o){for(var r=new Map,e=0;e<t.length;e+=2)r.set(t[e],t[e+1]);return r}for(var n=[],a=0;a<t.length;a+=2)n.push([t[e],t[e+1]]);return n}}
1,{type:"[[Set]]",lookup:i&&Set,shouldTransform:function(t,r){return i&&r instanceof Set},toSerializable:function(t){var r=[];return t.forEach((function(t){r.push(t)})),r},fromSerializable:function(t){if(i){for(var r=new Set,e=0;e<t.length;e++)r.add(t[e]);return r}return t}}],p=function(){function t(t){this.transforms=[],this.transformsMap=Object.create(null),this.serializer=t||f,this.addTransforms(d)}return t.prototype.addTransforms=function(t){for(var r=0,e=t=Array.isArray(t)?t:[t];r<e.length;r++){var n=e[r];if(this.transformsMap[n.type])throw new Error(\'Transform with type "\'+n.type+\'" was already added.\');this.transforms.push(n),this.transformsMap[n.type]=n}return this},t.prototype.removeTransforms=function(t){for(var r=0,e=t=Array.isArray(t)?t:[t];r<e.length;r++){var n=e[r],a=this.transforms.indexOf(n);a>-1&&this.transforms.splice(a,1),delete this.transformsMap[n.type]}return this},t.prototype.encode=function(t){var r=new c(t,this.transforms).transform();return this.serializer.serialize(r)},t.prototype.decode=function(t){var r=this.serializer.deserialize(t);return new l(r,this.transformsMap).transform()},t}();t.default=p}(z);var E=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};S.__esModule=!0,S.Decode=P=S.Encode=void 0;var k=E(O),C=E(w),D=E(A),I=E(j),N=E(z),R=[D.default,C.default,k.default,I.default],x=new N.default;x.addTransforms(R);var P=S.Encode=function(t){return JSON.parse(x.encode(t))};S.Decode=function(t){return x.decode(JSON.stringify(t))},function(r){var e=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};r.__esModule=!0;var a=e(n),i=e(o),u=S;r.default=function(t,r,e){void 0===e&&(e=!0);for(var n=t,o={pointers:{},src:{npm:"https://npmjs.com/package/console-feed",github:"https://github.com/samdenty99/console-feed"}},s=function(t){var a=n[t];n[t]=function(){a.apply(this,arguments);var n=[].slice.call(arguments);setTimeout((function(){var a=i.default(t,n);if(a){var o=a;e&&(o=u.Encode(a)),r(o,a)}}))},o.pointers[t]=a},f=0,c=a.default;f<c.length;f++)s(c[f]);return n.feed=o,n}}(e),r(e)(window.console,(function(t){var r=P(t);parent.postMessage({type:"console",codesandbox:!0,log:Array.isArray(r)?r[0]:r,channelId:scope.channelId},"*")}));\n\n};',id:"consoleHook"}],to=function(t,e){ti.forEach(function(r){var n,a=r.code,i=r.id;null===(n=t.contentWindow)||void 0===n||n.postMessage({uid:i,type:"INJECT_AND_INVOKE",code:"exports.activate = "+a,scope:{channelId:e}},"*")})},ts=function(t){function e(e,r,a){void 0===a&&(a={});var i=t.call(this,e,r,(0,n.h)((0,n.h)({},a),{bundlerURL:a.bundlerURL}))||this;return i._modulesCache=new Map,i.messageChannelId=(0,tn.g)(),i._initPromise=null,i.emitter=new tn.E,i.manageIframes(e),i.emulator=new te({iframe:i.emulatorIframe,runtimeUrl:i.options.bundlerURL}),i.updateSandbox(r),i}return(0,n.g)(e,t),e.prototype._init=function(t){return(0,n._)(this,void 0,void 0,function(){return(0,n.a)(this,function(e){switch(e.label){case 0:return[4,this.emulator.connect()];case 1:return e.sent(),[4,this.emulator.fs.init(t)];case 2:return e.sent(),[4,this.globalListeners()];case 3:return e.sent(),[2]}})})},e.prototype.compile=function(t){return(0,n._)(this,void 0,void 0,function(){var e,r;return(0,n.a)(this,function(n){switch(n.label){case 0:return n.trys.push([0,5,,6]),this.status="initializing",this.dispatch({type:"start",firstLoad:!0}),this._initPromise||(this._initPromise=this._init(t)),[4,this._initPromise];case 1:return n.sent(),this.dispatch({type:"connected"}),[4,this.createShellProcessFromTask(t)];case 2:return e=n.sent().id,[4,this.createPreviewURLFromId(e)];case 3:return n.sent(),[4,this.setLocationURLIntoIFrame()];case 4:return n.sent(),this.dispatchDoneMessage(),[3,6];case 5:return r=n.sent(),this.dispatch({type:"action",action:"notification",notificationType:"error",title:(0,tn.a)(r)}),this.dispatch({type:"done",compilatonError:!0}),[3,6];case 6:return[2]}})})},e.prototype.createShellProcessFromTask=function(t){return(0,n._)(this,void 0,void 0,function(){var e,r,a=this;return(0,n.a)(this,function(i){switch(i.label){case 0:return e=(0,tn.r)(t["/package.json"]),this.emulatorCommand=(0,tn.b)(e),this.emulatorShellProcess=this.emulator.shell.create(),[4,this.emulatorShellProcess.on("exit",function(t){a.dispatch({type:"action",action:"notification",notificationType:"error",title:(0,n.c)("Error: process.exit("+t+") called.")})})];case 1:return i.sent(),[4,this.emulatorShellProcess.on("progress",function(t){var e,r;if("command_running"===t.state||"starting_command"===t.state){a.dispatch({type:"shell/progress",data:(0,n.h)((0,n.h)({},t),{command:[null===(e=a.emulatorCommand)||void 0===e?void 0:e[0],null===(r=a.emulatorCommand)||void 0===r?void 0:r[1].join(" ")].join(" ")})}),a.status="installing-dependencies";return}a.dispatch({type:"shell/progress",data:t})})];case 2:return i.sent(),this.emulatorShellProcess.stdout.on("data",function(t){a.dispatch({type:"stdout",payload:{data:t,type:"out"}})}),this.emulatorShellProcess.stderr.on("data",function(t){a.dispatch({type:"stdout",payload:{data:t,type:"err"}})}),[4,(r=this.emulatorShellProcess).runCommand.apply(r,this.emulatorCommand)];case 3:return[2,i.sent()]}})})},e.prototype.createPreviewURLFromId=function(t){return(0,n._)(this,void 0,void 0,function(){var e;return(0,n.a)(this,function(r){switch(r.label){case 0:return this.iframePreviewUrl=void 0,[4,this.emulator.preview.getByShellId(t)];case 1:return e=r.sent().url,this.iframePreviewUrl=e+this.options.startRoute,[2]}})})},e.prototype.manageIframes=function(t){var e;if("string"==typeof t){var r=document.querySelector(t);(0,n.n)(r,"The element '"+t+"' was not found"),this.iframe=document.createElement("iframe")}else this.iframe=t;ta(this.iframe,this.options),(0,n.n)(this.iframe.parentNode,"The given iframe does not have a parent."),this.emulatorIframe=document.createElement("iframe"),this.emulatorIframe.classList.add("sp-bridge-frame"),null===(e=this.iframe.parentNode)||void 0===e||e.appendChild(this.emulatorIframe)},e.prototype.setLocationURLIntoIFrame=function(){return(0,n._)(this,void 0,void 0,function(){return(0,n.a)(this,function(t){switch(t.label){case 0:if(!this.iframePreviewUrl)return[3,2];return[4,function(t,e){return(0,n._)(this,void 0,void 0,function(){var r,a,i;return(0,n.a)(this,function(o){return r=t.contentWindow,(0,n.n)(r,"Failed to await preview iframe: no content window found"),a=0,[2,new Promise(function(r,o){var s=function(){var u=function(){clearTimeout(i),a=20,r(),t.removeEventListener("load",u)};if(a>=20){o((0,n.c)("Could not able to connect to preview."));return}t.setAttribute("src",e),i=setTimeout(function(){s(),t.removeEventListener("load",u)},9e4),a+=1,t.addEventListener("load",u)};t.addEventListener("error",function(){return o(Error("Iframe error"))}),t.addEventListener("abort",function(){return o(Error("Aborted"))}),s()})]})})}(this.iframe,this.iframePreviewUrl)];case 1:t.sent(),t.label=2;case 2:return[2]}})})},e.prototype.dispatchDoneMessage=function(){this.status="done",this.dispatch({type:"done",compilatonError:!1}),this.iframePreviewUrl&&this.dispatch({type:"urlchange",url:this.iframePreviewUrl,back:!1,forward:!1})},e.prototype.globalListeners=function(){return(0,n._)(this,void 0,void 0,function(){var t=this;return(0,n.a)(this,function(e){switch(e.label){case 0:return window.addEventListener("message",function(e){"PREVIEW_LOADED"===e.data.type&&to(t.iframe,t.messageChannelId),"urlchange"===e.data.type&&e.data.channelId===t.messageChannelId?t.dispatch({type:"urlchange",url:e.data.url,back:e.data.back,forward:e.data.forward}):e.data.channelId===t.messageChannelId&&t.dispatch(e.data)}),[4,this.emulator.fs.watch(["*"],[".next","node_modules","build","dist","vendor",".config",".vuepress"],function(e){return(0,n._)(t,void 0,void 0,function(){var t,r,a,i,o;return(0,n.a)(this,function(n){switch(n.label){case 0:if(!e)return[2];return r="newPath"in(t=e)?t.newPath:"path"in t?t.path:"",[4,this.emulator.fs.stat(r)];case 1:if("file"!==n.sent().type)return[2,null];n.label=2;case 2:switch(n.trys.push([2,10,,11]),t.type){case"change":case"create":return[3,3];case"remove":return[3,5];case"rename":return[3,6];
1case"close":return[3,8]}return[3,9];case 3:return[4,this.emulator.fs.readFile(t.path,"utf8")];case 4:return a=n.sent(),this.dispatch({type:"fs/change",path:t.path,content:a}),this._modulesCache.set(t.path,(0,tn.w)(a)),[3,9];case 5:return this.dispatch({type:"fs/remove",path:t.path}),this._modulesCache.delete(t.path),[3,9];case 6:return this.dispatch({type:"fs/remove",path:t.oldPath}),this._modulesCache.delete(t.oldPath),[4,this.emulator.fs.readFile(t.newPath,"utf8")];case 7:return i=n.sent(),this.dispatch({type:"fs/change",path:t.newPath,content:i}),this._modulesCache.set(t.newPath,(0,tn.w)(i)),[3,9];case 8:return[3,9];case 9:return[3,11];case 10:return o=n.sent(),this.dispatch({type:"action",action:"notification",notificationType:"error",title:(0,tn.a)(o)}),[3,11];case 11:return[2]}})})})];case 1:return e.sent(),[2]}})})},e.prototype.restartShellProcess=function(){var t;return(0,n._)(this,void 0,void 0,function(){return(0,n.a)(this,function(e){switch(e.label){case 0:if(!(this.emulatorShellProcess&&this.emulatorCommand))return[3,3];return this.dispatch({type:"start",firstLoad:!0}),this.status="initializing",[4,this.emulatorShellProcess.kill()];case 1:return e.sent(),null===(t=this.iframe)||void 0===t||t.removeAttribute("attr"),this.emulator.fs.rm("/node_modules/.vite",{recursive:!0,force:!0}),[4,this.compile(Object.fromEntries(this._modulesCache))];case 2:e.sent(),e.label=3;case 3:return[2]}})})},e.prototype.updateSandbox=function(t){var e,r=this,n=(0,tn.f)(t.files);if((null===(e=this.emulatorShellProcess)||void 0===e?void 0:e.state)==="running"){Object.entries(n).forEach(function(t){var e=t[0],n=t[1];r._modulesCache.get(e)&&(0,tn.r)(n)===(0,tn.r)(r._modulesCache.get(e))||r.emulator.fs.writeFile(e,n,{recursive:!0})});return}this.dispatch({codesandbox:!0,modules:n,template:t.template,type:"compile"}),Object.entries(n).forEach(function(t){var e=t[0],n=t[1];r._modulesCache.set(e,(0,tn.w)(n))})},e.prototype.dispatch=function(t){var e,r;return(0,n._)(this,void 0,void 0,function(){return(0,n.a)(this,function(n){switch(n.label){case 0:switch(t.type){case"compile":return[3,1];case"refresh":return[3,2];case"urlback":case"urlforward":return[3,4];case"shell/restart":return[3,5];case"shell/openPreview":return[3,6]}return[3,7];case 1:return this.compile(t.modules),[3,8];case 2:return[4,this.setLocationURLIntoIFrame()];case 3:return n.sent(),[3,8];case 4:return null===(r=null===(e=this.iframe)||void 0===e?void 0:e.contentWindow)||void 0===r||r.postMessage(t,"*"),[3,8];case 5:return this.restartShellProcess(),[3,8];case 6:return window.open(this.iframePreviewUrl,"_blank"),[3,8];case 7:this.emitter.dispatch(t),n.label=8;case 8:return[2]}})})},e.prototype.listen=function(t){return this.emitter.listener(t)},e.prototype.destroy=function(){this.emulatorIframe.remove(),this.emitter.cleanup()},e}(tr.S)}}]);
2//# sourceMappingURL=309.d212e640ced7c989.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.