@wikha/sdk 1.1.14 → 1.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -2
- package/dist/src/sdk.d.ts +1 -1
- package/dist/src/sdk.js +23 -19
- package/dist/wikha-sdk.umd.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -45,10 +45,20 @@ async function initiatePayment() {
|
|
|
45
45
|
payer_name: 'John Tshisola',
|
|
46
46
|
operation: WikhaSDK.PaymentType.payin,
|
|
47
47
|
currency: 'CDF',
|
|
48
|
-
notify_url: '[https://your-callback-url.com/notify](https://
|
|
49
|
-
return_url: '[https://your-website.com/success](https://
|
|
48
|
+
notify_url: '[https://your-callback-url.com/notify](https://your-callback-url.com/notify)',
|
|
49
|
+
return_url: '[https://your-website.com/success](https://your-website.com/success)',
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Note on Notifications (Webhooks):
|
|
54
|
+
* 1. The API supports `notify_url` or `notifyUrl`.
|
|
55
|
+
* 2. If provided in the payload, this URL will be used for webhooks.
|
|
56
|
+
* 3. NEW: If NOT provided, the API will fall back to the merchant's default notify_url
|
|
57
|
+
* configured in the Wikha Dashboard.
|
|
58
|
+
* 4. The webhook includes an 'X-Wikha-Signature' header (HMAC-SHA256) signed
|
|
59
|
+
* with your API Key.
|
|
60
|
+
*/
|
|
61
|
+
|
|
52
62
|
try {
|
|
53
63
|
const response = await sdk.processPayment(paymentData);
|
|
54
64
|
console.log('Payment initiated successfully:', response);
|
|
@@ -61,6 +71,36 @@ async function initiatePayment() {
|
|
|
61
71
|
|
|
62
72
|
initiatePayment();
|
|
63
73
|
```
|
|
74
|
+
|
|
75
|
+
## Processing a Payout (Withdrawal)
|
|
76
|
+
|
|
77
|
+
```TypeScript
|
|
78
|
+
import { WikhaSDK } from '@wikha/sdk';
|
|
79
|
+
|
|
80
|
+
const sdk = new WikhaSDK('YOUR_API_KEY', 'YOUR_MERCHANT_ID');
|
|
81
|
+
|
|
82
|
+
async function initiatePayout() {
|
|
83
|
+
const payoutData: WikhaSDK.WikhaPayload = {
|
|
84
|
+
provider: WikhaSDK.PaymentProviderType.mpesa,
|
|
85
|
+
payer_phone: '081XXXXXXX',
|
|
86
|
+
order_id: 'WITHDRAW-789',
|
|
87
|
+
amount: 50,
|
|
88
|
+
payer_name: 'Jane Doe',
|
|
89
|
+
operation: WikhaSDK.PaymentType.payout, // Mandatory for withdrawals
|
|
90
|
+
currency: 'USD',
|
|
91
|
+
notify_url: 'https://your-callback-url.com/payout-notify', // Highly recommended for async updates
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
const response = await sdk.processPayment(payoutData);
|
|
96
|
+
console.log('Payout initiated:', response);
|
|
97
|
+
} catch (error: any) {
|
|
98
|
+
console.error('Payout failed:', error.message);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
initiatePayout();
|
|
103
|
+
```
|
|
64
104
|
# Query transaction status
|
|
65
105
|
|
|
66
106
|
```typescript
|
package/dist/src/sdk.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const PAY_ENDPOINT = "https://api.wikha-hitech.com/v2";
|
|
1
|
+
export declare const PAY_ENDPOINT = "https://api.wikha-hitech.com/v2/payments";
|
|
2
2
|
export declare const TRANSACTION_QUERY_ENDPOINT = "https://api.wikha-hitech.com/v2/query";
|
|
3
3
|
export declare enum PaymentProviderType {
|
|
4
4
|
mpesa = "mpesa",
|
package/dist/src/sdk.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.WikhaSDK = exports.Environment = exports.MerchantStatus = exports.PaymentAggregatorType = exports.PaymentStatus = exports.PaymentType = exports.PaymentProviderType = exports.TRANSACTION_QUERY_ENDPOINT = exports.PAY_ENDPOINT = void 0;
|
|
5
5
|
// Constants
|
|
6
|
-
exports.PAY_ENDPOINT = "https://api.wikha-hitech.com/v2";
|
|
6
|
+
exports.PAY_ENDPOINT = "https://api.wikha-hitech.com/v2/payments";
|
|
7
7
|
exports.TRANSACTION_QUERY_ENDPOINT = "https://api.wikha-hitech.com/v2/query";
|
|
8
|
-
const isNode = typeof window ===
|
|
8
|
+
const isNode = typeof window === "undefined" && typeof process !== "undefined";
|
|
9
9
|
// Interfaces & Enums
|
|
10
10
|
var PaymentProviderType;
|
|
11
11
|
(function (PaymentProviderType) {
|
|
@@ -54,14 +54,14 @@ class WikhaSDK {
|
|
|
54
54
|
this.publicKey = publicKey || null;
|
|
55
55
|
}
|
|
56
56
|
getFetch() {
|
|
57
|
-
if (typeof globalThis.fetch ===
|
|
57
|
+
if (typeof globalThis.fetch === "function") {
|
|
58
58
|
return globalThis.fetch;
|
|
59
59
|
}
|
|
60
60
|
if (isNode) {
|
|
61
61
|
try {
|
|
62
62
|
// Use eval('require') to evade webpack/esbuild statically evaluating node-fetch for browsers
|
|
63
|
-
const req = eval(
|
|
64
|
-
return req(
|
|
63
|
+
const req = eval("require");
|
|
64
|
+
return req("node-fetch");
|
|
65
65
|
}
|
|
66
66
|
catch (e) {
|
|
67
67
|
console.warn("Native fetch not found and 'node-fetch' not installed.");
|
|
@@ -73,9 +73,11 @@ class WikhaSDK {
|
|
|
73
73
|
console.log("[WikhaSDK] Fetching public key from server...");
|
|
74
74
|
const myFetch = this.getFetch();
|
|
75
75
|
try {
|
|
76
|
-
const
|
|
76
|
+
const url = new URL(`${exports.PAY_ENDPOINT}/pk`);
|
|
77
|
+
url.searchParams.append("merchant_id", this.merchantId);
|
|
78
|
+
const response = await myFetch(url.toString(), {
|
|
77
79
|
method: "GET",
|
|
78
|
-
headers: {
|
|
80
|
+
headers: { Authorization: `Bearer ${this.apiKey}` },
|
|
79
81
|
});
|
|
80
82
|
if (!response.ok) {
|
|
81
83
|
throw new Error(`Failed to fetch public key: ${response.statusText}`);
|
|
@@ -95,17 +97,20 @@ class WikhaSDK {
|
|
|
95
97
|
if (!this.publicKey) {
|
|
96
98
|
await this.fetchPublicKey();
|
|
97
99
|
}
|
|
98
|
-
const dataString = JSON.stringify({
|
|
100
|
+
const dataString = JSON.stringify({
|
|
101
|
+
...data,
|
|
102
|
+
merchant_id: this.merchantId,
|
|
103
|
+
});
|
|
99
104
|
if (isNode) {
|
|
100
|
-
const req = eval(
|
|
101
|
-
const crypto = req(
|
|
105
|
+
const req = eval("require");
|
|
106
|
+
const crypto = req("crypto");
|
|
102
107
|
try {
|
|
103
108
|
const encrypted = crypto.publicEncrypt({
|
|
104
109
|
key: this.publicKey,
|
|
105
110
|
padding: crypto.constants.RSA_PKCS1_OAEP_PADDING,
|
|
106
|
-
oaepHash:
|
|
107
|
-
}, Buffer.from(dataString,
|
|
108
|
-
return encrypted.toString(
|
|
111
|
+
oaepHash: "SHA256",
|
|
112
|
+
}, Buffer.from(dataString, "utf-8"));
|
|
113
|
+
return encrypted.toString("base64");
|
|
109
114
|
}
|
|
110
115
|
catch (e) {
|
|
111
116
|
console.error("Encryption failed (Node.js legacy mode):", e);
|
|
@@ -117,8 +122,7 @@ class WikhaSDK {
|
|
|
117
122
|
try {
|
|
118
123
|
const pemHeader = "-----BEGIN PUBLIC KEY-----";
|
|
119
124
|
const pemFooter = "-----END PUBLIC KEY-----";
|
|
120
|
-
const pemContents = this.publicKey
|
|
121
|
-
.replace(pemHeader, "")
|
|
125
|
+
const pemContents = this.publicKey.replace(pemHeader, "")
|
|
122
126
|
.replace(pemFooter, "")
|
|
123
127
|
.replace(/\s/g, "");
|
|
124
128
|
const binaryDer = atob(pemContents);
|
|
@@ -145,10 +149,10 @@ class WikhaSDK {
|
|
|
145
149
|
const encryptedData = await this.encryptData(paymentData);
|
|
146
150
|
const myFetch = this.getFetch();
|
|
147
151
|
const response = await myFetch(exports.PAY_ENDPOINT, {
|
|
148
|
-
method:
|
|
152
|
+
method: "POST",
|
|
149
153
|
headers: {
|
|
150
154
|
Authorization: `Bearer ${this.apiKey}`,
|
|
151
|
-
|
|
155
|
+
"Content-Type": "application/json",
|
|
152
156
|
},
|
|
153
157
|
body: JSON.stringify({
|
|
154
158
|
encryptedData,
|
|
@@ -173,10 +177,10 @@ class WikhaSDK {
|
|
|
173
177
|
url.searchParams.append("merchant_id", this.merchantId);
|
|
174
178
|
url.searchParams.append("transaction_id", transactionId);
|
|
175
179
|
const response = await myFetch(url.toString(), {
|
|
176
|
-
method:
|
|
180
|
+
method: "GET",
|
|
177
181
|
headers: {
|
|
178
182
|
Authorization: `Bearer ${this.apiKey}`,
|
|
179
|
-
|
|
183
|
+
"Content-Type": "application/json",
|
|
180
184
|
},
|
|
181
185
|
});
|
|
182
186
|
if (!response.ok) {
|
package/dist/wikha-sdk.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see wikha-sdk.umd.js.LICENSE.txt */
|
|
2
|
-
!function webpackUniversalModuleDefinition(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.wikha=e():t.wikha=e()}(this,(()=>(()=>{var __webpack_modules__={73:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(504),e)},251:(t,e)=>{e.read=function(t,e,r,n,o){var i,f,u=8*o-n-1,s=(1<<u)-1,a=s>>1,c=-7,h=r?o-1:0,p=r?-1:1,l=t[e+h];for(h+=p,i=l&(1<<-c)-1,l>>=-c,c+=u;c>0;i=256*i+t[e+h],h+=p,c-=8);for(f=i&(1<<-c)-1,i>>=-c,c+=n;c>0;f=256*f+t[e+h],h+=p,c-=8);if(0===i)i=1-a;else{if(i===s)return f?NaN:1/0*(l?-1:1);f+=Math.pow(2,n),i-=a}return(l?-1:1)*f*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var f,u,s,a=8*i-o-1,c=(1<<a)-1,h=c>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:i-1,y=n?1:-1,d=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,f=c):(f=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-f))<1&&(f--,s*=2),(e+=f+h>=1?p/s:p*Math.pow(2,1-h))*s>=2&&(f++,s/=2),f+h>=c?(u=0,f=c):f+h>=1?(u=(e*s-1)*Math.pow(2,o),f+=h):(u=e*Math.pow(2,h-1)*Math.pow(2,o),f=0));o>=8;t[r+l]=255&u,l+=y,u/=256,o-=8);for(f=f<<o|u,a+=o;a>0;t[r+l]=255&f,l+=y,f/=256,a-=8);t[r+l-y]|=128*d}},504:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";var process=__webpack_require__(606),Buffer=__webpack_require__(922).hp;Object.defineProperty(exports,"__esModule",{value:!0}),exports.WikhaSDK=exports.Environment=exports.MerchantStatus=exports.PaymentAggregatorType=exports.PaymentStatus=exports.PaymentType=exports.PaymentProviderType=exports.TRANSACTION_QUERY_ENDPOINT=exports.PAY_ENDPOINT=void 0,exports.PAY_ENDPOINT="https://api.wikha-hitech.com/v2",exports.TRANSACTION_QUERY_ENDPOINT="https://api.wikha-hitech.com/v2/query";const isNode="undefined"==typeof window&&void 0!==process;var PaymentProviderType,PaymentType,PaymentStatus,PaymentAggregatorType,MerchantStatus,Environment;!function(t){t.mpesa="mpesa",t.orangemoney="orangemoney",t.afrimoney="afrimoney",t.airtelmoney="airtelmoney",t.paypal="paypal",t.braintree="braintree"}(PaymentProviderType||(exports.PaymentProviderType=PaymentProviderType={})),function(t){t.payin="payin",t.payout="payout",t.transfert="transfert"}(PaymentType||(exports.PaymentType=PaymentType={})),function(t){t.accepted="accepted",t.rejected="rejected",t.pending="pending",t.canceled="canceled"}(PaymentStatus||(exports.PaymentStatus=PaymentStatus={})),function(t){t.unipesa="unipesa",t.direct="direct",t.ligdicash="ligdicash",t.paypal="bank",t.pawapay="pawapay"}(PaymentAggregatorType||(exports.PaymentAggregatorType=PaymentAggregatorType={})),function(t){t.active="active",t.inactive="inactive"}(MerchantStatus||(exports.MerchantStatus=MerchantStatus={})),function(t){t.sandbox="sandbox",t.production="production"}(Environment||(exports.Environment=Environment={}));class WikhaSDK{constructor(t,e,r){this.apiKey=t,this.merchantId=e,this.publicKey=r||null}getFetch(){if("function"==typeof globalThis.fetch)return globalThis.fetch;if(isNode)try{const req=eval("require");return req("node-fetch")}catch(t){console.warn("Native fetch not found and 'node-fetch' not installed.")}throw new Error("Fetch API not found. Please use Node.js 18+ or install 'node-fetch'.")}async fetchPublicKey(){console.log("[WikhaSDK] Fetching public key from server...");const t=this.getFetch();try{const e=await t(`${exports.PAY_ENDPOINT}/pk`,{method:"GET",headers:{Authorization:`Bearer ${this.apiKey}`}});if(!e.ok)throw new Error(`Failed to fetch public key: ${e.statusText}`);const r=await e.json();if(!r.publicKey)throw new Error("Public key not present in response");return this.publicKey=r.publicKey,r.publicKey}catch(t){throw console.error("[WikhaSDK] Error fetching public key:",t),t}}async encryptData(data){this.publicKey||await this.fetchPublicKey();const dataString=JSON.stringify({...data,merchant_id:this.merchantId});if(isNode){const req=eval("require"),crypto=req("crypto");try{const t=crypto.publicEncrypt({key:this.publicKey,padding:crypto.constants.RSA_PKCS1_OAEP_PADDING,oaepHash:"SHA256"},Buffer.from(dataString,"utf-8"));return t.toString("base64")}catch(t){throw console.error("Encryption failed (Node.js legacy mode):",t),t}}else{const t=window.crypto;try{const e="-----BEGIN PUBLIC KEY-----",r="-----END PUBLIC KEY-----",n=this.publicKey.replace(e,"").replace(r,"").replace(/\s/g,""),o=atob(n),i=new Uint8Array(o.length);for(let t=0;t<o.length;t++)i[t]=o.charCodeAt(t);const f=await t.subtle.importKey("spki",i.buffer,{name:"RSA-OAEP",hash:"SHA-256"},!1,["encrypt"]),u=(new TextEncoder).encode(dataString),s=await t.subtle.encrypt({name:"RSA-OAEP"},f,u);return btoa(String.fromCharCode(...new Uint8Array(s)))}catch(t){throw console.error("Encryption failed (Browser mode):",t),t}}}async processPayment(t){try{const e=await this.encryptData(t),r=this.getFetch(),n=await r(exports.PAY_ENDPOINT,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({encryptedData:e,merchant_id:this.merchantId})});if(!n.ok){const t=await n.text();throw new Error(`HTTP error! status: ${n.status}, body: ${t}`)}return await n.json()}catch(t){throw console.error("Error processing payment:",t),t}}async queryTransaction(t){try{const e=this.getFetch(),r=new URL(exports.TRANSACTION_QUERY_ENDPOINT);r.searchParams.append("merchant_id",this.merchantId),r.searchParams.append("transaction_id",t);const n=await e(r.toString(),{method:"GET",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}});if(!n.ok){const t=await n.text();throw new Error(`HTTP error! status: ${n.status}, body: ${t}`)}return await n.json()}catch(t){throw console.error("Error querying transaction:",t),t}}}exports.WikhaSDK=WikhaSDK},526:(t,e)=>{"use strict";e.byteLength=function byteLength(t){var e=getLens(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function toByteArray(t){var e,r,i=getLens(t),f=i[0],u=i[1],s=new o(function _byteLength(t,e,r){return 3*(e+r)/4-r}(0,f,u)),a=0,c=u>0?f-4:f;for(r=0;r<c;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,s[a++]=255&e);1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e);return s},e.fromByteArray=function fromByteArray(t){for(var e,n=t.length,o=n%3,i=[],f=16383,u=0,s=n-o;u<s;u+=f)i.push(encodeChunk(t,u,u+f>s?s:u+f));1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return i.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0;f<64;++f)r[f]=i[f],n[i.charCodeAt(f)]=f;function getLens(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function encodeChunk(t,e,n){for(var o,i,f=[],u=e;u<n;u+=3)o=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(255&t[u+2]),f.push(r[(i=o)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return f.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},606:t=>{var e,r,n=t.exports={};function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(t){if(e===setTimeout)return setTimeout(t,0);if((e===defaultSetTimout||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(r){try{return e.call(null,t,0)}catch(r){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(t){e=defaultSetTimout}try{r="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(t){r=defaultClearTimeout}}();var o,i=[],f=!1,u=-1;function cleanUpNextTick(){f&&o&&(f=!1,o.length?i=o.concat(i):u=-1,i.length&&drainQueue())}function drainQueue(){if(!f){var t=runTimeout(cleanUpNextTick);f=!0;for(var e=i.length;e;){for(o=i,i=[];++u<e;)o&&o[u].run();u=-1,e=i.length}o=null,f=!1,function runClearTimeout(t){if(r===clearTimeout)return clearTimeout(t);if((r===defaultClearTimeout||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{return r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function Item(t,e){this.fun=t,this.array=e}function noop(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];i.push(new Item(t,e)),1!==i.length||f||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=noop,n.addListener=noop,n.once=noop,n.off=noop,n.removeListener=noop,n.removeAllListeners=noop,n.emit=noop,n.prependListener=noop,n.prependOnceListener=noop,n.listeners=function(t){return[]},n.binding=function(t){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},922:(t,e,r)=>{"use strict";const n=r(526),o=r(251),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.hp=Buffer,e.IS=50;const f=2147483647;function createBuffer(t){if(t>f)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,Buffer.prototype),e}function Buffer(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(t)}return from(t,e,r)}function from(t,e,r){if("string"==typeof t)return function fromString(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!Buffer.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|byteLength(t,e);let n=createBuffer(r);const o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return function fromArrayView(t){if(isInstance(t,Uint8Array)){const e=new Uint8Array(t);return fromArrayBuffer(e.buffer,e.byteOffset,e.byteLength)}return fromArrayLike(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(isInstance(t,ArrayBuffer)||t&&isInstance(t.buffer,ArrayBuffer))return fromArrayBuffer(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(isInstance(t,SharedArrayBuffer)||t&&isInstance(t.buffer,SharedArrayBuffer)))return fromArrayBuffer(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return Buffer.from(n,e,r);const o=function fromObject(t){if(Buffer.isBuffer(t)){const e=0|checked(t.length),r=createBuffer(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return"number"!=typeof t.length||numberIsNaN(t.length)?createBuffer(0):fromArrayLike(t);if("Buffer"===t.type&&Array.isArray(t.data))return fromArrayLike(t.data)}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return Buffer.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function assertSize(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function allocUnsafe(t){return assertSize(t),createBuffer(t<0?0:0|checked(t))}function fromArrayLike(t){const e=t.length<0?0:0|checked(t.length),r=createBuffer(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function fromArrayBuffer(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,Buffer.prototype),n}function checked(t){if(t>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return 0|t}function byteLength(t,e){if(Buffer.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||isInstance(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return utf8ToBytes(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(t).length;default:if(o)return n?-1:utf8ToBytes(t).length;e=(""+e).toLowerCase(),o=!0}}function slowToString(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return hexSlice(this,e,r);case"utf8":case"utf-8":return utf8Slice(this,e,r);case"ascii":return asciiSlice(this,e,r);case"latin1":case"binary":return latin1Slice(this,e,r);case"base64":return base64Slice(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function swap(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function bidirectionalIndexOf(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),numberIsNaN(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=Buffer.from(e,n)),Buffer.isBuffer(e))return 0===e.length?-1:arrayIndexOf(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):arrayIndexOf(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(t,e,r,n,o){let i,f=1,u=t.length,s=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;f=2,u/=2,s/=2,r/=2}function read(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(o){let n=-1;for(i=r;i<u;i++)if(read(t,i)===read(e,-1===n?0:i-n)){if(-1===n&&(n=i),i-n+1===s)return n*f}else-1!==n&&(i-=i-n),n=-1}else for(r+s>u&&(r=u-s),i=r;i>=0;i--){let r=!0;for(let n=0;n<s;n++)if(read(t,i+n)!==read(e,n)){r=!1;break}if(r)return i}return-1}function hexWrite(t,e,r,n){r=Number(r)||0;const o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;const i=e.length;let f;for(n>i/2&&(n=i/2),f=0;f<n;++f){const n=parseInt(e.substr(2*f,2),16);if(numberIsNaN(n))return f;t[r+f]=n}return f}function utf8Write(t,e,r,n){return blitBuffer(utf8ToBytes(e,t.length-r),t,r,n)}function asciiWrite(t,e,r,n){return blitBuffer(function asciiToBytes(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function base64Write(t,e,r,n){return blitBuffer(base64ToBytes(e),t,r,n)}function ucs2Write(t,e,r,n){return blitBuffer(function utf16leToBytes(t,e){let r,n,o;const i=[];for(let f=0;f<t.length&&!((e-=2)<0);++f)r=t.charCodeAt(f),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function base64Slice(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function utf8Slice(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o<r;){const e=t[o];let i=null,f=e>239?4:e>223?3:e>191?2:1;if(o+f<=r){let r,n,u,s;switch(f){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(s=(31&e)<<6|63&r,s>127&&(i=s));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(s=(15&e)<<12|(63&r)<<6|63&n,s>2047&&(s<55296||s>57343)&&(i=s));break;case 4:r=t[o+1],n=t[o+2],u=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&u)&&(s=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&u,s>65535&&s<1114112&&(i=s))}}null===i?(i=65533,f=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=f}return function decodeCodePointsArray(t){const e=t.length;if(e<=u)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=u));return r}(n)}Buffer.TYPED_ARRAY_SUPPORT=function typedArraySupport(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),Buffer.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(Buffer.prototype,"parent",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.buffer}}),Object.defineProperty(Buffer.prototype,"offset",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.byteOffset}}),Buffer.poolSize=8192,Buffer.from=function(t,e,r){return from(t,e,r)},Object.setPrototypeOf(Buffer.prototype,Uint8Array.prototype),Object.setPrototypeOf(Buffer,Uint8Array),Buffer.alloc=function(t,e,r){return function alloc(t,e,r){return assertSize(t),t<=0?createBuffer(t):void 0!==e?"string"==typeof r?createBuffer(t).fill(e,r):createBuffer(t).fill(e):createBuffer(t)}(t,e,r)},Buffer.allocUnsafe=function(t){return allocUnsafe(t)},Buffer.allocUnsafeSlow=function(t){return allocUnsafe(t)},Buffer.isBuffer=function isBuffer(t){return null!=t&&!0===t._isBuffer&&t!==Buffer.prototype},Buffer.compare=function compare(t,e){if(isInstance(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(t)||!Buffer.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},Buffer.isEncoding=function isEncoding(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function concat(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return Buffer.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=Buffer.allocUnsafe(e);let o=0;for(r=0;r<t.length;++r){let e=t[r];if(isInstance(e,Uint8Array))o+e.length>n.length?(Buffer.isBuffer(e)||(e=Buffer.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!Buffer.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function swap16(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)swap(this,e,e+1);return this},Buffer.prototype.swap32=function swap32(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)swap(this,e,e+3),swap(this,e+1,e+2);return this},Buffer.prototype.swap64=function swap64(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)swap(this,e,e+7),swap(this,e+1,e+6),swap(this,e+2,e+5),swap(this,e+3,e+4);return this},Buffer.prototype.toString=function toString(){const t=this.length;return 0===t?"":0===arguments.length?utf8Slice(this,0,t):slowToString.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function equals(t){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Buffer.compare(this,t)},Buffer.prototype.inspect=function inspect(){let t="";const r=e.IS;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},i&&(Buffer.prototype[i]=Buffer.prototype.inspect),Buffer.prototype.compare=function compare(t,e,r,n,o){if(isInstance(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),f=(r>>>=0)-(e>>>=0);const u=Math.min(i,f),s=this.slice(n,o),a=t.slice(e,r);for(let t=0;t<u;++t)if(s[t]!==a[t]){i=s[t],f=a[t];break}return i<f?-1:f<i?1:0},Buffer.prototype.includes=function includes(t,e,r){return-1!==this.indexOf(t,e,r)},Buffer.prototype.indexOf=function indexOf(t,e,r){return bidirectionalIndexOf(this,t,e,r,!0)},Buffer.prototype.lastIndexOf=function lastIndexOf(t,e,r){return bidirectionalIndexOf(this,t,e,r,!1)},Buffer.prototype.write=function write(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return hexWrite(this,t,e,r);case"utf8":case"utf-8":return utf8Write(this,t,e,r);case"ascii":case"latin1":case"binary":return asciiWrite(this,t,e,r);case"base64":return base64Write(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const u=4096;function asciiSlice(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function latin1Slice(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function hexSlice(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let o="";for(let n=e;n<r;++n)o+=c[t[n]];return o}function utf16leSlice(t,e,r){const n=t.slice(e,r);let o="";for(let t=0;t<n.length-1;t+=2)o+=String.fromCharCode(n[t]+256*n[t+1]);return o}function checkOffset(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function checkInt(t,e,r,n,o,i){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function wrtBigUInt64LE(t,e,r,n,o){checkIntBI(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,r}function wrtBigUInt64BE(t,e,r,n,o){checkIntBI(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=f,f>>=8,t[r+2]=f,f>>=8,t[r+1]=f,f>>=8,t[r]=f,r+8}function checkIEEE754(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(t,e,r,n,i){return e=+e,r>>>=0,i||checkIEEE754(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function writeDouble(t,e,r,n,i){return e=+e,r>>>=0,i||checkIEEE754(t,0,r,8),o.write(t,e,r,n,52,8),r+8}Buffer.prototype.slice=function slice(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,Buffer.prototype),n},Buffer.prototype.readUintLE=Buffer.prototype.readUIntLE=function readUIntLE(t,e,r){t>>>=0,e>>>=0,r||checkOffset(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return n},Buffer.prototype.readUintBE=Buffer.prototype.readUIntBE=function readUIntBE(t,e,r){t>>>=0,e>>>=0,r||checkOffset(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},Buffer.prototype.readUint8=Buffer.prototype.readUInt8=function readUInt8(t,e){return t>>>=0,e||checkOffset(t,1,this.length),this[t]},Buffer.prototype.readUint16LE=Buffer.prototype.readUInt16LE=function readUInt16LE(t,e){return t>>>=0,e||checkOffset(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUint16BE=Buffer.prototype.readUInt16BE=function readUInt16BE(t,e){return t>>>=0,e||checkOffset(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUint32LE=Buffer.prototype.readUInt32LE=function readUInt32LE(t,e){return t>>>=0,e||checkOffset(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUint32BE=Buffer.prototype.readUInt32BE=function readUInt32BE(t,e){return t>>>=0,e||checkOffset(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readBigUInt64LE=defineBigIntMethod((function readBigUInt64LE(t){validateNumber(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||boundsError(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))})),Buffer.prototype.readBigUInt64BE=defineBigIntMethod((function readBigUInt64BE(t){validateNumber(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||boundsError(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(o)})),Buffer.prototype.readIntLE=function readIntLE(t,e,r){t>>>=0,e>>>=0,r||checkOffset(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*e)),n},Buffer.prototype.readIntBE=function readIntBE(t,e,r){t>>>=0,e>>>=0,r||checkOffset(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},Buffer.prototype.readInt8=function readInt8(t,e){return t>>>=0,e||checkOffset(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Buffer.prototype.readInt16LE=function readInt16LE(t,e){t>>>=0,e||checkOffset(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function readInt16BE(t,e){t>>>=0,e||checkOffset(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function readInt32LE(t,e){return t>>>=0,e||checkOffset(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function readInt32BE(t,e){return t>>>=0,e||checkOffset(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readBigInt64LE=defineBigIntMethod((function readBigInt64LE(t){validateNumber(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||boundsError(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),Buffer.prototype.readBigInt64BE=defineBigIntMethod((function readBigInt64BE(t){validateNumber(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||boundsError(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),Buffer.prototype.readFloatLE=function readFloatLE(t,e){return t>>>=0,e||checkOffset(t,4,this.length),o.read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function readFloatBE(t,e){return t>>>=0,e||checkOffset(t,4,this.length),o.read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function readDoubleLE(t,e){return t>>>=0,e||checkOffset(t,8,this.length),o.read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function readDoubleBE(t,e){return t>>>=0,e||checkOffset(t,8,this.length),o.read(this,t,!1,52,8)},Buffer.prototype.writeUintLE=Buffer.prototype.writeUIntLE=function writeUIntLE(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){checkInt(this,t,e,r,Math.pow(2,8*r)-1,0)}let o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},Buffer.prototype.writeUintBE=Buffer.prototype.writeUIntBE=function writeUIntBE(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){checkInt(this,t,e,r,Math.pow(2,8*r)-1,0)}let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},Buffer.prototype.writeUint8=Buffer.prototype.writeUInt8=function writeUInt8(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,1,255,0),this[e]=255&t,e+1},Buffer.prototype.writeUint16LE=Buffer.prototype.writeUInt16LE=function writeUInt16LE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeUint16BE=Buffer.prototype.writeUInt16BE=function writeUInt16BE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeUint32LE=Buffer.prototype.writeUInt32LE=function writeUInt32LE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},Buffer.prototype.writeUint32BE=Buffer.prototype.writeUInt32BE=function writeUInt32BE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeBigUInt64LE=defineBigIntMethod((function writeBigUInt64LE(t,e=0){return wrtBigUInt64LE(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),Buffer.prototype.writeBigUInt64BE=defineBigIntMethod((function writeBigUInt64BE(t,e=0){return wrtBigUInt64BE(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),Buffer.prototype.writeIntLE=function writeIntLE(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);checkInt(this,t,e,r,n-1,-n)}let o=0,i=1,f=0;for(this[e]=255&t;++o<r&&(i*=256);)t<0&&0===f&&0!==this[e+o-1]&&(f=1),this[e+o]=(t/i|0)-f&255;return e+r},Buffer.prototype.writeIntBE=function writeIntBE(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);checkInt(this,t,e,r,n-1,-n)}let o=r-1,i=1,f=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===f&&0!==this[e+o+1]&&(f=1),this[e+o]=(t/i|0)-f&255;return e+r},Buffer.prototype.writeInt8=function writeInt8(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},Buffer.prototype.writeInt16LE=function writeInt16LE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeInt16BE=function writeInt16BE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeInt32LE=function writeInt32LE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},Buffer.prototype.writeInt32BE=function writeInt32BE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeBigInt64LE=defineBigIntMethod((function writeBigInt64LE(t,e=0){return wrtBigUInt64LE(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),Buffer.prototype.writeBigInt64BE=defineBigIntMethod((function writeBigInt64BE(t,e=0){return wrtBigUInt64BE(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),Buffer.prototype.writeFloatLE=function writeFloatLE(t,e,r){return writeFloat(this,t,e,!0,r)},Buffer.prototype.writeFloatBE=function writeFloatBE(t,e,r){return writeFloat(this,t,e,!1,r)},Buffer.prototype.writeDoubleLE=function writeDoubleLE(t,e,r){return writeDouble(this,t,e,!0,r)},Buffer.prototype.writeDoubleBE=function writeDoubleBE(t,e,r){return writeDouble(this,t,e,!1,r)},Buffer.prototype.copy=function copy(t,e,r,n){if(!Buffer.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const o=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),o},Buffer.prototype.fill=function fill(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{const i=Buffer.isBuffer(t)?t:Buffer.from(t,n),f=i.length;if(0===f)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=i[o%f]}return this};const s={};function E(t,e,r){s[t]=class NodeError extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function addNumericalSeparator(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function checkIntBI(t,e,r,n,o,i){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let o;throw o=i>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new s.ERR_OUT_OF_RANGE("value",o,t)}!function checkBounds(t,e,r){validateNumber(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||boundsError(e,t.length-(r+1))}(n,o,i)}function validateNumber(t,e){if("number"!=typeof t)throw new s.ERR_INVALID_ARG_TYPE(e,"number",t)}function boundsError(t,e,r){if(Math.floor(t)!==t)throw validateNumber(t,r),new s.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new s.ERR_BUFFER_OUT_OF_BOUNDS;throw new s.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}E("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),E("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),E("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=addNumericalSeparator(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=addNumericalSeparator(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const a=/[^+/0-9A-Za-z-_]/g;function utf8ToBytes(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let f=0;f<n;++f){if(r=t.charCodeAt(f),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function base64ToBytes(t){return n.toByteArray(function base64clean(t){if((t=(t=t.split("=")[0]).trim().replace(a,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function blitBuffer(t,e,r,n){let o;for(o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function isInstance(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function numberIsNaN(t){return t!=t}const c=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function defineBigIntMethod(t){return"undefined"==typeof BigInt?BufferBigIntNotDefined:t}function BufferBigIntNotDefined(){throw new Error("BigInt not supported")}}},__webpack_module_cache__={};function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var r=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t].call(r.exports,r,r.exports,__webpack_require__),r.exports}var __webpack_exports__=__webpack_require__(73);return __webpack_exports__})()));
|
|
2
|
+
!function webpackUniversalModuleDefinition(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.wikha=e():t.wikha=e()}(this,(()=>(()=>{var __webpack_modules__={73:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),o(r(504),e)},251:(t,e)=>{e.read=function(t,e,r,n,o){var i,f,u=8*o-n-1,s=(1<<u)-1,a=s>>1,c=-7,h=r?o-1:0,p=r?-1:1,l=t[e+h];for(h+=p,i=l&(1<<-c)-1,l>>=-c,c+=u;c>0;i=256*i+t[e+h],h+=p,c-=8);for(f=i&(1<<-c)-1,i>>=-c,c+=n;c>0;f=256*f+t[e+h],h+=p,c-=8);if(0===i)i=1-a;else{if(i===s)return f?NaN:1/0*(l?-1:1);f+=Math.pow(2,n),i-=a}return(l?-1:1)*f*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var f,u,s,a=8*i-o-1,c=(1<<a)-1,h=c>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:i-1,y=n?1:-1,d=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,f=c):(f=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-f))<1&&(f--,s*=2),(e+=f+h>=1?p/s:p*Math.pow(2,1-h))*s>=2&&(f++,s/=2),f+h>=c?(u=0,f=c):f+h>=1?(u=(e*s-1)*Math.pow(2,o),f+=h):(u=e*Math.pow(2,h-1)*Math.pow(2,o),f=0));o>=8;t[r+l]=255&u,l+=y,u/=256,o-=8);for(f=f<<o|u,a+=o;a>0;t[r+l]=255&f,l+=y,f/=256,a-=8);t[r+l-y]|=128*d}},504:(__unused_webpack_module,exports,__webpack_require__)=>{"use strict";var process=__webpack_require__(606),Buffer=__webpack_require__(922).hp;Object.defineProperty(exports,"__esModule",{value:!0}),exports.WikhaSDK=exports.Environment=exports.MerchantStatus=exports.PaymentAggregatorType=exports.PaymentStatus=exports.PaymentType=exports.PaymentProviderType=exports.TRANSACTION_QUERY_ENDPOINT=exports.PAY_ENDPOINT=void 0,exports.PAY_ENDPOINT="https://api.wikha-hitech.com/v2/payments",exports.TRANSACTION_QUERY_ENDPOINT="https://api.wikha-hitech.com/v2/query";const isNode="undefined"==typeof window&&void 0!==process;var PaymentProviderType,PaymentType,PaymentStatus,PaymentAggregatorType,MerchantStatus,Environment;!function(t){t.mpesa="mpesa",t.orangemoney="orangemoney",t.afrimoney="afrimoney",t.airtelmoney="airtelmoney",t.paypal="paypal",t.braintree="braintree"}(PaymentProviderType||(exports.PaymentProviderType=PaymentProviderType={})),function(t){t.payin="payin",t.payout="payout",t.transfert="transfert"}(PaymentType||(exports.PaymentType=PaymentType={})),function(t){t.accepted="accepted",t.rejected="rejected",t.pending="pending",t.canceled="canceled"}(PaymentStatus||(exports.PaymentStatus=PaymentStatus={})),function(t){t.unipesa="unipesa",t.direct="direct",t.ligdicash="ligdicash",t.paypal="bank",t.pawapay="pawapay"}(PaymentAggregatorType||(exports.PaymentAggregatorType=PaymentAggregatorType={})),function(t){t.active="active",t.inactive="inactive"}(MerchantStatus||(exports.MerchantStatus=MerchantStatus={})),function(t){t.sandbox="sandbox",t.production="production"}(Environment||(exports.Environment=Environment={}));class WikhaSDK{constructor(t,e,r){this.apiKey=t,this.merchantId=e,this.publicKey=r||null}getFetch(){if("function"==typeof globalThis.fetch)return globalThis.fetch;if(isNode)try{const req=eval("require");return req("node-fetch")}catch(t){console.warn("Native fetch not found and 'node-fetch' not installed.")}throw new Error("Fetch API not found. Please use Node.js 18+ or install 'node-fetch'.")}async fetchPublicKey(){console.log("[WikhaSDK] Fetching public key from server...");const t=this.getFetch();try{const e=new URL(`${exports.PAY_ENDPOINT}/pk`);e.searchParams.append("merchant_id",this.merchantId);const r=await t(e.toString(),{method:"GET",headers:{Authorization:`Bearer ${this.apiKey}`}});if(!r.ok)throw new Error(`Failed to fetch public key: ${r.statusText}`);const n=await r.json();if(!n.publicKey)throw new Error("Public key not present in response");return this.publicKey=n.publicKey,n.publicKey}catch(t){throw console.error("[WikhaSDK] Error fetching public key:",t),t}}async encryptData(data){this.publicKey||await this.fetchPublicKey();const dataString=JSON.stringify({...data,merchant_id:this.merchantId});if(isNode){const req=eval("require"),crypto=req("crypto");try{const t=crypto.publicEncrypt({key:this.publicKey,padding:crypto.constants.RSA_PKCS1_OAEP_PADDING,oaepHash:"SHA256"},Buffer.from(dataString,"utf-8"));return t.toString("base64")}catch(t){throw console.error("Encryption failed (Node.js legacy mode):",t),t}}else{const t=window.crypto;try{const e="-----BEGIN PUBLIC KEY-----",r="-----END PUBLIC KEY-----",n=this.publicKey.replace(e,"").replace(r,"").replace(/\s/g,""),o=atob(n),i=new Uint8Array(o.length);for(let t=0;t<o.length;t++)i[t]=o.charCodeAt(t);const f=await t.subtle.importKey("spki",i.buffer,{name:"RSA-OAEP",hash:"SHA-256"},!1,["encrypt"]),u=(new TextEncoder).encode(dataString),s=await t.subtle.encrypt({name:"RSA-OAEP"},f,u);return btoa(String.fromCharCode(...new Uint8Array(s)))}catch(t){throw console.error("Encryption failed (Browser mode):",t),t}}}async processPayment(t){try{const e=await this.encryptData(t),r=this.getFetch(),n=await r(exports.PAY_ENDPOINT,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({encryptedData:e,merchant_id:this.merchantId})});if(!n.ok){const t=await n.text();throw new Error(`HTTP error! status: ${n.status}, body: ${t}`)}return await n.json()}catch(t){throw console.error("Error processing payment:",t),t}}async queryTransaction(t){try{const e=this.getFetch(),r=new URL(exports.TRANSACTION_QUERY_ENDPOINT);r.searchParams.append("merchant_id",this.merchantId),r.searchParams.append("transaction_id",t);const n=await e(r.toString(),{method:"GET",headers:{Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}});if(!n.ok){const t=await n.text();throw new Error(`HTTP error! status: ${n.status}, body: ${t}`)}return await n.json()}catch(t){throw console.error("Error querying transaction:",t),t}}}exports.WikhaSDK=WikhaSDK},526:(t,e)=>{"use strict";e.byteLength=function byteLength(t){var e=getLens(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function toByteArray(t){var e,r,i=getLens(t),f=i[0],u=i[1],s=new o(function _byteLength(t,e,r){return 3*(e+r)/4-r}(0,f,u)),a=0,c=u>0?f-4:f;for(r=0;r<c;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,s[a++]=255&e);1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e);return s},e.fromByteArray=function fromByteArray(t){for(var e,n=t.length,o=n%3,i=[],f=16383,u=0,s=n-o;u<s;u+=f)i.push(encodeChunk(t,u,u+f>s?s:u+f));1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return i.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0;f<64;++f)r[f]=i[f],n[i.charCodeAt(f)]=f;function getLens(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function encodeChunk(t,e,n){for(var o,i,f=[],u=e;u<n;u+=3)o=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(255&t[u+2]),f.push(r[(i=o)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return f.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},606:t=>{var e,r,n=t.exports={};function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(t){if(e===setTimeout)return setTimeout(t,0);if((e===defaultSetTimout||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(r){try{return e.call(null,t,0)}catch(r){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(t){e=defaultSetTimout}try{r="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(t){r=defaultClearTimeout}}();var o,i=[],f=!1,u=-1;function cleanUpNextTick(){f&&o&&(f=!1,o.length?i=o.concat(i):u=-1,i.length&&drainQueue())}function drainQueue(){if(!f){var t=runTimeout(cleanUpNextTick);f=!0;for(var e=i.length;e;){for(o=i,i=[];++u<e;)o&&o[u].run();u=-1,e=i.length}o=null,f=!1,function runClearTimeout(t){if(r===clearTimeout)return clearTimeout(t);if((r===defaultClearTimeout||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{return r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function Item(t,e){this.fun=t,this.array=e}function noop(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];i.push(new Item(t,e)),1!==i.length||f||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=noop,n.addListener=noop,n.once=noop,n.off=noop,n.removeListener=noop,n.removeAllListeners=noop,n.emit=noop,n.prependListener=noop,n.prependOnceListener=noop,n.listeners=function(t){return[]},n.binding=function(t){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},922:(t,e,r)=>{"use strict";const n=r(526),o=r(251),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.hp=Buffer,e.IS=50;const f=2147483647;function createBuffer(t){if(t>f)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,Buffer.prototype),e}function Buffer(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(t)}return from(t,e,r)}function from(t,e,r){if("string"==typeof t)return function fromString(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!Buffer.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|byteLength(t,e);let n=createBuffer(r);const o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return function fromArrayView(t){if(isInstance(t,Uint8Array)){const e=new Uint8Array(t);return fromArrayBuffer(e.buffer,e.byteOffset,e.byteLength)}return fromArrayLike(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(isInstance(t,ArrayBuffer)||t&&isInstance(t.buffer,ArrayBuffer))return fromArrayBuffer(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(isInstance(t,SharedArrayBuffer)||t&&isInstance(t.buffer,SharedArrayBuffer)))return fromArrayBuffer(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return Buffer.from(n,e,r);const o=function fromObject(t){if(Buffer.isBuffer(t)){const e=0|checked(t.length),r=createBuffer(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return"number"!=typeof t.length||numberIsNaN(t.length)?createBuffer(0):fromArrayLike(t);if("Buffer"===t.type&&Array.isArray(t.data))return fromArrayLike(t.data)}(t);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return Buffer.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function assertSize(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function allocUnsafe(t){return assertSize(t),createBuffer(t<0?0:0|checked(t))}function fromArrayLike(t){const e=t.length<0?0:0|checked(t.length),r=createBuffer(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function fromArrayBuffer(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,Buffer.prototype),n}function checked(t){if(t>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return 0|t}function byteLength(t,e){if(Buffer.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||isInstance(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return utf8ToBytes(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(t).length;default:if(o)return n?-1:utf8ToBytes(t).length;e=(""+e).toLowerCase(),o=!0}}function slowToString(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return hexSlice(this,e,r);case"utf8":case"utf-8":return utf8Slice(this,e,r);case"ascii":return asciiSlice(this,e,r);case"latin1":case"binary":return latin1Slice(this,e,r);case"base64":return base64Slice(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function swap(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function bidirectionalIndexOf(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),numberIsNaN(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=Buffer.from(e,n)),Buffer.isBuffer(e))return 0===e.length?-1:arrayIndexOf(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):arrayIndexOf(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(t,e,r,n,o){let i,f=1,u=t.length,s=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;f=2,u/=2,s/=2,r/=2}function read(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(o){let n=-1;for(i=r;i<u;i++)if(read(t,i)===read(e,-1===n?0:i-n)){if(-1===n&&(n=i),i-n+1===s)return n*f}else-1!==n&&(i-=i-n),n=-1}else for(r+s>u&&(r=u-s),i=r;i>=0;i--){let r=!0;for(let n=0;n<s;n++)if(read(t,i+n)!==read(e,n)){r=!1;break}if(r)return i}return-1}function hexWrite(t,e,r,n){r=Number(r)||0;const o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;const i=e.length;let f;for(n>i/2&&(n=i/2),f=0;f<n;++f){const n=parseInt(e.substr(2*f,2),16);if(numberIsNaN(n))return f;t[r+f]=n}return f}function utf8Write(t,e,r,n){return blitBuffer(utf8ToBytes(e,t.length-r),t,r,n)}function asciiWrite(t,e,r,n){return blitBuffer(function asciiToBytes(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function base64Write(t,e,r,n){return blitBuffer(base64ToBytes(e),t,r,n)}function ucs2Write(t,e,r,n){return blitBuffer(function utf16leToBytes(t,e){let r,n,o;const i=[];for(let f=0;f<t.length&&!((e-=2)<0);++f)r=t.charCodeAt(f),n=r>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function base64Slice(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function utf8Slice(t,e,r){r=Math.min(t.length,r);const n=[];let o=e;for(;o<r;){const e=t[o];let i=null,f=e>239?4:e>223?3:e>191?2:1;if(o+f<=r){let r,n,u,s;switch(f){case 1:e<128&&(i=e);break;case 2:r=t[o+1],128==(192&r)&&(s=(31&e)<<6|63&r,s>127&&(i=s));break;case 3:r=t[o+1],n=t[o+2],128==(192&r)&&128==(192&n)&&(s=(15&e)<<12|(63&r)<<6|63&n,s>2047&&(s<55296||s>57343)&&(i=s));break;case 4:r=t[o+1],n=t[o+2],u=t[o+3],128==(192&r)&&128==(192&n)&&128==(192&u)&&(s=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&u,s>65535&&s<1114112&&(i=s))}}null===i?(i=65533,f=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=f}return function decodeCodePointsArray(t){const e=t.length;if(e<=u)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=u));return r}(n)}Buffer.TYPED_ARRAY_SUPPORT=function typedArraySupport(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),Buffer.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(Buffer.prototype,"parent",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.buffer}}),Object.defineProperty(Buffer.prototype,"offset",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.byteOffset}}),Buffer.poolSize=8192,Buffer.from=function(t,e,r){return from(t,e,r)},Object.setPrototypeOf(Buffer.prototype,Uint8Array.prototype),Object.setPrototypeOf(Buffer,Uint8Array),Buffer.alloc=function(t,e,r){return function alloc(t,e,r){return assertSize(t),t<=0?createBuffer(t):void 0!==e?"string"==typeof r?createBuffer(t).fill(e,r):createBuffer(t).fill(e):createBuffer(t)}(t,e,r)},Buffer.allocUnsafe=function(t){return allocUnsafe(t)},Buffer.allocUnsafeSlow=function(t){return allocUnsafe(t)},Buffer.isBuffer=function isBuffer(t){return null!=t&&!0===t._isBuffer&&t!==Buffer.prototype},Buffer.compare=function compare(t,e){if(isInstance(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(t)||!Buffer.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},Buffer.isEncoding=function isEncoding(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Buffer.concat=function concat(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return Buffer.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=Buffer.allocUnsafe(e);let o=0;for(r=0;r<t.length;++r){let e=t[r];if(isInstance(e,Uint8Array))o+e.length>n.length?(Buffer.isBuffer(e)||(e=Buffer.from(e)),e.copy(n,o)):Uint8Array.prototype.set.call(n,e,o);else{if(!Buffer.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,o)}o+=e.length}return n},Buffer.byteLength=byteLength,Buffer.prototype._isBuffer=!0,Buffer.prototype.swap16=function swap16(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)swap(this,e,e+1);return this},Buffer.prototype.swap32=function swap32(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)swap(this,e,e+3),swap(this,e+1,e+2);return this},Buffer.prototype.swap64=function swap64(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)swap(this,e,e+7),swap(this,e+1,e+6),swap(this,e+2,e+5),swap(this,e+3,e+4);return this},Buffer.prototype.toString=function toString(){const t=this.length;return 0===t?"":0===arguments.length?utf8Slice(this,0,t):slowToString.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function equals(t){if(!Buffer.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===Buffer.compare(this,t)},Buffer.prototype.inspect=function inspect(){let t="";const r=e.IS;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},i&&(Buffer.prototype[i]=Buffer.prototype.inspect),Buffer.prototype.compare=function compare(t,e,r,n,o){if(isInstance(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;let i=(o>>>=0)-(n>>>=0),f=(r>>>=0)-(e>>>=0);const u=Math.min(i,f),s=this.slice(n,o),a=t.slice(e,r);for(let t=0;t<u;++t)if(s[t]!==a[t]){i=s[t],f=a[t];break}return i<f?-1:f<i?1:0},Buffer.prototype.includes=function includes(t,e,r){return-1!==this.indexOf(t,e,r)},Buffer.prototype.indexOf=function indexOf(t,e,r){return bidirectionalIndexOf(this,t,e,r,!0)},Buffer.prototype.lastIndexOf=function lastIndexOf(t,e,r){return bidirectionalIndexOf(this,t,e,r,!1)},Buffer.prototype.write=function write(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return hexWrite(this,t,e,r);case"utf8":case"utf-8":return utf8Write(this,t,e,r);case"ascii":case"latin1":case"binary":return asciiWrite(this,t,e,r);case"base64":return base64Write(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const u=4096;function asciiSlice(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function latin1Slice(t,e,r){let n="";r=Math.min(t.length,r);for(let o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function hexSlice(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let o="";for(let n=e;n<r;++n)o+=c[t[n]];return o}function utf16leSlice(t,e,r){const n=t.slice(e,r);let o="";for(let t=0;t<n.length-1;t+=2)o+=String.fromCharCode(n[t]+256*n[t+1]);return o}function checkOffset(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function checkInt(t,e,r,n,o,i){if(!Buffer.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function wrtBigUInt64LE(t,e,r,n,o){checkIntBI(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i,i>>=8,t[r++]=i;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,r}function wrtBigUInt64BE(t,e,r,n,o){checkIntBI(e,n,o,t,r,7);let i=Number(e&BigInt(4294967295));t[r+7]=i,i>>=8,t[r+6]=i,i>>=8,t[r+5]=i,i>>=8,t[r+4]=i;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=f,f>>=8,t[r+2]=f,f>>=8,t[r+1]=f,f>>=8,t[r]=f,r+8}function checkIEEE754(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(t,e,r,n,i){return e=+e,r>>>=0,i||checkIEEE754(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function writeDouble(t,e,r,n,i){return e=+e,r>>>=0,i||checkIEEE754(t,0,r,8),o.write(t,e,r,n,52,8),r+8}Buffer.prototype.slice=function slice(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,Buffer.prototype),n},Buffer.prototype.readUintLE=Buffer.prototype.readUIntLE=function readUIntLE(t,e,r){t>>>=0,e>>>=0,r||checkOffset(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return n},Buffer.prototype.readUintBE=Buffer.prototype.readUIntBE=function readUIntBE(t,e,r){t>>>=0,e>>>=0,r||checkOffset(t,e,this.length);let n=this[t+--e],o=1;for(;e>0&&(o*=256);)n+=this[t+--e]*o;return n},Buffer.prototype.readUint8=Buffer.prototype.readUInt8=function readUInt8(t,e){return t>>>=0,e||checkOffset(t,1,this.length),this[t]},Buffer.prototype.readUint16LE=Buffer.prototype.readUInt16LE=function readUInt16LE(t,e){return t>>>=0,e||checkOffset(t,2,this.length),this[t]|this[t+1]<<8},Buffer.prototype.readUint16BE=Buffer.prototype.readUInt16BE=function readUInt16BE(t,e){return t>>>=0,e||checkOffset(t,2,this.length),this[t]<<8|this[t+1]},Buffer.prototype.readUint32LE=Buffer.prototype.readUInt32LE=function readUInt32LE(t,e){return t>>>=0,e||checkOffset(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Buffer.prototype.readUint32BE=Buffer.prototype.readUInt32BE=function readUInt32BE(t,e){return t>>>=0,e||checkOffset(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Buffer.prototype.readBigUInt64LE=defineBigIntMethod((function readBigUInt64LE(t){validateNumber(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||boundsError(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,o=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(o)<<BigInt(32))})),Buffer.prototype.readBigUInt64BE=defineBigIntMethod((function readBigUInt64BE(t){validateNumber(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||boundsError(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],o=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(o)})),Buffer.prototype.readIntLE=function readIntLE(t,e,r){t>>>=0,e>>>=0,r||checkOffset(t,e,this.length);let n=this[t],o=1,i=0;for(;++i<e&&(o*=256);)n+=this[t+i]*o;return o*=128,n>=o&&(n-=Math.pow(2,8*e)),n},Buffer.prototype.readIntBE=function readIntBE(t,e,r){t>>>=0,e>>>=0,r||checkOffset(t,e,this.length);let n=e,o=1,i=this[t+--n];for(;n>0&&(o*=256);)i+=this[t+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i},Buffer.prototype.readInt8=function readInt8(t,e){return t>>>=0,e||checkOffset(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Buffer.prototype.readInt16LE=function readInt16LE(t,e){t>>>=0,e||checkOffset(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function readInt16BE(t,e){t>>>=0,e||checkOffset(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function readInt32LE(t,e){return t>>>=0,e||checkOffset(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Buffer.prototype.readInt32BE=function readInt32BE(t,e){return t>>>=0,e||checkOffset(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Buffer.prototype.readBigInt64LE=defineBigIntMethod((function readBigInt64LE(t){validateNumber(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||boundsError(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),Buffer.prototype.readBigInt64BE=defineBigIntMethod((function readBigInt64BE(t){validateNumber(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||boundsError(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),Buffer.prototype.readFloatLE=function readFloatLE(t,e){return t>>>=0,e||checkOffset(t,4,this.length),o.read(this,t,!0,23,4)},Buffer.prototype.readFloatBE=function readFloatBE(t,e){return t>>>=0,e||checkOffset(t,4,this.length),o.read(this,t,!1,23,4)},Buffer.prototype.readDoubleLE=function readDoubleLE(t,e){return t>>>=0,e||checkOffset(t,8,this.length),o.read(this,t,!0,52,8)},Buffer.prototype.readDoubleBE=function readDoubleBE(t,e){return t>>>=0,e||checkOffset(t,8,this.length),o.read(this,t,!1,52,8)},Buffer.prototype.writeUintLE=Buffer.prototype.writeUIntLE=function writeUIntLE(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){checkInt(this,t,e,r,Math.pow(2,8*r)-1,0)}let o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},Buffer.prototype.writeUintBE=Buffer.prototype.writeUIntBE=function writeUIntBE(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){checkInt(this,t,e,r,Math.pow(2,8*r)-1,0)}let o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},Buffer.prototype.writeUint8=Buffer.prototype.writeUInt8=function writeUInt8(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,1,255,0),this[e]=255&t,e+1},Buffer.prototype.writeUint16LE=Buffer.prototype.writeUInt16LE=function writeUInt16LE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeUint16BE=Buffer.prototype.writeUInt16BE=function writeUInt16BE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeUint32LE=Buffer.prototype.writeUInt32LE=function writeUInt32LE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},Buffer.prototype.writeUint32BE=Buffer.prototype.writeUInt32BE=function writeUInt32BE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeBigUInt64LE=defineBigIntMethod((function writeBigUInt64LE(t,e=0){return wrtBigUInt64LE(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),Buffer.prototype.writeBigUInt64BE=defineBigIntMethod((function writeBigUInt64BE(t,e=0){return wrtBigUInt64BE(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),Buffer.prototype.writeIntLE=function writeIntLE(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);checkInt(this,t,e,r,n-1,-n)}let o=0,i=1,f=0;for(this[e]=255&t;++o<r&&(i*=256);)t<0&&0===f&&0!==this[e+o-1]&&(f=1),this[e+o]=(t/i|0)-f&255;return e+r},Buffer.prototype.writeIntBE=function writeIntBE(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);checkInt(this,t,e,r,n-1,-n)}let o=r-1,i=1,f=0;for(this[e+o]=255&t;--o>=0&&(i*=256);)t<0&&0===f&&0!==this[e+o+1]&&(f=1),this[e+o]=(t/i|0)-f&255;return e+r},Buffer.prototype.writeInt8=function writeInt8(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},Buffer.prototype.writeInt16LE=function writeInt16LE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},Buffer.prototype.writeInt16BE=function writeInt16BE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},Buffer.prototype.writeInt32LE=function writeInt32LE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},Buffer.prototype.writeInt32BE=function writeInt32BE(t,e,r){return t=+t,e>>>=0,r||checkInt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},Buffer.prototype.writeBigInt64LE=defineBigIntMethod((function writeBigInt64LE(t,e=0){return wrtBigUInt64LE(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),Buffer.prototype.writeBigInt64BE=defineBigIntMethod((function writeBigInt64BE(t,e=0){return wrtBigUInt64BE(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),Buffer.prototype.writeFloatLE=function writeFloatLE(t,e,r){return writeFloat(this,t,e,!0,r)},Buffer.prototype.writeFloatBE=function writeFloatBE(t,e,r){return writeFloat(this,t,e,!1,r)},Buffer.prototype.writeDoubleLE=function writeDoubleLE(t,e,r){return writeDouble(this,t,e,!0,r)},Buffer.prototype.writeDoubleBE=function writeDoubleBE(t,e,r){return writeDouble(this,t,e,!1,r)},Buffer.prototype.copy=function copy(t,e,r,n){if(!Buffer.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const o=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),o},Buffer.prototype.fill=function fill(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{const i=Buffer.isBuffer(t)?t:Buffer.from(t,n),f=i.length;if(0===f)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=i[o%f]}return this};const s={};function E(t,e,r){s[t]=class NodeError extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function addNumericalSeparator(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function checkIntBI(t,e,r,n,o,i){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let o;throw o=i>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new s.ERR_OUT_OF_RANGE("value",o,t)}!function checkBounds(t,e,r){validateNumber(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||boundsError(e,t.length-(r+1))}(n,o,i)}function validateNumber(t,e){if("number"!=typeof t)throw new s.ERR_INVALID_ARG_TYPE(e,"number",t)}function boundsError(t,e,r){if(Math.floor(t)!==t)throw validateNumber(t,r),new s.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new s.ERR_BUFFER_OUT_OF_BOUNDS;throw new s.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}E("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),E("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),E("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=addNumericalSeparator(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=addNumericalSeparator(o)),o+="n"),n+=` It must be ${e}. Received ${o}`,n}),RangeError);const a=/[^+/0-9A-Za-z-_]/g;function utf8ToBytes(t,e){let r;e=e||1/0;const n=t.length;let o=null;const i=[];for(let f=0;f<n;++f){if(r=t.charCodeAt(f),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function base64ToBytes(t){return n.toByteArray(function base64clean(t){if((t=(t=t.split("=")[0]).trim().replace(a,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function blitBuffer(t,e,r,n){let o;for(o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function isInstance(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function numberIsNaN(t){return t!=t}const c=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)e[n+o]=t[r]+t[o]}return e}();function defineBigIntMethod(t){return"undefined"==typeof BigInt?BufferBigIntNotDefined:t}function BufferBigIntNotDefined(){throw new Error("BigInt not supported")}}},__webpack_module_cache__={};function __webpack_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var r=__webpack_module_cache__[t]={exports:{}};return __webpack_modules__[t].call(r.exports,r,r.exports,__webpack_require__),r.exports}var __webpack_exports__=__webpack_require__(73);return __webpack_exports__})()));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wikha/sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.16",
|
|
4
4
|
"description": "A JavaScript SDK for interacting with the Wikha payment gateway.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -58,4 +58,4 @@
|
|
|
58
58
|
"node-fetch": "^3.3.2",
|
|
59
59
|
"tslib": "^2.8.1"
|
|
60
60
|
}
|
|
61
|
-
}
|
|
61
|
+
}
|