-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimjoy-rpc-socketio.min.js.map
1 lines (1 loc) · 366 KB
/
imjoy-rpc-socketio.min.js.map
1
{"version":3,"sources":["webpack://[name]/webpack/universalModuleDefinition","webpack://[name]/webpack/bootstrap","webpack://[name]/./src/utils.js","webpack://[name]/./src/rpc.js","webpack://[name]/./node_modules/@socket.io/component-emitter/index.js","webpack://[name]/./node_modules/engine.io-client/build/esm/globalThis.browser.js","webpack://[name]/./node_modules/engine.io-client/build/esm/util.js","webpack://[name]/./src/pluginIframe.js","webpack://[name]/./node_modules/engine.io-client/build/esm/transports/websocket-constructor.browser.js","webpack://[name]/./node_modules/engine.io-parser/build/esm/commons.js","webpack://[name]/./node_modules/engine.io-parser/build/esm/encodePacket.browser.js","webpack://[name]/./node_modules/@socket.io/base64-arraybuffer/dist/base64-arraybuffer.es5.js","webpack://[name]/./node_modules/engine.io-parser/build/esm/decodePacket.browser.js","webpack://[name]/./node_modules/engine.io-parser/build/esm/index.js","webpack://[name]/./src/pluginCore.js","webpack://[name]/./node_modules/engine.io-client/build/esm/transport.js","webpack://[name]/./node_modules/parseqs/index.js","webpack://[name]/./src/main.js","webpack://[name]/./src/plugin.webworker.js","webpack://[name]/./node_modules/parseuri/index.js","webpack://[name]/./node_modules/yeast/index.js","webpack://[name]/./node_modules/worker-loader/dist/workers/InlineWorker.js","webpack://[name]/./node_modules/has-cors/index.js","webpack://[name]/./node_modules/engine.io-client/build/esm/transports/websocket.js","webpack://[name]/./node_modules/backo2/index.js","webpack://[name]/./node_modules/buffer/index.js","webpack://[name]/(webpack)/buildin/global.js","webpack://[name]/./node_modules/base64-js/index.js","webpack://[name]/./node_modules/ieee754/index.js","webpack://[name]/./node_modules/isarray/index.js","webpack://[name]/./node_modules/engine.io-client/build/esm/transports/xmlhttprequest.browser.js","webpack://[name]/./node_modules/engine.io-client/build/esm/transports/polling.js","webpack://[name]/./node_modules/engine.io-client/build/esm/transports/polling-xhr.js","webpack://[name]/./node_modules/engine.io-client/build/esm/transports/index.js","webpack://[name]/./node_modules/engine.io-client/build/esm/socket.js","webpack://[name]/./node_modules/engine.io-client/build/esm/index.js","webpack://[name]/./node_modules/socket.io-client/node_modules/socket.io-parser/build/esm/is-binary.js","webpack://[name]/./node_modules/socket.io-client/node_modules/socket.io-parser/build/esm/binary.js","webpack://[name]/./node_modules/socket.io-client/node_modules/socket.io-parser/build/esm/index.js","webpack://[name]/./node_modules/socket.io-client/build/esm/on.js","webpack://[name]/./node_modules/socket.io-client/build/esm/socket.js","webpack://[name]/./node_modules/socket.io-client/build/esm/manager.js","webpack://[name]/./node_modules/socket.io-client/build/esm/index.js","webpack://[name]/./node_modules/socket.io-client/build/esm/url.js","webpack://[name]/./src/socketIOMain.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","randId","Math","random","toString","substr","Date","getTime","dtypeToTypedArray","int8","Int8Array","int16","Int16Array","int32","Int32Array","uint8","Uint8Array","uint16","Uint16Array","uint32","Uint32Array","float32","Float32Array","float64","Float64Array","array","Array","async","loadRequirementsInWindow","requirements","_importScript","url","Promise","resolve","reject","scriptTag","document","createElement","src","type","onload","onreadystatechange","this","readyState","onerror","head","appendChild","importScripts","args","slice","arguments","len","length","isArray","link_node","toLowerCase","endsWith","startsWith","rel","href","import","console","log","e","loadRequirementsInWebworker","loadRequirements","WorkerGlobalScope","self","normalizeConfig","config","version","description","id","target_origin","allow_execution","keys","reduce","typedArrayToDtypeMapping","typedArrayToDtypeKeys","arrType","push","eval","typedArrayToDtype","obj","dtype","constructor","pt","getPrototypeOf","cacheUrlInServiceWorker","message","command","navigator","serviceWorker","register","messageChannel","MessageChannel","port1","onmessage","event","data","error","result","controller","postMessage","port2","cacheRequirements","req","catch","setupServiceWorker","baseUrl","targetOrigin","cacheCallback","then","registration","scope","err","Error","addEventListener","origin","urlJoin","join","replace","MessageEmitter","debug","_event_handlers","_once_handlers","_debug","emit","on","handler","once","___event_run_once","off","idx","indexOf","splice","_fire","warn","API_VERSION","ArrayBufferView","_appendBuffer","buffer1","buffer2","tmp","byteLength","set","buffer","indexObject","is","split","RPC","connection","codecs","super","_connection","_codecs","_object_store","_method_weakmap","WeakMap","_object_weakmap","_local_api","_remote_set","execute","_store","ReferenceStore","_method_refs","onReady","onBusy","_setupMessageHanlders","init","peer_id","setConfig","k","getRemoteCallStack","getStack","getRemote","_remote_interface","setInterface","_interface","forwarding_functions","func_name","_remote","Function","sendInterface","_encode","api","_disposeObject","objectId","disposeObject","has","object_id","code","String","method","method_this","promise","_unwrap","includes","apply","fetch","_setRemoteInterface","disconnect","requestRemote","_ndarray","typedArray","shape","_dtype","_rtype","_rvalue","_rshape","_rdtype","_decode","intf","assign","_reportRemoteSet","_genRemoteMethod","targetId","me","remoteMethod","put","wrapped_resolve","wrapped_reject","encodedPromise","_wrap","__promise_pair","argLength","withKwargs","_rkwargs","transferables","__transferables__","target_id","with_kwargs","__remote_method","aObject","asInterface","aType","ArrayBuffer","bObject","_rtarget_id","_rintf","cid","_rname","temp","_transfer","isarray","tp","codec","encoder","encodedObj","tf","Tensor","v_buffer","dataSync","nj","NdArray","selection","File","_rpath","_path","webkitRelativePath","Boolean","RegExp","ImageData","FileList","FileSystemDirectoryHandle","FileSystemFileHandle","FileSystemHandle","FileSystemWritableFileStream","_rmime","Blob","DataView","Set","from","Map","getOwnPropertyNames","concat","hasFunction","withPromise","decoder","_genRemoteCallback","Uint8","reshape","arraytype","tensor","v","undefined","remoteCallback","reset","setTimeout","_indices","_readyHandler","_busyHandler","readyHandler","busyHandler","_genId","shift","_releaseId","pop","Emitter","mixin","fn","_callbacks","removeListener","removeAllListeners","removeEventListener","cb","callbacks","emitReserved","listeners","hasListeners","pick","attr","acc","NATIVE_SET_TIMEOUT","NATIVE_CLEAR_TIMEOUT","clearTimeout","installTimerFunctions","opts","useNativeTimers","setTimeoutFn","clearTimeoutFn","_htmlToElement","html","template","trim","innerHTML","content","firstChild","_inWebWorker","executeEsModule","dataUri","encodeURIComponent","Connection","connect","broadcastChannel","BroadcastChannel","globalThis","location","handleEvent","parent","script_node","setAttribute","attrs","lang","node","createTextNode","body","style_node","link_node_","stack","setupIframe","dedicated_thread","api_version","conn","connectRPC","nextTick","WebSocket","MozWebSocket","usingBrowserWebSocket","defaultBinaryType","PACKET_TYPES","PACKET_TYPES_REVERSE","forEach","ERROR_PACKET","withNativeBlob","withNativeArrayBuffer","encodeBlobAsBase64","callback","fileReader","FileReader","readAsDataURL","supportsBinary","isView","chars","lookup","charCodeAt","decodeBase64Packet","binaryType","decoded","base64","encoded1","encoded2","encoded3","encoded4","bufferLength","arraybuffer","bytes","decode","mapBinary","encodedPacket","charAt","substring","SEPARATOR","fromCharCode","encodePayload","packets","encodedPackets","count","packet","decodePayload","encodedPayload","decodedPacket","protocol","rpc","launchConnected","registerCodec","setup","export","onLoad","checkHandler","connected","connectedHandlers","dispose","_rpc","dispatchEvent","CustomEvent","detail","Transport","writable","query","socket","msg","desc","doOpen","doClose","onClose","write","onPacket","encode","str","qs","qry","pairs","pair","decodeURIComponent","waitForInitialization","enable_service_worker","base_url","cache_requirements","credential_required","verify_credential","cfg","credential","auth","setupRPC","expose_api_globally","top","_inIframe","worker","PluginWorker","fallbackTimeout","terminate","setupWebWorker","re","parts","b","exec","uri","source","host","authority","ipv6uri","pathNames","path","names","queryKey","$0","$1","$2","prev","alphabet","map","seed","num","encoded","floor","yeast","now","URL","webkitURL","blob","BlobBuilder","WebKitBlobBuilder","MozBlobBuilder","MSBlobBuilder","append","getBlob","Worker","createObjectURL","XMLHttpRequest","isReactNative","product","WS","forceBase64","check","protocols","extraHeaders","headers","ws","addEventListeners","onopen","autoUnref","_socket","unref","onOpen","onclose","ev","onData","onError","lastPacket","options","compress","perMessageDeflate","Buffer","threshold","send","close","schema","secure","port","Number","timestampRequests","timestampParam","b64","encodedQuery","hostname","Backoff","ms","min","max","factor","jitter","attempts","duration","pow","rand","deviation","setMin","setMax","setJitter","ieee754","kMaxLength","TYPED_ARRAY_SUPPORT","createBuffer","that","RangeError","__proto__","arg","encodingOrOffset","allocUnsafe","TypeError","byteOffset","fromArrayLike","fromArrayBuffer","string","encoding","isEncoding","actual","fromString","isBuffer","checked","copy","val","fromObject","assertSize","size","loweredCase","utf8ToBytes","base64ToBytes","slowToString","start","end","hexSlice","utf8Slice","asciiSlice","latin1Slice","base64Slice","utf16leSlice","swap","bidirectionalIndexOf","dir","isNaN","arrayIndexOf","lastIndexOf","arr","indexSize","arrLength","valLength","read","buf","readUInt16BE","foundIndex","found","j","hexWrite","offset","remaining","strLen","parsed","parseInt","utf8Write","blitBuffer","asciiWrite","byteArray","asciiToBytes","latin1Write","base64Write","ucs2Write","units","hi","lo","utf16leToBytes","fromByteArray","res","secondByte","thirdByte","fourthByte","tempCodePoint","firstByte","codePoint","bytesPerSequence","codePoints","decodeCodePointsArray","SlowBuffer","alloc","INSPECT_MAX_BYTES","global","foo","subarray","typedArraySupport","poolSize","_augment","species","configurable","fill","allocUnsafeSlow","_isBuffer","compare","a","x","y","list","pos","swap16","swap32","swap64","equals","inspect","match","target","thisStart","thisEnd","thisCopy","targetCopy","isFinite","toJSON","_arr","ret","out","toHex","checkOffset","ext","checkInt","objectWriteUInt16","littleEndian","objectWriteUInt32","checkIEEE754","writeFloat","noAssert","writeDouble","newBuf","sliceLen","readUIntLE","mul","readUIntBE","readUInt8","readUInt16LE","readUInt32LE","readUInt32BE","readIntLE","readIntBE","readInt8","readInt16LE","readInt16BE","readInt32LE","readInt32BE","readFloatLE","readFloatBE","readDoubleLE","readDoubleBE","writeUIntLE","writeUIntBE","writeUInt8","writeUInt16LE","writeUInt16BE","writeUInt32LE","writeUInt32BE","writeIntLE","limit","sub","writeIntBE","writeInt8","writeInt16LE","writeInt16BE","writeInt32LE","writeInt32BE","writeFloatLE","writeFloatBE","writeDoubleLE","writeDoubleBE","targetStart","INVALID_BASE64_RE","Infinity","leadSurrogate","toByteArray","stringtrim","base64clean","dst","g","lens","getLens","validLen","placeHoldersLen","Arr","_byteLength","curByte","revLookup","extraBytes","len2","encodeChunk","output","isLE","mLen","nBytes","eLen","eMax","eBias","nBits","NaN","rt","abs","LN2","xdomain","polling","poll","onPause","pause","total","doPoll","doWrite","sid","empty","hasXHR2","responseType","xd","xscheme","xs","xhr","open","setDisableHeaderCheck","setRequestHeader","withCredentials","requestTimeout","timeout","status","index","requestsCount","requests","cleanup","onSuccess","fromError","abort","responseText","attachEvent","unloadHandler","terminationEvent","transports","websocket","isSSL","request","pollXhr","writeBuffer","prevBufferLen","agent","upgrade","rememberUpgrade","rejectUnauthorized","transportOptions","closeOnBeforeunload","upgrades","pingInterval","pingTimeout","pingTimeoutTimer","transport","offlineEventListener","clone","EIO","priorWebsocketSuccess","createTransport","setTransport","onDrain","failed","onTransportOpen","upgrading","flush","freezeTransport","onTransportClose","onupgrade","to","probe","onHandshake","JSON","parse","resetPingTimeout","sendPacket","filterUpgrades","cleanupAndClose","waitForUpgrade","reason","filteredUpgrades","withNativeFile","isBinary","deconstructPacket","buffers","packetData","pack","_deconstructPacket","placeholder","_placeholder","newData","attachments","reconstructPacket","_reconstructPacket","PacketType","EVENT","ACK","hasBinary","encodeAsString","BINARY_EVENT","BINARY_ACK","encodeAsBinary","nsp","stringify","deconstruction","unshift","decodeString","reconstructor","takeBinaryData","next","payload","tryParse","isPayloadValid","CONNECT","DISCONNECT","CONNECT_ERROR","finishedReconstruction","reconPack","binData","RESERVED_EVENTS","freeze","connect_error","disconnecting","newListener","io","disconnected","receiveBuffer","sendBuffer","ids","acks","flags","_autoConnect","subs","onpacket","subEvents","_readyState","ack","_registerAckCallback","isTransportWritable","engine","volatile","timer","_packet","onconnect","onevent","onack","ondisconnect","destroy","emitEvent","_anyListeners","listener","sent","emitBuffered","subDestroy","_a","nsps","reconnection","reconnectionAttempts","reconnectionDelay","reconnectionDelayMax","randomizationFactor","backoff","_parser","parser","Encoder","Decoder","autoConnect","_reconnection","_reconnectionAttempts","_reconnectionDelay","_randomizationFactor","_reconnectionDelayMax","_timeout","_reconnecting","reconnect","skipReconnect","openSubDestroy","errorSub","maybeReconnectOnOpen","onping","ondata","ondecoded","add","active","_close","delay","onreconnect","attempt","cache","loc","test","sameNamespace","forceNew","multiplex","Manager","Socket","server_url","token","Authorization","basePath","pathname","success","plugin_id","_disconnected","connectToServer"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,mBAAoB,GAAIH,GACL,iBAAZC,QACdA,QAA0B,iBAAID,IAE9BD,EAAuB,iBAAIC,IAR7B,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAAStB,GACX,oBAAXuB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAenB,EAASuB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAenB,EAAS,aAAc,CAAEyB,OAAO,KAQvDnB,EAAoBoB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQ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","file":"imjoy-rpc-socketio.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"imjoyRPCSocketIO\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"imjoyRPCSocketIO\"] = factory();\n\telse\n\t\troot[\"imjoyRPCSocketIO\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 29);\n","export function randId() {\n return (\n Math.random()\n .toString(36)\n .substr(2, 10) + new Date().getTime()\n );\n}\n\nexport const dtypeToTypedArray = {\n int8: Int8Array,\n int16: Int16Array,\n int32: Int32Array,\n uint8: Uint8Array,\n uint16: Uint16Array,\n uint32: Uint32Array,\n float32: Float32Array,\n float64: Float64Array,\n array: Array\n};\n\nexport async function loadRequirementsInWindow(requirements) {\n function _importScript(url) {\n //url is URL of external file, implementationCode is the code\n //to be called from the file, location is the location to\n //insert the <script> element\n return new Promise((resolve, reject) => {\n var scriptTag = document.createElement(\"script\");\n scriptTag.src = url;\n scriptTag.type = \"text/javascript\";\n scriptTag.onload = resolve;\n scriptTag.onreadystatechange = function() {\n if (this.readyState === \"loaded\" || this.readyState === \"complete\") {\n resolve();\n }\n };\n scriptTag.onerror = reject;\n document.head.appendChild(scriptTag);\n });\n }\n\n // support importScripts outside web worker\n async function importScripts() {\n var args = Array.prototype.slice.call(arguments),\n len = args.length,\n i = 0;\n for (; i < len; i++) {\n await _importScript(args[i]);\n }\n }\n\n if (\n requirements &&\n (Array.isArray(requirements) || typeof requirements === \"string\")\n ) {\n try {\n var link_node;\n requirements =\n typeof requirements === \"string\" ? [requirements] : requirements;\n if (Array.isArray(requirements)) {\n for (var i = 0; i < requirements.length; i++) {\n if (\n requirements[i].toLowerCase().endsWith(\".css\") ||\n requirements[i].startsWith(\"css:\")\n ) {\n if (requirements[i].startsWith(\"css:\")) {\n requirements[i] = requirements[i].slice(4);\n }\n link_node = document.createElement(\"link\");\n link_node.rel = \"stylesheet\";\n link_node.href = requirements[i];\n document.head.appendChild(link_node);\n } else if (\n requirements[i].toLowerCase().endsWith(\".mjs\") ||\n requirements[i].startsWith(\"mjs:\")\n ) {\n // import esmodule\n if (requirements[i].startsWith(\"mjs:\")) {\n requirements[i] = requirements[i].slice(4);\n }\n await import(/* webpackIgnore: true */ requirements[i]);\n } else if (\n requirements[i].toLowerCase().endsWith(\".js\") ||\n requirements[i].startsWith(\"js:\")\n ) {\n if (requirements[i].startsWith(\"js:\")) {\n requirements[i] = requirements[i].slice(3);\n }\n await importScripts(requirements[i]);\n } else if (requirements[i].startsWith(\"http\")) {\n await importScripts(requirements[i]);\n } else if (requirements[i].startsWith(\"cache:\")) {\n //ignore cache\n } else {\n console.log(\"Unprocessed requirements url: \" + requirements[i]);\n }\n }\n } else {\n throw \"unsupported requirements definition\";\n }\n } catch (e) {\n throw \"failed to import required scripts: \" + requirements.toString();\n }\n }\n}\n\nexport async function loadRequirementsInWebworker(requirements) {\n if (\n requirements &&\n (Array.isArray(requirements) || typeof requirements === \"string\")\n ) {\n try {\n if (!Array.isArray(requirements)) {\n requirements = [requirements];\n }\n for (var i = 0; i < requirements.length; i++) {\n if (\n requirements[i].toLowerCase().endsWith(\".css\") ||\n requirements[i].startsWith(\"css:\")\n ) {\n throw \"unable to import css in a webworker\";\n } else if (\n requirements[i].toLowerCase().endsWith(\".js\") ||\n requirements[i].startsWith(\"js:\")\n ) {\n if (requirements[i].startsWith(\"js:\")) {\n requirements[i] = requirements[i].slice(3);\n }\n importScripts(requirements[i]);\n } else if (requirements[i].startsWith(\"http\")) {\n importScripts(requirements[i]);\n } else if (requirements[i].startsWith(\"cache:\")) {\n //ignore cache\n } else {\n console.log(\"Unprocessed requirements url: \" + requirements[i]);\n }\n }\n } catch (e) {\n throw \"failed to import required scripts: \" + requirements.toString();\n }\n }\n}\n\nexport function loadRequirements(requirements) {\n if (\n typeof WorkerGlobalScope !== \"undefined\" &&\n self instanceof WorkerGlobalScope\n ) {\n return loadRequirementsInWebworker(requirements);\n } else {\n return loadRequirementsInWindow(requirements);\n }\n}\n\nexport function normalizeConfig(config) {\n config.version = config.version || \"0.1.0\";\n config.description =\n config.description || `[TODO: add description for ${config.name} ]`;\n config.type = config.type || \"rpc-window\";\n config.id = config.id || randId();\n config.target_origin = config.target_origin || \"*\";\n config.allow_execution = config.allow_execution || false;\n // remove functions\n config = Object.keys(config).reduce((p, c) => {\n if (typeof config[c] !== \"function\") p[c] = config[c];\n return p;\n }, {});\n return config;\n}\nexport const typedArrayToDtypeMapping = {\n Int8Array: \"int8\",\n Int16Array: \"int16\",\n Int32Array: \"int32\",\n Uint8Array: \"uint8\",\n Uint16Array: \"uint16\",\n Uint32Array: \"uint32\",\n Float32Array: \"float32\",\n Float64Array: \"float64\",\n Array: \"array\"\n};\n\nconst typedArrayToDtypeKeys = [];\nfor (const arrType of Object.keys(typedArrayToDtypeMapping)) {\n typedArrayToDtypeKeys.push(eval(arrType));\n}\n\nexport function typedArrayToDtype(obj) {\n let dtype = typedArrayToDtypeMapping[obj.constructor.name];\n if (!dtype) {\n const pt = Object.getPrototypeOf(obj);\n for (const arrType of typedArrayToDtypeKeys) {\n if (pt instanceof arrType) {\n dtype = typedArrayToDtypeMapping[arrType.name];\n break;\n }\n }\n }\n return dtype;\n}\n\nfunction cacheUrlInServiceWorker(url) {\n return new Promise(function(resolve, reject) {\n const message = {\n command: \"add\",\n url: url\n };\n if (!navigator.serviceWorker || !navigator.serviceWorker.register) {\n reject(\"Service worker is not supported.\");\n return;\n }\n const messageChannel = new MessageChannel();\n messageChannel.port1.onmessage = function(event) {\n if (event.data && event.data.error) {\n reject(event.data.error);\n } else {\n resolve(event.data && event.data.result);\n }\n };\n\n if (navigator.serviceWorker && navigator.serviceWorker.controller) {\n navigator.serviceWorker.controller.postMessage(message, [\n messageChannel.port2\n ]);\n } else {\n reject(\"Service worker controller is not available\");\n }\n });\n}\n\nexport async function cacheRequirements(requirements) {\n requirements = requirements || [];\n if (!Array.isArray(requirements)) {\n requirements = [requirements];\n }\n for (let req of requirements) {\n //remove prefix\n if (req.startsWith(\"js:\")) req = req.slice(3);\n if (req.startsWith(\"css:\")) req = req.slice(4);\n if (req.startsWith(\"cache:\")) req = req.slice(6);\n if (!req.startsWith(\"http\")) continue;\n\n await cacheUrlInServiceWorker(req).catch(e => {\n console.error(e);\n });\n }\n}\n\nexport function setupServiceWorker(baseUrl, targetOrigin, cacheCallback) {\n // register service worker for offline access\n if (\"serviceWorker\" in navigator) {\n baseUrl = baseUrl || \"/\";\n navigator.serviceWorker.register(baseUrl + \"plugin-service-worker.js\").then(\n function(registration) {\n // Registration was successful\n console.log(\n \"ServiceWorker registration successful with scope: \",\n registration.scope\n );\n },\n function(err) {\n // registration failed :(\n console.log(\"ServiceWorker registration failed: \", err);\n }\n );\n targetOrigin = targetOrigin || \"*\";\n cacheCallback = cacheCallback || cacheRequirements;\n if (cacheCallback && typeof cacheCallback !== \"function\") {\n throw new Error(\"config.cache_requirements must be a function\");\n }\n window.addEventListener(\"message\", function(e) {\n if (targetOrigin === \"*\" || e.origin === targetOrigin) {\n const m = e.data;\n if (m.type === \"cacheRequirements\") {\n cacheCallback(m.requirements);\n }\n }\n });\n }\n}\n\n//#Source https://bit.ly/2neWfJ2\nexport function urlJoin(...args) {\n return args\n .join(\"/\")\n .replace(/[\\/]+/g, \"/\")\n .replace(/^(.+):\\//, \"$1://\")\n .replace(/^file:/, \"file:/\")\n .replace(/\\/(\\?|&|#[^!])/g, \"$1\")\n .replace(/\\?/g, \"&\")\n .replace(\"&\", \"?\");\n}\n\nexport class MessageEmitter {\n constructor(debug) {\n this._event_handlers = {};\n this._once_handlers = {};\n this._debug = debug;\n }\n emit() {\n throw new Error(\"emit is not implemented\");\n }\n on(event, handler) {\n if (!this._event_handlers[event]) {\n this._event_handlers[event] = [];\n }\n this._event_handlers[event].push(handler);\n }\n once(event, handler) {\n handler.___event_run_once = true;\n this.on(event, handler);\n }\n off(event, handler) {\n if (!event && !handler) {\n // remove all events handlers\n this._event_handlers = {};\n } else if (event && !handler) {\n // remove all hanlders for the event\n if (this._event_handlers[event]) this._event_handlers[event] = [];\n } else {\n // remove a specific handler\n if (this._event_handlers[event]) {\n const idx = this._event_handlers[event].indexOf(handler);\n if (idx >= 0) {\n this._event_handlers[event].splice(idx, 1);\n }\n }\n }\n }\n _fire(event, data) {\n if (this._event_handlers[event]) {\n var i = this._event_handlers[event].length;\n while (i--) {\n const handler = this._event_handlers[event][i];\n try {\n handler(data);\n } catch (e) {\n console.error(e);\n } finally {\n if (handler.___event_run_once) {\n this._event_handlers[event].splice(i, 1);\n }\n }\n }\n } else {\n if (this._debug) {\n console.warn(\"unhandled event\", event, data);\n }\n }\n }\n}\n","/**\n * Contains the RPC object used both by the application\n * site, and by each plugin\n */\nimport {\n randId,\n typedArrayToDtype,\n dtypeToTypedArray,\n MessageEmitter\n} from \"./utils.js\";\n\nexport const API_VERSION = \"0.2.3\";\n\nconst ArrayBufferView = Object.getPrototypeOf(\n Object.getPrototypeOf(new Uint8Array())\n).constructor;\n\nfunction _appendBuffer(buffer1, buffer2) {\n const tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);\n tmp.set(new Uint8Array(buffer1), 0);\n tmp.set(new Uint8Array(buffer2), buffer1.byteLength);\n return tmp.buffer;\n}\n\nfunction indexObject(obj, is) {\n if (!is) throw new Error(\"undefined index\");\n if (typeof is === \"string\") return indexObject(obj, is.split(\".\"));\n else if (is.length === 0) return obj;\n else return indexObject(obj[is[0]], is.slice(1));\n}\n\n/**\n * RPC object represents a single site in the\n * communication protocol between the application and the plugin\n *\n * @param {Object} connection a special object allowing to send\n * and receive messages from the opposite site (basically it\n * should only provide send() and onMessage() methods)\n */\nexport class RPC extends MessageEmitter {\n constructor(connection, config, codecs) {\n super(config && config.debug);\n this._connection = connection;\n this.config = config || {};\n this._codecs = codecs || {};\n this._object_store = {};\n this._method_weakmap = new WeakMap();\n this._object_weakmap = new WeakMap();\n this._local_api = null;\n this._remote_set = false;\n // make sure there is an execute function\n const name = this.config.name;\n this._connection.execute =\n this._connection.execute ||\n function() {\n throw new Error(`connection.execute not implemented (in \"${name}\")`);\n };\n this._store = new ReferenceStore();\n this._method_refs = new ReferenceStore();\n this._method_refs.onReady(() => {\n this._fire(\"remoteIdle\");\n });\n this._method_refs.onBusy(() => {\n this._fire(\"remoteBusy\");\n });\n this._setupMessageHanlders();\n }\n\n init() {\n this._connection.emit({\n type: \"initialized\",\n config: this.config,\n peer_id: this._connection.peer_id\n });\n }\n\n setConfig(config) {\n if (config)\n for (const k of Object.keys(config)) {\n this.config[k] = config[k];\n }\n }\n /**\n * Set a handler to be called when received a responce from the\n * remote site reporting that the previously provided interface\n * has been successfully set as remote for that site\n *\n * @param {Function} handler\n */\n\n getRemoteCallStack() {\n return this._method_refs.getStack();\n }\n\n /**\n * @returns {Object} set of remote interface methods\n */\n getRemote() {\n return this._remote_interface;\n }\n\n /**\n * Sets the interface of this site making it available to the\n * remote site by sending a message with a set of methods names\n *\n * @param {Object} _interface to set\n */\n setInterface(_interface, config) {\n config = config || {};\n this.config.name = config.name || this.config.name;\n this.config.description = config.description || this.config.description;\n if (this.config.forwarding_functions) {\n for (let func_name of this.config.forwarding_functions) {\n const _remote = this._remote_interface;\n if (_remote[func_name]) {\n if (_interface.constructor === Object) {\n if (!_interface[func_name]) {\n _interface[func_name] = (...args) => {\n _remote[func_name](...args);\n };\n }\n } else if (_interface.constructor.constructor === Function) {\n if (!_interface.constructor.prototype[func_name]) {\n _interface.constructor.prototype[func_name] = (...args) => {\n _remote[func_name](...args);\n };\n }\n }\n }\n }\n }\n this._local_api = _interface;\n if (!this._remote_set) this._fire(\"interfaceAvailable\");\n else this.sendInterface();\n return new Promise(resolve => {\n this.once(\"interfaceSetAsRemote\", resolve);\n });\n }\n\n /**\n * Sends the actual interface to the remote site upon it was\n * updated or by a special request of the remote site\n */\n sendInterface() {\n if (!this._local_api) {\n throw new Error(\"interface is not set.\");\n }\n this._encode(this._local_api, true).then(api => {\n this._connection.emit({ type: \"setInterface\", api: api });\n });\n }\n\n _disposeObject(objectId) {\n if (this._object_store[objectId]) {\n delete this._object_store[objectId];\n } else {\n throw new Error(`Object (id=${objectId}) not found.`);\n }\n }\n\n disposeObject(obj) {\n return new Promise((resolve, reject) => {\n if (this._object_weakmap.has(obj)) {\n const objectId = this._object_weakmap.get(obj);\n this._connection.once(\"disposed\", data => {\n if (data.error) reject(new Error(data.error));\n else resolve();\n });\n this._connection.emit({\n type: \"disposeObject\",\n object_id: objectId\n });\n } else {\n throw new Error(\"Invalid object\");\n }\n });\n }\n\n /**\n * Handles a message from the remote site\n */\n _setupMessageHanlders() {\n this._connection.on(\"init\", this.init);\n this._connection.on(\"execute\", data => {\n Promise.resolve(this._connection.execute(data.code))\n .then(() => {\n this._connection.emit({ type: \"executed\" });\n })\n .catch(e => {\n console.error(e);\n this._connection.emit({\n type: \"executed\",\n error: String(e)\n });\n });\n });\n\n this._connection.on(\"method\", async data => {\n let resolve, reject, method, method_this, args, result;\n try {\n if (data.promise) {\n [resolve, reject] = await this._unwrap(data.promise, false);\n }\n const _interface = this._object_store[data.object_id];\n method = indexObject(_interface, data.name);\n if (data.name.includes(\".\")) {\n const tmp = data.name.split(\".\");\n const intf_index = tmp.slice(0, tmp.length - 1).join(\".\");\n method_this = indexObject(_interface, intf_index);\n } else {\n method_this = _interface;\n }\n args = await this._unwrap(data.args, true);\n if (data.promise) {\n result = method.apply(method_this, args);\n if (\n result instanceof Promise ||\n (method.constructor && method.constructor.name === \"AsyncFunction\")\n ) {\n result.then(resolve).catch(reject);\n } else {\n resolve(result);\n }\n } else {\n method.apply(method_this, args);\n }\n } catch (err) {\n console.error(this.config.name, err);\n if (reject) {\n reject(err);\n }\n }\n });\n\n this._connection.on(\"callback\", async data => {\n let resolve, reject, method, args, result;\n try {\n if (data.promise) {\n [resolve, reject] = await this._unwrap(data.promise, false);\n }\n if (data.promise) {\n method = this._store.fetch(data.id);\n args = await this._unwrap(data.args, true);\n if (!method) {\n throw new Error(\n \"Callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.\"\n );\n }\n result = method.apply(null, args);\n if (\n result instanceof Promise ||\n (method.constructor && method.constructor.name === \"AsyncFunction\")\n ) {\n result.then(resolve).catch(reject);\n } else {\n resolve(result);\n }\n } else {\n method = this._store.fetch(data.id);\n args = await this._unwrap(data.args, true);\n if (!method) {\n throw new Error(\n \"Please notice that callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.\"\n );\n }\n method.apply(null, args);\n }\n } catch (err) {\n console.error(this.config.name, err);\n if (reject) {\n reject(err);\n }\n }\n });\n this._connection.on(\"disposeObject\", data => {\n try {\n this._disposeObject(data.object_id);\n this._connection.emit({\n type: \"disposed\"\n });\n } catch (e) {\n console.error(e);\n this._connection.emit({\n type: \"disposed\",\n error: String(e)\n });\n }\n });\n this._connection.on(\"setInterface\", data => {\n this._setRemoteInterface(data.api);\n });\n this._connection.on(\"getInterface\", () => {\n this._fire(\"getInterface\");\n if (this._local_api) {\n this.sendInterface();\n } else {\n this.once(\"interfaceAvailable\", () => {\n this.sendInterface();\n });\n }\n });\n this._connection.on(\"interfaceSetAsRemote\", () => {\n this._remote_set = true;\n this._fire(\"interfaceSetAsRemote\");\n });\n this._connection.on(\"disconnect\", () => {\n this._fire(\"beforeDisconnect\");\n this._connection.disconnect();\n this._fire(\"disconnected\");\n });\n }\n\n /**\n * Sends a requests to the remote site asking it to provide its\n * current interface\n */\n requestRemote() {\n this._connection.emit({ type: \"getInterface\" });\n }\n\n _ndarray(typedArray, shape, dtype) {\n const _dtype = typedArrayToDtype(typedArray);\n if (dtype && dtype !== _dtype) {\n throw \"dtype doesn't match the type of the array: \" +\n _dtype +\n \" != \" +\n dtype;\n }\n shape = shape || [typedArray.length];\n return {\n _rtype: \"ndarray\",\n _rvalue: typedArray.buffer,\n _rshape: shape,\n _rdtype: _dtype\n };\n }\n\n /**\n * Sets the new remote interface provided by the other site\n *\n * @param {Array} names list of function names\n */\n _setRemoteInterface(api) {\n this._decode(api).then(intf => {\n // update existing interface instead of recreating it\n // this will preserve the object reference\n if (this._remote_interface) {\n // clear the interface\n for (let k in this._remote_interface) delete this._remote_interface[k];\n // then assign the new interfaces\n Object.assign(this._remote_interface, intf);\n } else this._remote_interface = intf;\n this._fire(\"remoteReady\");\n this._reportRemoteSet();\n });\n }\n\n /**\n * Generates the wrapped function corresponding to a single remote\n * method. When the generated function is called, it will send the\n * corresponding message to the remote site asking it to execute\n * the particular method of its interface\n *\n * @param {String} name of the remote method\n *\n * @returns {Function} wrapped remote method\n */\n _genRemoteMethod(targetId, name, objectId) {\n const me = this;\n const remoteMethod = function() {\n return new Promise(async (resolve, reject) => {\n let id = null;\n try {\n id = me._method_refs.put(objectId ? objectId + \"/\" + name : name);\n const wrapped_resolve = function() {\n if (id !== null) me._method_refs.fetch(id);\n return resolve.apply(this, arguments);\n };\n const wrapped_reject = function() {\n if (id !== null) me._method_refs.fetch(id);\n return reject.apply(this, arguments);\n };\n\n const encodedPromise = await me._wrap([\n wrapped_resolve,\n wrapped_reject\n ]);\n\n // store the key id for removing them from the reference store together\n wrapped_resolve.__promise_pair = encodedPromise[1]._rvalue;\n wrapped_reject.__promise_pair = encodedPromise[0]._rvalue;\n\n let args = Array.prototype.slice.call(arguments);\n const argLength = args.length;\n // if the last argument is an object, mark it as kwargs\n const withKwargs =\n argLength > 0 &&\n typeof args[argLength - 1] === \"object\" &&\n args[argLength - 1] !== null &&\n args[argLength - 1]._rkwargs;\n if (withKwargs) delete args[argLength - 1]._rkwargs;\n if (\n name === \"register\" ||\n name === \"registerService\" ||\n name === \"register_service\" ||\n name === \"export\" ||\n name === \"on\"\n ) {\n args = await me._wrap(args, true);\n } else {\n args = await me._wrap(args);\n }\n const transferables = args.__transferables__;\n if (transferables) delete args.__transferables__;\n me._connection.emit(\n {\n type: \"method\",\n target_id: targetId,\n name: name,\n object_id: objectId,\n args: args,\n promise: encodedPromise,\n with_kwargs: withKwargs\n },\n transferables\n );\n } catch (e) {\n if (id) me._method_refs.fetch(id);\n reject(\n `Failed to exectue remote method (interface: ${objectId ||\n me.id}, method: ${name}), error: ${e}`\n );\n }\n });\n };\n remoteMethod.__remote_method = true;\n return remoteMethod;\n }\n\n /**\n * Sends a responce reporting that interface just provided by the\n * remote site was successfully set by this site as remote\n */\n _reportRemoteSet() {\n this._connection.emit({ type: \"interfaceSetAsRemote\" });\n }\n\n /**\n * Prepares the provided set of remote method arguments for\n * sending to the remote site, replaces all the callbacks with\n * identifiers\n *\n * @param {Array} args to wrap\n *\n * @returns {Array} wrapped arguments\n */\n async _encode(aObject, asInterface, objectId) {\n const aType = typeof aObject;\n if (\n aType === \"number\" ||\n aType === \"string\" ||\n aType === \"boolean\" ||\n aObject === null ||\n aObject === undefined ||\n aObject instanceof ArrayBuffer\n ) {\n return aObject;\n }\n\n let bObject;\n if (typeof aObject === \"function\") {\n if (asInterface) {\n if (!objectId) throw new Error(\"objectId is not specified.\");\n bObject = {\n _rtype: \"interface\",\n _rtarget_id: this._connection.peer_id,\n _rintf: objectId,\n _rvalue: asInterface\n };\n this._method_weakmap.set(aObject, bObject);\n } else if (this._method_weakmap.has(aObject)) {\n bObject = this._method_weakmap.get(aObject);\n } else {\n const cid = this._store.put(aObject);\n bObject = {\n _rtype: \"callback\",\n _rtarget_id: this._connection.peer_id,\n _rname: (aObject.constructor && aObject.constructor.name) || cid,\n _rvalue: cid\n };\n }\n return bObject;\n }\n\n // skip if already encoded\n if (aObject.constructor instanceof Object && aObject._rtype) {\n // make sure the interface functions are encoded\n if (aObject._rintf) {\n const temp = aObject._rtype;\n delete aObject._rtype;\n\n bObject = await this._encode(aObject, asInterface, objectId);\n bObject._rtype = temp;\n } else {\n bObject = aObject;\n }\n return bObject;\n }\n\n const transferables = [];\n const _transfer = aObject._transfer;\n const isarray = Array.isArray(aObject);\n\n for (let tp of Object.keys(this._codecs)) {\n const codec = this._codecs[tp];\n if (codec.encoder && aObject instanceof codec.type) {\n // TODO: what if multiple encoders found\n let encodedObj = await Promise.resolve(codec.encoder(aObject));\n if (encodedObj && !encodedObj._rtype) encodedObj._rtype = codec.name;\n // encode the functions in the interface object\n if (encodedObj && encodedObj._rintf) {\n const temp = encodedObj._rtype;\n delete encodedObj._rtype;\n encodedObj = await this._encode(encodedObj, asInterface, objectId);\n encodedObj._rtype = temp;\n }\n bObject = encodedObj;\n return bObject;\n }\n }\n\n if (\n /*global tf*/\n typeof tf !== \"undefined\" &&\n tf.Tensor &&\n aObject instanceof tf.Tensor\n ) {\n const v_buffer = aObject.dataSync();\n if (aObject._transfer || _transfer) {\n transferables.push(v_buffer.buffer);\n delete aObject._transfer;\n }\n bObject = {\n _rtype: \"ndarray\",\n _rvalue: v_buffer.buffer,\n _rshape: aObject.shape,\n _rdtype: aObject.dtype\n };\n } else if (\n /*global nj*/\n typeof nj !== \"undefined\" &&\n nj.NdArray &&\n aObject instanceof nj.NdArray\n ) {\n const dtype = typedArrayToDtype(aObject.selection.data);\n if (aObject._transfer || _transfer) {\n transferables.push(aObject.selection.data.buffer);\n delete aObject._transfer;\n }\n bObject = {\n _rtype: \"ndarray\",\n _rvalue: aObject.selection.data.buffer,\n _rshape: aObject.shape,\n _rdtype: dtype\n };\n } else if (aObject instanceof Error) {\n console.error(aObject);\n bObject = { _rtype: \"error\", _rvalue: aObject.toString() };\n } else if (typeof File !== \"undefined\" && aObject instanceof File) {\n bObject = {\n _rtype: \"file\",\n _rvalue: aObject,\n _rpath: aObject._path || aObject.webkitRelativePath\n };\n }\n // send objects supported by structure clone algorithm\n // https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm\n else if (\n aObject !== Object(aObject) ||\n aObject instanceof Boolean ||\n aObject instanceof String ||\n aObject instanceof Date ||\n aObject instanceof RegExp ||\n aObject instanceof ImageData ||\n (typeof FileList !== \"undefined\" && aObject instanceof FileList) ||\n (typeof FileSystemDirectoryHandle !== \"undefined\" &&\n aObject instanceof FileSystemDirectoryHandle) ||\n (typeof FileSystemFileHandle !== \"undefined\" &&\n aObject instanceof FileSystemFileHandle) ||\n (typeof FileSystemHandle !== \"undefined\" &&\n aObject instanceof FileSystemHandle) ||\n (typeof FileSystemWritableFileStream !== \"undefined\" &&\n aObject instanceof FileSystemWritableFileStream)\n ) {\n bObject = aObject;\n // TODO: avoid object such as DynamicPlugin instance.\n } else if (typeof File !== \"undefined\" && aObject instanceof File) {\n bObject = {\n _rtype: \"file\",\n _rname: aObject.name,\n _rmime: aObject.type,\n _rvalue: aObject,\n _rpath: aObject._path || aObject.webkitRelativePath\n };\n } else if (aObject instanceof Blob) {\n bObject = { _rtype: \"blob\", _rvalue: aObject };\n } else if (aObject instanceof ArrayBufferView) {\n if (aObject._transfer || _transfer) {\n transferables.push(aObject.buffer);\n delete aObject._transfer;\n }\n const dtype = typedArrayToDtype(aObject);\n bObject = {\n _rtype: \"typedarray\",\n _rvalue: aObject.buffer,\n _rdtype: dtype\n };\n } else if (aObject instanceof DataView) {\n if (aObject._transfer || _transfer) {\n transferables.push(aObject.buffer);\n delete aObject._transfer;\n }\n bObject = { _rtype: \"memoryview\", _rvalue: aObject.buffer };\n } else if (aObject instanceof Set) {\n bObject = {\n _rtype: \"set\",\n _rvalue: await this._encode(Array.from(aObject), asInterface)\n };\n } else if (aObject instanceof Map) {\n bObject = {\n _rtype: \"orderedmap\",\n _rvalue: await this._encode(Array.from(aObject), asInterface)\n };\n } else if (\n aObject.constructor instanceof Object ||\n Array.isArray(aObject)\n ) {\n bObject = isarray ? [] : {};\n let keys;\n // an object/array\n if (aObject.constructor === Object || Array.isArray(aObject)) {\n keys = Object.keys(aObject);\n }\n // a class\n else if (aObject.constructor === Function) {\n throw new Error(\"Please instantiate the class before exportting it.\");\n }\n // instance of a class\n else if (aObject.constructor.constructor === Function) {\n keys = Object.getOwnPropertyNames(\n Object.getPrototypeOf(aObject)\n ).concat(Object.keys(aObject));\n // TODO: use a proxy object to represent the actual object\n // always encode class instance as interface\n asInterface = true;\n } else {\n throw Error(\"Unsupported interface type\");\n }\n\n let hasFunction = false;\n // encode interfaces\n if (aObject._rintf || asInterface) {\n if (!objectId) {\n if (typeof aObject._rintf === \"string\" && aObject._rintf.length > 0) {\n objectId = aObject._rintf; // enable custom object id\n } else {\n objectId = randId();\n }\n // Note: object with the same id will be overwritten\n if (this._object_store[objectId])\n console.warn(\n `Overwritting interface object with the same id: ${objectId}`\n );\n this._object_store[objectId] = aObject;\n }\n for (let k of keys) {\n if (k === \"constructor\") continue;\n if (k.startsWith(\"_\")) {\n continue;\n }\n bObject[k] = await this._encode(\n aObject[k],\n typeof asInterface === \"string\" ? asInterface + \".\" + k : k,\n objectId\n );\n if (typeof aObject[k] === \"function\") {\n hasFunction = true;\n }\n }\n // object id for dispose the object remotely\n if (hasFunction) bObject._rintf = objectId;\n // remove interface when closed\n if (aObject.on && typeof aObject.on === \"function\") {\n aObject.on(\"close\", () => {\n delete this._object_store[objectId];\n });\n }\n } else {\n for (let k of keys) {\n if ([\"hasOwnProperty\", \"constructor\"].includes(k)) continue;\n bObject[k] = await this._encode(aObject[k]);\n }\n }\n // for example, browserFS object\n } else if (typeof aObject === \"object\") {\n const keys = Object.getOwnPropertyNames(\n Object.getPrototypeOf(aObject)\n ).concat(Object.keys(aObject));\n const objectId = randId();\n\n for (let k of keys) {\n if ([\"hasOwnProperty\", \"constructor\"].includes(k)) continue;\n // encode as interface\n bObject[k] = await this._encode(aObject[k], k, bObject);\n }\n // object id, used for dispose the object\n bObject._rintf = objectId;\n } else {\n throw \"imjoy-rpc: Unsupported data type:\" + aObject;\n }\n\n if (transferables.length > 0) {\n bObject.__transferables__ = transferables;\n }\n if (!bObject) {\n throw new Error(\"Failed to encode object\");\n }\n return bObject;\n }\n\n async _decode(aObject, withPromise) {\n if (!aObject) {\n return aObject;\n }\n let bObject;\n if (aObject[\"_rtype\"]) {\n if (\n this._codecs[aObject._rtype] &&\n this._codecs[aObject._rtype].decoder\n ) {\n if (aObject._rintf) {\n const temp = aObject._rtype;\n delete aObject._rtype;\n aObject = await this._decode(aObject, withPromise);\n aObject._rtype = temp;\n }\n bObject = await Promise.resolve(\n this._codecs[aObject._rtype].decoder(aObject)\n );\n } else if (aObject._rtype === \"callback\") {\n bObject = this._genRemoteCallback(\n aObject._rtarget_id,\n aObject._rvalue,\n withPromise\n );\n } else if (aObject._rtype === \"interface\") {\n bObject = this._genRemoteMethod(\n aObject._rtarget_id,\n aObject._rvalue,\n aObject._rintf\n );\n } else if (aObject._rtype === \"ndarray\") {\n /*global nj tf*/\n //create build array/tensor if used in the plugin\n if (typeof nj !== \"undefined\" && nj.array) {\n if (Array.isArray(aObject._rvalue)) {\n aObject._rvalue = aObject._rvalue.reduce(_appendBuffer);\n }\n bObject = nj\n .array(new Uint8(aObject._rvalue), aObject._rdtype)\n .reshape(aObject._rshape);\n } else if (typeof tf !== \"undefined\" && tf.Tensor) {\n if (Array.isArray(aObject._rvalue)) {\n aObject._rvalue = aObject._rvalue.reduce(_appendBuffer);\n }\n const arraytype = dtypeToTypedArray[aObject._rdtype];\n bObject = tf.tensor(\n new arraytype(aObject._rvalue),\n aObject._rshape,\n aObject._rdtype\n );\n } else {\n //keep it as regular if transfered to the main app\n bObject = aObject;\n }\n } else if (aObject._rtype === \"error\") {\n bObject = new Error(aObject._rvalue);\n } else if (aObject._rtype === \"file\") {\n if (aObject._rvalue instanceof File) {\n bObject = aObject._rvalue;\n //patch _path\n bObject._path = aObject._rpath;\n } else {\n bObject = new File([aObject._rvalue], aObject._rname, {\n type: aObject._rmime\n });\n bObject._path = aObject._rpath;\n }\n } else if (aObject._rtype === \"typedarray\") {\n const arraytype = dtypeToTypedArray[aObject._rdtype];\n if (!arraytype)\n throw new Error(\"unsupported dtype: \" + aObject._rdtype);\n bObject = new arraytype(aObject._rvalue);\n } else if (aObject._rtype === \"memoryview\") {\n bObject = new DataView(aObject._rvalue);\n } else if (aObject._rtype === \"blob\") {\n if (aObject._rvalue instanceof Blob) {\n bObject = aObject._rvalue;\n } else {\n bObject = new Blob([aObject._rvalue], { type: aObject._rmime });\n }\n } else if (aObject._rtype === \"orderedmap\") {\n bObject = new Map(await this._decode(aObject._rvalue, withPromise));\n } else if (aObject._rtype === \"set\") {\n bObject = new Set(await this._decode(aObject._rvalue, withPromise));\n } else {\n // make sure all the interface functions are decoded\n if (aObject._rintf) {\n const temp = aObject._rtype;\n delete aObject._rtype;\n bObject = await this._decode(aObject, withPromise);\n bObject._rtype = temp;\n } else bObject = aObject;\n }\n } else if (aObject.constructor === Object || Array.isArray(aObject)) {\n const isarray = Array.isArray(aObject);\n bObject = isarray ? [] : {};\n for (let k of Object.keys(aObject)) {\n if (isarray || aObject.hasOwnProperty(k)) {\n const v = aObject[k];\n bObject[k] = await this._decode(v, withPromise);\n }\n }\n } else {\n bObject = aObject;\n }\n if (bObject === undefined) {\n throw new Error(\"Failed to decode object\");\n }\n // store the object id for dispose\n if (aObject._rintf) {\n this._object_weakmap.set(bObject, aObject._rintf);\n }\n return bObject;\n }\n\n async _wrap(args, asInterface) {\n return await this._encode(args, asInterface);\n }\n\n /**\n * Unwraps the set of arguments delivered from the remote site,\n * replaces all callback identifiers with a function which will\n * initiate sending that callback identifier back to other site\n *\n * @param {Object} args to unwrap\n *\n * @param {Boolean} withPromise is true means this the callback should contain a promise\n *\n * @returns {Array} unwrapped args\n */\n async _unwrap(args, withPromise) {\n return await this._decode(args, withPromise);\n }\n\n /**\n * Generates the wrapped function corresponding to a single remote\n * callback. When the generated function is called, it will send\n * the corresponding message to the remote site asking it to\n * execute the particular callback previously saved during a call\n * by the remote site a method from the interface of this site\n *\n * @param {Number} id of the remote callback to execute\n * @param {Number} argNum argument index of the callback\n * @param {Boolean} withPromise is true means this the callback should contain a promise\n *\n * @returns {Function} wrapped remote callback\n */\n _genRemoteCallback(targetId, cid, withPromise) {\n const me = this;\n let remoteCallback;\n if (withPromise) {\n remoteCallback = function() {\n return new Promise(async (resolve, reject) => {\n const args = await me._wrap(Array.prototype.slice.call(arguments));\n const argLength = args.length;\n // if the last argument is an object, mark it as kwargs\n const withKwargs =\n argLength > 0 &&\n typeof args[argLength - 1] === \"object\" &&\n args[argLength - 1] !== null &&\n args[argLength - 1]._rkwargs;\n if (withKwargs) delete args[argLength - 1]._rkwargs;\n const transferables = args.__transferables__;\n if (transferables) delete args.__transferables__;\n\n const encodedPromise = await me._wrap([resolve, reject]);\n // store the key id for removing them from the reference store together\n resolve.__promise_pair = encodedPromise[1]._rvalue;\n reject.__promise_pair = encodedPromise[0]._rvalue;\n try {\n me._connection.emit(\n {\n type: \"callback\",\n target_id: targetId,\n id: cid,\n args: args,\n promise: encodedPromise,\n with_kwargs: withKwargs\n },\n transferables\n );\n } catch (e) {\n reject(`Failed to exectue remote callback ( id: ${cid}).`);\n }\n });\n };\n return remoteCallback;\n } else {\n remoteCallback = async function() {\n const args = await me._wrap(Array.prototype.slice.call(arguments));\n const argLength = args.length;\n // if the last argument is an object, mark it as kwargs\n const withKwargs =\n argLength > 0 &&\n typeof args[argLength - 1] === \"object\" &&\n args[argLength - 1] !== null &&\n args[argLength - 1]._rkwargs;\n if (withKwargs) delete args[argLength - 1]._rkwargs;\n const transferables = args.__transferables__;\n if (transferables) delete args.__transferables__;\n return me._connection.emit(\n {\n type: \"callback\",\n target_id: targetId,\n id: cid,\n args: args,\n with_kwargs: withKwargs\n },\n transferables\n );\n };\n return remoteCallback;\n }\n }\n\n reset() {\n this._event_handlers = {};\n this._once_handlers = {};\n this._remote_interface = null;\n this._object_store = {};\n this._method_weakmap = new WeakMap();\n this._object_weakmap = new WeakMap();\n this._local_api = null;\n this._store = new ReferenceStore();\n this._method_refs = new ReferenceStore();\n }\n\n /**\n * Sends the notification message and breaks the connection\n */\n disconnect() {\n this._connection.emit({ type: \"disconnect\" });\n this.reset();\n setTimeout(() => {\n this._connection.disconnect();\n }, 2000);\n }\n}\n\n/**\n * ReferenceStore is a special object which stores other objects\n * and provides the references (number) instead. This reference\n * may then be sent over a json-based communication channel (IPC\n * to another Node.js process or a message to the Worker). Other\n * site may then provide the reference in the responce message\n * implying the given object should be activated.\n *\n * Primary usage for the ReferenceStore is a storage for the\n * callbacks, which therefore makes it possible to initiate a\n * callback execution by the opposite site (which normally cannot\n * directly execute functions over the communication channel).\n *\n * Each stored object can only be fetched once and is not\n * available for the second time. Each stored object must be\n * fetched, since otherwise it will remain stored forever and\n * consume memory.\n *\n * Stored object indeces are simply the numbers, which are however\n * released along with the objects, and are later reused again (in\n * order to postpone the overflow, which should not likely happen,\n * but anyway).\n */\nclass ReferenceStore {\n constructor() {\n this._store = {}; // stored object\n this._indices = [0]; // smallest available indices\n this._readyHandler = function() {};\n this._busyHandler = function() {};\n this._readyHandler();\n }\n\n /**\n * call handler when the store is empty\n *\n * @param {FUNCTION} id of a handler\n */\n onReady(readyHandler) {\n this._readyHandler = readyHandler || function() {};\n }\n\n /**\n * call handler when the store is not empty\n *\n * @param {FUNCTION} id of a handler\n */\n onBusy(busyHandler) {\n this._busyHandler = busyHandler || function() {};\n }\n\n /**\n * get the length of the store\n *\n */\n getStack() {\n return Object.keys(this._store).length;\n }\n\n /**\n * @function _genId() generates the new reference id\n *\n * @returns {Number} smallest available id and reserves it\n */\n _genId() {\n let id;\n if (this._indices.length === 1) {\n id = this._indices[0]++;\n } else {\n id = this._indices.shift();\n }\n\n return id;\n }\n\n /**\n * Releases the given reference id so that it will be available by\n * another object stored\n *\n * @param {Number} id to release\n */\n _releaseId(id) {\n for (let i = 0; i < this._indices.length; i++) {\n if (id < this._indices[i]) {\n this._indices.splice(i, 0, id);\n break;\n }\n }\n\n // cleaning-up the sequence tail\n for (let i = this._indices.length - 1; i >= 0; i--) {\n if (this._indices[i] - 1 === this._indices[i - 1]) {\n this._indices.pop();\n } else {\n break;\n }\n }\n }\n\n /**\n * Stores the given object and returns the refernce id instead\n *\n * @param {Object} obj to store\n *\n * @returns {Number} reference id of the stored object\n */\n put(obj) {\n if (this._busyHandler && Object.keys(this._store).length === 0) {\n this._busyHandler();\n }\n const id = this._genId();\n this._store[id] = obj;\n return id;\n }\n\n /**\n * Retrieves previously stored object and releases its reference\n *\n * @param {Number} id of an object to retrieve\n */\n fetch(id) {\n const obj = this._store[id];\n if (obj && !obj.__remote_method) {\n delete this._store[id];\n this._releaseId(id);\n if (this._readyHandler && Object.keys(this._store).length === 0) {\n this._readyHandler();\n }\n }\n if (obj && obj.__promise_pair) {\n this.fetch(obj.__promise_pair);\n }\n return obj;\n }\n}\n","\n/**\n * Expose `Emitter`.\n */\n\nexports.Emitter = Emitter;\n\n/**\n * Initialize a new `Emitter`.\n *\n * @api public\n */\n\nfunction Emitter(obj) {\n if (obj) return mixin(obj);\n}\n\n/**\n * Mixin the emitter properties.\n *\n * @param {Object} obj\n * @return {Object}\n * @api private\n */\n\nfunction mixin(obj) {\n for (var key in Emitter.prototype) {\n obj[key] = Emitter.prototype[key];\n }\n return obj;\n}\n\n/**\n * Listen on the given `event` with `fn`.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.on =\nEmitter.prototype.addEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n (this._callbacks['$' + event] = this._callbacks['$' + event] || [])\n .push(fn);\n return this;\n};\n\n/**\n * Adds an `event` listener that will be invoked a single\n * time then automatically removed.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.once = function(event, fn){\n function on() {\n this.off(event, on);\n fn.apply(this, arguments);\n }\n\n on.fn = fn;\n this.on(event, on);\n return this;\n};\n\n/**\n * Remove the given callback for `event` or all\n * registered callbacks.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.off =\nEmitter.prototype.removeListener =\nEmitter.prototype.removeAllListeners =\nEmitter.prototype.removeEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n\n // all\n if (0 == arguments.length) {\n this._callbacks = {};\n return this;\n }\n\n // specific event\n var callbacks = this._callbacks['$' + event];\n if (!callbacks) return this;\n\n // remove all handlers\n if (1 == arguments.length) {\n delete this._callbacks['$' + event];\n return this;\n }\n\n // remove specific handler\n var cb;\n for (var i = 0; i < callbacks.length; i++) {\n cb = callbacks[i];\n if (cb === fn || cb.fn === fn) {\n callbacks.splice(i, 1);\n break;\n }\n }\n\n // Remove event specific arrays for event types that no\n // one is subscribed for to avoid memory leak.\n if (callbacks.length === 0) {\n delete this._callbacks['$' + event];\n }\n\n return this;\n};\n\n/**\n * Emit `event` with the given args.\n *\n * @param {String} event\n * @param {Mixed} ...\n * @return {Emitter}\n */\n\nEmitter.prototype.emit = function(event){\n this._callbacks = this._callbacks || {};\n\n var args = new Array(arguments.length - 1)\n , callbacks = this._callbacks['$' + event];\n\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n\n if (callbacks) {\n callbacks = callbacks.slice(0);\n for (var i = 0, len = callbacks.length; i < len; ++i) {\n callbacks[i].apply(this, args);\n }\n }\n\n return this;\n};\n\n// alias used for reserved events (protected method)\nEmitter.prototype.emitReserved = Emitter.prototype.emit;\n\n/**\n * Return array of callbacks for `event`.\n *\n * @param {String} event\n * @return {Array}\n * @api public\n */\n\nEmitter.prototype.listeners = function(event){\n this._callbacks = this._callbacks || {};\n return this._callbacks['$' + event] || [];\n};\n\n/**\n * Check if this emitter has `event` handlers.\n *\n * @param {String} event\n * @return {Boolean}\n * @api public\n */\n\nEmitter.prototype.hasListeners = function(event){\n return !! this.listeners(event).length;\n};\n","export default (() => {\n if (typeof self !== \"undefined\") {\n return self;\n }\n else if (typeof window !== \"undefined\") {\n return window;\n }\n else {\n return Function(\"return this\")();\n }\n})();\n","import globalThis from \"./globalThis.js\";\nexport function pick(obj, ...attr) {\n return attr.reduce((acc, k) => {\n if (obj.hasOwnProperty(k)) {\n acc[k] = obj[k];\n }\n return acc;\n }, {});\n}\n// Keep a reference to the real timeout functions so they can be used when overridden\nconst NATIVE_SET_TIMEOUT = setTimeout;\nconst NATIVE_CLEAR_TIMEOUT = clearTimeout;\nexport function installTimerFunctions(obj, opts) {\n if (opts.useNativeTimers) {\n obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThis);\n obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThis);\n }\n else {\n obj.setTimeoutFn = setTimeout.bind(globalThis);\n obj.clearTimeoutFn = clearTimeout.bind(globalThis);\n }\n}\n","/**\n * Contains the routines loaded by the plugin iframe under web-browser\n * in case when worker failed to initialize\n *\n * Initializes the web environment version of the platform-dependent\n * connection object for the plugin site\n */\nimport { connectRPC } from \"./pluginCore.js\";\nimport { API_VERSION } from \"./rpc.js\";\nimport { loadRequirementsInWindow, MessageEmitter, randId } from \"./utils.js\";\n// Create a new, plain <span> element\nfunction _htmlToElement(html) {\n var template = document.createElement(\"template\");\n html = html.trim(); // Never return a text node of whitespace as the result\n template.innerHTML = html;\n return template.content.firstChild;\n}\n\nconst _inWebWorker =\n typeof WorkerGlobalScope !== \"undefined\" && self instanceof WorkerGlobalScope;\n\nasync function executeEsModule(content) {\n const dataUri =\n \"data:text/javascript;charset=utf-8,\" + encodeURIComponent(content);\n await import(/* webpackIgnore: true */ dataUri);\n}\n\nexport class Connection extends MessageEmitter {\n constructor(config) {\n super(config && config.debug);\n this.config = config || {};\n this.peer_id = randId();\n }\n connect() {\n this.config.target_origin = this.config.target_origin || \"*\";\n // this will call handleEvent function\n if (this.config.broadcastChannel) {\n this.broadcastChannel = new BroadcastChannel(\n this.config.broadcastChannel\n );\n } else {\n this.broadcastChannel = null;\n }\n if (this.broadcastChannel)\n this.broadcastChannel.addEventListener(\"message\", this);\n else globalThis.addEventListener(\"message\", this);\n this.emit({\n type: \"initialized\",\n config: this.config,\n origin: globalThis.location.origin,\n peer_id: this.peer_id\n });\n this._fire(\"connected\");\n }\n handleEvent(e) {\n if (\n e.type === \"message\" &&\n (this.broadcastChannel ||\n this.config.target_origin === \"*\" ||\n !e.origin ||\n e.origin === this.config.target_origin)\n ) {\n if (e.data.peer_id === this.peer_id) {\n this._fire(e.data.type, e.data);\n } else if (this.config.debug) {\n console.log(\n `connection peer id mismatch ${e.data.peer_id} !== ${this.peer_id}`\n );\n }\n }\n }\n disconnect() {\n this._fire(\"beforeDisconnect\");\n globalThis.removeEventListener(\"message\", this);\n this._fire(\"disconnected\");\n }\n emit(data) {\n let transferables;\n if (this.broadcastChannel) this.broadcastChannel.postMessage(data);\n else {\n if (data.__transferables__) {\n transferables = data.__transferables__;\n delete data.__transferables__;\n } else if (_inWebWorker) self.postMessage(data, transferables);\n else parent.postMessage(data, this.config.target_origin, transferables);\n }\n }\n async execute(code) {\n try {\n if (code.type === \"requirements\") {\n await loadRequirementsInWindow(code.requirements);\n } else if (code.type === \"script\") {\n if (code.src) {\n var script_node = document.createElement(\"script\");\n script_node.setAttribute(\"type\", code.attrs.type);\n script_node.setAttribute(\"src\", code.src);\n document.head.appendChild(script_node);\n } else {\n if (code.content && code.attrs.lang === \"javascript\") {\n // document.addEventListener(\"DOMContentLoaded\", function(){\n if (code.attrs.type === \"module\") {\n await executeEsModule(code.content);\n } else {\n eval(code.content);\n }\n // });\n } else {\n var node = document.createElement(\"script\");\n for (let k in code.attrs) {\n node.setAttribute(k, code.attrs[k]);\n }\n node.appendChild(document.createTextNode(code.content));\n document.body.appendChild(node);\n }\n }\n } else if (code.type === \"style\") {\n const style_node = document.createElement(\"style\");\n if (code.src) {\n style_node.src = code.src;\n }\n style_node.innerHTML = code.content;\n document.head.appendChild(style_node);\n } else if (code.type === \"link\") {\n const link_node_ = document.createElement(\"link\");\n if (code.rel) {\n link_node_.rel = code.rel;\n }\n if (code.href) {\n link_node_.href = code.href;\n }\n if (code.attrs && code.attrs.type) {\n link_node_.type = code.attrs.type;\n }\n document.head.appendChild(link_node_);\n } else if (code.type === \"html\") {\n document.body.appendChild(_htmlToElement(code.content));\n } else {\n throw \"unsupported code type.\";\n }\n if (_inWebWorker) self.postMessage({ type: \"executed\" });\n else parent.postMessage({ type: \"executed\" }, this.config.target_origin);\n } catch (e) {\n console.error(\"failed to execute scripts: \", code, e);\n if (_inWebWorker)\n self.postMessage({ type: \"executed\", error: e.stack || String(e) });\n else\n parent.postMessage(\n { type: \"executed\", error: e.stack || String(e) },\n this.config.target_origin\n );\n }\n }\n}\n\nexport default function setupIframe(config) {\n config = config || {};\n config.dedicated_thread = false;\n config.lang = \"javascript\";\n config.api_version = API_VERSION;\n const conn = new Connection(config);\n connectRPC(conn, config);\n conn.connect();\n}\n","import globalThis from \"../globalThis.js\";\nexport const nextTick = (() => {\n const isPromiseAvailable = typeof Promise === \"function\" && typeof Promise.resolve === \"function\";\n if (isPromiseAvailable) {\n return cb => Promise.resolve().then(cb);\n }\n else {\n return (cb, setTimeoutFn) => setTimeoutFn(cb, 0);\n }\n})();\nexport const WebSocket = globalThis.WebSocket || globalThis.MozWebSocket;\nexport const usingBrowserWebSocket = true;\nexport const defaultBinaryType = \"arraybuffer\";\n","const PACKET_TYPES = Object.create(null); // no Map = no polyfill\nPACKET_TYPES[\"open\"] = \"0\";\nPACKET_TYPES[\"close\"] = \"1\";\nPACKET_TYPES[\"ping\"] = \"2\";\nPACKET_TYPES[\"pong\"] = \"3\";\nPACKET_TYPES[\"message\"] = \"4\";\nPACKET_TYPES[\"upgrade\"] = \"5\";\nPACKET_TYPES[\"noop\"] = \"6\";\nconst PACKET_TYPES_REVERSE = Object.create(null);\nObject.keys(PACKET_TYPES).forEach(key => {\n PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key;\n});\nconst ERROR_PACKET = { type: \"error\", data: \"parser error\" };\nexport { PACKET_TYPES, PACKET_TYPES_REVERSE, ERROR_PACKET };\n","import { PACKET_TYPES } from \"./commons.js\";\nconst withNativeBlob = typeof Blob === \"function\" ||\n (typeof Blob !== \"undefined\" &&\n Object.prototype.toString.call(Blob) === \"[object BlobConstructor]\");\nconst withNativeArrayBuffer = typeof ArrayBuffer === \"function\";\n// ArrayBuffer.isView method is not defined in IE10\nconst isView = obj => {\n return typeof ArrayBuffer.isView === \"function\"\n ? ArrayBuffer.isView(obj)\n : obj && obj.buffer instanceof ArrayBuffer;\n};\nconst encodePacket = ({ type, data }, supportsBinary, callback) => {\n if (withNativeBlob && data instanceof Blob) {\n if (supportsBinary) {\n return callback(data);\n }\n else {\n return encodeBlobAsBase64(data, callback);\n }\n }\n else if (withNativeArrayBuffer &&\n (data instanceof ArrayBuffer || isView(data))) {\n if (supportsBinary) {\n return callback(data);\n }\n else {\n return encodeBlobAsBase64(new Blob([data]), callback);\n }\n }\n // plain string\n return callback(PACKET_TYPES[type] + (data || \"\"));\n};\nconst encodeBlobAsBase64 = (data, callback) => {\n const fileReader = new FileReader();\n fileReader.onload = function () {\n const content = fileReader.result.split(\",\")[1];\n callback(\"b\" + content);\n };\n return fileReader.readAsDataURL(data);\n};\nexport default encodePacket;\n","/*\n * base64-arraybuffer 1.0.1 <https://github.com/niklasvh/base64-arraybuffer>\n * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>\n * Released under MIT License\n */\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n// Use a lookup table to find the index.\nvar lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\nfor (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n}\nvar encode = function (arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';\n for (i = 0; i < len; i += 3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + '=';\n }\n else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + '==';\n }\n return base64;\n};\nvar decode = function (base64) {\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\n if (base64[base64.length - 1] === '=') {\n bufferLength--;\n if (base64[base64.length - 2] === '=') {\n bufferLength--;\n }\n }\n var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);\n for (i = 0; i < len; i += 4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i + 1)];\n encoded3 = lookup[base64.charCodeAt(i + 2)];\n encoded4 = lookup[base64.charCodeAt(i + 3)];\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n return arraybuffer;\n};\n\nexport { decode, encode };\n//# sourceMappingURL=base64-arraybuffer.es5.js.map\n","import { ERROR_PACKET, PACKET_TYPES_REVERSE } from \"./commons.js\";\nimport { decode } from \"@socket.io/base64-arraybuffer\";\nconst withNativeArrayBuffer = typeof ArrayBuffer === \"function\";\nconst decodePacket = (encodedPacket, binaryType) => {\n if (typeof encodedPacket !== \"string\") {\n return {\n type: \"message\",\n data: mapBinary(encodedPacket, binaryType)\n };\n }\n const type = encodedPacket.charAt(0);\n if (type === \"b\") {\n return {\n type: \"message\",\n data: decodeBase64Packet(encodedPacket.substring(1), binaryType)\n };\n }\n const packetType = PACKET_TYPES_REVERSE[type];\n if (!packetType) {\n return ERROR_PACKET;\n }\n return encodedPacket.length > 1\n ? {\n type: PACKET_TYPES_REVERSE[type],\n data: encodedPacket.substring(1)\n }\n : {\n type: PACKET_TYPES_REVERSE[type]\n };\n};\nconst decodeBase64Packet = (data, binaryType) => {\n if (withNativeArrayBuffer) {\n const decoded = decode(data);\n return mapBinary(decoded, binaryType);\n }\n else {\n return { base64: true, data }; // fallback for old browsers\n }\n};\nconst mapBinary = (data, binaryType) => {\n switch (binaryType) {\n case \"blob\":\n return data instanceof ArrayBuffer ? new Blob([data]) : data;\n case \"arraybuffer\":\n default:\n return data; // assuming the data is already an ArrayBuffer\n }\n};\nexport default decodePacket;\n","import encodePacket from \"./encodePacket.js\";\nimport decodePacket from \"./decodePacket.js\";\nconst SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text\nconst encodePayload = (packets, callback) => {\n // some packets may be added to the array while encoding, so the initial length must be saved\n const length = packets.length;\n const encodedPackets = new Array(length);\n let count = 0;\n packets.forEach((packet, i) => {\n // force base64 encoding for binary packets\n encodePacket(packet, false, encodedPacket => {\n encodedPackets[i] = encodedPacket;\n if (++count === length) {\n callback(encodedPackets.join(SEPARATOR));\n }\n });\n });\n};\nconst decodePayload = (encodedPayload, binaryType) => {\n const encodedPackets = encodedPayload.split(SEPARATOR);\n const packets = [];\n for (let i = 0; i < encodedPackets.length; i++) {\n const decodedPacket = decodePacket(encodedPackets[i], binaryType);\n packets.push(decodedPacket);\n if (decodedPacket.type === \"error\") {\n break;\n }\n }\n return packets;\n};\nexport const protocol = 4;\nexport { encodePacket, encodePayload, decodePacket, decodePayload };\n","/**\n * Core plugin script loaded into the plugin process/thread.\n *\n * Initializes the plugin-site API global methods.\n */\nimport { RPC } from \"./rpc.js\";\n\nexport function connectRPC(connection, config) {\n config = config || {};\n const codecs = {};\n\n const rpc = new RPC(connection, config, codecs);\n rpc.on(\"getInterface\", function() {\n launchConnected();\n });\n\n rpc.on(\"remoteReady\", function() {\n const api = rpc.getRemote() || {};\n api.registerCodec = function(config) {\n if (!config[\"name\"] || (!config[\"encoder\"] && !config[\"decoder\"])) {\n throw new Error(\n \"Invalid codec format, please make sure you provide a name, type, encoder and decoder.\"\n );\n } else {\n if (config.type) {\n for (let k of Object.keys(codecs)) {\n if (codecs[k].type === config.type || k === config.name) {\n delete codecs[k];\n console.warn(\"Remove duplicated codec: \" + k);\n }\n }\n }\n codecs[config[\"name\"]] = config;\n }\n };\n api.init = function(config) {\n // register a minimal plugin api\n rpc.setInterface({ setup() {} }, config);\n };\n api.disposeObject = function(obj) {\n rpc.disposeObject(obj);\n };\n api.export = function(_interface, config) {\n rpc.setInterface(_interface, config);\n };\n api.onLoad = function(handler) {\n handler = checkHandler(handler);\n if (connected) {\n handler();\n } else {\n connectedHandlers.push(handler);\n }\n };\n api.dispose = function(_interface) {\n rpc.disconnect();\n };\n api._rpc = rpc;\n\n if (\n typeof WorkerGlobalScope !== \"undefined\" &&\n self instanceof WorkerGlobalScope\n ) {\n self.api = api;\n self.postMessage({\n type: \"imjoy_remote_api_ready\"\n });\n self.dispatchEvent(\n new CustomEvent(\"imjoy_remote_api_ready\", { detail: api })\n );\n } else if (typeof window) {\n window.dispatchEvent(\n new CustomEvent(\"imjoy_remote_api_ready\", { detail: api })\n );\n }\n });\n\n let connected = false;\n const connectedHandlers = [];\n\n const launchConnected = function() {\n if (!connected) {\n connected = true;\n\n let handler;\n while ((handler = connectedHandlers.pop())) {\n handler();\n }\n }\n };\n\n const checkHandler = function(handler) {\n const type = typeof handler;\n if (type !== \"function\") {\n const msg =\n \"A function may only be subsribed to the event, \" +\n type +\n \" was provided instead\";\n throw new Error(msg);\n }\n return handler;\n };\n\n return rpc;\n}\n","import { decodePacket } from \"engine.io-parser\";\nimport { Emitter } from \"@socket.io/component-emitter\";\nimport { installTimerFunctions } from \"./util.js\";\nexport class Transport extends Emitter {\n /**\n * Transport abstract constructor.\n *\n * @param {Object} options.\n * @api private\n */\n constructor(opts) {\n super();\n this.writable = false;\n installTimerFunctions(this, opts);\n this.opts = opts;\n this.query = opts.query;\n this.readyState = \"\";\n this.socket = opts.socket;\n }\n /**\n * Emits an error.\n *\n * @param {String} str\n * @return {Transport} for chaining\n * @api protected\n */\n onError(msg, desc) {\n const err = new Error(msg);\n // @ts-ignore\n err.type = \"TransportError\";\n // @ts-ignore\n err.description = desc;\n super.emit(\"error\", err);\n return this;\n }\n /**\n * Opens the transport.\n *\n * @api public\n */\n open() {\n if (\"closed\" === this.readyState || \"\" === this.readyState) {\n this.readyState = \"opening\";\n this.doOpen();\n }\n return this;\n }\n /**\n * Closes the transport.\n *\n * @api public\n */\n close() {\n if (\"opening\" === this.readyState || \"open\" === this.readyState) {\n this.doClose();\n this.onClose();\n }\n return this;\n }\n /**\n * Sends multiple packets.\n *\n * @param {Array} packets\n * @api public\n */\n send(packets) {\n if (\"open\" === this.readyState) {\n this.write(packets);\n }\n else {\n // this might happen if the transport was silently closed in the beforeunload event handler\n }\n }\n /**\n * Called upon open\n *\n * @api protected\n */\n onOpen() {\n this.readyState = \"open\";\n this.writable = true;\n super.emit(\"open\");\n }\n /**\n * Called with data.\n *\n * @param {String} data\n * @api protected\n */\n onData(data) {\n const packet = decodePacket(data, this.socket.binaryType);\n this.onPacket(packet);\n }\n /**\n * Called with a decoded packet.\n *\n * @api protected\n */\n onPacket(packet) {\n super.emit(\"packet\", packet);\n }\n /**\n * Called upon close.\n *\n * @api protected\n */\n onClose() {\n this.readyState = \"closed\";\n super.emit(\"close\");\n }\n}\n","/**\n * Compiles a querystring\n * Returns string representation of the object\n *\n * @param {Object}\n * @api private\n */\n\nexports.encode = function (obj) {\n var str = '';\n\n for (var i in obj) {\n if (obj.hasOwnProperty(i)) {\n if (str.length) str += '&';\n str += encodeURIComponent(i) + '=' + encodeURIComponent(obj[i]);\n }\n }\n\n return str;\n};\n\n/**\n * Parses a simple querystring into an object\n *\n * @param {String} qs\n * @api private\n */\n\nexports.decode = function(qs){\n var qry = {};\n var pairs = qs.split('&');\n for (var i = 0, l = pairs.length; i < l; i++) {\n var pair = pairs[i].split('=');\n qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);\n }\n return qry;\n};\n","/**\n * Contains the code executed in the sandboxed frame under web-browser\n *\n * Tries to create a Web-Worker inside the frame and set up the\n * communication between the worker and the parent window. Some\n * browsers restrict creating a worker inside a sandboxed iframe - if\n * this happens, the plugin initialized right inside the frame (in the\n * same thread)\n */\nimport PluginWorker from \"./plugin.webworker.js\";\nimport setupIframe from \"./pluginIframe.js\";\nimport {\n randId,\n normalizeConfig,\n setupServiceWorker,\n loadRequirements\n} from \"./utils.js\";\n\nexport { RPC, API_VERSION } from \"./rpc.js\";\nexport { version as VERSION } from \"../package.json\";\nexport { loadRequirements };\n\nfunction _inIframe() {\n try {\n return window.self !== window.top;\n } catch (e) {\n return true;\n }\n}\n\nfunction _inWebWorker() {\n return (\n typeof WorkerGlobalScope !== \"undefined\" &&\n self instanceof WorkerGlobalScope\n );\n}\n\n/**\n * Initializes the plugin inside a web worker. May throw an exception\n * in case this was not permitted by the browser.\n */\nfunction setupWebWorker(config) {\n if (!config.allow_execution)\n throw new Error(\n \"web-worker plugin can only work with allow_execution=true\"\n );\n let broadcastChannel = null;\n if (config.broadcastChannel) {\n broadcastChannel = new BroadcastChannel(config.broadcastChannel);\n }\n const worker = new PluginWorker();\n // mixed content warning in Chrome silently skips worker\n // initialization without exception, handling this with timeout\n const fallbackTimeout = setTimeout(function() {\n worker.terminate();\n console.warn(\n `Plugin failed to start as a web-worker, running in an iframe instead.`\n );\n setupIframe(config);\n }, 2000);\n const peer_id = randId();\n\n // forwarding messages between the worker and parent window\n worker.addEventListener(\"message\", function(e) {\n let transferables = undefined;\n const m = e.data;\n if (m.type === \"worker-ready\") {\n // send config to the worker\n worker.postMessage({ type: \"connectRPC\", config: config });\n clearTimeout(fallbackTimeout);\n return;\n } else if (m.type === \"initialized\") {\n // complete the missing fields\n m.config = Object.assign({}, config, m.config);\n m.origin = window.location.origin;\n m.peer_id = peer_id;\n } else if (m.type === \"imjoy_remote_api_ready\") {\n // if it's a webworker, there will be no api object returned\n window.dispatchEvent(\n new CustomEvent(\"imjoy_remote_api_ready\", { detail: null })\n );\n } else if (\n m.type === \"cacheRequirements\" &&\n typeof cache_requirements === \"function\"\n ) {\n cache_requirements(m.requirements);\n } else if (m.type === \"disconnect\") {\n worker.terminate();\n } else {\n if (m.__transferables__) {\n transferables = m.__transferables__;\n delete m.__transferables__;\n }\n }\n if (broadcastChannel) broadcastChannel.postMessage(m);\n else parent.postMessage(m, config.target_origin || \"*\", transferables);\n });\n\n (broadcastChannel || window).addEventListener(\"message\", function(e) {\n if (\n e.type === \"message\" &&\n (broadcastChannel ||\n config.target_origin === \"*\" ||\n e.origin === config.target_origin)\n ) {\n let transferables = undefined;\n const m = e.data;\n if (m.__transferables__) {\n transferables = m.__transferables__;\n delete m.__transferables__;\n }\n if (m.peer_id === peer_id) {\n worker.postMessage(m, transferables);\n } else if (config.debug) {\n console.log(`connection peer id mismatch ${m.peer_id} !== ${peer_id}`);\n }\n }\n });\n}\n\nexport function waitForInitialization(config) {\n if (_inWebWorker()) {\n globalThis.parent = self;\n }\n config = config || {};\n if (config.enable_service_worker) {\n setupServiceWorker(\n config.base_url,\n config.target_origin,\n config.cache_requirements\n );\n config.enable_service_worker = false;\n }\n if (config.cache_requirements) {\n delete config.cache_requirements;\n }\n const targetOrigin = config.target_origin || \"*\";\n if (\n config.credential_required &&\n typeof config.verify_credential !== \"function\"\n ) {\n throw new Error(\n \"Please also provide the `verify_credential` function with `credential_required`.\"\n );\n }\n if (config.credential_required && targetOrigin === \"*\") {\n throw new Error(\n \"`target_origin` was set to `*` with `credential_required=true`, there is a security risk that you may leak the credential to website from other origin. Please specify the `target_origin` explicitly.\"\n );\n }\n const done = () => {\n globalThis.removeEventListener(\"message\", handleEvent);\n };\n const peer_id = randId();\n const handleEvent = e => {\n if (\n e.type === \"message\" &&\n (!e.origin || targetOrigin === \"*\" || e.origin === targetOrigin)\n ) {\n if (e.data.type === \"initialize\") {\n done();\n if (e.data.peer_id !== peer_id) {\n // TODO: throw an error when we are sure all the peers will send the peer_id\n console.warn(\n `${e.data.config &&\n e.data.config.name}: connection peer id mismatch ${\n e.data.peer_id\n } !== ${peer_id}`\n );\n }\n const cfg = e.data.config;\n // override the target_origin setting if it's configured by the rpc client\n // otherwise take the setting from the core\n if (targetOrigin !== \"*\") {\n cfg.target_origin = targetOrigin;\n }\n if (config.credential_required) {\n config.verify_credential(cfg.credential).then(result => {\n if (result && result.auth && !result.error) {\n // pass the authentication information with tokens\n cfg.auth = result.auth;\n setupRPC(cfg).then(() => {\n console.log(\"ImJoy RPC loaded successfully!\");\n });\n } else {\n throw new Error(\n \"Failed to verify the credentail:\" + (result && result.error)\n );\n }\n });\n } else {\n setupRPC(cfg).then(() => {\n console.log(\"ImJoy RPC loaded successfully!\");\n });\n }\n } else {\n throw new Error(`unrecognized message: ${e.data}`);\n }\n }\n };\n globalThis.addEventListener(\"message\", handleEvent);\n\n if (_inWebWorker()) {\n parent.postMessage({\n type: \"imjoyRPCReady\",\n config: config,\n peer_id: peer_id\n });\n } else {\n parent.postMessage(\n { type: \"imjoyRPCReady\", config: config, peer_id: peer_id },\n \"*\"\n );\n }\n}\n\nexport function setupRPC(config) {\n config = config || {};\n config.name = config.name || randId();\n config = normalizeConfig(config);\n if (config.enable_service_worker) {\n setupServiceWorker(\n config.base_url,\n config.target_origin,\n config.cache_requirements\n );\n }\n if (config.cache_requirements) {\n delete config.cache_requirements;\n }\n return new Promise((resolve, reject) => {\n const handleEvent = e => {\n const api = e.detail;\n if (config.expose_api_globally) {\n globalThis.api = api;\n }\n // imjoy plugin api\n resolve(api);\n globalThis.removeEventListener(\"imjoy_remote_api_ready\", handleEvent);\n };\n if (_inIframe()) {\n if (config.type === \"web-worker\") {\n try {\n setupWebWorker(config);\n } catch (e) {\n // fallback to iframe\n setupIframe(config);\n }\n } else if (\n [\"rpc-window\", \"rpc-worker\", \"iframe\", \"window\"].includes(config.type)\n ) {\n setupIframe(config);\n } else {\n console.error(\"Unsupported plugin type: \" + config.type);\n reject(\"Unsupported plugin type: \" + config.type);\n return;\n }\n globalThis.addEventListener(\"imjoy_remote_api_ready\", handleEvent);\n } else if (_inWebWorker()) {\n // inside a webworker\n setupIframe(config);\n } else {\n reject(\n new Error(\"imjoy-rpc should only run inside an iframe or a webworker.\")\n );\n }\n });\n}\n","module.exports = function() {\n return require(\"!!/home/runner/work/imjoy-rpc/imjoy-rpc/javascript/node_modules/worker-loader/dist/workers/InlineWorker.js\")(\"!function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){\\\"undefined\\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\\"Module\\\"}),Object.defineProperty(e,\\\"__esModule\\\",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&\\\"object\\\"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,\\\"default\\\",{enumerable:!0,value:e}),2&t&&\\\"string\\\"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,\\\"a\\\",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p=\\\"\\\",r(r.s=3)}([function(module,__webpack_exports__,__webpack_require__){\\\"use strict\\\";function randId(){return Math.random().toString(36).substr(2,10)+(new Date).getTime()}__webpack_require__.d(__webpack_exports__,\\\"d\\\",(function(){return randId})),__webpack_require__.d(__webpack_exports__,\\\"b\\\",(function(){return dtypeToTypedArray})),__webpack_require__.d(__webpack_exports__,\\\"c\\\",(function(){return loadRequirementsInWebworker})),__webpack_require__.d(__webpack_exports__,\\\"e\\\",(function(){return typedArrayToDtype})),__webpack_require__.d(__webpack_exports__,\\\"a\\\",(function(){return MessageEmitter}));const dtypeToTypedArray={int8:Int8Array,int16:Int16Array,int32:Int32Array,uint8:Uint8Array,uint16:Uint16Array,uint32:Uint32Array,float32:Float32Array,float64:Float64Array,array:Array};async function loadRequirementsInWindow(e){function t(e){return new Promise((t,r)=>{var n=document.createElement(\\\"script\\\");n.src=e,n.type=\\\"text/javascript\\\",n.onload=t,n.onreadystatechange=function(){\\\"loaded\\\"!==this.readyState&&\\\"complete\\\"!==this.readyState||t()},n.onerror=r,document.head.appendChild(n)})}async function r(){for(var e=Array.prototype.slice.call(arguments),r=e.length,n=0;n<r;n++)await t(e[n])}if(e&&(Array.isArray(e)||\\\"string\\\"==typeof e))try{var n;if(e=\\\"string\\\"==typeof e?[e]:e,!Array.isArray(e))throw\\\"unsupported requirements definition\\\";for(var i=0;i<e.length;i++)e[i].toLowerCase().endsWith(\\\".css\\\")||e[i].startsWith(\\\"css:\\\")?(e[i].startsWith(\\\"css:\\\")&&(e[i]=e[i].slice(4)),(n=document.createElement(\\\"link\\\")).rel=\\\"stylesheet\\\",n.href=e[i],document.head.appendChild(n)):e[i].toLowerCase().endsWith(\\\".mjs\\\")||e[i].startsWith(\\\"mjs:\\\")?(e[i].startsWith(\\\"mjs:\\\")&&(e[i]=e[i].slice(4)),await import(e[i])):e[i].toLowerCase().endsWith(\\\".js\\\")||e[i].startsWith(\\\"js:\\\")?(e[i].startsWith(\\\"js:\\\")&&(e[i]=e[i].slice(3)),await r(e[i])):e[i].startsWith(\\\"http\\\")?await r(e[i]):e[i].startsWith(\\\"cache:\\\")||console.log(\\\"Unprocessed requirements url: \\\"+e[i])}catch(t){throw\\\"failed to import required scripts: \\\"+e.toString()}}async function loadRequirementsInWebworker(e){if(e&&(Array.isArray(e)||\\\"string\\\"==typeof e))try{Array.isArray(e)||(e=[e]);for(var t=0;t<e.length;t++){if(e[t].toLowerCase().endsWith(\\\".css\\\")||e[t].startsWith(\\\"css:\\\"))throw\\\"unable to import css in a webworker\\\";e[t].toLowerCase().endsWith(\\\".js\\\")||e[t].startsWith(\\\"js:\\\")?(e[t].startsWith(\\\"js:\\\")&&(e[t]=e[t].slice(3)),importScripts(e[t])):e[t].startsWith(\\\"http\\\")?importScripts(e[t]):e[t].startsWith(\\\"cache:\\\")||console.log(\\\"Unprocessed requirements url: \\\"+e[t])}}catch(t){throw\\\"failed to import required scripts: \\\"+e.toString()}}function loadRequirements(e){return\\\"undefined\\\"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?loadRequirementsInWebworker(e):loadRequirementsInWindow(e)}function normalizeConfig(e){return e.version=e.version||\\\"0.1.0\\\",e.description=e.description||`[TODO: add description for ${e.name} ]`,e.type=e.type||\\\"rpc-window\\\",e.id=e.id||randId(),e.target_origin=e.target_origin||\\\"*\\\",e.allow_execution=e.allow_execution||!1,e=Object.keys(e).reduce((t,r)=>(\\\"function\\\"!=typeof e[r]&&(t[r]=e[r]),t),{})}const typedArrayToDtypeMapping={Int8Array:\\\"int8\\\",Int16Array:\\\"int16\\\",Int32Array:\\\"int32\\\",Uint8Array:\\\"uint8\\\",Uint16Array:\\\"uint16\\\",Uint32Array:\\\"uint32\\\",Float32Array:\\\"float32\\\",Float64Array:\\\"float64\\\",Array:\\\"array\\\"},typedArrayToDtypeKeys=[];for(const arrType of Object.keys(typedArrayToDtypeMapping))typedArrayToDtypeKeys.push(eval(arrType));function typedArrayToDtype(e){let t=typedArrayToDtypeMapping[e.constructor.name];if(!t){const r=Object.getPrototypeOf(e);for(const e of typedArrayToDtypeKeys)if(r instanceof e){t=typedArrayToDtypeMapping[e.name];break}}return t}function cacheUrlInServiceWorker(e){return new Promise((function(t,r){const n={command:\\\"add\\\",url:e};if(!navigator.serviceWorker||!navigator.serviceWorker.register)return void r(\\\"Service worker is not supported.\\\");const i=new MessageChannel;i.port1.onmessage=function(e){e.data&&e.data.error?r(e.data.error):t(e.data&&e.data.result)},navigator.serviceWorker&&navigator.serviceWorker.controller?navigator.serviceWorker.controller.postMessage(n,[i.port2]):r(\\\"Service worker controller is not available\\\")}))}async function cacheRequirements(e){e=e||[],Array.isArray(e)||(e=[e]);for(let t of e)t.startsWith(\\\"js:\\\")&&(t=t.slice(3)),t.startsWith(\\\"css:\\\")&&(t=t.slice(4)),t.startsWith(\\\"cache:\\\")&&(t=t.slice(6)),t.startsWith(\\\"http\\\")&&await cacheUrlInServiceWorker(t).catch(e=>{console.error(e)})}function setupServiceWorker(e,t,r){if(\\\"serviceWorker\\\"in navigator){if(e=e||\\\"/\\\",navigator.serviceWorker.register(e+\\\"plugin-service-worker.js\\\").then((function(e){console.log(\\\"ServiceWorker registration successful with scope: \\\",e.scope)}),(function(e){console.log(\\\"ServiceWorker registration failed: \\\",e)})),t=t||\\\"*\\\",(r=r||cacheRequirements)&&\\\"function\\\"!=typeof r)throw new Error(\\\"config.cache_requirements must be a function\\\");window.addEventListener(\\\"message\\\",(function(e){if(\\\"*\\\"===t||e.origin===t){const t=e.data;\\\"cacheRequirements\\\"===t.type&&r(t.requirements)}}))}}function urlJoin(...e){return e.join(\\\"/\\\").replace(/[\\\\/]+/g,\\\"/\\\").replace(/^(.+):\\\\//,\\\"$1://\\\").replace(/^file:/,\\\"file:/\\\").replace(/\\\\/(\\\\?|&|#[^!])/g,\\\"$1\\\").replace(/\\\\?/g,\\\"&\\\").replace(\\\"&\\\",\\\"?\\\")}class MessageEmitter{constructor(e){this._event_handlers={},this._once_handlers={},this._debug=e}emit(){throw new Error(\\\"emit is not implemented\\\")}on(e,t){this._event_handlers[e]||(this._event_handlers[e]=[]),this._event_handlers[e].push(t)}once(e,t){t.___event_run_once=!0,this.on(e,t)}off(e,t){if(e||t){if(e&&!t)this._event_handlers[e]&&(this._event_handlers[e]=[]);else if(this._event_handlers[e]){const r=this._event_handlers[e].indexOf(t);r>=0&&this._event_handlers[e].splice(r,1)}}else this._event_handlers={}}_fire(e,t){if(this._event_handlers[e])for(var r=this._event_handlers[e].length;r--;){const n=this._event_handlers[e][r];try{n(t)}catch(e){console.error(e)}finally{n.___event_run_once&&this._event_handlers[e].splice(r,1)}}else this._debug&&console.warn(\\\"unhandled event\\\",e,t)}}},function(e,t,r){\\\"use strict\\\";r.d(t,\\\"a\\\",(function(){return i})),r.d(t,\\\"b\\\",(function(){return c}));var n=r(0);const i=\\\"0.2.3\\\",o=Object.getPrototypeOf(Object.getPrototypeOf(new Uint8Array)).constructor;function s(e,t){const r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e),0),r.set(new Uint8Array(t),e.byteLength),r.buffer}function a(e,t){if(!t)throw new Error(\\\"undefined index\\\");return\\\"string\\\"==typeof t?a(e,t.split(\\\".\\\")):0===t.length?e:a(e[t[0]],t.slice(1))}class c extends n.a{constructor(e,t,r){super(t&&t.debug),this._connection=e,this.config=t||{},this._codecs=r||{},this._object_store={},this._method_weakmap=new WeakMap,this._object_weakmap=new WeakMap,this._local_api=null,this._remote_set=!1;const n=this.config.name;this._connection.execute=this._connection.execute||function(){throw new Error(`connection.execute not implemented (in \\\"${n}\\\")`)},this._store=new _,this._method_refs=new _,this._method_refs.onReady(()=>{this._fire(\\\"remoteIdle\\\")}),this._method_refs.onBusy(()=>{this._fire(\\\"remoteBusy\\\")}),this._setupMessageHanlders()}init(){this._connection.emit({type:\\\"initialized\\\",config:this.config,peer_id:this._connection.peer_id})}setConfig(e){if(e)for(const t of Object.keys(e))this.config[t]=e[t]}getRemoteCallStack(){return this._method_refs.getStack()}getRemote(){return this._remote_interface}setInterface(e,t){if(t=t||{},this.config.name=t.name||this.config.name,this.config.description=t.description||this.config.description,this.config.forwarding_functions)for(let t of this.config.forwarding_functions){const r=this._remote_interface;r[t]&&(e.constructor===Object?e[t]||(e[t]=(...e)=>{r[t](...e)}):e.constructor.constructor===Function&&(e.constructor.prototype[t]||(e.constructor.prototype[t]=(...e)=>{r[t](...e)})))}return this._local_api=e,this._remote_set?this.sendInterface():this._fire(\\\"interfaceAvailable\\\"),new Promise(e=>{this.once(\\\"interfaceSetAsRemote\\\",e)})}sendInterface(){if(!this._local_api)throw new Error(\\\"interface is not set.\\\");this._encode(this._local_api,!0).then(e=>{this._connection.emit({type:\\\"setInterface\\\",api:e})})}_disposeObject(e){if(!this._object_store[e])throw new Error(`Object (id=${e}) not found.`);delete this._object_store[e]}disposeObject(e){return new Promise((t,r)=>{if(!this._object_weakmap.has(e))throw new Error(\\\"Invalid object\\\");{const n=this._object_weakmap.get(e);this._connection.once(\\\"disposed\\\",e=>{e.error?r(new Error(e.error)):t()}),this._connection.emit({type:\\\"disposeObject\\\",object_id:n})}})}_setupMessageHanlders(){this._connection.on(\\\"init\\\",this.init),this._connection.on(\\\"execute\\\",e=>{Promise.resolve(this._connection.execute(e.code)).then(()=>{this._connection.emit({type:\\\"executed\\\"})}).catch(e=>{console.error(e),this._connection.emit({type:\\\"executed\\\",error:String(e)})})}),this._connection.on(\\\"method\\\",async e=>{let t,r,n,i,o,s;try{e.promise&&([t,r]=await this._unwrap(e.promise,!1));const c=this._object_store[e.object_id];if(n=a(c,e.name),e.name.includes(\\\".\\\")){const t=e.name.split(\\\".\\\");i=a(c,t.slice(0,t.length-1).join(\\\".\\\"))}else i=c;o=await this._unwrap(e.args,!0),e.promise?(s=n.apply(i,o),s instanceof Promise||n.constructor&&\\\"AsyncFunction\\\"===n.constructor.name?s.then(t).catch(r):t(s)):n.apply(i,o)}catch(e){console.error(this.config.name,e),r&&r(e)}}),this._connection.on(\\\"callback\\\",async e=>{let t,r,n,i,o;try{if(e.promise&&([t,r]=await this._unwrap(e.promise,!1)),e.promise){if(n=this._store.fetch(e.id),i=await this._unwrap(e.args,!0),!n)throw new Error(\\\"Callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.\\\");o=n.apply(null,i),o instanceof Promise||n.constructor&&\\\"AsyncFunction\\\"===n.constructor.name?o.then(t).catch(r):t(o)}else{if(n=this._store.fetch(e.id),i=await this._unwrap(e.args,!0),!n)throw new Error(\\\"Please notice that callback function can only called once, if you want to call a function for multiple times, please make it as a plugin api function. See https://imjoy.io/docs for more details.\\\");n.apply(null,i)}}catch(e){console.error(this.config.name,e),r&&r(e)}}),this._connection.on(\\\"disposeObject\\\",e=>{try{this._disposeObject(e.object_id),this._connection.emit({type:\\\"disposed\\\"})}catch(e){console.error(e),this._connection.emit({type:\\\"disposed\\\",error:String(e)})}}),this._connection.on(\\\"setInterface\\\",e=>{this._setRemoteInterface(e.api)}),this._connection.on(\\\"getInterface\\\",()=>{this._fire(\\\"getInterface\\\"),this._local_api?this.sendInterface():this.once(\\\"interfaceAvailable\\\",()=>{this.sendInterface()})}),this._connection.on(\\\"interfaceSetAsRemote\\\",()=>{this._remote_set=!0,this._fire(\\\"interfaceSetAsRemote\\\")}),this._connection.on(\\\"disconnect\\\",()=>{this._fire(\\\"beforeDisconnect\\\"),this._connection.disconnect(),this._fire(\\\"disconnected\\\")})}requestRemote(){this._connection.emit({type:\\\"getInterface\\\"})}_ndarray(e,t,r){const i=Object(n.e)(e);if(r&&r!==i)throw\\\"dtype doesn't match the type of the array: \\\"+i+\\\" != \\\"+r;return t=t||[e.length],{_rtype:\\\"ndarray\\\",_rvalue:e.buffer,_rshape:t,_rdtype:i}}_setRemoteInterface(e){this._decode(e).then(e=>{if(this._remote_interface){for(let e in this._remote_interface)delete this._remote_interface[e];Object.assign(this._remote_interface,e)}else this._remote_interface=e;this._fire(\\\"remoteReady\\\"),this._reportRemoteSet()})}_genRemoteMethod(e,t,r){const n=this,i=function(){return new Promise(async(i,o)=>{let s=null;try{s=n._method_refs.put(r?r+\\\"/\\\"+t:t);const a=function(){return null!==s&&n._method_refs.fetch(s),i.apply(this,arguments)},c=function(){return null!==s&&n._method_refs.fetch(s),o.apply(this,arguments)},_=await n._wrap([a,c]);a.__promise_pair=_[1]._rvalue,c.__promise_pair=_[0]._rvalue;let l=Array.prototype.slice.call(arguments);const f=l.length,d=f>0&&\\\"object\\\"==typeof l[f-1]&&null!==l[f-1]&&l[f-1]._rkwargs;d&&delete l[f-1]._rkwargs,l=\\\"register\\\"===t||\\\"registerService\\\"===t||\\\"register_service\\\"===t||\\\"export\\\"===t||\\\"on\\\"===t?await n._wrap(l,!0):await n._wrap(l);const p=l.__transferables__;p&&delete l.__transferables__,n._connection.emit({type:\\\"method\\\",target_id:e,name:t,object_id:r,args:l,promise:_,with_kwargs:d},p)}catch(e){s&&n._method_refs.fetch(s),o(`Failed to exectue remote method (interface: ${r||n.id}, method: ${t}), error: ${e}`)}})};return i.__remote_method=!0,i}_reportRemoteSet(){this._connection.emit({type:\\\"interfaceSetAsRemote\\\"})}async _encode(e,t,r){const i=typeof e;if(\\\"number\\\"===i||\\\"string\\\"===i||\\\"boolean\\\"===i||null==e||e instanceof ArrayBuffer)return e;let s;if(\\\"function\\\"==typeof e){if(t){if(!r)throw new Error(\\\"objectId is not specified.\\\");s={_rtype:\\\"interface\\\",_rtarget_id:this._connection.peer_id,_rintf:r,_rvalue:t},this._method_weakmap.set(e,s)}else if(this._method_weakmap.has(e))s=this._method_weakmap.get(e);else{const t=this._store.put(e);s={_rtype:\\\"callback\\\",_rtarget_id:this._connection.peer_id,_rname:e.constructor&&e.constructor.name||t,_rvalue:t}}return s}if(e.constructor instanceof Object&&e._rtype){if(e._rintf){const n=e._rtype;delete e._rtype,s=await this._encode(e,t,r),s._rtype=n}else s=e;return s}const a=[],c=e._transfer,_=Array.isArray(e);for(let n of Object.keys(this._codecs)){const i=this._codecs[n];if(i.encoder&&e instanceof i.type){let n=await Promise.resolve(i.encoder(e));if(n&&!n._rtype&&(n._rtype=i.name),n&&n._rintf){const e=n._rtype;delete n._rtype,n=await this._encode(n,t,r),n._rtype=e}return s=n,s}}if(\\\"undefined\\\"!=typeof tf&&tf.Tensor&&e instanceof tf.Tensor){const t=e.dataSync();(e._transfer||c)&&(a.push(t.buffer),delete e._transfer),s={_rtype:\\\"ndarray\\\",_rvalue:t.buffer,_rshape:e.shape,_rdtype:e.dtype}}else if(\\\"undefined\\\"!=typeof nj&&nj.NdArray&&e instanceof nj.NdArray){const t=Object(n.e)(e.selection.data);(e._transfer||c)&&(a.push(e.selection.data.buffer),delete e._transfer),s={_rtype:\\\"ndarray\\\",_rvalue:e.selection.data.buffer,_rshape:e.shape,_rdtype:t}}else if(e instanceof Error)console.error(e),s={_rtype:\\\"error\\\",_rvalue:e.toString()};else if(\\\"undefined\\\"!=typeof File&&e instanceof File)s={_rtype:\\\"file\\\",_rvalue:e,_rpath:e._path||e.webkitRelativePath};else if(e!==Object(e)||e instanceof Boolean||e instanceof String||e instanceof Date||e instanceof RegExp||e instanceof ImageData||\\\"undefined\\\"!=typeof FileList&&e instanceof FileList||\\\"undefined\\\"!=typeof FileSystemDirectoryHandle&&e instanceof FileSystemDirectoryHandle||\\\"undefined\\\"!=typeof FileSystemFileHandle&&e instanceof FileSystemFileHandle||\\\"undefined\\\"!=typeof FileSystemHandle&&e instanceof FileSystemHandle||\\\"undefined\\\"!=typeof FileSystemWritableFileStream&&e instanceof FileSystemWritableFileStream)s=e;else if(\\\"undefined\\\"!=typeof File&&e instanceof File)s={_rtype:\\\"file\\\",_rname:e.name,_rmime:e.type,_rvalue:e,_rpath:e._path||e.webkitRelativePath};else if(e instanceof Blob)s={_rtype:\\\"blob\\\",_rvalue:e};else if(e instanceof o){(e._transfer||c)&&(a.push(e.buffer),delete e._transfer);const t=Object(n.e)(e);s={_rtype:\\\"typedarray\\\",_rvalue:e.buffer,_rdtype:t}}else if(e instanceof DataView)(e._transfer||c)&&(a.push(e.buffer),delete e._transfer),s={_rtype:\\\"memoryview\\\",_rvalue:e.buffer};else if(e instanceof Set)s={_rtype:\\\"set\\\",_rvalue:await this._encode(Array.from(e),t)};else if(e instanceof Map)s={_rtype:\\\"orderedmap\\\",_rvalue:await this._encode(Array.from(e),t)};else if(e.constructor instanceof Object||Array.isArray(e)){let i;if(s=_?[]:{},e.constructor===Object||Array.isArray(e))i=Object.keys(e);else{if(e.constructor===Function)throw new Error(\\\"Please instantiate the class before exportting it.\\\");if(e.constructor.constructor!==Function)throw Error(\\\"Unsupported interface type\\\");i=Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.keys(e)),t=!0}let o=!1;if(e._rintf||t){r||(r=\\\"string\\\"==typeof e._rintf&&e._rintf.length>0?e._rintf:Object(n.d)(),this._object_store[r]&&console.warn(\\\"Overwritting interface object with the same id: \\\"+r),this._object_store[r]=e);for(let n of i)\\\"constructor\\\"!==n&&(n.startsWith(\\\"_\\\")||(s[n]=await this._encode(e[n],\\\"string\\\"==typeof t?t+\\\".\\\"+n:n,r),\\\"function\\\"==typeof e[n]&&(o=!0)));o&&(s._rintf=r),e.on&&\\\"function\\\"==typeof e.on&&e.on(\\\"close\\\",()=>{delete this._object_store[r]})}else for(let t of i)[\\\"hasOwnProperty\\\",\\\"constructor\\\"].includes(t)||(s[t]=await this._encode(e[t]))}else{if(\\\"object\\\"!=typeof e)throw\\\"imjoy-rpc: Unsupported data type:\\\"+e;{const t=Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.keys(e)),r=Object(n.d)();for(let r of t)[\\\"hasOwnProperty\\\",\\\"constructor\\\"].includes(r)||(s[r]=await this._encode(e[r],r,s));s._rintf=r}}if(a.length>0&&(s.__transferables__=a),!s)throw new Error(\\\"Failed to encode object\\\");return s}async _decode(e,t){if(!e)return e;let r;if(e._rtype)if(this._codecs[e._rtype]&&this._codecs[e._rtype].decoder){if(e._rintf){const r=e._rtype;delete e._rtype,(e=await this._decode(e,t))._rtype=r}r=await Promise.resolve(this._codecs[e._rtype].decoder(e))}else if(\\\"callback\\\"===e._rtype)r=this._genRemoteCallback(e._rtarget_id,e._rvalue,t);else if(\\\"interface\\\"===e._rtype)r=this._genRemoteMethod(e._rtarget_id,e._rvalue,e._rintf);else if(\\\"ndarray\\\"===e._rtype)if(\\\"undefined\\\"!=typeof nj&&nj.array)Array.isArray(e._rvalue)&&(e._rvalue=e._rvalue.reduce(s)),r=nj.array(new Uint8(e._rvalue),e._rdtype).reshape(e._rshape);else if(\\\"undefined\\\"!=typeof tf&&tf.Tensor){Array.isArray(e._rvalue)&&(e._rvalue=e._rvalue.reduce(s));const t=n.b[e._rdtype];r=tf.tensor(new t(e._rvalue),e._rshape,e._rdtype)}else r=e;else if(\\\"error\\\"===e._rtype)r=new Error(e._rvalue);else if(\\\"file\\\"===e._rtype)e._rvalue instanceof File?(r=e._rvalue,r._path=e._rpath):(r=new File([e._rvalue],e._rname,{type:e._rmime}),r._path=e._rpath);else if(\\\"typedarray\\\"===e._rtype){const t=n.b[e._rdtype];if(!t)throw new Error(\\\"unsupported dtype: \\\"+e._rdtype);r=new t(e._rvalue)}else if(\\\"memoryview\\\"===e._rtype)r=new DataView(e._rvalue);else if(\\\"blob\\\"===e._rtype)r=e._rvalue instanceof Blob?e._rvalue:new Blob([e._rvalue],{type:e._rmime});else if(\\\"orderedmap\\\"===e._rtype)r=new Map(await this._decode(e._rvalue,t));else if(\\\"set\\\"===e._rtype)r=new Set(await this._decode(e._rvalue,t));else if(e._rintf){const n=e._rtype;delete e._rtype,r=await this._decode(e,t),r._rtype=n}else r=e;else if(e.constructor===Object||Array.isArray(e)){const n=Array.isArray(e);r=n?[]:{};for(let i of Object.keys(e))if(n||e.hasOwnProperty(i)){const n=e[i];r[i]=await this._decode(n,t)}}else r=e;if(void 0===r)throw new Error(\\\"Failed to decode object\\\");return e._rintf&&this._object_weakmap.set(r,e._rintf),r}async _wrap(e,t){return await this._encode(e,t)}async _unwrap(e,t){return await this._decode(e,t)}_genRemoteCallback(e,t,r){const n=this;let i;return r?(i=function(){return new Promise(async(r,i)=>{const o=await n._wrap(Array.prototype.slice.call(arguments)),s=o.length,a=s>0&&\\\"object\\\"==typeof o[s-1]&&null!==o[s-1]&&o[s-1]._rkwargs;a&&delete o[s-1]._rkwargs;const c=o.__transferables__;c&&delete o.__transferables__;const _=await n._wrap([r,i]);r.__promise_pair=_[1]._rvalue,i.__promise_pair=_[0]._rvalue;try{n._connection.emit({type:\\\"callback\\\",target_id:e,id:t,args:o,promise:_,with_kwargs:a},c)}catch(e){i(`Failed to exectue remote callback ( id: ${t}).`)}})},i):(i=async function(){const r=await n._wrap(Array.prototype.slice.call(arguments)),i=r.length,o=i>0&&\\\"object\\\"==typeof r[i-1]&&null!==r[i-1]&&r[i-1]._rkwargs;o&&delete r[i-1]._rkwargs;const s=r.__transferables__;return s&&delete r.__transferables__,n._connection.emit({type:\\\"callback\\\",target_id:e,id:t,args:r,with_kwargs:o},s)},i)}reset(){this._event_handlers={},this._once_handlers={},this._remote_interface=null,this._object_store={},this._method_weakmap=new WeakMap,this._object_weakmap=new WeakMap,this._local_api=null,this._store=new _,this._method_refs=new _}disconnect(){this._connection.emit({type:\\\"disconnect\\\"}),this.reset(),setTimeout(()=>{this._connection.disconnect()},2e3)}}class _{constructor(){this._store={},this._indices=[0],this._readyHandler=function(){},this._busyHandler=function(){},this._readyHandler()}onReady(e){this._readyHandler=e||function(){}}onBusy(e){this._busyHandler=e||function(){}}getStack(){return Object.keys(this._store).length}_genId(){let e;return e=1===this._indices.length?this._indices[0]++:this._indices.shift(),e}_releaseId(e){for(let t=0;t<this._indices.length;t++)if(e<this._indices[t]){this._indices.splice(t,0,e);break}for(let e=this._indices.length-1;e>=0&&this._indices[e]-1===this._indices[e-1];e--)this._indices.pop()}put(e){this._busyHandler&&0===Object.keys(this._store).length&&this._busyHandler();const t=this._genId();return this._store[t]=e,t}fetch(e){const t=this._store[e];return t&&!t.__remote_method&&(delete this._store[e],this._releaseId(e),this._readyHandler&&0===Object.keys(this._store).length&&this._readyHandler()),t&&t.__promise_pair&&this.fetch(t.__promise_pair),t}}},function(e,t,r){\\\"use strict\\\";r.d(t,\\\"a\\\",(function(){return i}));var n=r(1);function i(e,t){t=t||{};const r={},i=new n.b(e,t,r);i.on(\\\"getInterface\\\",(function(){a()})),i.on(\\\"remoteReady\\\",(function(){const e=i.getRemote()||{};e.registerCodec=function(e){if(!e.name||!e.encoder&&!e.decoder)throw new Error(\\\"Invalid codec format, please make sure you provide a name, type, encoder and decoder.\\\");if(e.type)for(let t of Object.keys(r))r[t].type!==e.type&&t!==e.name||(delete r[t],console.warn(\\\"Remove duplicated codec: \\\"+t));r[e.name]=e},e.init=function(e){i.setInterface({setup(){}},e)},e.disposeObject=function(e){i.disposeObject(e)},e.export=function(e,t){i.setInterface(e,t)},e.onLoad=function(e){e=c(e),o?e():s.push(e)},e.dispose=function(e){i.disconnect()},e._rpc=i,\\\"undefined\\\"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?(self.api=e,self.postMessage({type:\\\"imjoy_remote_api_ready\\\"}),self.dispatchEvent(new CustomEvent(\\\"imjoy_remote_api_ready\\\",{detail:e}))):window.dispatchEvent(new CustomEvent(\\\"imjoy_remote_api_ready\\\",{detail:e}))}));let o=!1;const s=[],a=function(){if(!o){let e;for(o=!0;e=s.pop();)e()}},c=function(e){const t=typeof e;if(\\\"function\\\"!==t){throw new Error(\\\"A function may only be subsribed to the event, \\\"+t+\\\" was provided instead\\\")}return e};return i}},function(module,__webpack_exports__,__webpack_require__){\\\"use strict\\\";__webpack_require__.r(__webpack_exports__);var _pluginCore_js__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(2),_rpc_js__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1),_utils_js__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(0);if(!(\\\"undefined\\\"!=typeof WorkerGlobalScope&&self&&self instanceof WorkerGlobalScope))throw new Error(\\\"This script can only loaded in a webworker\\\");async function executeEsModule(e){const t=\\\"data:text/javascript;charset=utf-8,\\\"+encodeURIComponent(e);await import(t)}class Connection extends _utils_js__WEBPACK_IMPORTED_MODULE_2__.a{constructor(e){super(e&&e.debug),this.config=e||{}}connect(){self.addEventListener(\\\"message\\\",e=>{this._fire(e.data.type,e.data)}),this.emit({type:\\\"initialized\\\",config:this.config})}disconnect(){this._fire(\\\"beforeDisconnect\\\"),self.close(),this._fire(\\\"disconnected\\\")}emit(e){let t=void 0;e.__transferables__&&(t=e.__transferables__,delete e.__transferables__),self.postMessage(e,t)}async execute(code){if(\\\"requirements\\\"===code.type)await Object(_utils_js__WEBPACK_IMPORTED_MODULE_2__.c)(code.requirements);else{if(\\\"script\\\"!==code.type)throw\\\"unsupported code type.\\\";try{\\\"module\\\"===code.attrs.type?await executeEsModule(code.content):eval(code.content)}catch(e){throw console.error(e.message,e.stack),e}}\\\"requirements\\\"===code.type&&self.postMessage({type:\\\"cacheRequirements\\\",requirements:code.requirements})}}const config={type:\\\"web-worker\\\",dedicated_thread:!0,allow_execution:!0,lang:\\\"javascript\\\",api_version:_rpc_js__WEBPACK_IMPORTED_MODULE_1__.a},conn=new Connection(config);conn.on(\\\"connectRPC\\\",e=>{Object(_pluginCore_js__WEBPACK_IMPORTED_MODULE_0__.a)(conn,Object.assign(e.config,config))}),conn.connect(),self.postMessage({type:\\\"worker-ready\\\"})}]);\\n//# sourceMappingURL=plugin.webworker.js.map\", null);\n};","/**\n * Parses an URI\n *\n * @author Steven Levithan <stevenlevithan.com> (MIT license)\n * @api private\n */\n\nvar re = /^(?:(?![^:@]+:[^:@\\/]*@)(http|https|ws|wss):\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/;\n\nvar parts = [\n 'source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'\n];\n\nmodule.exports = function parseuri(str) {\n var src = str,\n b = str.indexOf('['),\n e = str.indexOf(']');\n\n if (b != -1 && e != -1) {\n str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ';') + str.substring(e, str.length);\n }\n\n var m = re.exec(str || ''),\n uri = {},\n i = 14;\n\n while (i--) {\n uri[parts[i]] = m[i] || '';\n }\n\n if (b != -1 && e != -1) {\n uri.source = src;\n uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ':');\n uri.authority = uri.authority.replace('[', '').replace(']', '').replace(/;/g, ':');\n uri.ipv6uri = true;\n }\n\n uri.pathNames = pathNames(uri, uri['path']);\n uri.queryKey = queryKey(uri, uri['query']);\n\n return uri;\n};\n\nfunction pathNames(obj, path) {\n var regx = /\\/{2,9}/g,\n names = path.replace(regx, \"/\").split(\"/\");\n\n if (path.substr(0, 1) == '/' || path.length === 0) {\n names.splice(0, 1);\n }\n if (path.substr(path.length - 1, 1) == '/') {\n names.splice(names.length - 1, 1);\n }\n\n return names;\n}\n\nfunction queryKey(uri, query) {\n var data = {};\n\n query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function ($0, $1, $2) {\n if ($1) {\n data[$1] = $2;\n }\n });\n\n return data;\n}\n","'use strict';\n\nvar alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split('')\n , length = 64\n , map = {}\n , seed = 0\n , i = 0\n , prev;\n\n/**\n * Return a string representing the specified number.\n *\n * @param {Number} num The number to convert.\n * @returns {String} The string representation of the number.\n * @api public\n */\nfunction encode(num) {\n var encoded = '';\n\n do {\n encoded = alphabet[num % length] + encoded;\n num = Math.floor(num / length);\n } while (num > 0);\n\n return encoded;\n}\n\n/**\n * Return the integer value specified by the given string.\n *\n * @param {String} str The string to convert.\n * @returns {Number} The integer value represented by the string.\n * @api public\n */\nfunction decode(str) {\n var decoded = 0;\n\n for (i = 0; i < str.length; i++) {\n decoded = decoded * length + map[str.charAt(i)];\n }\n\n return decoded;\n}\n\n/**\n * Yeast: A tiny growing id generator.\n *\n * @returns {String} A unique id.\n * @api public\n */\nfunction yeast() {\n var now = encode(+new Date());\n\n if (now !== prev) return seed = 0, prev = now;\n return now +'.'+ encode(seed++);\n}\n\n//\n// Map each character to its index.\n//\nfor (; i < length; i++) map[alphabet[i]] = i;\n\n//\n// Expose the `yeast`, `encode` and `decode` functions.\n//\nyeast.encode = encode;\nyeast.decode = decode;\nmodule.exports = yeast;\n","'use strict';\n\n// http://stackoverflow.com/questions/10343913/how-to-create-a-web-worker-from-a-string\n\nvar URL = window.URL || window.webkitURL;\n\nmodule.exports = function (content, url) {\n try {\n try {\n var blob;\n\n try {\n // BlobBuilder = Deprecated, but widely implemented\n var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;\n\n blob = new BlobBuilder();\n\n blob.append(content);\n\n blob = blob.getBlob();\n } catch (e) {\n // The proposed API\n blob = new Blob([content]);\n }\n\n return new Worker(URL.createObjectURL(blob));\n } catch (e) {\n return new Worker('data:application/javascript,' + encodeURIComponent(content));\n }\n } catch (e) {\n if (!url) {\n throw Error('Inline worker is not supported');\n }\n\n return new Worker(url);\n }\n};","\n/**\n * Module exports.\n *\n * Logic borrowed from Modernizr:\n *\n * - https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cors.js\n */\n\ntry {\n module.exports = typeof XMLHttpRequest !== 'undefined' &&\n 'withCredentials' in new XMLHttpRequest();\n} catch (err) {\n // if XMLHttp support is disabled in IE then it will throw\n // when trying to create\n module.exports = false;\n}\n","import { Transport } from \"../transport.js\";\nimport parseqs from \"parseqs\";\nimport yeast from \"yeast\";\nimport { pick } from \"../util.js\";\nimport { defaultBinaryType, nextTick, usingBrowserWebSocket, WebSocket } from \"./websocket-constructor.js\";\nimport { encodePacket } from \"engine.io-parser\";\n// detect ReactNative environment\nconst isReactNative = typeof navigator !== \"undefined\" &&\n typeof navigator.product === \"string\" &&\n navigator.product.toLowerCase() === \"reactnative\";\nexport class WS extends Transport {\n /**\n * WebSocket transport constructor.\n *\n * @api {Object} connection options\n * @api public\n */\n constructor(opts) {\n super(opts);\n this.supportsBinary = !opts.forceBase64;\n }\n /**\n * Transport name.\n *\n * @api public\n */\n get name() {\n return \"websocket\";\n }\n /**\n * Opens socket.\n *\n * @api private\n */\n doOpen() {\n if (!this.check()) {\n // let probe timeout\n return;\n }\n const uri = this.uri();\n const protocols = this.opts.protocols;\n // React Native only supports the 'headers' option, and will print a warning if anything else is passed\n const opts = isReactNative\n ? {}\n : pick(this.opts, \"agent\", \"perMessageDeflate\", \"pfx\", \"key\", \"passphrase\", \"cert\", \"ca\", \"ciphers\", \"rejectUnauthorized\", \"localAddress\", \"protocolVersion\", \"origin\", \"maxPayload\", \"family\", \"checkServerIdentity\");\n if (this.opts.extraHeaders) {\n opts.headers = this.opts.extraHeaders;\n }\n try {\n this.ws =\n usingBrowserWebSocket && !isReactNative\n ? protocols\n ? new WebSocket(uri, protocols)\n : new WebSocket(uri)\n : new WebSocket(uri, protocols, opts);\n }\n catch (err) {\n return this.emit(\"error\", err);\n }\n this.ws.binaryType = this.socket.binaryType || defaultBinaryType;\n this.addEventListeners();\n }\n /**\n * Adds event listeners to the socket\n *\n * @api private\n */\n addEventListeners() {\n this.ws.onopen = () => {\n if (this.opts.autoUnref) {\n this.ws._socket.unref();\n }\n this.onOpen();\n };\n this.ws.onclose = this.onClose.bind(this);\n this.ws.onmessage = ev => this.onData(ev.data);\n this.ws.onerror = e => this.onError(\"websocket error\", e);\n }\n /**\n * Writes data to socket.\n *\n * @param {Array} array of packets.\n * @api private\n */\n write(packets) {\n this.writable = false;\n // encodePacket efficient as it uses WS framing\n // no need for encodePayload\n for (let i = 0; i < packets.length; i++) {\n const packet = packets[i];\n const lastPacket = i === packets.length - 1;\n encodePacket(packet, this.supportsBinary, data => {\n // always create a new object (GH-437)\n const opts = {};\n if (!usingBrowserWebSocket) {\n if (packet.options) {\n opts.compress = packet.options.compress;\n }\n if (this.opts.perMessageDeflate) {\n const len = \"string\" === typeof data ? Buffer.byteLength(data) : data.length;\n if (len < this.opts.perMessageDeflate.threshold) {\n opts.compress = false;\n }\n }\n }\n // Sometimes the websocket has already been closed but the browser didn't\n // have a chance of informing us about it yet, in that case send will\n // throw an error\n try {\n if (usingBrowserWebSocket) {\n // TypeError is thrown when passing the second argument on Safari\n this.ws.send(data);\n }\n else {\n this.ws.send(data, opts);\n }\n }\n catch (e) {\n }\n if (lastPacket) {\n // fake drain\n // defer to next tick to allow Socket to clear writeBuffer\n nextTick(() => {\n this.writable = true;\n this.emit(\"drain\");\n }, this.setTimeoutFn);\n }\n });\n }\n }\n /**\n * Closes socket.\n *\n * @api private\n */\n doClose() {\n if (typeof this.ws !== \"undefined\") {\n this.ws.close();\n this.ws = null;\n }\n }\n /**\n * Generates uri for connection.\n *\n * @api private\n */\n uri() {\n let query = this.query || {};\n const schema = this.opts.secure ? \"wss\" : \"ws\";\n let port = \"\";\n // avoid port if default for schema\n if (this.opts.port &&\n ((\"wss\" === schema && Number(this.opts.port) !== 443) ||\n (\"ws\" === schema && Number(this.opts.port) !== 80))) {\n port = \":\" + this.opts.port;\n }\n // append timestamp to URI\n if (this.opts.timestampRequests) {\n query[this.opts.timestampParam] = yeast();\n }\n // communicate binary support capabilities\n if (!this.supportsBinary) {\n query.b64 = 1;\n }\n const encodedQuery = parseqs.encode(query);\n const ipv6 = this.opts.hostname.indexOf(\":\") !== -1;\n return (schema +\n \"://\" +\n (ipv6 ? \"[\" + this.opts.hostname + \"]\" : this.opts.hostname) +\n port +\n this.opts.path +\n (encodedQuery.length ? \"?\" + encodedQuery : \"\"));\n }\n /**\n * Feature detection for WebSocket.\n *\n * @return {Boolean} whether this transport is available.\n * @api public\n */\n check() {\n return (!!WebSocket &&\n !(\"__initialize\" in WebSocket && this.name === WS.prototype.name));\n }\n}\n","\n/**\n * Expose `Backoff`.\n */\n\nmodule.exports = Backoff;\n\n/**\n * Initialize backoff timer with `opts`.\n *\n * - `min` initial timeout in milliseconds [100]\n * - `max` max timeout [10000]\n * - `jitter` [0]\n * - `factor` [2]\n *\n * @param {Object} opts\n * @api public\n */\n\nfunction Backoff(opts) {\n opts = opts || {};\n this.ms = opts.min || 100;\n this.max = opts.max || 10000;\n this.factor = opts.factor || 2;\n this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;\n this.attempts = 0;\n}\n\n/**\n * Return the backoff duration.\n *\n * @return {Number}\n * @api public\n */\n\nBackoff.prototype.duration = function(){\n var ms = this.ms * Math.pow(this.factor, this.attempts++);\n if (this.jitter) {\n var rand = Math.random();\n var deviation = Math.floor(rand * this.jitter * ms);\n ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;\n }\n return Math.min(ms, this.max) | 0;\n};\n\n/**\n * Reset the number of attempts.\n *\n * @api public\n */\n\nBackoff.prototype.reset = function(){\n this.attempts = 0;\n};\n\n/**\n * Set the minimum duration\n *\n * @api public\n */\n\nBackoff.prototype.setMin = function(min){\n this.ms = min;\n};\n\n/**\n * Set the maximum duration\n *\n * @api public\n */\n\nBackoff.prototype.setMax = function(max){\n this.max = max;\n};\n\n/**\n * Set the jitter\n *\n * @api public\n */\n\nBackoff.prototype.setJitter = function(jitter){\n this.jitter = jitter;\n};\n\n","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh <http://feross.org>\n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nvar base64 = require('base64-js')\nvar ieee754 = require('ieee754')\nvar isArray = require('isarray')\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return '<Buffer ' + str + '>'\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n","// browser shim for xmlhttprequest module\nimport hasCORS from \"has-cors\";\nimport globalThis from \"../globalThis.js\";\nexport default function (opts) {\n const xdomain = opts.xdomain;\n // XMLHttpRequest can be disabled on IE\n try {\n if (\"undefined\" !== typeof XMLHttpRequest && (!xdomain || hasCORS)) {\n return new XMLHttpRequest();\n }\n }\n catch (e) { }\n if (!xdomain) {\n try {\n return new globalThis[[\"Active\"].concat(\"Object\").join(\"X\")](\"Microsoft.XMLHTTP\");\n }\n catch (e) { }\n }\n}\n","import { Transport } from \"../transport.js\";\nimport yeast from \"yeast\";\nimport parseqs from \"parseqs\";\nimport { encodePayload, decodePayload } from \"engine.io-parser\";\nexport class Polling extends Transport {\n constructor() {\n super(...arguments);\n this.polling = false;\n }\n /**\n * Transport name.\n */\n get name() {\n return \"polling\";\n }\n /**\n * Opens the socket (triggers polling). We write a PING message to determine\n * when the transport is open.\n *\n * @api private\n */\n doOpen() {\n this.poll();\n }\n /**\n * Pauses polling.\n *\n * @param {Function} callback upon buffers are flushed and transport is paused\n * @api private\n */\n pause(onPause) {\n this.readyState = \"pausing\";\n const pause = () => {\n this.readyState = \"paused\";\n onPause();\n };\n if (this.polling || !this.writable) {\n let total = 0;\n if (this.polling) {\n total++;\n this.once(\"pollComplete\", function () {\n --total || pause();\n });\n }\n if (!this.writable) {\n total++;\n this.once(\"drain\", function () {\n --total || pause();\n });\n }\n }\n else {\n pause();\n }\n }\n /**\n * Starts polling cycle.\n *\n * @api public\n */\n poll() {\n this.polling = true;\n this.doPoll();\n this.emit(\"poll\");\n }\n /**\n * Overloads onData to detect payloads.\n *\n * @api private\n */\n onData(data) {\n const callback = packet => {\n // if its the first message we consider the transport open\n if (\"opening\" === this.readyState && packet.type === \"open\") {\n this.onOpen();\n }\n // if its a close packet, we close the ongoing requests\n if (\"close\" === packet.type) {\n this.onClose();\n return false;\n }\n // otherwise bypass onData and handle the message\n this.onPacket(packet);\n };\n // decode payload\n decodePayload(data, this.socket.binaryType).forEach(callback);\n // if an event did not trigger closing\n if (\"closed\" !== this.readyState) {\n // if we got data we're not polling\n this.polling = false;\n this.emit(\"pollComplete\");\n if (\"open\" === this.readyState) {\n this.poll();\n }\n else {\n }\n }\n }\n /**\n * For polling, send a close packet.\n *\n * @api private\n */\n doClose() {\n const close = () => {\n this.write([{ type: \"close\" }]);\n };\n if (\"open\" === this.readyState) {\n close();\n }\n else {\n // in case we're trying to close while\n // handshaking is in progress (GH-164)\n this.once(\"open\", close);\n }\n }\n /**\n * Writes a packets payload.\n *\n * @param {Array} data packets\n * @param {Function} drain callback\n * @api private\n */\n write(packets) {\n this.writable = false;\n encodePayload(packets, data => {\n this.doWrite(data, () => {\n this.writable = true;\n this.emit(\"drain\");\n });\n });\n }\n /**\n * Generates uri for connection.\n *\n * @api private\n */\n uri() {\n let query = this.query || {};\n const schema = this.opts.secure ? \"https\" : \"http\";\n let port = \"\";\n // cache busting is forced\n if (false !== this.opts.timestampRequests) {\n query[this.opts.timestampParam] = yeast();\n }\n if (!this.supportsBinary && !query.sid) {\n query.b64 = 1;\n }\n // avoid port if default for schema\n if (this.opts.port &&\n ((\"https\" === schema && Number(this.opts.port) !== 443) ||\n (\"http\" === schema && Number(this.opts.port) !== 80))) {\n port = \":\" + this.opts.port;\n }\n const encodedQuery = parseqs.encode(query);\n const ipv6 = this.opts.hostname.indexOf(\":\") !== -1;\n return (schema +\n \"://\" +\n (ipv6 ? \"[\" + this.opts.hostname + \"]\" : this.opts.hostname) +\n port +\n this.opts.path +\n (encodedQuery.length ? \"?\" + encodedQuery : \"\"));\n }\n}\n","/* global attachEvent */\nimport XMLHttpRequest from \"./xmlhttprequest.js\";\nimport globalThis from \"../globalThis.js\";\nimport { installTimerFunctions, pick } from \"../util.js\";\nimport { Emitter } from \"@socket.io/component-emitter\";\nimport { Polling } from \"./polling.js\";\n/**\n * Empty function\n */\nfunction empty() { }\nconst hasXHR2 = (function () {\n const xhr = new XMLHttpRequest({\n xdomain: false\n });\n return null != xhr.responseType;\n})();\nexport class XHR extends Polling {\n /**\n * XHR Polling constructor.\n *\n * @param {Object} opts\n * @api public\n */\n constructor(opts) {\n super(opts);\n if (typeof location !== \"undefined\") {\n const isSSL = \"https:\" === location.protocol;\n let port = location.port;\n // some user agents have empty `location.port`\n if (!port) {\n port = isSSL ? \"443\" : \"80\";\n }\n this.xd =\n (typeof location !== \"undefined\" &&\n opts.hostname !== location.hostname) ||\n port !== opts.port;\n this.xs = opts.secure !== isSSL;\n }\n /**\n * XHR supports binary\n */\n const forceBase64 = opts && opts.forceBase64;\n this.supportsBinary = hasXHR2 && !forceBase64;\n }\n /**\n * Creates a request.\n *\n * @param {String} method\n * @api private\n */\n request(opts = {}) {\n Object.assign(opts, { xd: this.xd, xs: this.xs }, this.opts);\n return new Request(this.uri(), opts);\n }\n /**\n * Sends data.\n *\n * @param {String} data to send.\n * @param {Function} called upon flush.\n * @api private\n */\n doWrite(data, fn) {\n const req = this.request({\n method: \"POST\",\n data: data\n });\n req.on(\"success\", fn);\n req.on(\"error\", err => {\n this.onError(\"xhr post error\", err);\n });\n }\n /**\n * Starts a poll cycle.\n *\n * @api private\n */\n doPoll() {\n const req = this.request();\n req.on(\"data\", this.onData.bind(this));\n req.on(\"error\", err => {\n this.onError(\"xhr poll error\", err);\n });\n this.pollXhr = req;\n }\n}\nexport class Request extends Emitter {\n /**\n * Request constructor\n *\n * @param {Object} options\n * @api public\n */\n constructor(uri, opts) {\n super();\n installTimerFunctions(this, opts);\n this.opts = opts;\n this.method = opts.method || \"GET\";\n this.uri = uri;\n this.async = false !== opts.async;\n this.data = undefined !== opts.data ? opts.data : null;\n this.create();\n }\n /**\n * Creates the XHR object and sends the request.\n *\n * @api private\n */\n create() {\n const opts = pick(this.opts, \"agent\", \"pfx\", \"key\", \"passphrase\", \"cert\", \"ca\", \"ciphers\", \"rejectUnauthorized\", \"autoUnref\");\n opts.xdomain = !!this.opts.xd;\n opts.xscheme = !!this.opts.xs;\n const xhr = (this.xhr = new XMLHttpRequest(opts));\n try {\n xhr.open(this.method, this.uri, this.async);\n try {\n if (this.opts.extraHeaders) {\n xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);\n for (let i in this.opts.extraHeaders) {\n if (this.opts.extraHeaders.hasOwnProperty(i)) {\n xhr.setRequestHeader(i, this.opts.extraHeaders[i]);\n }\n }\n }\n }\n catch (e) { }\n if (\"POST\" === this.method) {\n try {\n xhr.setRequestHeader(\"Content-type\", \"text/plain;charset=UTF-8\");\n }\n catch (e) { }\n }\n try {\n xhr.setRequestHeader(\"Accept\", \"*/*\");\n }\n catch (e) { }\n // ie6 check\n if (\"withCredentials\" in xhr) {\n xhr.withCredentials = this.opts.withCredentials;\n }\n if (this.opts.requestTimeout) {\n xhr.timeout = this.opts.requestTimeout;\n }\n xhr.onreadystatechange = () => {\n if (4 !== xhr.readyState)\n return;\n if (200 === xhr.status || 1223 === xhr.status) {\n this.onLoad();\n }\n else {\n // make sure the `error` event handler that's user-set\n // does not throw in the same tick and gets caught here\n this.setTimeoutFn(() => {\n this.onError(typeof xhr.status === \"number\" ? xhr.status : 0);\n }, 0);\n }\n };\n xhr.send(this.data);\n }\n catch (e) {\n // Need to defer since .create() is called directly from the constructor\n // and thus the 'error' event can only be only bound *after* this exception\n // occurs. Therefore, also, we cannot throw here at all.\n this.setTimeoutFn(() => {\n this.onError(e);\n }, 0);\n return;\n }\n if (typeof document !== \"undefined\") {\n this.index = Request.requestsCount++;\n Request.requests[this.index] = this;\n }\n }\n /**\n * Called upon successful response.\n *\n * @api private\n */\n onSuccess() {\n this.emit(\"success\");\n this.cleanup();\n }\n /**\n * Called if we have data.\n *\n * @api private\n */\n onData(data) {\n this.emit(\"data\", data);\n this.onSuccess();\n }\n /**\n * Called upon error.\n *\n * @api private\n */\n onError(err) {\n this.emit(\"error\", err);\n this.cleanup(true);\n }\n /**\n * Cleans up house.\n *\n * @api private\n */\n cleanup(fromError) {\n if (\"undefined\" === typeof this.xhr || null === this.xhr) {\n return;\n }\n this.xhr.onreadystatechange = empty;\n if (fromError) {\n try {\n this.xhr.abort();\n }\n catch (e) { }\n }\n if (typeof document !== \"undefined\") {\n delete Request.requests[this.index];\n }\n this.xhr = null;\n }\n /**\n * Called upon load.\n *\n * @api private\n */\n onLoad() {\n const data = this.xhr.responseText;\n if (data !== null) {\n this.onData(data);\n }\n }\n /**\n * Aborts the request.\n *\n * @api public\n */\n abort() {\n this.cleanup();\n }\n}\nRequest.requestsCount = 0;\nRequest.requests = {};\n/**\n * Aborts pending requests when unloading the window. This is needed to prevent\n * memory leaks (e.g. when using IE) and to ensure that no spurious error is\n * emitted.\n */\nif (typeof document !== \"undefined\") {\n // @ts-ignore\n if (typeof attachEvent === \"function\") {\n // @ts-ignore\n attachEvent(\"onunload\", unloadHandler);\n }\n else if (typeof addEventListener === \"function\") {\n const terminationEvent = \"onpagehide\" in globalThis ? \"pagehide\" : \"unload\";\n addEventListener(terminationEvent, unloadHandler, false);\n }\n}\nfunction unloadHandler() {\n for (let i in Request.requests) {\n if (Request.requests.hasOwnProperty(i)) {\n Request.requests[i].abort();\n }\n }\n}\n","import { XHR } from \"./polling-xhr.js\";\nimport { WS } from \"./websocket.js\";\nexport const transports = {\n websocket: WS,\n polling: XHR\n};\n","import { transports } from \"./transports/index.js\";\nimport { installTimerFunctions } from \"./util.js\";\nimport parseqs from \"parseqs\";\nimport parseuri from \"parseuri\";\nimport { Emitter } from \"@socket.io/component-emitter\";\nimport { protocol } from \"engine.io-parser\";\nexport class Socket extends Emitter {\n /**\n * Socket constructor.\n *\n * @param {String|Object} uri or options\n * @param {Object} opts - options\n * @api public\n */\n constructor(uri, opts = {}) {\n super();\n if (uri && \"object\" === typeof uri) {\n opts = uri;\n uri = null;\n }\n if (uri) {\n uri = parseuri(uri);\n opts.hostname = uri.host;\n opts.secure = uri.protocol === \"https\" || uri.protocol === \"wss\";\n opts.port = uri.port;\n if (uri.query)\n opts.query = uri.query;\n }\n else if (opts.host) {\n opts.hostname = parseuri(opts.host).host;\n }\n installTimerFunctions(this, opts);\n this.secure =\n null != opts.secure\n ? opts.secure\n : typeof location !== \"undefined\" && \"https:\" === location.protocol;\n if (opts.hostname && !opts.port) {\n // if no port is specified manually, use the protocol default\n opts.port = this.secure ? \"443\" : \"80\";\n }\n this.hostname =\n opts.hostname ||\n (typeof location !== \"undefined\" ? location.hostname : \"localhost\");\n this.port =\n opts.port ||\n (typeof location !== \"undefined\" && location.port\n ? location.port\n : this.secure\n ? \"443\"\n : \"80\");\n this.transports = opts.transports || [\"polling\", \"websocket\"];\n this.readyState = \"\";\n this.writeBuffer = [];\n this.prevBufferLen = 0;\n this.opts = Object.assign({\n path: \"/engine.io\",\n agent: false,\n withCredentials: false,\n upgrade: true,\n timestampParam: \"t\",\n rememberUpgrade: false,\n rejectUnauthorized: true,\n perMessageDeflate: {\n threshold: 1024\n },\n transportOptions: {},\n closeOnBeforeunload: true\n }, opts);\n this.opts.path = this.opts.path.replace(/\\/$/, \"\") + \"/\";\n if (typeof this.opts.query === \"string\") {\n this.opts.query = parseqs.decode(this.opts.query);\n }\n // set on handshake\n this.id = null;\n this.upgrades = null;\n this.pingInterval = null;\n this.pingTimeout = null;\n // set on heartbeat\n this.pingTimeoutTimer = null;\n if (typeof addEventListener === \"function\") {\n if (this.opts.closeOnBeforeunload) {\n // Firefox closes the connection when the \"beforeunload\" event is emitted but not Chrome. This event listener\n // ensures every browser behaves the same (no \"disconnect\" event at the Socket.IO level when the page is\n // closed/reloaded)\n addEventListener(\"beforeunload\", () => {\n if (this.transport) {\n // silently close the transport\n this.transport.removeAllListeners();\n this.transport.close();\n }\n }, false);\n }\n if (this.hostname !== \"localhost\") {\n this.offlineEventListener = () => {\n this.onClose(\"transport close\");\n };\n addEventListener(\"offline\", this.offlineEventListener, false);\n }\n }\n this.open();\n }\n /**\n * Creates transport of the given type.\n *\n * @param {String} transport name\n * @return {Transport}\n * @api private\n */\n createTransport(name) {\n const query = clone(this.opts.query);\n // append engine.io protocol identifier\n query.EIO = protocol;\n // transport name\n query.transport = name;\n // session id if we already have one\n if (this.id)\n query.sid = this.id;\n const opts = Object.assign({}, this.opts.transportOptions[name], this.opts, {\n query,\n socket: this,\n hostname: this.hostname,\n secure: this.secure,\n port: this.port\n });\n return new transports[name](opts);\n }\n /**\n * Initializes transport to use and starts probe.\n *\n * @api private\n */\n open() {\n let transport;\n if (this.opts.rememberUpgrade &&\n Socket.priorWebsocketSuccess &&\n this.transports.indexOf(\"websocket\") !== -1) {\n transport = \"websocket\";\n }\n else if (0 === this.transports.length) {\n // Emit error on next tick so it can be listened to\n this.setTimeoutFn(() => {\n this.emitReserved(\"error\", \"No transports available\");\n }, 0);\n return;\n }\n else {\n transport = this.transports[0];\n }\n this.readyState = \"opening\";\n // Retry with the next transport if the transport is disabled (jsonp: false)\n try {\n transport = this.createTransport(transport);\n }\n catch (e) {\n this.transports.shift();\n this.open();\n return;\n }\n transport.open();\n this.setTransport(transport);\n }\n /**\n * Sets the current transport. Disables the existing one (if any).\n *\n * @api private\n */\n setTransport(transport) {\n if (this.transport) {\n this.transport.removeAllListeners();\n }\n // set up transport\n this.transport = transport;\n // set up transport listeners\n transport\n .on(\"drain\", this.onDrain.bind(this))\n .on(\"packet\", this.onPacket.bind(this))\n .on(\"error\", this.onError.bind(this))\n .on(\"close\", () => {\n this.onClose(\"transport close\");\n });\n }\n /**\n * Probes a transport.\n *\n * @param {String} transport name\n * @api private\n */\n probe(name) {\n let transport = this.createTransport(name);\n let failed = false;\n Socket.priorWebsocketSuccess = false;\n const onTransportOpen = () => {\n if (failed)\n return;\n transport.send([{ type: \"ping\", data: \"probe\" }]);\n transport.once(\"packet\", msg => {\n if (failed)\n return;\n if (\"pong\" === msg.type && \"probe\" === msg.data) {\n this.upgrading = true;\n this.emitReserved(\"upgrading\", transport);\n if (!transport)\n return;\n Socket.priorWebsocketSuccess = \"websocket\" === transport.name;\n this.transport.pause(() => {\n if (failed)\n return;\n if (\"closed\" === this.readyState)\n return;\n cleanup();\n this.setTransport(transport);\n transport.send([{ type: \"upgrade\" }]);\n this.emitReserved(\"upgrade\", transport);\n transport = null;\n this.upgrading = false;\n this.flush();\n });\n }\n else {\n const err = new Error(\"probe error\");\n // @ts-ignore\n err.transport = transport.name;\n this.emitReserved(\"upgradeError\", err);\n }\n });\n };\n function freezeTransport() {\n if (failed)\n return;\n // Any callback called by transport should be ignored since now\n failed = true;\n cleanup();\n transport.close();\n transport = null;\n }\n // Handle any error that happens while probing\n const onerror = err => {\n const error = new Error(\"probe error: \" + err);\n // @ts-ignore\n error.transport = transport.name;\n freezeTransport();\n this.emitReserved(\"upgradeError\", error);\n };\n function onTransportClose() {\n onerror(\"transport closed\");\n }\n // When the socket is closed while we're probing\n function onclose() {\n onerror(\"socket closed\");\n }\n // When the socket is upgraded while we're probing\n function onupgrade(to) {\n if (transport && to.name !== transport.name) {\n freezeTransport();\n }\n }\n // Remove all listeners on the transport and on self\n const cleanup = () => {\n transport.removeListener(\"open\", onTransportOpen);\n transport.removeListener(\"error\", onerror);\n transport.removeListener(\"close\", onTransportClose);\n this.off(\"close\", onclose);\n this.off(\"upgrading\", onupgrade);\n };\n transport.once(\"open\", onTransportOpen);\n transport.once(\"error\", onerror);\n transport.once(\"close\", onTransportClose);\n this.once(\"close\", onclose);\n this.once(\"upgrading\", onupgrade);\n transport.open();\n }\n /**\n * Called when connection is deemed open.\n *\n * @api private\n */\n onOpen() {\n this.readyState = \"open\";\n Socket.priorWebsocketSuccess = \"websocket\" === this.transport.name;\n this.emitReserved(\"open\");\n this.flush();\n // we check for `readyState` in case an `open`\n // listener already closed the socket\n if (\"open\" === this.readyState &&\n this.opts.upgrade &&\n this.transport.pause) {\n let i = 0;\n const l = this.upgrades.length;\n for (; i < l; i++) {\n this.probe(this.upgrades[i]);\n }\n }\n }\n /**\n * Handles a packet.\n *\n * @api private\n */\n onPacket(packet) {\n if (\"opening\" === this.readyState ||\n \"open\" === this.readyState ||\n \"closing\" === this.readyState) {\n this.emitReserved(\"packet\", packet);\n // Socket is live - any packet counts\n this.emitReserved(\"heartbeat\");\n switch (packet.type) {\n case \"open\":\n this.onHandshake(JSON.parse(packet.data));\n break;\n case \"ping\":\n this.resetPingTimeout();\n this.sendPacket(\"pong\");\n this.emitReserved(\"ping\");\n this.emitReserved(\"pong\");\n break;\n case \"error\":\n const err = new Error(\"server error\");\n // @ts-ignore\n err.code = packet.data;\n this.onError(err);\n break;\n case \"message\":\n this.emitReserved(\"data\", packet.data);\n this.emitReserved(\"message\", packet.data);\n break;\n }\n }\n else {\n }\n }\n /**\n * Called upon handshake completion.\n *\n * @param {Object} data - handshake obj\n * @api private\n */\n onHandshake(data) {\n this.emitReserved(\"handshake\", data);\n this.id = data.sid;\n this.transport.query.sid = data.sid;\n this.upgrades = this.filterUpgrades(data.upgrades);\n this.pingInterval = data.pingInterval;\n this.pingTimeout = data.pingTimeout;\n this.onOpen();\n // In case open handler closes socket\n if (\"closed\" === this.readyState)\n return;\n this.resetPingTimeout();\n }\n /**\n * Sets and resets ping timeout timer based on server pings.\n *\n * @api private\n */\n resetPingTimeout() {\n this.clearTimeoutFn(this.pingTimeoutTimer);\n this.pingTimeoutTimer = this.setTimeoutFn(() => {\n this.onClose(\"ping timeout\");\n }, this.pingInterval + this.pingTimeout);\n if (this.opts.autoUnref) {\n this.pingTimeoutTimer.unref();\n }\n }\n /**\n * Called on `drain` event\n *\n * @api private\n */\n onDrain() {\n this.writeBuffer.splice(0, this.prevBufferLen);\n // setting prevBufferLen = 0 is very important\n // for example, when upgrading, upgrade packet is sent over,\n // and a nonzero prevBufferLen could cause problems on `drain`\n this.prevBufferLen = 0;\n if (0 === this.writeBuffer.length) {\n this.emitReserved(\"drain\");\n }\n else {\n this.flush();\n }\n }\n /**\n * Flush write buffers.\n *\n * @api private\n */\n flush() {\n if (\"closed\" !== this.readyState &&\n this.transport.writable &&\n !this.upgrading &&\n this.writeBuffer.length) {\n this.transport.send(this.writeBuffer);\n // keep track of current length of writeBuffer\n // splice writeBuffer and callbackBuffer on `drain`\n this.prevBufferLen = this.writeBuffer.length;\n this.emitReserved(\"flush\");\n }\n }\n /**\n * Sends a message.\n *\n * @param {String} message.\n * @param {Function} callback function.\n * @param {Object} options.\n * @return {Socket} for chaining.\n * @api public\n */\n write(msg, options, fn) {\n this.sendPacket(\"message\", msg, options, fn);\n return this;\n }\n send(msg, options, fn) {\n this.sendPacket(\"message\", msg, options, fn);\n return this;\n }\n /**\n * Sends a packet.\n *\n * @param {String} packet type.\n * @param {String} data.\n * @param {Object} options.\n * @param {Function} callback function.\n * @api private\n */\n sendPacket(type, data, options, fn) {\n if (\"function\" === typeof data) {\n fn = data;\n data = undefined;\n }\n if (\"function\" === typeof options) {\n fn = options;\n options = null;\n }\n if (\"closing\" === this.readyState || \"closed\" === this.readyState) {\n return;\n }\n options = options || {};\n options.compress = false !== options.compress;\n const packet = {\n type: type,\n data: data,\n options: options\n };\n this.emitReserved(\"packetCreate\", packet);\n this.writeBuffer.push(packet);\n if (fn)\n this.once(\"flush\", fn);\n this.flush();\n }\n /**\n * Closes the connection.\n *\n * @api public\n */\n close() {\n const close = () => {\n this.onClose(\"forced close\");\n this.transport.close();\n };\n const cleanupAndClose = () => {\n this.off(\"upgrade\", cleanupAndClose);\n this.off(\"upgradeError\", cleanupAndClose);\n close();\n };\n const waitForUpgrade = () => {\n // wait for upgrade to finish since we can't send packets while pausing a transport\n this.once(\"upgrade\", cleanupAndClose);\n this.once(\"upgradeError\", cleanupAndClose);\n };\n if (\"opening\" === this.readyState || \"open\" === this.readyState) {\n this.readyState = \"closing\";\n if (this.writeBuffer.length) {\n this.once(\"drain\", () => {\n if (this.upgrading) {\n waitForUpgrade();\n }\n else {\n close();\n }\n });\n }\n else if (this.upgrading) {\n waitForUpgrade();\n }\n else {\n close();\n }\n }\n return this;\n }\n /**\n * Called upon transport error\n *\n * @api private\n */\n onError(err) {\n Socket.priorWebsocketSuccess = false;\n this.emitReserved(\"error\", err);\n this.onClose(\"transport error\", err);\n }\n /**\n * Called upon transport close.\n *\n * @api private\n */\n onClose(reason, desc) {\n if (\"opening\" === this.readyState ||\n \"open\" === this.readyState ||\n \"closing\" === this.readyState) {\n // clear timers\n this.clearTimeoutFn(this.pingTimeoutTimer);\n // stop event from firing again for transport\n this.transport.removeAllListeners(\"close\");\n // ensure transport won't stay open\n this.transport.close();\n // ignore further transport communication\n this.transport.removeAllListeners();\n if (typeof removeEventListener === \"function\") {\n removeEventListener(\"offline\", this.offlineEventListener, false);\n }\n // set ready state\n this.readyState = \"closed\";\n // clear session id\n this.id = null;\n // emit close event\n this.emitReserved(\"close\", reason, desc);\n // clean buffers after, so users can still\n // grab the buffers on `close` event\n this.writeBuffer = [];\n this.prevBufferLen = 0;\n }\n }\n /**\n * Filters upgrades, returning only those matching client transports.\n *\n * @param {Array} server upgrades\n * @api private\n *\n */\n filterUpgrades(upgrades) {\n const filteredUpgrades = [];\n let i = 0;\n const j = upgrades.length;\n for (; i < j; i++) {\n if (~this.transports.indexOf(upgrades[i]))\n filteredUpgrades.push(upgrades[i]);\n }\n return filteredUpgrades;\n }\n}\nSocket.protocol = protocol;\nfunction clone(obj) {\n const o = {};\n for (let i in obj) {\n if (obj.hasOwnProperty(i)) {\n o[i] = obj[i];\n }\n }\n return o;\n}\n","import { Socket } from \"./socket.js\";\nexport { Socket };\nexport const protocol = Socket.protocol;\nexport { Transport } from \"./transport.js\";\nexport { transports } from \"./transports/index.js\";\nexport { installTimerFunctions } from \"./util.js\";\n","const withNativeArrayBuffer = typeof ArrayBuffer === \"function\";\nconst isView = (obj) => {\n return typeof ArrayBuffer.isView === \"function\"\n ? ArrayBuffer.isView(obj)\n : obj.buffer instanceof ArrayBuffer;\n};\nconst toString = Object.prototype.toString;\nconst withNativeBlob = typeof Blob === \"function\" ||\n (typeof Blob !== \"undefined\" &&\n toString.call(Blob) === \"[object BlobConstructor]\");\nconst withNativeFile = typeof File === \"function\" ||\n (typeof File !== \"undefined\" &&\n toString.call(File) === \"[object FileConstructor]\");\n/**\n * Returns true if obj is a Buffer, an ArrayBuffer, a Blob or a File.\n *\n * @private\n */\nexport function isBinary(obj) {\n return ((withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj))) ||\n (withNativeBlob && obj instanceof Blob) ||\n (withNativeFile && obj instanceof File));\n}\nexport function hasBinary(obj, toJSON) {\n if (!obj || typeof obj !== \"object\") {\n return false;\n }\n if (Array.isArray(obj)) {\n for (let i = 0, l = obj.length; i < l; i++) {\n if (hasBinary(obj[i])) {\n return true;\n }\n }\n return false;\n }\n if (isBinary(obj)) {\n return true;\n }\n if (obj.toJSON &&\n typeof obj.toJSON === \"function\" &&\n arguments.length === 1) {\n return hasBinary(obj.toJSON(), true);\n }\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {\n return true;\n }\n }\n return false;\n}\n","import { isBinary } from \"./is-binary.js\";\n/**\n * Replaces every Buffer | ArrayBuffer | Blob | File in packet with a numbered placeholder.\n *\n * @param {Object} packet - socket.io event packet\n * @return {Object} with deconstructed packet and list of buffers\n * @public\n */\nexport function deconstructPacket(packet) {\n const buffers = [];\n const packetData = packet.data;\n const pack = packet;\n pack.data = _deconstructPacket(packetData, buffers);\n pack.attachments = buffers.length; // number of binary 'attachments'\n return { packet: pack, buffers: buffers };\n}\nfunction _deconstructPacket(data, buffers) {\n if (!data)\n return data;\n if (isBinary(data)) {\n const placeholder = { _placeholder: true, num: buffers.length };\n buffers.push(data);\n return placeholder;\n }\n else if (Array.isArray(data)) {\n const newData = new Array(data.length);\n for (let i = 0; i < data.length; i++) {\n newData[i] = _deconstructPacket(data[i], buffers);\n }\n return newData;\n }\n else if (typeof data === \"object\" && !(data instanceof Date)) {\n const newData = {};\n for (const key in data) {\n if (data.hasOwnProperty(key)) {\n newData[key] = _deconstructPacket(data[key], buffers);\n }\n }\n return newData;\n }\n return data;\n}\n/**\n * Reconstructs a binary packet from its placeholder packet and buffers\n *\n * @param {Object} packet - event packet with placeholders\n * @param {Array} buffers - binary buffers to put in placeholder positions\n * @return {Object} reconstructed packet\n * @public\n */\nexport function reconstructPacket(packet, buffers) {\n packet.data = _reconstructPacket(packet.data, buffers);\n packet.attachments = undefined; // no longer useful\n return packet;\n}\nfunction _reconstructPacket(data, buffers) {\n if (!data)\n return data;\n if (data && data._placeholder) {\n return buffers[data.num]; // appropriate buffer (should be natural order anyway)\n }\n else if (Array.isArray(data)) {\n for (let i = 0; i < data.length; i++) {\n data[i] = _reconstructPacket(data[i], buffers);\n }\n }\n else if (typeof data === \"object\") {\n for (const key in data) {\n if (data.hasOwnProperty(key)) {\n data[key] = _reconstructPacket(data[key], buffers);\n }\n }\n }\n return data;\n}\n","import { Emitter } from \"@socket.io/component-emitter\";\nimport { deconstructPacket, reconstructPacket } from \"./binary.js\";\nimport { isBinary, hasBinary } from \"./is-binary.js\";\n/**\n * Protocol version.\n *\n * @public\n */\nexport const protocol = 5;\nexport var PacketType;\n(function (PacketType) {\n PacketType[PacketType[\"CONNECT\"] = 0] = \"CONNECT\";\n PacketType[PacketType[\"DISCONNECT\"] = 1] = \"DISCONNECT\";\n PacketType[PacketType[\"EVENT\"] = 2] = \"EVENT\";\n PacketType[PacketType[\"ACK\"] = 3] = \"ACK\";\n PacketType[PacketType[\"CONNECT_ERROR\"] = 4] = \"CONNECT_ERROR\";\n PacketType[PacketType[\"BINARY_EVENT\"] = 5] = \"BINARY_EVENT\";\n PacketType[PacketType[\"BINARY_ACK\"] = 6] = \"BINARY_ACK\";\n})(PacketType || (PacketType = {}));\n/**\n * A socket.io Encoder instance\n */\nexport class Encoder {\n /**\n * Encode a packet as a single string if non-binary, or as a\n * buffer sequence, depending on packet type.\n *\n * @param {Object} obj - packet object\n */\n encode(obj) {\n if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {\n if (hasBinary(obj)) {\n obj.type =\n obj.type === PacketType.EVENT\n ? PacketType.BINARY_EVENT\n : PacketType.BINARY_ACK;\n return this.encodeAsBinary(obj);\n }\n }\n return [this.encodeAsString(obj)];\n }\n /**\n * Encode packet as string.\n */\n encodeAsString(obj) {\n // first is type\n let str = \"\" + obj.type;\n // attachments if we have them\n if (obj.type === PacketType.BINARY_EVENT ||\n obj.type === PacketType.BINARY_ACK) {\n str += obj.attachments + \"-\";\n }\n // if we have a namespace other than `/`\n // we append it followed by a comma `,`\n if (obj.nsp && \"/\" !== obj.nsp) {\n str += obj.nsp + \",\";\n }\n // immediately followed by the id\n if (null != obj.id) {\n str += obj.id;\n }\n // json data\n if (null != obj.data) {\n str += JSON.stringify(obj.data);\n }\n return str;\n }\n /**\n * Encode packet as 'buffer sequence' by removing blobs, and\n * deconstructing packet into object with placeholders and\n * a list of buffers.\n */\n encodeAsBinary(obj) {\n const deconstruction = deconstructPacket(obj);\n const pack = this.encodeAsString(deconstruction.packet);\n const buffers = deconstruction.buffers;\n buffers.unshift(pack); // add packet info to beginning of data list\n return buffers; // write all the buffers\n }\n}\n/**\n * A socket.io Decoder instance\n *\n * @return {Object} decoder\n */\nexport class Decoder extends Emitter {\n constructor() {\n super();\n }\n /**\n * Decodes an encoded packet string into packet JSON.\n *\n * @param {String} obj - encoded packet\n */\n add(obj) {\n let packet;\n if (typeof obj === \"string\") {\n packet = this.decodeString(obj);\n if (packet.type === PacketType.BINARY_EVENT ||\n packet.type === PacketType.BINARY_ACK) {\n // binary packet's json\n this.reconstructor = new BinaryReconstructor(packet);\n // no attachments, labeled binary but no binary data to follow\n if (packet.attachments === 0) {\n super.emitReserved(\"decoded\", packet);\n }\n }\n else {\n // non-binary full packet\n super.emitReserved(\"decoded\", packet);\n }\n }\n else if (isBinary(obj) || obj.base64) {\n // raw binary data\n if (!this.reconstructor) {\n throw new Error(\"got binary data when not reconstructing a packet\");\n }\n else {\n packet = this.reconstructor.takeBinaryData(obj);\n if (packet) {\n // received final buffer\n this.reconstructor = null;\n super.emitReserved(\"decoded\", packet);\n }\n }\n }\n else {\n throw new Error(\"Unknown type: \" + obj);\n }\n }\n /**\n * Decode a packet String (JSON data)\n *\n * @param {String} str\n * @return {Object} packet\n */\n decodeString(str) {\n let i = 0;\n // look up type\n const p = {\n type: Number(str.charAt(0)),\n };\n if (PacketType[p.type] === undefined) {\n throw new Error(\"unknown packet type \" + p.type);\n }\n // look up attachments if type binary\n if (p.type === PacketType.BINARY_EVENT ||\n p.type === PacketType.BINARY_ACK) {\n const start = i + 1;\n while (str.charAt(++i) !== \"-\" && i != str.length) { }\n const buf = str.substring(start, i);\n if (buf != Number(buf) || str.charAt(i) !== \"-\") {\n throw new Error(\"Illegal attachments\");\n }\n p.attachments = Number(buf);\n }\n // look up namespace (if any)\n if (\"/\" === str.charAt(i + 1)) {\n const start = i + 1;\n while (++i) {\n const c = str.charAt(i);\n if (\",\" === c)\n break;\n if (i === str.length)\n break;\n }\n p.nsp = str.substring(start, i);\n }\n else {\n p.nsp = \"/\";\n }\n // look up id\n const next = str.charAt(i + 1);\n if (\"\" !== next && Number(next) == next) {\n const start = i + 1;\n while (++i) {\n const c = str.charAt(i);\n if (null == c || Number(c) != c) {\n --i;\n break;\n }\n if (i === str.length)\n break;\n }\n p.id = Number(str.substring(start, i + 1));\n }\n // look up json data\n if (str.charAt(++i)) {\n const payload = tryParse(str.substr(i));\n if (Decoder.isPayloadValid(p.type, payload)) {\n p.data = payload;\n }\n else {\n throw new Error(\"invalid payload\");\n }\n }\n return p;\n }\n static isPayloadValid(type, payload) {\n switch (type) {\n case PacketType.CONNECT:\n return typeof payload === \"object\";\n case PacketType.DISCONNECT:\n return payload === undefined;\n case PacketType.CONNECT_ERROR:\n return typeof payload === \"string\" || typeof payload === \"object\";\n case PacketType.EVENT:\n case PacketType.BINARY_EVENT:\n return Array.isArray(payload) && payload.length > 0;\n case PacketType.ACK:\n case PacketType.BINARY_ACK:\n return Array.isArray(payload);\n }\n }\n /**\n * Deallocates a parser's resources\n */\n destroy() {\n if (this.reconstructor) {\n this.reconstructor.finishedReconstruction();\n }\n }\n}\nfunction tryParse(str) {\n try {\n return JSON.parse(str);\n }\n catch (e) {\n return false;\n }\n}\n/**\n * A manager of a binary event's 'buffer sequence'. Should\n * be constructed whenever a packet of type BINARY_EVENT is\n * decoded.\n *\n * @param {Object} packet\n * @return {BinaryReconstructor} initialized reconstructor\n */\nclass BinaryReconstructor {\n constructor(packet) {\n this.packet = packet;\n this.buffers = [];\n this.reconPack = packet;\n }\n /**\n * Method to be called when binary data received from connection\n * after a BINARY_EVENT packet.\n *\n * @param {Buffer | ArrayBuffer} binData - the raw binary data received\n * @return {null | Object} returns null if more binary data is expected or\n * a reconstructed packet object if all buffers have been received.\n */\n takeBinaryData(binData) {\n this.buffers.push(binData);\n if (this.buffers.length === this.reconPack.attachments) {\n // done with buffer list\n const packet = reconstructPacket(this.reconPack, this.buffers);\n this.finishedReconstruction();\n return packet;\n }\n return null;\n }\n /**\n * Cleans up binary packet reconstruction variables.\n */\n finishedReconstruction() {\n this.reconPack = null;\n this.buffers = [];\n }\n}\n","export function on(obj, ev, fn) {\n obj.on(ev, fn);\n return function subDestroy() {\n obj.off(ev, fn);\n };\n}\n","import { PacketType } from \"socket.io-parser\";\nimport { on } from \"./on.js\";\nimport { Emitter, } from \"@socket.io/component-emitter\";\n/**\n * Internal events.\n * These events can't be emitted by the user.\n */\nconst RESERVED_EVENTS = Object.freeze({\n connect: 1,\n connect_error: 1,\n disconnect: 1,\n disconnecting: 1,\n // EventEmitter reserved events: https://nodejs.org/api/events.html#events_event_newlistener\n newListener: 1,\n removeListener: 1,\n});\nexport class Socket extends Emitter {\n /**\n * `Socket` constructor.\n *\n * @public\n */\n constructor(io, nsp, opts) {\n super();\n this.connected = false;\n this.disconnected = true;\n this.receiveBuffer = [];\n this.sendBuffer = [];\n this.ids = 0;\n this.acks = {};\n this.flags = {};\n this.io = io;\n this.nsp = nsp;\n if (opts && opts.auth) {\n this.auth = opts.auth;\n }\n if (this.io._autoConnect)\n this.open();\n }\n /**\n * Subscribe to open, close and packet events\n *\n * @private\n */\n subEvents() {\n if (this.subs)\n return;\n const io = this.io;\n this.subs = [\n on(io, \"open\", this.onopen.bind(this)),\n on(io, \"packet\", this.onpacket.bind(this)),\n on(io, \"error\", this.onerror.bind(this)),\n on(io, \"close\", this.onclose.bind(this)),\n ];\n }\n /**\n * Whether the Socket will try to reconnect when its Manager connects or reconnects\n */\n get active() {\n return !!this.subs;\n }\n /**\n * \"Opens\" the socket.\n *\n * @public\n */\n connect() {\n if (this.connected)\n return this;\n this.subEvents();\n if (!this.io[\"_reconnecting\"])\n this.io.open(); // ensure open\n if (\"open\" === this.io._readyState)\n this.onopen();\n return this;\n }\n /**\n * Alias for connect()\n */\n open() {\n return this.connect();\n }\n /**\n * Sends a `message` event.\n *\n * @return self\n * @public\n */\n send(...args) {\n args.unshift(\"message\");\n this.emit.apply(this, args);\n return this;\n }\n /**\n * Override `emit`.\n * If the event is in `events`, it's emitted normally.\n *\n * @return self\n * @public\n */\n emit(ev, ...args) {\n if (RESERVED_EVENTS.hasOwnProperty(ev)) {\n throw new Error('\"' + ev + '\" is a reserved event name');\n }\n args.unshift(ev);\n const packet = {\n type: PacketType.EVENT,\n data: args,\n };\n packet.options = {};\n packet.options.compress = this.flags.compress !== false;\n // event ack callback\n if (\"function\" === typeof args[args.length - 1]) {\n const id = this.ids++;\n const ack = args.pop();\n this._registerAckCallback(id, ack);\n packet.id = id;\n }\n const isTransportWritable = this.io.engine &&\n this.io.engine.transport &&\n this.io.engine.transport.writable;\n const discardPacket = this.flags.volatile && (!isTransportWritable || !this.connected);\n if (discardPacket) {\n }\n else if (this.connected) {\n this.packet(packet);\n }\n else {\n this.sendBuffer.push(packet);\n }\n this.flags = {};\n return this;\n }\n /**\n * @private\n */\n _registerAckCallback(id, ack) {\n const timeout = this.flags.timeout;\n if (timeout === undefined) {\n this.acks[id] = ack;\n return;\n }\n // @ts-ignore\n const timer = this.io.setTimeoutFn(() => {\n delete this.acks[id];\n for (let i = 0; i < this.sendBuffer.length; i++) {\n if (this.sendBuffer[i].id === id) {\n this.sendBuffer.splice(i, 1);\n }\n }\n ack.call(this, new Error(\"operation has timed out\"));\n }, timeout);\n this.acks[id] = (...args) => {\n // @ts-ignore\n this.io.clearTimeoutFn(timer);\n ack.apply(this, [null, ...args]);\n };\n }\n /**\n * Sends a packet.\n *\n * @param packet\n * @private\n */\n packet(packet) {\n packet.nsp = this.nsp;\n this.io._packet(packet);\n }\n /**\n * Called upon engine `open`.\n *\n * @private\n */\n onopen() {\n if (typeof this.auth == \"function\") {\n this.auth((data) => {\n this.packet({ type: PacketType.CONNECT, data });\n });\n }\n else {\n this.packet({ type: PacketType.CONNECT, data: this.auth });\n }\n }\n /**\n * Called upon engine or manager `error`.\n *\n * @param err\n * @private\n */\n onerror(err) {\n if (!this.connected) {\n this.emitReserved(\"connect_error\", err);\n }\n }\n /**\n * Called upon engine `close`.\n *\n * @param reason\n * @private\n */\n onclose(reason) {\n this.connected = false;\n this.disconnected = true;\n delete this.id;\n this.emitReserved(\"disconnect\", reason);\n }\n /**\n * Called with socket packet.\n *\n * @param packet\n * @private\n */\n onpacket(packet) {\n const sameNamespace = packet.nsp === this.nsp;\n if (!sameNamespace)\n return;\n switch (packet.type) {\n case PacketType.CONNECT:\n if (packet.data && packet.data.sid) {\n const id = packet.data.sid;\n this.onconnect(id);\n }\n else {\n this.emitReserved(\"connect_error\", new Error(\"It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)\"));\n }\n break;\n case PacketType.EVENT:\n this.onevent(packet);\n break;\n case PacketType.BINARY_EVENT:\n this.onevent(packet);\n break;\n case PacketType.ACK:\n this.onack(packet);\n break;\n case PacketType.BINARY_ACK:\n this.onack(packet);\n break;\n case PacketType.DISCONNECT:\n this.ondisconnect();\n break;\n case PacketType.CONNECT_ERROR:\n this.destroy();\n const err = new Error(packet.data.message);\n // @ts-ignore\n err.data = packet.data.data;\n this.emitReserved(\"connect_error\", err);\n break;\n }\n }\n /**\n * Called upon a server event.\n *\n * @param packet\n * @private\n */\n onevent(packet) {\n const args = packet.data || [];\n if (null != packet.id) {\n args.push(this.ack(packet.id));\n }\n if (this.connected) {\n this.emitEvent(args);\n }\n else {\n this.receiveBuffer.push(Object.freeze(args));\n }\n }\n emitEvent(args) {\n if (this._anyListeners && this._anyListeners.length) {\n const listeners = this._anyListeners.slice();\n for (const listener of listeners) {\n listener.apply(this, args);\n }\n }\n super.emit.apply(this, args);\n }\n /**\n * Produces an ack callback to emit with an event.\n *\n * @private\n */\n ack(id) {\n const self = this;\n let sent = false;\n return function (...args) {\n // prevent double callbacks\n if (sent)\n return;\n sent = true;\n self.packet({\n type: PacketType.ACK,\n id: id,\n data: args,\n });\n };\n }\n /**\n * Called upon a server acknowlegement.\n *\n * @param packet\n * @private\n */\n onack(packet) {\n const ack = this.acks[packet.id];\n if (\"function\" === typeof ack) {\n ack.apply(this, packet.data);\n delete this.acks[packet.id];\n }\n else {\n }\n }\n /**\n * Called upon server connect.\n *\n * @private\n */\n onconnect(id) {\n this.id = id;\n this.connected = true;\n this.disconnected = false;\n this.emitBuffered();\n this.emitReserved(\"connect\");\n }\n /**\n * Emit buffered events (received and emitted).\n *\n * @private\n */\n emitBuffered() {\n this.receiveBuffer.forEach((args) => this.emitEvent(args));\n this.receiveBuffer = [];\n this.sendBuffer.forEach((packet) => this.packet(packet));\n this.sendBuffer = [];\n }\n /**\n * Called upon server disconnect.\n *\n * @private\n */\n ondisconnect() {\n this.destroy();\n this.onclose(\"io server disconnect\");\n }\n /**\n * Called upon forced client/server side disconnections,\n * this method ensures the manager stops tracking us and\n * that reconnections don't get triggered for this.\n *\n * @private\n */\n destroy() {\n if (this.subs) {\n // clean subscriptions to avoid reconnections\n this.subs.forEach((subDestroy) => subDestroy());\n this.subs = undefined;\n }\n this.io[\"_destroy\"](this);\n }\n /**\n * Disconnects the socket manually.\n *\n * @return self\n * @public\n */\n disconnect() {\n if (this.connected) {\n this.packet({ type: PacketType.DISCONNECT });\n }\n // remove socket from pool\n this.destroy();\n if (this.connected) {\n // fire events\n this.onclose(\"io client disconnect\");\n }\n return this;\n }\n /**\n * Alias for disconnect()\n *\n * @return self\n * @public\n */\n close() {\n return this.disconnect();\n }\n /**\n * Sets the compress flag.\n *\n * @param compress - if `true`, compresses the sending data\n * @return self\n * @public\n */\n compress(compress) {\n this.flags.compress = compress;\n return this;\n }\n /**\n * Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not\n * ready to send messages.\n *\n * @returns self\n * @public\n */\n get volatile() {\n this.flags.volatile = true;\n return this;\n }\n /**\n * Sets a modifier for a subsequent event emission that the callback will be called with an error when the\n * given number of milliseconds have elapsed without an acknowledgement from the server:\n *\n * ```\n * socket.timeout(5000).emit(\"my-event\", (err) => {\n * if (err) {\n * // the server did not acknowledge the event in the given delay\n * }\n * });\n * ```\n *\n * @returns self\n * @public\n */\n timeout(timeout) {\n this.flags.timeout = timeout;\n return this;\n }\n /**\n * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the\n * callback.\n *\n * @param listener\n * @public\n */\n onAny(listener) {\n this._anyListeners = this._anyListeners || [];\n this._anyListeners.push(listener);\n return this;\n }\n /**\n * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the\n * callback. The listener is added to the beginning of the listeners array.\n *\n * @param listener\n * @public\n */\n prependAny(listener) {\n this._anyListeners = this._anyListeners || [];\n this._anyListeners.unshift(listener);\n return this;\n }\n /**\n * Removes the listener that will be fired when any event is emitted.\n *\n * @param listener\n * @public\n */\n offAny(listener) {\n if (!this._anyListeners) {\n return this;\n }\n if (listener) {\n const listeners = this._anyListeners;\n for (let i = 0; i < listeners.length; i++) {\n if (listener === listeners[i]) {\n listeners.splice(i, 1);\n return this;\n }\n }\n }\n else {\n this._anyListeners = [];\n }\n return this;\n }\n /**\n * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,\n * e.g. to remove listeners.\n *\n * @public\n */\n listenersAny() {\n return this._anyListeners || [];\n }\n}\n","import { Socket as Engine, installTimerFunctions, } from \"engine.io-client\";\nimport { Socket } from \"./socket.js\";\nimport * as parser from \"socket.io-parser\";\nimport { on } from \"./on.js\";\nimport Backoff from \"backo2\";\nimport { Emitter, } from \"@socket.io/component-emitter\";\nexport class Manager extends Emitter {\n constructor(uri, opts) {\n var _a;\n super();\n this.nsps = {};\n this.subs = [];\n if (uri && \"object\" === typeof uri) {\n opts = uri;\n uri = undefined;\n }\n opts = opts || {};\n opts.path = opts.path || \"/socket.io\";\n this.opts = opts;\n installTimerFunctions(this, opts);\n this.reconnection(opts.reconnection !== false);\n this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);\n this.reconnectionDelay(opts.reconnectionDelay || 1000);\n this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000);\n this.randomizationFactor((_a = opts.randomizationFactor) !== null && _a !== void 0 ? _a : 0.5);\n this.backoff = new Backoff({\n min: this.reconnectionDelay(),\n max: this.reconnectionDelayMax(),\n jitter: this.randomizationFactor(),\n });\n this.timeout(null == opts.timeout ? 20000 : opts.timeout);\n this._readyState = \"closed\";\n this.uri = uri;\n const _parser = opts.parser || parser;\n this.encoder = new _parser.Encoder();\n this.decoder = new _parser.Decoder();\n this._autoConnect = opts.autoConnect !== false;\n if (this._autoConnect)\n this.open();\n }\n reconnection(v) {\n if (!arguments.length)\n return this._reconnection;\n this._reconnection = !!v;\n return this;\n }\n reconnectionAttempts(v) {\n if (v === undefined)\n return this._reconnectionAttempts;\n this._reconnectionAttempts = v;\n return this;\n }\n reconnectionDelay(v) {\n var _a;\n if (v === undefined)\n return this._reconnectionDelay;\n this._reconnectionDelay = v;\n (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMin(v);\n return this;\n }\n randomizationFactor(v) {\n var _a;\n if (v === undefined)\n return this._randomizationFactor;\n this._randomizationFactor = v;\n (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setJitter(v);\n return this;\n }\n reconnectionDelayMax(v) {\n var _a;\n if (v === undefined)\n return this._reconnectionDelayMax;\n this._reconnectionDelayMax = v;\n (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMax(v);\n return this;\n }\n timeout(v) {\n if (!arguments.length)\n return this._timeout;\n this._timeout = v;\n return this;\n }\n /**\n * Starts trying to reconnect if reconnection is enabled and we have not\n * started reconnecting yet\n *\n * @private\n */\n maybeReconnectOnOpen() {\n // Only try to reconnect if it's the first time we're connecting\n if (!this._reconnecting &&\n this._reconnection &&\n this.backoff.attempts === 0) {\n // keeps reconnection from firing twice for the same reconnection loop\n this.reconnect();\n }\n }\n /**\n * Sets the current transport `socket`.\n *\n * @param {Function} fn - optional, callback\n * @return self\n * @public\n */\n open(fn) {\n if (~this._readyState.indexOf(\"open\"))\n return this;\n this.engine = new Engine(this.uri, this.opts);\n const socket = this.engine;\n const self = this;\n this._readyState = \"opening\";\n this.skipReconnect = false;\n // emit `open`\n const openSubDestroy = on(socket, \"open\", function () {\n self.onopen();\n fn && fn();\n });\n // emit `error`\n const errorSub = on(socket, \"error\", (err) => {\n self.cleanup();\n self._readyState = \"closed\";\n this.emitReserved(\"error\", err);\n if (fn) {\n fn(err);\n }\n else {\n // Only do this if there is no fn to handle the error\n self.maybeReconnectOnOpen();\n }\n });\n if (false !== this._timeout) {\n const timeout = this._timeout;\n if (timeout === 0) {\n openSubDestroy(); // prevents a race condition with the 'open' event\n }\n // set timer\n const timer = this.setTimeoutFn(() => {\n openSubDestroy();\n socket.close();\n // @ts-ignore\n socket.emit(\"error\", new Error(\"timeout\"));\n }, timeout);\n if (this.opts.autoUnref) {\n timer.unref();\n }\n this.subs.push(function subDestroy() {\n clearTimeout(timer);\n });\n }\n this.subs.push(openSubDestroy);\n this.subs.push(errorSub);\n return this;\n }\n /**\n * Alias for open()\n *\n * @return self\n * @public\n */\n connect(fn) {\n return this.open(fn);\n }\n /**\n * Called upon transport open.\n *\n * @private\n */\n onopen() {\n // clear old subs\n this.cleanup();\n // mark as open\n this._readyState = \"open\";\n this.emitReserved(\"open\");\n // add new subs\n const socket = this.engine;\n this.subs.push(on(socket, \"ping\", this.onping.bind(this)), on(socket, \"data\", this.ondata.bind(this)), on(socket, \"error\", this.onerror.bind(this)), on(socket, \"close\", this.onclose.bind(this)), on(this.decoder, \"decoded\", this.ondecoded.bind(this)));\n }\n /**\n * Called upon a ping.\n *\n * @private\n */\n onping() {\n this.emitReserved(\"ping\");\n }\n /**\n * Called with data.\n *\n * @private\n */\n ondata(data) {\n this.decoder.add(data);\n }\n /**\n * Called when parser fully decodes a packet.\n *\n * @private\n */\n ondecoded(packet) {\n this.emitReserved(\"packet\", packet);\n }\n /**\n * Called upon socket error.\n *\n * @private\n */\n onerror(err) {\n this.emitReserved(\"error\", err);\n }\n /**\n * Creates a new socket for the given `nsp`.\n *\n * @return {Socket}\n * @public\n */\n socket(nsp, opts) {\n let socket = this.nsps[nsp];\n if (!socket) {\n socket = new Socket(this, nsp, opts);\n this.nsps[nsp] = socket;\n }\n return socket;\n }\n /**\n * Called upon a socket close.\n *\n * @param socket\n * @private\n */\n _destroy(socket) {\n const nsps = Object.keys(this.nsps);\n for (const nsp of nsps) {\n const socket = this.nsps[nsp];\n if (socket.active) {\n return;\n }\n }\n this._close();\n }\n /**\n * Writes a packet.\n *\n * @param packet\n * @private\n */\n _packet(packet) {\n const encodedPackets = this.encoder.encode(packet);\n for (let i = 0; i < encodedPackets.length; i++) {\n this.engine.write(encodedPackets[i], packet.options);\n }\n }\n /**\n * Clean up transport subscriptions and packet buffer.\n *\n * @private\n */\n cleanup() {\n this.subs.forEach((subDestroy) => subDestroy());\n this.subs.length = 0;\n this.decoder.destroy();\n }\n /**\n * Close the current socket.\n *\n * @private\n */\n _close() {\n this.skipReconnect = true;\n this._reconnecting = false;\n this.onclose(\"forced close\");\n if (this.engine)\n this.engine.close();\n }\n /**\n * Alias for close()\n *\n * @private\n */\n disconnect() {\n return this._close();\n }\n /**\n * Called upon engine close.\n *\n * @private\n */\n onclose(reason) {\n this.cleanup();\n this.backoff.reset();\n this._readyState = \"closed\";\n this.emitReserved(\"close\", reason);\n if (this._reconnection && !this.skipReconnect) {\n this.reconnect();\n }\n }\n /**\n * Attempt a reconnection.\n *\n * @private\n */\n reconnect() {\n if (this._reconnecting || this.skipReconnect)\n return this;\n const self = this;\n if (this.backoff.attempts >= this._reconnectionAttempts) {\n this.backoff.reset();\n this.emitReserved(\"reconnect_failed\");\n this._reconnecting = false;\n }\n else {\n const delay = this.backoff.duration();\n this._reconnecting = true;\n const timer = this.setTimeoutFn(() => {\n if (self.skipReconnect)\n return;\n this.emitReserved(\"reconnect_attempt\", self.backoff.attempts);\n // check again for the case socket closed in above events\n if (self.skipReconnect)\n return;\n self.open((err) => {\n if (err) {\n self._reconnecting = false;\n self.reconnect();\n this.emitReserved(\"reconnect_error\", err);\n }\n else {\n self.onreconnect();\n }\n });\n }, delay);\n if (this.opts.autoUnref) {\n timer.unref();\n }\n this.subs.push(function subDestroy() {\n clearTimeout(timer);\n });\n }\n }\n /**\n * Called upon successful reconnect.\n *\n * @private\n */\n onreconnect() {\n const attempt = this.backoff.attempts;\n this._reconnecting = false;\n this.backoff.reset();\n this.emitReserved(\"reconnect\", attempt);\n }\n}\n","import { url } from \"./url.js\";\nimport { Manager } from \"./manager.js\";\nimport { Socket } from \"./socket.js\";\n/**\n * Managers cache.\n */\nconst cache = {};\nfunction lookup(uri, opts) {\n if (typeof uri === \"object\") {\n opts = uri;\n uri = undefined;\n }\n opts = opts || {};\n const parsed = url(uri, opts.path || \"/socket.io\");\n const source = parsed.source;\n const id = parsed.id;\n const path = parsed.path;\n const sameNamespace = cache[id] && path in cache[id][\"nsps\"];\n const newConnection = opts.forceNew ||\n opts[\"force new connection\"] ||\n false === opts.multiplex ||\n sameNamespace;\n let io;\n if (newConnection) {\n io = new Manager(source, opts);\n }\n else {\n if (!cache[id]) {\n cache[id] = new Manager(source, opts);\n }\n io = cache[id];\n }\n if (parsed.query && !opts.query) {\n opts.query = parsed.queryKey;\n }\n return io.socket(parsed.path, opts);\n}\n// so that \"lookup\" can be used both as a function (e.g. `io(...)`) and as a\n// namespace (e.g. `io.connect(...)`), for backward compatibility\nObject.assign(lookup, {\n Manager,\n Socket,\n io: lookup,\n connect: lookup,\n});\n/**\n * Protocol version.\n *\n * @public\n */\nexport { protocol } from \"socket.io-parser\";\n/**\n * Expose constructors for standalone build.\n *\n * @public\n */\nexport { Manager, Socket, lookup as io, lookup as connect, lookup as default, };\n","import parseuri from \"parseuri\";\n/**\n * URL parser.\n *\n * @param uri - url\n * @param path - the request path of the connection\n * @param loc - An object meant to mimic window.location.\n * Defaults to window.location.\n * @public\n */\nexport function url(uri, path = \"\", loc) {\n let obj = uri;\n // default to window.location\n loc = loc || (typeof location !== \"undefined\" && location);\n if (null == uri)\n uri = loc.protocol + \"//\" + loc.host;\n // relative path support\n if (typeof uri === \"string\") {\n if (\"/\" === uri.charAt(0)) {\n if (\"/\" === uri.charAt(1)) {\n uri = loc.protocol + uri;\n }\n else {\n uri = loc.host + uri;\n }\n }\n if (!/^(https?|wss?):\\/\\//.test(uri)) {\n if (\"undefined\" !== typeof loc) {\n uri = loc.protocol + \"//\" + uri;\n }\n else {\n uri = \"https://\" + uri;\n }\n }\n // parse\n obj = parseuri(uri);\n }\n // make sure we treat `localhost:80` and `localhost` equally\n if (!obj.port) {\n if (/^(http|ws)$/.test(obj.protocol)) {\n obj.port = \"80\";\n }\n else if (/^(http|ws)s$/.test(obj.protocol)) {\n obj.port = \"443\";\n }\n }\n obj.path = obj.path || \"/\";\n const ipv6 = obj.host.indexOf(\":\") !== -1;\n const host = ipv6 ? \"[\" + obj.host + \"]\" : obj.host;\n // define unique id\n obj.id = obj.protocol + \"://\" + host + \":\" + obj.port + path;\n // define href\n obj.href =\n obj.protocol +\n \"://\" +\n host +\n (loc && loc.port === obj.port ? \"\" : \":\" + obj.port);\n return obj;\n}\n","/**\n * Contains the routines loaded by the plugin iframe under web-browser\n * in case when worker failed to initialize\n *\n * Initializes the web environment version of the platform-dependent\n * connection object for the plugin site\n */\nimport { connectRPC } from \"./pluginCore.js\";\nimport { RPC, API_VERSION } from \"./rpc.js\";\nimport {\n MessageEmitter,\n randId,\n normalizeConfig,\n loadRequirements\n} from \"./utils.js\";\nimport io from \"socket.io-client\";\n\nexport { setupRPC, waitForInitialization } from \"./main.js\";\nexport { version as VERSION } from \"../package.json\";\nexport { RPC, API_VERSION };\nexport { loadRequirements };\n\nexport class Connection extends MessageEmitter {\n constructor(config) {\n super(config && config.debug);\n this.config = config || {};\n this.peer_id = randId();\n }\n init() {\n return new Promise((resolve, reject) => {\n const config = this.config;\n const url = config.server_url;\n const extraHeaders = {};\n if (config.token) {\n extraHeaders.Authorization = \"Bearer \" + config.token;\n }\n const basePath = new URL(url).pathname;\n // Note: extraHeaders only works for polling transport (the default)\n // If we switch to websocket only, the headers won't be respected\n const socket = io(url, {\n withCredentials: true,\n extraHeaders,\n path:\n (basePath.endsWith(\"/\") ? basePath.slice(0, -1) : basePath) +\n \"/socket.io\"\n });\n let connected = false;\n socket.on(\"connect\", () => {\n if (connected) {\n console.warn(\"Skipping reconnect to the server\");\n return;\n }\n socket.emit(\"register_plugin\", config, result => {\n if (!result.success) {\n console.error(result.detail);\n reject(result.detail);\n return;\n }\n connected = true;\n this.plugin_id = result.plugin_id;\n socket.on(\"plugin_message\", data => {\n if (data.peer_id === this.peer_id) {\n this._fire(data.type, data);\n } else if (this.config.debug) {\n console.log(\n `connection peer id mismatch ${data.peer_id} !== ${this.peer_id}`\n );\n }\n });\n\n this.once(\"initialize\", () => {\n if (!this.rpc) {\n this.rpc = connectRPC(this, config);\n } else {\n this.rpc.once(\"remoteReady\", () => {\n this.rpc.sendInterface();\n });\n }\n this.connect();\n resolve();\n });\n this.emit({\n type: \"imjoyRPCReady\",\n config: config,\n peer_id: this.peer_id\n });\n });\n this._disconnected = false;\n });\n socket.on(\"connect_error\", () => {\n reject(\"connection error\");\n this._fire(\"connectFailure\");\n });\n socket.on(\"disconnect\", () => {\n reject(\"disconnected\");\n this.disconnect();\n this._fire(\"disconnected\");\n });\n this.socket = socket;\n });\n }\n connect() {\n this.emit({\n type: \"initialized\",\n config: this.config,\n origin: globalThis.location.origin,\n peer_id: this.peer_id\n });\n this._fire(\"connected\");\n }\n reset() {\n this._event_handlers = {};\n this._once_handlers = {};\n }\n execute() {\n throw new Error(\"Execution is not allowed for socketio connection\");\n }\n disconnect() {\n this._fire(\"beforeDisconnect\");\n this.socket.disconnect();\n this.init();\n this._fire(\"disconnected\");\n }\n emit(data) {\n data.plugin_id = this.plugin_id;\n this.socket.emit(\"plugin_message\", data, result => {\n if (!result.success) this._fire(\"error\", data.detail);\n });\n }\n}\n\nexport function connectToServer(config) {\n config = config || {};\n if (!config.server_url) throw new Error(\"Server URL is not specified.\");\n config.name = config.name || randId();\n config = normalizeConfig(config);\n return new Promise((resolve, reject) => {\n const handleEvent = e => {\n const api = e.detail;\n if (config.expose_api_globally) {\n globalThis.api = api;\n }\n // imjoy plugin api\n resolve(api);\n globalThis.removeEventListener(\"imjoy_remote_api_ready\", handleEvent);\n };\n globalThis.addEventListener(\"imjoy_remote_api_ready\", handleEvent);\n config = config || {};\n config.dedicated_thread = false;\n config.lang = \"javascript\";\n config.api_version = API_VERSION;\n const conn = new Connection(config);\n conn.init().catch(reject);\n });\n}\n"],"sourceRoot":""}