/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/electron-fetch@1.9.1/lib/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var url=require("url"),http=require("http"),https=require("https"),zlib=require("zlib"),Stream=require("stream"),encoding=require("encoding");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var http__namespace=_interopNamespace(http),https__namespace=_interopNamespace(https),zlib__namespace=_interopNamespace(zlib),Stream__default=_interopDefaultLegacy(Stream);function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function _createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}const BUFFER=Symbol("buffer"),TYPE=Symbol("type"),CLOSED=Symbol("closed");class Blob{constructor(){Object.defineProperty(this,Symbol.toStringTag,{value:"Blob",writable:!1,enumerable:!1,configurable:!0}),this[CLOSED]=!1,this[TYPE]="";const e=arguments[0],t=arguments[1],r=[];if(e){const t=e,o=Number(t.length);for(let e=0;e<o;e++){const o=t[e];let n;n=o instanceof Buffer?o:ArrayBuffer.isView(o)?Buffer.from(new Uint8Array(o.buffer,o.byteOffset,o.byteLength)):o instanceof ArrayBuffer?Buffer.from(new Uint8Array(o)):o instanceof Blob?o[BUFFER]:Buffer.from("string"==typeof o?o:String(o)),r.push(n)}}this[BUFFER]=Buffer.concat(r);const o=t&&void 0!==t.type&&String(t.type).toLowerCase();o&&!/[^\u0020-\u007E]/.test(o)&&(this[TYPE]=o)}get size(){return this[CLOSED]?0:this[BUFFER].length}get type(){return this[TYPE]}get isClosed(){return this[CLOSED]}slice(){const e=this.size,t=arguments[0],r=arguments[1];let o,n;o=void 0===t?0:t<0?Math.max(e+t,0):Math.min(t,e),n=void 0===r?e:r<0?Math.max(e+r,0):Math.min(r,e);const s=Math.max(n-o,0),i=this[BUFFER].slice(o,o+s),a=new Blob([],{type:arguments[2]});return a[BUFFER]=i,a[CLOSED]=this[CLOSED],a}close(){this[CLOSED]=!0}}Object.defineProperty(Blob.prototype,Symbol.toStringTag,{value:"BlobPrototype",writable:!1,enumerable:!1,configurable:!0});const netErrorMap={ERR_CONNECTION_REFUSED:"ECONNREFUSED",ERR_EMPTY_RESPONSE:"ECONNRESET",ERR_NAME_NOT_RESOLVED:"ENOTFOUND",ERR_CONTENT_DECODING_FAILED:"Z_DATA_ERROR",ERR_CONTENT_DECODING_INIT_FAILED:"Z_DATA_ERROR"};function FetchError(e,t,r){Error.call(this,e);const o=/^.*net::(.*)/;if(o.test(e)){let t=o.exec(e)[1];Object.prototype.hasOwnProperty.call(netErrorMap,t)&&(t=netErrorMap[t]),r={code:t}}this.message=e,this.type=t,r&&(this.code=this.errno=r.code),Error.captureStackTrace(this,this.constructor)}FetchError.prototype=Object.create(Error.prototype),FetchError.prototype.constructor=FetchError,FetchError.prototype.name="FetchError";const DISTURBED=Symbol("disturbed");function Body(e,{size:t=0,timeout:r=0}={}){null==e?e=null:"string"==typeof e||e instanceof Blob||Buffer.isBuffer(e)||e instanceof Stream__default.default||(e=String(e)),this.body=e,this[DISTURBED]=!1,this.size=t,this.timeout=r}function consumeBody(){if(this[DISTURBED])return Promise.reject(new Error(`body used already for: ${this.url}`));if(this[DISTURBED]=!0,null===this.body)return Promise.resolve(Buffer.alloc(0));if("string"==typeof this.body)return Promise.resolve(Buffer.from(this.body));if(this.body instanceof Blob)return Promise.resolve(this.body[BUFFER]);if(Buffer.isBuffer(this.body))return Promise.resolve(this.body);if(!(this.body instanceof Stream__default.default))return Promise.resolve(Buffer.alloc(0));const e=[];let t=0,r=!1;return new Promise(((o,n)=>{let s;this.timeout&&(s=setTimeout((()=>{r=!0,n(new FetchError(`Response timeout while trying to fetch ${this.url} (over ${this.timeout}ms)`,"body-timeout")),this.body.emit("cancel-request")}),this.timeout)),this.body.on("error",(e=>{n(new FetchError(`Invalid response body while trying to fetch ${this.url}: ${e.message}`,"system",e))})),this.body.on("data",(o=>{if(!r&&null!==o){if(this.size&&t+o.length>this.size)return r=!0,n(new FetchError(`content size at ${this.url} over limit: ${this.size}`,"max-size")),void this.body.emit("cancel-request");t+=o.length,e.push(o)}})),this.body.on("end",(()=>{r||(clearTimeout(s),o(Buffer.concat(e)))}))}))}function convertBody(e,t){const r=t.get("content-type");let o,n="utf-8";r&&(o=/charset=([^;]*)/i.exec(r));const s=e.slice(0,1024).toString();return!o&&s&&(o=/<meta.+?charset=(['"])(.+?)\1/i.exec(s)),!o&&s&&(o=/<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(s),o&&(o=/charset=(.*)/i.exec(o.pop()))),!o&&s&&(o=/<\?xml.+?encoding=(['"])(.+?)\1/i.exec(s)),o&&(n=o.pop(),"gb2312"!==n&&"gbk"!==n||(n="gb18030")),encoding.convert(e,"UTF-8",n).toString()}function clone(e){let t,r,o=e.body;if(e.bodyUsed)throw new Error("cannot clone body after it is used");return o instanceof Stream__default.default&&"function"!=typeof o.getBoundary&&(t=new Stream.PassThrough,r=new Stream.PassThrough,o.pipe(t),o.pipe(r),e.body=t,o=r),o}function extractContentType(e){const t=e.body;return null===t?null:"string"==typeof t?"text/plain;charset=UTF-8":t instanceof Blob?t.type||null:Buffer.isBuffer(t)?null:"function"==typeof t.getBoundary?`multipart/form-data;boundary=${t.getBoundary()}`:null}function getTotalBytes(e){const t=e.body;return null===t?0:"string"==typeof t?Buffer.byteLength(t):t instanceof Blob?t.size:Buffer.isBuffer(t)?t.length:t&&"function"==typeof t.getLengthSync&&(t._lengthRetrievers&&0===t._lengthRetrievers.length||t.hasKnownLength&&t.hasKnownLength())?t.getLengthSync():null}function writeToStream(e,t){const r=t.body;null===r?e.end():"string"==typeof r?(e.write(r),e.end()):r instanceof Blob?(e.write(r[BUFFER]),e.end()):Buffer.isBuffer(r)?(e.write(r),e.end()):(t.useElectronNet&&(e.chunkedEncoding=t.chunkedEncoding,e.write("")),r.pipe(new Stream.PassThrough).pipe(e))}function isValidTokenChar(e){return e>=94&&e<=122||(e>=65&&e<=90||(45===e||(e>=48&&e<=57||34!==e&&40!==e&&41!==e&&44!==e&&(e>=33&&e<=46||(124===e||126===e)))))}function checkIsHttpToken(e){if("string"!=typeof e||0===e.length)return!1;if(!isValidTokenChar(e.charCodeAt(0)))return!1;const t=e.length;if(t>1){if(!isValidTokenChar(e.charCodeAt(1)))return!1;if(t>2){if(!isValidTokenChar(e.charCodeAt(2)))return!1;if(t>3){if(!isValidTokenChar(e.charCodeAt(3)))return!1;for(let r=4;r<t;r++)if(!isValidTokenChar(e.charCodeAt(r)))return!1}}}return!0}function checkInvalidHeaderChar(e){if((e+="").length<1)return!1;let t=e.charCodeAt(0);if(t<=31&&9!==t||t>255||127===t)return!0;if(e.length<2)return!1;if(t=e.charCodeAt(1),t<=31&&9!==t||t>255||127===t)return!0;if(e.length<3)return!1;if(t=e.charCodeAt(2),t<=31&&9!==t||t>255||127===t)return!0;for(let r=3;r<e.length;++r)if(t=e.charCodeAt(r),t<=31&&9!==t||t>255||127===t)return!0;return!1}function sanitizeName(e){if(!checkIsHttpToken(e+=""))throw new TypeError(`${e} is not a legal HTTP header name`);return e.toLowerCase()}function sanitizeValue(e){if(checkInvalidHeaderChar(e+=""))throw new TypeError(`${e} is not a legal HTTP header value`);return e}Body.prototype={get bodyUsed(){return this[DISTURBED]},arrayBuffer(){return consumeBody.call(this).then((e=>e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)))},blob(){const e=this.headers&&this.headers.get("content-type")||"";return consumeBody.call(this).then((t=>Object.assign(new Blob([],{type:e.toLowerCase()}),{[BUFFER]:t})))},json(){return consumeBody.call(this).then((e=>JSON.parse(e.toString())))},text(){return consumeBody.call(this).then((e=>e.toString()))},buffer(){return consumeBody.call(this)},textConverted(){return consumeBody.call(this).then((e=>convertBody(e,this.headers)))}},Body.mixIn=function(e){for(var t,r=_createForOfIteratorHelperLoose(Object.getOwnPropertyNames(Body.prototype));!(t=r()).done;){const r=t.value;if(!(r in e)){const t=Object.getOwnPropertyDescriptor(Body.prototype,r);Object.defineProperty(e,r,t)}}};const MAP=Symbol("map");class Headers{constructor(e=void 0){if(this[MAP]=Object.create(null),null==e);else{if("object"!=typeof e)throw new TypeError("Provided initializer must be an object");{const a=e[Symbol.iterator];if(null!=a){if("function"!=typeof a)throw new TypeError("Header pairs must be iterable");const s=[];for(var t,r=_createForOfIteratorHelperLoose(e);!(t=r()).done;){const e=t.value;if("object"!=typeof e||"function"!=typeof e[Symbol.iterator])throw new TypeError("Each header pair must be iterable");s.push(Array.from(e))}for(var o=0,n=s;o<n.length;o++){const e=n[o];if(2!==e.length)throw new TypeError("Each header pair must be a name/value tuple");this.append(e[0],e[1])}}else for(var s=0,i=Object.keys(e);s<i.length;s++){const t=i[s],r=e[t];this.append(t,r)}}}Object.defineProperty(this,Symbol.toStringTag,{value:"Headers",writable:!1,enumerable:!1,configurable:!0})}get(e){const t=this[MAP][sanitizeName(e)];return t?t.join(","):null}forEach(e,t=void 0){let r=getHeaderPairs(this),o=0;for(;o<r.length;){const n=r[o],s=n[0],i=n[1];e.call(t,i,s,this),r=getHeaderPairs(this),o++}}set(e,t){this[MAP][sanitizeName(e)]=[sanitizeValue(t)]}append(e,t){this.has(e)?this[MAP][sanitizeName(e)].push(sanitizeValue(t)):this.set(e,t)}has(e){return!!this[MAP][sanitizeName(e)]}delete(e){delete this[MAP][sanitizeName(e)]}raw(){return this[MAP]}keys(){return createHeadersIterator(this,"key")}values(){return createHeadersIterator(this,"value")}[Symbol.iterator](){return createHeadersIterator(this,"key+value")}}function getHeaderPairs(e,t){if("key"===t)return Object.keys(e[MAP]).sort().map((e=>[e]));const r=[];for(var o,n=_createForOfIteratorHelperLoose(Object.keys(e[MAP]).sort());!(o=n()).done;){const t=o.value;for(var s,i=_createForOfIteratorHelperLoose(e[MAP][t]);!(s=i()).done;){const e=s.value;r.push([t,e])}}return r}Headers.prototype.entries=Headers.prototype[Symbol.iterator],Object.defineProperty(Headers.prototype,Symbol.toStringTag,{value:"HeadersPrototype",writable:!1,enumerable:!1,configurable:!0});const INTERNAL=Symbol("internal");function createHeadersIterator(e,t){const r=Object.create(HeadersIteratorPrototype);return r[INTERNAL]={target:e,kind:t,index:0},r}const HeadersIteratorPrototype=Object.setPrototypeOf({next(){if(!this||Object.getPrototypeOf(this)!==HeadersIteratorPrototype)throw new TypeError("Value of `this` is not a HeadersIterator");const e=this[INTERNAL],t=e.target,r=e.kind,o=e.index,n=getHeaderPairs(t,r);if(o>=n.length)return{value:void 0,done:!0};const s=n[o];let i;return this[INTERNAL].index=o+1,i="key"===r?s[0]:"value"===r?s[1]:s,{value:i,done:!1}}},Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));Object.defineProperty(HeadersIteratorPrototype,Symbol.toStringTag,{value:"HeadersIterator",writable:!1,enumerable:!1,configurable:!0});class Response{constructor(e=null,t={}){Body.call(this,e,t),this.url=t.url,this.status=t.status||200,this.statusText=t.statusText||http.STATUS_CODES[this.status],this.headers=new Headers(t.headers),this.useElectronNet=t.useElectronNet,Object.defineProperty(this,Symbol.toStringTag,{value:"Response",writable:!1,enumerable:!1,configurable:!0})}get ok(){return this.status>=200&&this.status<300}clone(){return new Response(clone(this),{url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,useElectronNet:this.useElectronNet})}}Body.mixIn(Response.prototype),Object.defineProperty(Response.prototype,Symbol.toStringTag,{value:"ResponsePrototype",writable:!1,enumerable:!1,configurable:!0});const PARSED_URL=Symbol("url");class Request{constructor(e,t={}){let r;e instanceof Request?r=url.parse(e.url):(r=e&&e.href?url.parse(e.href):url.parse(`${e}`),e={});const o=t.method||e.method||"GET";if((null!=t.body||e instanceof Request&&null!==e.body)&&("GET"===o||"HEAD"===o))throw new TypeError("Request with GET/HEAD method cannot have body");const n=null!=t.body?t.body:e instanceof Request&&null!==e.body?clone(e):null;if(Body.call(this,n,{timeout:t.timeout||e.timeout||0,size:t.size||e.size||0}),this.method=o.toUpperCase(),this.redirect=t.redirect||e.redirect||"follow",this.signal=t.signal||e.signal||null,this.headers=new Headers(t.headers||e.headers||{}),this.headers.delete("Content-Length"),this.chunkedEncoding=!1,this.useElectronNet=void 0!==t.useElectronNet?t.useElectronNet:e.useElectronNet,this.useElectronNet&&!process.versions.electron)throw new Error("Cannot use Electron/net module on Node.js!");if(void 0===this.useElectronNet&&(this.useElectronNet=Boolean(process.versions.electron)),this.useElectronNet&&(this.useSessionCookies=void 0!==t.useSessionCookies?t.useSessionCookies:e.useSessionCookies),null!=t.body){const e=extractContentType(this);null===e||this.headers.has("Content-Type")||this.headers.append("Content-Type",e)}this.follow=void 0!==t.follow?t.follow:void 0!==e.follow?e.follow:20,this.counter=t.counter||e.counter||0,this.session=t.session||e.session,this[PARSED_URL]=r,Object.defineProperty(this,Symbol.toStringTag,{value:"Request",writable:!1,enumerable:!1,configurable:!0})}get url(){return url.format(this[PARSED_URL])}clone(){return new Request(this)}}function getNodeRequestOptions(e){const t=e[PARSED_URL],r=new Headers(e.headers);if(r.has("Accept")||r.set("Accept","*/*"),!t.protocol||!t.hostname)throw new TypeError("Only absolute URLs are supported");if(!/^https?:$/.test(t.protocol))throw new TypeError("Only HTTP(S) protocols are supported");let o=null;if(null==e.body&&/^(POST|PUT)$/i.test(e.method)&&(o="0"),null!=e.body){const t=getTotalBytes(e);"number"==typeof t&&(o=String(t))}return o?e.useElectronNet||r.set("Content-Length",o):e.chunkedEncoding=!0,r.has("User-Agent")||r.set("User-Agent",`electron-fetch/1.0 ${e.useElectronNet?"electron":"node"} (+https://github.com/arantes555/electron-fetch)`),r.set("Accept-Encoding","gzip,deflate"),r.has("Connection")||r.set("Connection","close"),Object.assign({},t,{method:e.method,headers:r.raw()})}let electron;Body.mixIn(Request.prototype),Object.defineProperty(Request.prototype,Symbol.toStringTag,{value:"RequestPrototype",writable:!1,enumerable:!1,configurable:!0}),process.versions.electron&&(electron=require("electron"));const isReady=electron&&electron.app&&!electron.app.isReady()?new Promise((e=>electron.app.once("ready",e))):Promise.resolve();function fetch(e,t={}){return isReady.then((()=>new Promise(((r,o)=>{const n=new Request(e,t),s=getNodeRequestOptions(n),i=n.useElectronNet?electron.net.request:("https:"===s.protocol?https__namespace:http__namespace).request;if(s.headers.host&&(s.headers.host=s.headers.host[0]),n.signal&&n.signal.aborted)return void o(new FetchError("request aborted","abort"));let a;n.useElectronNet?(a=s.headers,delete s.headers,s.session=t.session||electron.session.defaultSession,s.useSessionCookies=n.useSessionCookies):(t.agent&&(s.agent=t.agent),t.onLogin&&o(new Error('"onLogin" option is only supported with "useElectronNet" enabled')));const l=i(s);if(n.useElectronNet)for(const e in a)if("string"==typeof a[e])l.setHeader(e,a[e]);else for(var c,u=_createForOfIteratorHelperLoose(a[e]);!(c=u()).done;){const t=c.value;l.setHeader(e,t)}let h;const d=()=>{n.useElectronNet?l.abort():l.destroy()},f=()=>{const e=new FetchError("request aborted","abort");o(e),d(),l.emit("error",e)};n.signal&&n.signal.addEventListener("abort",f),n.timeout&&(h=setTimeout((()=>{const e=new FetchError(`network timeout at: ${n.url}`,"request-timeout");o(e),d()}),n.timeout)),n.useElectronNet&&l.on("login",((e,r)=>{t.user&&t.password?r(t.user,t.password):t.onLogin?t.onLogin(e).then((e=>{e?r(e.username,e.password):r()})).catch((e=>{d(),o(e)})):(d(),o(new FetchError(`login event received from ${e.host} but no credentials or onLogin handler provided`,"proxy",{code:"PROXY_AUTH_FAILED"})))})),l.on("error",(e=>{clearTimeout(h),n.signal&&n.signal.removeEventListener("abort",f),o(new FetchError(`request to ${n.url} failed, reason: ${e.message}`,"system",e))})),l.on("abort",(()=>{clearTimeout(h),n.signal&&n.signal.removeEventListener("abort",f)})),l.on("response",(e=>{try{if(clearTimeout(h),n.signal&&n.signal.removeEventListener("abort",f),fetch.isRedirect(e.statusCode)&&"manual"!==n.redirect)return"error"===n.redirect?void o(new FetchError(`redirect mode is set to error: ${n.url}`,"no-redirect")):n.counter>=n.follow?void o(new FetchError(`maximum redirect reached at: ${n.url}`,"max-redirect")):e.headers.location?(303!==e.statusCode&&(301!==e.statusCode&&302!==e.statusCode||"POST"!==n.method)||(n.method="GET",n.body=null,n.headers.delete("content-length")),n.counter++,void r(fetch(url.resolve(n.url,e.headers.location),n))):void o(new FetchError(`redirect location header missing at: ${n.url}`,"invalid-redirect"));const l=new Headers;for(var t=0,s=Object.keys(e.headers);t<s.length;t++){const r=s[t];if(Array.isArray(e.headers[r]))for(var i,a=_createForOfIteratorHelperLoose(e.headers[r]);!(i=a()).done;){const e=i.value;l.append(r,e)}else l.append(r,e.headers[r])}"manual"===n.redirect&&l.has("location")&&l.set("location",url.resolve(n.url,l.get("location")));let c=new Stream.PassThrough;e.on("error",(e=>c.emit("error",e))),e.pipe(c),c.on("error",d),c.on("cancel-request",d);const u=()=>{e.destroy(),e.emit("error",new FetchError("request aborted","abort"))};n.signal&&(n.signal.addEventListener("abort",u),e.on("end",(()=>{n.signal.removeEventListener("abort",u)})),e.on("error",(()=>{n.signal.removeEventListener("abort",u)})));const p={url:n.url,status:e.statusCode,statusText:e.statusMessage,headers:l,size:n.size,timeout:n.timeout,useElectronNet:n.useElectronNet,useSessionCookies:n.useSessionCookies},y=l.get("Content-Encoding");if(!n.useElectronNet&&"HEAD"!==n.method&&null!==y&&204!==e.statusCode&&304!==e.statusCode)if("gzip"===y||"x-gzip"===y)c=c.pipe(zlib__namespace.createGunzip());else if("deflate"===y||"x-deflate"===y){return e.pipe(new Stream.PassThrough).once("data",(e=>{c=8==(15&e[0])?c.pipe(zlib__namespace.createInflate()):c.pipe(zlib__namespace.createInflateRaw());const t=new Response(c,p);r(t)}))}const b=new Response(c,p);r(b)}catch(e){o(new FetchError(`Invalid response: ${e.message}`,"invalid-response")),d()}})),writeToStream(l,n)}))))}fetch.isRedirect=e=>301===e||302===e||303===e||307===e||308===e,exports.FetchError=FetchError,exports.Headers=Headers,exports.Request=Request,exports.Response=Response,exports.default=fetch;
//# sourceMappingURL=/sm/7f6bad2af0ed0807d5607c35d3f8577a505e0bb24e8e3883ffce144c527dbb27.map