@micro-cms/crypto-payments 1.0.29 → 1.0.30

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/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var St=Object.create;var tt=Object.defineProperty;var Nt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var Tt=Object.getPrototypeOf,Mt=Object.prototype.hasOwnProperty;var W=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var vt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of kt(t))!Mt.call(e,i)&&i!==r&&tt(e,i,{get:()=>t[i],enumerable:!(n=Nt(t,i))||n.enumerable});return e};var Rt=(e,t,r)=>(r=e!=null?St(Tt(e)):{},vt(t||!e||!e.__esModule?tt(r,"default",{value:e,enumerable:!0}):r,e));var nt=W(L=>{"use strict";L.byteLength=Lt;L.toByteArray=$t;L.fromByteArray=Ot;var B=[],E=[],_t=typeof Uint8Array<"u"?Uint8Array:Array,O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(C=0,rt=O.length;C<rt;++C)B[C]=O[C],E[O.charCodeAt(C)]=C;var C,rt;E[45]=62;E[95]=63;function et(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function Lt(e){var t=et(e),r=t[0],n=t[1];return(r+n)*3/4-n}function Dt(e,t,r){return(t+r)*3/4-r}function $t(e){var t,r=et(e),n=r[0],i=r[1],o=new _t(Dt(e,n,i)),c=0,a=i>0?n-4:n,m;for(m=0;m<a;m+=4)t=E[e.charCodeAt(m)]<<18|E[e.charCodeAt(m+1)]<<12|E[e.charCodeAt(m+2)]<<6|E[e.charCodeAt(m+3)],o[c++]=t>>16&255,o[c++]=t>>8&255,o[c++]=t&255;return i===2&&(t=E[e.charCodeAt(m)]<<2|E[e.charCodeAt(m+1)]>>4,o[c++]=t&255),i===1&&(t=E[e.charCodeAt(m)]<<10|E[e.charCodeAt(m+1)]<<4|E[e.charCodeAt(m+2)]>>2,o[c++]=t>>8&255,o[c++]=t&255),o}function jt(e){return B[e>>18&63]+B[e>>12&63]+B[e>>6&63]+B[e&63]}function Wt(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(jt(n));return i.join("")}function Ot(e){for(var t,r=e.length,n=r%3,i=[],o=16383,c=0,a=r-n;c<a;c+=o)i.push(Wt(e,c,c+o>a?a:c+o));return n===1?(t=e[r-1],i.push(B[t>>2]+B[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(B[t>>10]+B[t>>4&63]+B[t<<2&63]+"=")),i.join("")}});var it=W(V=>{"use strict";V.read=function(e,t,r,n,i){var o,c,a=i*8-n-1,m=(1<<a)-1,h=m>>1,l=-7,u=r?i-1:0,b=r?-1:1,w=e[t+u];for(u+=b,o=w&(1<<-l)-1,w>>=-l,l+=a;l>0;o=o*256+e[t+u],u+=b,l-=8);for(c=o&(1<<-l)-1,o>>=-l,l+=n;l>0;c=c*256+e[t+u],u+=b,l-=8);if(o===0)o=1-h;else{if(o===m)return c?NaN:(w?-1:1)*(1/0);c=c+Math.pow(2,n),o=o-h}return(w?-1:1)*c*Math.pow(2,o-n)};V.write=function(e,t,r,n,i,o){var c,a,m,h=o*8-i-1,l=(1<<h)-1,u=l>>1,b=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=n?0:o-1,A=n?1:-1,v=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,c=l):(c=Math.floor(Math.log(t)/Math.LN2),t*(m=Math.pow(2,-c))<1&&(c--,m*=2),c+u>=1?t+=b/m:t+=b*Math.pow(2,1-u),t*m>=2&&(c++,m/=2),c+u>=l?(a=0,c=l):c+u>=1?(a=(t*m-1)*Math.pow(2,i),c=c+u):(a=t*Math.pow(2,u-1)*Math.pow(2,i),c=0));i>=8;e[r+w]=a&255,w+=A,a/=256,i-=8);for(c=c<<i|a,h+=i;h>0;e[r+w]=c&255,w+=A,c/=256,h-=8);e[r+w-A]|=v*128}});var bt=W(M=>{"use strict";var q=nt(),k=it(),ot=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;M.Buffer=s;M.SlowBuffer=zt;M.INSPECT_MAX_BYTES=50;var D=2147483647;M.kMaxLength=D;s.TYPED_ARRAY_SUPPORT=Vt();!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&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.");function Vt(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}});Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function U(e){if(e>D)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return z(e)}return mt(e,t,r)}s.poolSize=8192;function mt(e,t,r){if(typeof e=="string")return Gt(e,t);if(ArrayBuffer.isView(e))return Ht(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(I(e,ArrayBuffer)||e&&I(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(I(e,SharedArrayBuffer)||e&&I(e.buffer,SharedArrayBuffer)))return H(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return s.from(n,t,r);let i=Yt(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return s.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}s.from=function(e,t,r){return mt(e,t,r)};Object.setPrototypeOf(s.prototype,Uint8Array.prototype);Object.setPrototypeOf(s,Uint8Array);function ut(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function qt(e,t,r){return ut(e),e<=0?U(e):t!==void 0?typeof r=="string"?U(e).fill(t,r):U(e).fill(t):U(e)}s.alloc=function(e,t,r){return qt(e,t,r)};function z(e){return ut(e),U(e<0?0:K(e)|0)}s.allocUnsafe=function(e){return z(e)};s.allocUnsafeSlow=function(e){return z(e)};function Gt(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=lt(e,t)|0,n=U(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function G(e){let t=e.length<0?0:K(e.length)|0,r=U(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function Ht(e){if(I(e,Uint8Array)){let t=new Uint8Array(e);return H(t.buffer,t.byteOffset,t.byteLength)}return G(e)}function H(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,s.prototype),n}function Yt(e){if(s.isBuffer(e)){let t=K(e.length)|0,r=U(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||X(e.length)?U(0):G(e);if(e.type==="Buffer"&&Array.isArray(e.data))return G(e.data)}function K(e){if(e>=D)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+D.toString(16)+" bytes");return e|0}function zt(e){return+e!=e&&(e=0),s.alloc(+e)}s.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==s.prototype};s.compare=function(t,r){if(I(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),I(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(t)||!s.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let o=0,c=Math.min(n,i);o<c;++o)if(t[o]!==r[o]){n=t[o],i=r[o];break}return n<i?-1:i<n?1:0};s.isEncoding=function(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}};s.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return s.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=s.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){let c=t[n];if(I(c,Uint8Array))o+c.length>i.length?(s.isBuffer(c)||(c=s.from(c)),c.copy(i,o)):Uint8Array.prototype.set.call(i,c,o);else if(s.isBuffer(c))c.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=c.length}return i};function lt(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||I(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Y(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Et(e).length;default:if(i)return n?-1:Y(e).length;t=(""+t).toLowerCase(),i=!0}}s.byteLength=lt;function Kt(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return or(this,t,r);case"utf8":case"utf-8":return ft(this,t,r);case"ascii":return nr(this,t,r);case"latin1":case"binary":return ir(this,t,r);case"base64":return rr(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return cr(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function S(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}s.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)S(this,r,r+1);return this};s.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)S(this,r,r+3),S(this,r+1,r+2);return this};s.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)S(this,r,r+7),S(this,r+1,r+6),S(this,r+2,r+5),S(this,r+3,r+4);return this};s.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?ft(this,0,t):Kt.apply(this,arguments)};s.prototype.toLocaleString=s.prototype.toString;s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:s.compare(this,t)===0};s.prototype.inspect=function(){let t="",r=M.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};ot&&(s.prototype[ot]=s.prototype.inspect);s.prototype.compare=function(t,r,n,i,o){if(I(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;let c=o-i,a=n-r,m=Math.min(c,a),h=this.slice(i,o),l=t.slice(r,n);for(let u=0;u<m;++u)if(h[u]!==l[u]){c=h[u],a=l[u];break}return c<a?-1:a<c?1:0};function ht(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,X(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=s.from(t,n)),s.isBuffer(t))return t.length===0?-1:ct(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):ct(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function ct(e,t,r,n,i){let o=1,c=e.length,a=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;o=2,c/=2,a/=2,r/=2}function m(l,u){return o===1?l[u]:l.readUInt16BE(u*o)}let h;if(i){let l=-1;for(h=r;h<c;h++)if(m(e,h)===m(t,l===-1?0:h-l)){if(l===-1&&(l=h),h-l+1===a)return l*o}else l!==-1&&(h-=h-l),l=-1}else for(r+a>c&&(r=c-a),h=r;h>=0;h--){let l=!0;for(let u=0;u<a;u++)if(m(e,h+u)!==m(t,u)){l=!1;break}if(l)return h}return-1}s.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};s.prototype.indexOf=function(t,r,n){return ht(this,t,r,n,!0)};s.prototype.lastIndexOf=function(t,r,n){return ht(this,t,r,n,!1)};function Jt(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/2);let c;for(c=0;c<n;++c){let a=parseInt(t.substr(c*2,2),16);if(X(a))return c;e[r+c]=a}return c}function Xt(e,t,r,n){return $(Y(t,e.length-r),e,r,n)}function Zt(e,t,r,n){return $(ur(t),e,r,n)}function Qt(e,t,r,n){return $(Et(t),e,r,n)}function tr(e,t,r,n){return $(lr(t,e.length-r),e,r,n)}s.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let c=!1;for(;;)switch(i){case"hex":return Jt(this,t,r,n);case"utf8":case"utf-8":return Xt(this,t,r,n);case"ascii":case"latin1":case"binary":return Zt(this,t,r,n);case"base64":return Qt(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return tr(this,t,r,n);default:if(c)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),c=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function rr(e,t,r){return t===0&&r===e.length?q.fromByteArray(e):q.fromByteArray(e.slice(t,r))}function ft(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let o=e[i],c=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let m,h,l,u;switch(a){case 1:o<128&&(c=o);break;case 2:m=e[i+1],(m&192)===128&&(u=(o&31)<<6|m&63,u>127&&(c=u));break;case 3:m=e[i+1],h=e[i+2],(m&192)===128&&(h&192)===128&&(u=(o&15)<<12|(m&63)<<6|h&63,u>2047&&(u<55296||u>57343)&&(c=u));break;case 4:m=e[i+1],h=e[i+2],l=e[i+3],(m&192)===128&&(h&192)===128&&(l&192)===128&&(u=(o&15)<<18|(m&63)<<12|(h&63)<<6|l&63,u>65535&&u<1114112&&(c=u))}}c===null?(c=65533,a=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|c&1023),n.push(c),i+=a}return er(n)}var st=4096;function er(e){let t=e.length;if(t<=st)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=st));return r}function nr(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function ir(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function or(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=t;o<r;++o)i+=hr[e[o]];return i}function cr(e,t,r){let n=e.slice(t,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}s.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,s.prototype),i};function d(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||d(t,r,this.length);let i=this[t],o=1,c=0;for(;++c<r&&(o*=256);)i+=this[t+c]*o;return i};s.prototype.readUintBE=s.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||d(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};s.prototype.readUint8=s.prototype.readUInt8=function(t,r){return t=t>>>0,r||d(t,1,this.length),this[t]};s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||d(t,2,this.length),this[t]|this[t+1]<<8};s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||d(t,2,this.length),this[t]<<8|this[t+1]};s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||d(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||d(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};s.prototype.readBigUInt64LE=P(function(t){t=t>>>0,T(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&_(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});s.prototype.readBigUInt64BE=P(function(t){t=t>>>0,T(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&_(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});s.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||d(t,r,this.length);let i=this[t],o=1,c=0;for(;++c<r&&(o*=256);)i+=this[t+c]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};s.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||d(t,r,this.length);let i=r,o=1,c=this[t+--i];for(;i>0&&(o*=256);)c+=this[t+--i]*o;return o*=128,c>=o&&(c-=Math.pow(2,8*r)),c};s.prototype.readInt8=function(t,r){return t=t>>>0,r||d(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};s.prototype.readInt16LE=function(t,r){t=t>>>0,r||d(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};s.prototype.readInt16BE=function(t,r){t=t>>>0,r||d(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};s.prototype.readInt32LE=function(t,r){return t=t>>>0,r||d(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};s.prototype.readInt32BE=function(t,r){return t=t>>>0,r||d(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};s.prototype.readBigInt64LE=P(function(t){t=t>>>0,T(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&_(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});s.prototype.readBigInt64BE=P(function(t){t=t>>>0,T(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&_(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});s.prototype.readFloatLE=function(t,r){return t=t>>>0,r||d(t,4,this.length),k.read(this,t,!0,23,4)};s.prototype.readFloatBE=function(t,r){return t=t>>>0,r||d(t,4,this.length),k.read(this,t,!1,23,4)};s.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||d(t,8,this.length),k.read(this,t,!0,52,8)};s.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||d(t,8,this.length),k.read(this,t,!1,52,8)};function x(e,t,r,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;x(this,t,r,n,a,0)}let o=1,c=0;for(this[r]=t&255;++c<n&&(o*=256);)this[r+c]=t/o&255;return r+n};s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;x(this,t,r,n,a,0)}let o=n-1,c=1;for(this[r+o]=t&255;--o>=0&&(c*=256);)this[r+o]=t/c&255;return r+n};s.prototype.writeUint8=s.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||x(this,t,r,1,255,0),this[r]=t&255,r+1};s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||x(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||x(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||x(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||x(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function pt(e,t,r,n,i){xt(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o;let c=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=c,c=c>>8,e[r++]=c,c=c>>8,e[r++]=c,c=c>>8,e[r++]=c,r}function dt(e,t,r,n,i){xt(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o=o>>8,e[r+6]=o,o=o>>8,e[r+5]=o,o=o>>8,e[r+4]=o;let c=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=c,c=c>>8,e[r+2]=c,c=c>>8,e[r+1]=c,c=c>>8,e[r]=c,r+8}s.prototype.writeBigUInt64LE=P(function(t,r=0){return pt(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});s.prototype.writeBigUInt64BE=P(function(t,r=0){return dt(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});s.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let m=Math.pow(2,8*n-1);x(this,t,r,n,m-1,-m)}let o=0,c=1,a=0;for(this[r]=t&255;++o<n&&(c*=256);)t<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(t/c>>0)-a&255;return r+n};s.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let m=Math.pow(2,8*n-1);x(this,t,r,n,m-1,-m)}let o=n-1,c=1,a=0;for(this[r+o]=t&255;--o>=0&&(c*=256);)t<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(t/c>>0)-a&255;return r+n};s.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||x(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};s.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||x(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};s.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||x(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};s.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||x(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};s.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||x(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};s.prototype.writeBigInt64LE=P(function(t,r=0){return pt(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});s.prototype.writeBigInt64BE=P(function(t,r=0){return dt(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function yt(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function wt(e,t,r,n,i){return t=+t,r=r>>>0,i||yt(e,t,r,4,34028234663852886e22,-34028234663852886e22),k.write(e,t,r,n,23,4),r+4}s.prototype.writeFloatLE=function(t,r,n){return wt(this,t,r,!0,n)};s.prototype.writeFloatBE=function(t,r,n){return wt(this,t,r,!1,n)};function gt(e,t,r,n,i){return t=+t,r=r>>>0,i||yt(e,t,r,8,17976931348623157e292,-17976931348623157e292),k.write(e,t,r,n,52,8),r+8}s.prototype.writeDoubleLE=function(t,r,n){return gt(this,t,r,!0,n)};s.prototype.writeDoubleBE=function(t,r,n){return gt(this,t,r,!1,n)};s.prototype.copy=function(t,r,n,i){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);let o=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),o};s.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!s.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let c=t.charCodeAt(0);(i==="utf8"&&c<128||i==="latin1")&&(t=c)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{let c=s.isBuffer(t)?t:s.from(t,i),a=c.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=c[o%a]}return this};var N={};function J(e,t,r){N[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}J("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);J("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);J("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=at(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=at(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function at(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function sr(e,t,r){T(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&_(t,e.length-(r+1))}function xt(e,t,r,n,i,o){if(e>r||e<t){let c=typeof t=="bigint"?"n":"",a;throw o>3?t===0||t===BigInt(0)?a=`>= 0${c} and < 2${c} ** ${(o+1)*8}${c}`:a=`>= -(2${c} ** ${(o+1)*8-1}${c}) and < 2 ** ${(o+1)*8-1}${c}`:a=`>= ${t}${c} and <= ${r}${c}`,new N.ERR_OUT_OF_RANGE("value",a,e)}sr(n,i,o)}function T(e,t){if(typeof e!="number")throw new N.ERR_INVALID_ARG_TYPE(t,"number",e)}function _(e,t,r){throw Math.floor(e)!==e?(T(e,r),new N.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new N.ERR_BUFFER_OUT_OF_BOUNDS:new N.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var ar=/[^+/0-9A-Za-z-_]/g;function mr(e){if(e=e.split("=")[0],e=e.trim().replace(ar,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function Y(e,t){t=t||1/0;let r,n=e.length,i=null,o=[];for(let c=0;c<n;++c){if(r=e.charCodeAt(c),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(c+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function ur(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function lr(e,t){let r,n,i,o=[];for(let c=0;c<e.length&&!((t-=2)<0);++c)r=e.charCodeAt(c),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function Et(e){return q.toByteArray(mr(e))}function $(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function I(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function X(e){return e!==e}var hr=(function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t})();function P(e){return typeof BigInt>"u"?fr:e}function fr(){throw new Error("BigInt not supported")}});var Ct=Rt(bt());import{useState as Z,useCallback as Pt}from"react";import{Connection as pr,PublicKey as j,Transaction as dr,SystemProgram as yr,LAMPORTS_PER_SOL as wr}from"@solana/web3.js";import{TOKEN_PROGRAM_ID as gr,createTransferInstruction as xr,getMint as Er}from"@solana/spl-token";var br=new j("4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"),Br=new j("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Bt=()=>{let e=()=>{if(typeof window<"u"&&"solana"in window){let n=window;if(n.solana?.isPhantom)return n.solana}},t=async()=>{let n=e();if(n)try{return(await n.connect()).publicKey.toString()}catch{throw new Error("User rejected the connection")}else throw new Error("Phantom wallet not found")},r=async n=>{let i=e();if(!i)throw new Error("Wallet not connected");try{let o=!window.location.host.includes("localhost")&&!window.location.host.includes("dev."),c=o?"https://api.mainnet-beta.solana.com":"https://api.devnet.solana.com",a=new pr(c,"confirmed"),m=await i.connect({onlyIfTrusted:!0}),h=new j(m.publicKey.toString()),l=new j(n.paymentAddress),u=new dr;if(n.currency?.toUpperCase()==="USDC"){let A=o?Br:br,v=await Er(a,A),Q=Math.round(Number(n.amount)*Math.pow(10,v.decimals)),{getAssociatedTokenAddress:f}=await import("@solana/spl-token"),g=await f(A,h),F=await f(A,l);u.add(xr(g,F,h,Q,[],gr))}else u.add(yr.transfer({fromPubkey:h,toPubkey:l,lamports:Math.round(Number(n.amount)*wr)}));let{blockhash:b}=await a.getLatestBlockhash();u.recentBlockhash=b,u.feePayer=h;let{signature:w}=await i.signAndSendTransaction(u);return w}catch(o){throw console.error("Solana Transaction Error:",o),o.message?.includes("User rejected")?new Error("Transaction rejected by user"):new Error(o.message||"Failed to send Solana transaction")}};return{isAvailable:!!e(),connect:t,sendPayment:r}};var It=()=>{let e=()=>{if(typeof window<"u"&&"ethereum"in window)return window.ethereum},t=async()=>{let n=e();if(n)try{return(await n.request({method:"eth_requestAccounts"}))[0]}catch{throw new Error("User rejected the connection")}else throw new Error("MetaMask or EVM wallet not found")},r=async n=>{let i=e();if(!i)throw new Error("Wallet not connected");let o=await i.request({method:"eth_accounts"});if(!o||o.length===0)throw new Error("No accounts found. Please connect your wallet first.");let c=n.currency.toUpperCase()==="USDC"?6:18,a="0x"+BigInt(Math.floor(Number(n.amount)*Math.pow(10,c))).toString(16);try{return await i.request({method:"eth_sendTransaction",params:[{from:o[0],to:n.paymentAddress,value:n.currency.toUpperCase()==="ETH"?a:"0x0"}]})}catch(m){throw m.code===4001?new Error("Transaction rejected by user"):new Error(m.message||"Failed to send transaction")}};return{isAvailable:!!e(),connect:t,sendPayment:r}};import{useLayoutEffect as Ar}from"react";import{Wallet as Fr,CheckCircle as Ur,Loader2 as Pr,AlertCircle as Cr,ExternalLink as Sr,Cpu as Nr}from"lucide-react";import{clsx as kr}from"clsx";import{twMerge as Tr}from"tailwind-merge";var Ir=".mcms-mx-auto{margin-left:auto;margin-right:auto}.mcms-mb-3{margin-bottom:.75rem}.mcms-mb-4{margin-bottom:1rem}.mcms-mb-6{margin-bottom:1.5rem}.mcms-mt-1{margin-top:.25rem}.mcms-flex{display:flex}.mcms-h-12{height:3rem}.mcms-h-3{height:.75rem}.mcms-h-4{height:1rem}.mcms-h-5{height:1.25rem}.mcms-h-8{height:2rem}.mcms-w-12{width:3rem}.mcms-w-3{width:.75rem}.mcms-w-4{width:1rem}.mcms-w-5{width:1.25rem}.mcms-w-8{width:2rem}.mcms-w-full{width:100%}.mcms-shrink-0{flex-shrink:0}@keyframes mcms-spin{to{transform:rotate(1turn)}}.mcms-animate-spin{animation:mcms-spin 1s linear infinite}.mcms-flex-col{flex-direction:column}.mcms-items-center{align-items:center}.mcms-justify-center{justify-content:center}.mcms-justify-between{justify-content:space-between}.mcms-gap-1{gap:.25rem}.mcms-gap-2{gap:.5rem}.mcms-gap-3{gap:.75rem}.mcms-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.mcms-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem*var(--tw-space-y-reverse))}.mcms-overflow-hidden{overflow:hidden}.mcms-break-all{word-break:break-all}.mcms-rounded-2xl{border-radius:1rem}.mcms-rounded-lg{border-radius:.5rem}.mcms-rounded-xl{border-radius:.75rem}.mcms-border{border-width:1px}.mcms-border-t{border-top-width:1px}.mcms-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.mcms-border-red-100{--tw-border-opacity:1;border-color:rgb(254 226 226/var(--tw-border-opacity,1))}.mcms-border-slate-100{--tw-border-opacity:1;border-color:rgb(241 245 249/var(--tw-border-opacity,1))}.mcms-border-slate-200{--tw-border-opacity:1;border-color:rgb(226 232 240/var(--tw-border-opacity,1))}.mcms-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.mcms-bg-indigo-50{--tw-bg-opacity:1;background-color:rgb(238 242 255/var(--tw-bg-opacity,1))}.mcms-bg-indigo-600{--tw-bg-opacity:1;background-color:rgb(79 70 229/var(--tw-bg-opacity,1))}.mcms-bg-orange-500{--tw-bg-opacity:1;background-color:rgb(249 115 22/var(--tw-bg-opacity,1))}.mcms-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.mcms-bg-slate-100{--tw-bg-opacity:1;background-color:rgb(241 245 249/var(--tw-bg-opacity,1))}.mcms-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.mcms-bg-slate-900{--tw-bg-opacity:1;background-color:rgb(15 23 42/var(--tw-bg-opacity,1))}.mcms-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.mcms-p-2{padding:.5rem}.mcms-p-3{padding:.75rem}.mcms-p-4{padding:1rem}.mcms-p-6{padding:1.5rem}.mcms-px-4{padding-left:1rem;padding-right:1rem}.mcms-px-6{padding-left:1.5rem;padding-right:1.5rem}.mcms-py-3{padding-top:.75rem;padding-bottom:.75rem}.mcms-py-8{padding-top:2rem;padding-bottom:2rem}.mcms-text-center{text-align:center}.mcms-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.mcms-text-lg{font-size:1.125rem;line-height:1.75rem}.mcms-text-sm{font-size:.875rem;line-height:1.25rem}.mcms-text-xs{font-size:.75rem;line-height:1rem}.mcms-font-bold{font-weight:700}.mcms-font-medium{font-weight:500}.mcms-font-semibold{font-weight:600}.mcms-uppercase{text-transform:uppercase}.mcms-tracking-wider{letter-spacing:.05em}.mcms-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.mcms-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.mcms-text-indigo-600{--tw-text-opacity:1;color:rgb(79 70 229/var(--tw-text-opacity,1))}.mcms-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.mcms-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity,1))}.mcms-text-slate-500{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity,1))}.mcms-text-slate-600{--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.mcms-text-slate-900{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity,1))}.mcms-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.mcms-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.mcms-transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover:mcms-bg-black:hover{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.hover:mcms-bg-indigo-700:hover{--tw-bg-opacity:1;background-color:rgb(67 56 202/var(--tw-bg-opacity,1))}.hover:mcms-bg-orange-600:hover{--tw-bg-opacity:1;background-color:rgb(234 88 12/var(--tw-bg-opacity,1))}.hover:mcms-text-indigo-700:hover{--tw-text-opacity:1;color:rgb(67 56 202/var(--tw-text-opacity,1))}",At=()=>{if(typeof document>"u"||document.getElementById("mcms-crypto-styles"))return;let e=document.createElement("style");e.id="mcms-crypto-styles",e.textContent=Ir,document.head.appendChild(e)};import{jsx as p,jsxs as y}from"react/jsx-runtime";function Ft(...e){return Tr(kr(e))}var Zr=({className:e,...t})=>{Ar(()=>{At()},[]);let{status:r,intent:n,error:i,initiate:o,verify:c,setStatus:a,isSolanaAvailable:m,handleSolanaPay:h,isEVMAvailable:l,handleEVMPay:u}=Ut(t);return r==="success"?y("div",{className:Ft("mcms-p-6 mcms-text-center mcms-bg-green-50 mcms-rounded-xl mcms-border mcms-border-green-200",e),children:[p(Ur,{className:"mcms-mx-auto mcms-w-12 mcms-h-12 mcms-text-green-500 mcms-mb-4"}),p("h3",{className:"mcms-text-lg mcms-font-semibold mcms-green-900",children:"Payment Successful"}),p("p",{className:"mcms-text-green-700 mcms-mt-1",children:"Your order has been confirmed."})]}):y("div",{className:Ft("mcms-bg-white mcms-rounded-2xl mcms-border mcms-border-slate-200 mcms-shadow-sm mcms-overflow-hidden",e),children:[y("div",{className:"mcms-p-6",children:[y("div",{className:"mcms-flex mcms-items-center mcms-gap-3 mcms-mb-6",children:[p("div",{className:"mcms-p-2 mcms-bg-indigo-50 mcms-rounded-lg",children:p(Fr,{className:"mcms-w-5 mcms-h-5 mcms-text-indigo-600"})}),y("div",{children:[p("h3",{className:"mcms-font-semibold mcms-text-slate-900",children:"Crypto Payment"}),p("p",{className:"mcms-text-sm mcms-text-slate-500",children:"Pay securely using your wallet"})]})]}),i&&y("div",{className:"mcms-mb-4 mcms-p-3 mcms-bg-red-50 mcms-border mcms-border-red-100 mcms-rounded-lg mcms-flex mcms-gap-3 mcms-text-red-700 mcms-text-sm",children:[p(Cr,{className:"mcms-w-4 mcms-h-4 mcms-shrink-0"}),p("p",{children:i})]}),r==="idle"&&p("button",{onClick:o,className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-indigo-600 hover:mcms-bg-indigo-700 mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:"Start Payment"}),(r==="connecting"||r==="initiating"||r==="verifying")&&y("div",{className:"mcms-py-8 mcms-text-center",children:[p(Pr,{className:"mcms-w-8 mcms-h-8 mcms-text-indigo-600 mcms-animate-spin mcms-mx-auto mcms-mb-3"}),p("p",{className:"mcms-text-slate-600 mcms-font-medium",children:r==="connecting"?"Connecting wallet...":r==="initiating"?"Preparing transaction...":"Verifying on-chain..."})]}),r==="pending_signature"&&n&&y("div",{className:"mcms-space-y-4",children:[y("div",{className:"mcms-p-4 mcms-bg-slate-50 mcms-rounded-xl mcms-space-y-2",children:[y("div",{className:"mcms-flex mcms-justify-between mcms-text-sm",children:[p("span",{className:"mcms-text-slate-500",children:"Amount to pay"}),y("span",{className:"mcms-font-mono mcms-font-medium mcms-text-slate-900",children:[n.amount," ",n.currency]})]}),y("div",{className:"mcms-flex mcms-justify-between mcms-text-sm",children:[p("span",{className:"mcms-text-slate-500",children:"Order ID"}),p("span",{className:"mcms-font-mono mcms-text-slate-900",children:n.orderId})]}),y("div",{className:"mcms-flex mcms-justify-between mcms-text-sm",children:[p("span",{className:"mcms-text-slate-500",children:"Network"}),p("span",{className:"mcms-text-slate-900 mcms-font-medium",children:n.network})]})]}),y("div",{className:"mcms-space-y-2",children:[p("p",{className:"mcms-text-xs mcms-text-slate-500 mcms-uppercase mcms-font-bold mcms-tracking-wider",children:"Destination Address"}),p("div",{className:"mcms-p-3 mcms-bg-slate-100 mcms-rounded-lg mcms-font-mono mcms-text-xs mcms-break-all mcms-text-slate-600 mcms-border mcms-border-slate-200 mcms-flex mcms-justify-center",children:n.paymentAddress?`${n.paymentAddress.slice(0,6)}...${n.paymentAddress.slice(-4)}`:"Establishing..."})]}),p("div",{className:"mcms-flex mcms-flex-col mcms-gap-2",children:n.network?.toLowerCase().includes("solana")&&m?y("button",{onClick:h,className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-indigo-600 hover:mcms-bg-indigo-700 mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:[p(Nr,{className:"mcms-w-4 mcms-h-4"}),"Pay with Phantom"]}):(n.network?.toLowerCase().includes("ethereum")||n.network?.toLowerCase().includes("evm")||n.network?.toLowerCase().includes("polygon"))&&l?y("button",{onClick:u,className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-orange-500 hover:mcms-bg-orange-600 mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:[p("img",{src:"https://upload.wikimedia.org/wikipedia/commons/3/36/MetaMask_Mirror_Logo.svg",className:"mcms-w-4 mcms-h-4",alt:"MetaMask"}),"Pay with MetaMask"]}):p("button",{onClick:()=>{a("verifying"),setTimeout(()=>c("0x_mock_transaction_hash_generic"),2e3)},className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-slate-900 hover:mcms-bg-black mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:"Confirm in Wallet"})})]})]}),y("div",{className:"mcms-bg-slate-50 mcms-px-6 mcms-py-3 mcms-border-t mcms-border-slate-100 mcms-flex mcms-justify-between mcms-items-center",children:[p("span",{className:"mcms-text-xs mcms-text-slate-400",children:"Powered by Micro-CMS Crypto"}),y("a",{href:"#",className:"mcms-text-xs mcms-text-indigo-600 hover:mcms-text-indigo-700 mcms-font-medium mcms-flex mcms-items-center mcms-gap-1",children:["Help ",p(Sr,{className:"mcms-w-3 mcms-h-3"})]})]})]})};typeof window<"u"&&(window.Buffer||(window.Buffer=Ct.Buffer),window.global||(window.global=window));var Ut=e=>{let[t,r]=Z("idle"),[n,i]=Z(null),[o,c]=Z(null),a=Pt(async()=>{try{if(r("initiating"),i(null),e.provider){let F=await e.provider.initiatePayment(e.orderId,{amount:e.amount,currency:e.currency});c(F),r("pending_signature");return}let f=await fetch(e.endpoints?.initiate||"/api/orders/initiate",{method:"POST",headers:{"Content-Type":"application/json",...e.headers||{}},body:JSON.stringify({productId:e.orderId,amount:e.amount,currency:e.currency,paymentProvider:"crypto"})});if(!f.ok){let F=await f.json();throw new Error(F.error||"Failed to initiate payment intent")}let g=await f.json();c(g),r("pending_signature")}catch(f){i(f.message),r("error"),e.onError?.(f)}},[e.provider,e.endpoints?.initiate,e.orderId,e.amount,e.currency,e.onError,e.headers]),m=Pt(async f=>{try{if(r("verifying"),e.provider){let R=await e.provider.verifyPayment(f,e.orderId);if(R.status==="confirmed")r("success"),e.onSuccess?.(R);else throw new Error("Payment not confirmed yet, status: "+R.status);return}let g=await fetch(e.endpoints?.verify||"/api/orders/verify-payment",{method:"POST",headers:{"Content-Type":"application/json",...e.headers||{}},body:JSON.stringify({orderId:o?.orderId||e.orderId,transactionHash:f})});if(!g.ok){let R=await g.json();throw new Error(R.error||"Payment verification failed")}let F=await g.json();if(F.status==="confirmed")r("success"),e.onSuccess?.(F);else throw new Error("Payment not confirmed yet, status: "+F.status)}catch(g){i(g.message),r("error"),e.onError?.(g)}},[e.provider,e.endpoints?.verify,e.orderId,e.onSuccess,e.onError,e.headers,o?.orderId]),{isAvailable:h,connect:l,sendPayment:u}=Bt(),b=async()=>{try{if(!o){i("Payment intent not established."),r("error");return}r("connecting");let f=await l();console.log("Connected to Solana with public key:",f),r("pending_signature");let g=await u(o);r("verifying"),await m(g)}catch(f){i(f.message||"Failed to connect to Phantom or sign transaction."),r("error"),e.onError?.(f instanceof Error?f:new Error(String(f)))}},{isAvailable:w,connect:A,sendPayment:v}=It();return{status:t,intent:o,error:n,initiate:a,verify:m,setStatus:r,isSolanaAvailable:h,handleSolanaPay:b,isEVMAvailable:w,handleEVMPay:async()=>{try{if(!o){i("Payment intent not established."),r("error");return}r("connecting");let f=await A();console.log("Connected to EVM with account:",f),r("pending_signature");let g=await v(o);r("verifying"),await m(g)}catch(f){i(f.message||"Failed to connect to MetaMask or sign transaction."),r("error"),e.onError?.(f instanceof Error?f:new Error(String(f)))}}}};export{Ir as CSS_CONTENT,Zr as PaymentWidget,At as injectStyles,It as useEVMWallet,Ut as usePayment,Bt as useSolanaWallet};
1
+ import{a as v,b as bt}from"./chunk-73SFLUWV.mjs";var J=v(T=>{"use strict";T.byteLength=Bt;T.toByteArray=Ft;T.fromByteArray=Ct;var E=[],b=[],Et=typeof Uint8Array<"u"?Uint8Array:Array,M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(A=0,z=M.length;A<z;++A)E[A]=M[A],b[M.charCodeAt(A)]=A;var A,z;b[45]=62;b[95]=63;function H(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function Bt(e){var t=H(e),r=t[0],n=t[1];return(r+n)*3/4-n}function It(e,t,r){return(t+r)*3/4-r}function Ft(e){var t,r=H(e),n=r[0],i=r[1],o=new Et(It(e,n,i)),c=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)t=b[e.charCodeAt(u)]<<18|b[e.charCodeAt(u+1)]<<12|b[e.charCodeAt(u+2)]<<6|b[e.charCodeAt(u+3)],o[c++]=t>>16&255,o[c++]=t>>8&255,o[c++]=t&255;return i===2&&(t=b[e.charCodeAt(u)]<<2|b[e.charCodeAt(u+1)]>>4,o[c++]=t&255),i===1&&(t=b[e.charCodeAt(u)]<<10|b[e.charCodeAt(u+1)]<<4|b[e.charCodeAt(u+2)]>>2,o[c++]=t>>8&255,o[c++]=t&255),o}function At(e){return E[e>>18&63]+E[e>>12&63]+E[e>>6&63]+E[e&63]}function Ut(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16&16711680)+(e[o+1]<<8&65280)+(e[o+2]&255),i.push(At(n));return i.join("")}function Ct(e){for(var t,r=e.length,n=r%3,i=[],o=16383,c=0,a=r-n;c<a;c+=o)i.push(Ut(e,c,c+o>a?a:c+o));return n===1?(t=e[r-1],i.push(E[t>>2]+E[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(E[t>>10]+E[t>>4&63]+E[t<<2&63]+"=")),i.join("")}});var X=v(L=>{"use strict";L.read=function(e,t,r,n,i){var o,c,a=i*8-n-1,u=(1<<a)-1,h=u>>1,l=-7,m=r?i-1:0,p=r?-1:1,d=e[t+m];for(m+=p,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=o*256+e[t+m],m+=p,l-=8);for(c=o&(1<<-l)-1,o>>=-l,l+=n;l>0;c=c*256+e[t+m],m+=p,l-=8);if(o===0)o=1-h;else{if(o===u)return c?NaN:(d?-1:1)*(1/0);c=c+Math.pow(2,n),o=o-h}return(d?-1:1)*c*Math.pow(2,o-n)};L.write=function(e,t,r,n,i,o){var c,a,u,h=o*8-i-1,l=(1<<h)-1,m=l>>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,x=n?1:-1,xt=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,c=l):(c=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-c))<1&&(c--,u*=2),c+m>=1?t+=p/u:t+=p*Math.pow(2,1-m),t*u>=2&&(c++,u/=2),c+m>=l?(a=0,c=l):c+m>=1?(a=(t*u-1)*Math.pow(2,i),c=c+m):(a=t*Math.pow(2,m-1)*Math.pow(2,i),c=0));i>=8;e[r+d]=a&255,d+=x,a/=256,i-=8);for(c=c<<i|a,h+=i;h>0;e[r+d]=c&255,d+=x,c/=256,h-=8);e[r+d-x]|=xt*128}});var ft=v(P=>{"use strict";var D=J(),N=X(),K=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;P.Buffer=s;P.SlowBuffer=Rt;P.INSPECT_MAX_BYTES=50;var R=2147483647;P.kMaxLength=R;s.TYPED_ARRAY_SUPPORT=Nt();!s.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&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.");function Nt(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}});Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}});function I(e){if(e>R)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,s.prototype),t}function s(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return W(e)}return rt(e,t,r)}s.poolSize=8192;function rt(e,t,r){if(typeof e=="string")return Pt(e,t);if(ArrayBuffer.isView(e))return St(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(B(e,ArrayBuffer)||e&&B(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(B(e,SharedArrayBuffer)||e&&B(e.buffer,SharedArrayBuffer)))return j(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return s.from(n,t,r);let i=Tt(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return s.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}s.from=function(e,t,r){return rt(e,t,r)};Object.setPrototypeOf(s.prototype,Uint8Array.prototype);Object.setPrototypeOf(s,Uint8Array);function et(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function kt(e,t,r){return et(e),e<=0?I(e):t!==void 0?typeof r=="string"?I(e).fill(t,r):I(e).fill(t):I(e)}s.alloc=function(e,t,r){return kt(e,t,r)};function W(e){return et(e),I(e<0?0:V(e)|0)}s.allocUnsafe=function(e){return W(e)};s.allocUnsafeSlow=function(e){return W(e)};function Pt(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!s.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=nt(e,t)|0,n=I(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function $(e){let t=e.length<0?0:V(e.length)|0,r=I(t);for(let n=0;n<t;n+=1)r[n]=e[n]&255;return r}function St(e){if(B(e,Uint8Array)){let t=new Uint8Array(e);return j(t.buffer,t.byteOffset,t.byteLength)}return $(e)}function j(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&r===void 0?n=new Uint8Array(e):r===void 0?n=new Uint8Array(e,t):n=new Uint8Array(e,t,r),Object.setPrototypeOf(n,s.prototype),n}function Tt(e){if(s.isBuffer(e)){let t=V(e.length)|0,r=I(t);return r.length===0||e.copy(r,0,0,t),r}if(e.length!==void 0)return typeof e.length!="number"||Y(e.length)?I(0):$(e);if(e.type==="Buffer"&&Array.isArray(e.data))return $(e.data)}function V(e){if(e>=R)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+R.toString(16)+" bytes");return e|0}function Rt(e){return+e!=e&&(e=0),s.alloc(+e)}s.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==s.prototype};s.compare=function(t,r){if(B(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),B(r,Uint8Array)&&(r=s.from(r,r.offset,r.byteLength)),!s.isBuffer(t)||!s.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let o=0,c=Math.min(n,i);o<c;++o)if(t[o]!==r[o]){n=t[o],i=r[o];break}return n<i?-1:i<n?1:0};s.isEncoding=function(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}};s.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return s.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;let i=s.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){let c=t[n];if(B(c,Uint8Array))o+c.length>i.length?(s.isBuffer(c)||(c=s.from(c)),c.copy(i,o)):Uint8Array.prototype.set.call(i,c,o);else if(s.isBuffer(c))c.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=c.length}return i};function nt(e,t){if(s.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||B(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return O(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return ht(e).length;default:if(i)return n?-1:O(e).length;t=(""+t).toLowerCase(),i=!0}}s.byteLength=nt;function _t(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return Gt(this,t,r);case"utf8":case"utf-8":return ot(this,t,r);case"ascii":return Wt(this,t,r);case"latin1":case"binary":return Vt(this,t,r);case"base64":return jt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Yt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}s.prototype._isBuffer=!0;function U(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}s.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<t;r+=2)U(this,r,r+1);return this};s.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<t;r+=4)U(this,r,r+3),U(this,r+1,r+2);return this};s.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<t;r+=8)U(this,r,r+7),U(this,r+1,r+6),U(this,r+2,r+5),U(this,r+3,r+4);return this};s.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?ot(this,0,t):_t.apply(this,arguments)};s.prototype.toLocaleString=s.prototype.toString;s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:s.compare(this,t)===0};s.prototype.inspect=function(){let t="",r=P.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"};K&&(s.prototype[K]=s.prototype.inspect);s.prototype.compare=function(t,r,n,i,o){if(B(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;let c=o-i,a=n-r,u=Math.min(c,a),h=this.slice(i,o),l=t.slice(r,n);for(let m=0;m<u;++m)if(h[m]!==l[m]){c=h[m],a=l[m];break}return c<a?-1:a<c?1:0};function it(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Y(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=s.from(t,n)),s.isBuffer(t))return t.length===0?-1:Z(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Z(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Z(e,t,r,n,i){let o=1,c=e.length,a=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;o=2,c/=2,a/=2,r/=2}function u(l,m){return o===1?l[m]:l.readUInt16BE(m*o)}let h;if(i){let l=-1;for(h=r;h<c;h++)if(u(e,h)===u(t,l===-1?0:h-l)){if(l===-1&&(l=h),h-l+1===a)return l*o}else l!==-1&&(h-=h-l),l=-1}else for(r+a>c&&(r=c-a),h=r;h>=0;h--){let l=!0;for(let m=0;m<a;m++)if(u(e,h+m)!==u(t,m)){l=!1;break}if(l)return h}return-1}s.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};s.prototype.indexOf=function(t,r,n){return it(this,t,r,n,!0)};s.prototype.lastIndexOf=function(t,r,n){return it(this,t,r,n,!1)};function vt(e,t,r,n){r=Number(r)||0;let i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=t.length;n>o/2&&(n=o/2);let c;for(c=0;c<n;++c){let a=parseInt(t.substr(c*2,2),16);if(Y(a))return c;e[r+c]=a}return c}function Mt(e,t,r,n){return _(O(t,e.length-r),e,r,n)}function Lt(e,t,r,n){return _(Jt(t),e,r,n)}function Dt(e,t,r,n){return _(ht(t),e,r,n)}function $t(e,t,r,n){return _(Xt(t,e.length-r),e,r,n)}s.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let c=!1;for(;;)switch(i){case"hex":return vt(this,t,r,n);case"utf8":case"utf-8":return Mt(this,t,r,n);case"ascii":case"latin1":case"binary":return Lt(this,t,r,n);case"base64":return Dt(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $t(this,t,r,n);default:if(c)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),c=!0}};s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jt(e,t,r){return t===0&&r===e.length?D.fromByteArray(e):D.fromByteArray(e.slice(t,r))}function ot(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i<r;){let o=e[i],c=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let u,h,l,m;switch(a){case 1:o<128&&(c=o);break;case 2:u=e[i+1],(u&192)===128&&(m=(o&31)<<6|u&63,m>127&&(c=m));break;case 3:u=e[i+1],h=e[i+2],(u&192)===128&&(h&192)===128&&(m=(o&15)<<12|(u&63)<<6|h&63,m>2047&&(m<55296||m>57343)&&(c=m));break;case 4:u=e[i+1],h=e[i+2],l=e[i+3],(u&192)===128&&(h&192)===128&&(l&192)===128&&(m=(o&15)<<18|(u&63)<<12|(h&63)<<6|l&63,m>65535&&m<1114112&&(c=m))}}c===null?(c=65533,a=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|c&1023),n.push(c),i+=a}return Ot(n)}var Q=4096;function Ot(e){let t=e.length;if(t<=Q)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Q));return r}function Wt(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function Vt(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function Gt(e,t,r){let n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=t;o<r;++o)i+=Kt[e[o]];return i}function Yt(e,t,r){let n=e.slice(t,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}s.prototype.slice=function(t,r){let n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);let i=this.subarray(t,r);return Object.setPrototypeOf(i,s.prototype),i};function y(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}s.prototype.readUintLE=s.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||y(t,r,this.length);let i=this[t],o=1,c=0;for(;++c<r&&(o*=256);)i+=this[t+c]*o;return i};s.prototype.readUintBE=s.prototype.readUIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||y(t,r,this.length);let i=this[t+--r],o=1;for(;r>0&&(o*=256);)i+=this[t+--r]*o;return i};s.prototype.readUint8=s.prototype.readUInt8=function(t,r){return t=t>>>0,r||y(t,1,this.length),this[t]};s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||y(t,2,this.length),this[t]|this[t+1]<<8};s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||y(t,2,this.length),this[t]<<8|this[t+1]};s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||y(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||y(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};s.prototype.readBigUInt64LE=F(function(t){t=t>>>0,k(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&S(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});s.prototype.readBigUInt64BE=F(function(t){t=t>>>0,k(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&S(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});s.prototype.readIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||y(t,r,this.length);let i=this[t],o=1,c=0;for(;++c<r&&(o*=256);)i+=this[t+c]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};s.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||y(t,r,this.length);let i=r,o=1,c=this[t+--i];for(;i>0&&(o*=256);)c+=this[t+--i]*o;return o*=128,c>=o&&(c-=Math.pow(2,8*r)),c};s.prototype.readInt8=function(t,r){return t=t>>>0,r||y(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};s.prototype.readInt16LE=function(t,r){t=t>>>0,r||y(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};s.prototype.readInt16BE=function(t,r){t=t>>>0,r||y(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};s.prototype.readInt32LE=function(t,r){return t=t>>>0,r||y(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};s.prototype.readInt32BE=function(t,r){return t=t>>>0,r||y(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};s.prototype.readBigInt64LE=F(function(t){t=t>>>0,k(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&S(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});s.prototype.readBigInt64BE=F(function(t){t=t>>>0,k(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&S(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)});s.prototype.readFloatLE=function(t,r){return t=t>>>0,r||y(t,4,this.length),N.read(this,t,!0,23,4)};s.prototype.readFloatBE=function(t,r){return t=t>>>0,r||y(t,4,this.length),N.read(this,t,!1,23,4)};s.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||y(t,8,this.length),N.read(this,t,!0,52,8)};s.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||y(t,8,this.length),N.read(this,t,!1,52,8)};function g(e,t,r,n,i,o){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;g(this,t,r,n,a,0)}let o=1,c=0;for(this[r]=t&255;++c<n&&(o*=256);)this[r+c]=t/o&255;return r+n};s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;g(this,t,r,n,a,0)}let o=n-1,c=1;for(this[r+o]=t&255;--o>=0&&(c*=256);)this[r+o]=t/c&255;return r+n};s.prototype.writeUint8=s.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,1,255,0),this[r]=t&255,r+1};s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function ct(e,t,r,n,i){lt(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o,o=o>>8,e[r++]=o;let c=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=c,c=c>>8,e[r++]=c,c=c>>8,e[r++]=c,c=c>>8,e[r++]=c,r}function st(e,t,r,n,i){lt(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o=o>>8,e[r+6]=o,o=o>>8,e[r+5]=o,o=o>>8,e[r+4]=o;let c=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=c,c=c>>8,e[r+2]=c,c=c>>8,e[r+1]=c,c=c>>8,e[r]=c,r+8}s.prototype.writeBigUInt64LE=F(function(t,r=0){return ct(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});s.prototype.writeBigUInt64BE=F(function(t,r=0){return st(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});s.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let u=Math.pow(2,8*n-1);g(this,t,r,n,u-1,-u)}let o=0,c=1,a=0;for(this[r]=t&255;++o<n&&(c*=256);)t<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(t/c>>0)-a&255;return r+n};s.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let u=Math.pow(2,8*n-1);g(this,t,r,n,u-1,-u)}let o=n-1,c=1,a=0;for(this[r+o]=t&255;--o>=0&&(c*=256);)t<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(t/c>>0)-a&255;return r+n};s.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};s.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};s.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};s.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};s.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||g(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};s.prototype.writeBigInt64LE=F(function(t,r=0){return ct(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});s.prototype.writeBigInt64BE=F(function(t,r=0){return st(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function mt(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function at(e,t,r,n,i){return t=+t,r=r>>>0,i||mt(e,t,r,4,34028234663852886e22,-34028234663852886e22),N.write(e,t,r,n,23,4),r+4}s.prototype.writeFloatLE=function(t,r,n){return at(this,t,r,!0,n)};s.prototype.writeFloatBE=function(t,r,n){return at(this,t,r,!1,n)};function ut(e,t,r,n,i){return t=+t,r=r>>>0,i||mt(e,t,r,8,17976931348623157e292,-17976931348623157e292),N.write(e,t,r,n,52,8),r+8}s.prototype.writeDoubleLE=function(t,r,n){return ut(this,t,r,!0,n)};s.prototype.writeDoubleBE=function(t,r,n){return ut(this,t,r,!1,n)};s.prototype.copy=function(t,r,n,i){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);let o=i-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),r),o};s.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!s.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let c=t.charCodeAt(0);(i==="utf8"&&c<128||i==="latin1")&&(t=c)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let o;if(typeof t=="number")for(o=r;o<n;++o)this[o]=t;else{let c=s.isBuffer(t)?t:s.from(t,i),a=c.length;if(a===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=c[o%a]}return this};var C={};function G(e,t,r){C[e]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}G("ERR_BUFFER_OUT_OF_BOUNDS",function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);G("ERR_INVALID_ARG_TYPE",function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError);G("ERR_OUT_OF_RANGE",function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=tt(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=tt(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function tt(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function qt(e,t,r){k(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&S(t,e.length-(r+1))}function lt(e,t,r,n,i,o){if(e>r||e<t){let c=typeof t=="bigint"?"n":"",a;throw o>3?t===0||t===BigInt(0)?a=`>= 0${c} and < 2${c} ** ${(o+1)*8}${c}`:a=`>= -(2${c} ** ${(o+1)*8-1}${c}) and < 2 ** ${(o+1)*8-1}${c}`:a=`>= ${t}${c} and <= ${r}${c}`,new C.ERR_OUT_OF_RANGE("value",a,e)}qt(n,i,o)}function k(e,t){if(typeof e!="number")throw new C.ERR_INVALID_ARG_TYPE(t,"number",e)}function S(e,t,r){throw Math.floor(e)!==e?(k(e,r),new C.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new C.ERR_BUFFER_OUT_OF_BOUNDS:new C.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var zt=/[^+/0-9A-Za-z-_]/g;function Ht(e){if(e=e.split("=")[0],e=e.trim().replace(zt,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function O(e,t){t=t||1/0;let r,n=e.length,i=null,o=[];for(let c=0;c<n;++c){if(r=e.charCodeAt(c),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(c+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function Jt(e){let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function Xt(e,t){let r,n,i,o=[];for(let c=0;c<e.length&&!((t-=2)<0);++c)r=e.charCodeAt(c),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function ht(e){return D.toByteArray(Ht(e))}function _(e,t,r,n){let i;for(i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function B(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Y(e){return e!==e}var Kt=(function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t})();function F(e){return typeof BigInt>"u"?Zt:e}function Zt(){throw new Error("BigInt not supported")}});var gt=bt(ft());import{useState as q,useCallback as wt}from"react";import{useLayoutEffect as tr}from"react";import{Wallet as rr,CheckCircle as er,Loader2 as nr,AlertCircle as ir,ExternalLink as or,Cpu as cr}from"lucide-react";import{clsx as sr}from"clsx";import{twMerge as mr}from"tailwind-merge";var Qt=".mcms-mx-auto{margin-left:auto;margin-right:auto}.mcms-mb-3{margin-bottom:.75rem}.mcms-mb-4{margin-bottom:1rem}.mcms-mb-6{margin-bottom:1.5rem}.mcms-mt-1{margin-top:.25rem}.mcms-flex{display:flex}.mcms-h-12{height:3rem}.mcms-h-3{height:.75rem}.mcms-h-4{height:1rem}.mcms-h-5{height:1.25rem}.mcms-h-8{height:2rem}.mcms-w-12{width:3rem}.mcms-w-3{width:.75rem}.mcms-w-4{width:1rem}.mcms-w-5{width:1.25rem}.mcms-w-8{width:2rem}.mcms-w-full{width:100%}.mcms-shrink-0{flex-shrink:0}@keyframes mcms-spin{to{transform:rotate(1turn)}}.mcms-animate-spin{animation:mcms-spin 1s linear infinite}.mcms-flex-col{flex-direction:column}.mcms-items-center{align-items:center}.mcms-justify-center{justify-content:center}.mcms-justify-between{justify-content:space-between}.mcms-gap-1{gap:.25rem}.mcms-gap-2{gap:.5rem}.mcms-gap-3{gap:.75rem}.mcms-space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(.5rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem*var(--tw-space-y-reverse))}.mcms-space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse:0;margin-top:calc(1rem*(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem*var(--tw-space-y-reverse))}.mcms-overflow-hidden{overflow:hidden}.mcms-break-all{word-break:break-all}.mcms-rounded-2xl{border-radius:1rem}.mcms-rounded-lg{border-radius:.5rem}.mcms-rounded-xl{border-radius:.75rem}.mcms-border{border-width:1px}.mcms-border-t{border-top-width:1px}.mcms-border-green-200{--tw-border-opacity:1;border-color:rgb(187 247 208/var(--tw-border-opacity,1))}.mcms-border-red-100{--tw-border-opacity:1;border-color:rgb(254 226 226/var(--tw-border-opacity,1))}.mcms-border-slate-100{--tw-border-opacity:1;border-color:rgb(241 245 249/var(--tw-border-opacity,1))}.mcms-border-slate-200{--tw-border-opacity:1;border-color:rgb(226 232 240/var(--tw-border-opacity,1))}.mcms-bg-green-50{--tw-bg-opacity:1;background-color:rgb(240 253 244/var(--tw-bg-opacity,1))}.mcms-bg-indigo-50{--tw-bg-opacity:1;background-color:rgb(238 242 255/var(--tw-bg-opacity,1))}.mcms-bg-indigo-600{--tw-bg-opacity:1;background-color:rgb(79 70 229/var(--tw-bg-opacity,1))}.mcms-bg-orange-500{--tw-bg-opacity:1;background-color:rgb(249 115 22/var(--tw-bg-opacity,1))}.mcms-bg-red-50{--tw-bg-opacity:1;background-color:rgb(254 242 242/var(--tw-bg-opacity,1))}.mcms-bg-slate-100{--tw-bg-opacity:1;background-color:rgb(241 245 249/var(--tw-bg-opacity,1))}.mcms-bg-slate-50{--tw-bg-opacity:1;background-color:rgb(248 250 252/var(--tw-bg-opacity,1))}.mcms-bg-slate-900{--tw-bg-opacity:1;background-color:rgb(15 23 42/var(--tw-bg-opacity,1))}.mcms-bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity,1))}.mcms-p-2{padding:.5rem}.mcms-p-3{padding:.75rem}.mcms-p-4{padding:1rem}.mcms-p-6{padding:1.5rem}.mcms-px-4{padding-left:1rem;padding-right:1rem}.mcms-px-6{padding-left:1.5rem;padding-right:1.5rem}.mcms-py-3{padding-top:.75rem;padding-bottom:.75rem}.mcms-py-8{padding-top:2rem;padding-bottom:2rem}.mcms-text-center{text-align:center}.mcms-font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.mcms-text-lg{font-size:1.125rem;line-height:1.75rem}.mcms-text-sm{font-size:.875rem;line-height:1.25rem}.mcms-text-xs{font-size:.75rem;line-height:1rem}.mcms-font-bold{font-weight:700}.mcms-font-medium{font-weight:500}.mcms-font-semibold{font-weight:600}.mcms-uppercase{text-transform:uppercase}.mcms-tracking-wider{letter-spacing:.05em}.mcms-text-green-500{--tw-text-opacity:1;color:rgb(34 197 94/var(--tw-text-opacity,1))}.mcms-text-green-700{--tw-text-opacity:1;color:rgb(21 128 61/var(--tw-text-opacity,1))}.mcms-text-indigo-600{--tw-text-opacity:1;color:rgb(79 70 229/var(--tw-text-opacity,1))}.mcms-text-red-700{--tw-text-opacity:1;color:rgb(185 28 28/var(--tw-text-opacity,1))}.mcms-text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity,1))}.mcms-text-slate-500{--tw-text-opacity:1;color:rgb(100 116 139/var(--tw-text-opacity,1))}.mcms-text-slate-600{--tw-text-opacity:1;color:rgb(71 85 105/var(--tw-text-opacity,1))}.mcms-text-slate-900{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity,1))}.mcms-text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity,1))}.mcms-shadow-sm{--tw-shadow:0 1px 2px 0 rgba(0,0,0,.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.mcms-transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover:mcms-bg-black:hover{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity,1))}.hover:mcms-bg-indigo-700:hover{--tw-bg-opacity:1;background-color:rgb(67 56 202/var(--tw-bg-opacity,1))}.hover:mcms-bg-orange-600:hover{--tw-bg-opacity:1;background-color:rgb(234 88 12/var(--tw-bg-opacity,1))}.hover:mcms-text-indigo-700:hover{--tw-text-opacity:1;color:rgb(67 56 202/var(--tw-text-opacity,1))}",pt=()=>{if(typeof document>"u"||document.getElementById("mcms-crypto-styles"))return;let e=document.createElement("style");e.id="mcms-crypto-styles",e.textContent=Qt,document.head.appendChild(e)};import{jsx as f,jsxs as w}from"react/jsx-runtime";function dt(...e){return mr(sr(e))}var Br=({className:e,...t})=>{tr(()=>{typeof window<"u"&&pt()},[]);let{status:r,intent:n,error:i,initiate:o,verify:c,setStatus:a,handleSolanaPay:u,handleEVMPay:h}=yt(t);return r==="success"?w("div",{className:dt("mcms-p-6 mcms-text-center mcms-bg-green-50 mcms-rounded-xl mcms-border mcms-border-green-200",e),children:[f(er,{className:"mcms-mx-auto mcms-w-12 mcms-h-12 mcms-text-green-500 mcms-mb-4"}),f("h3",{className:"mcms-text-lg mcms-font-semibold mcms-green-900",children:"Payment Successful"}),f("p",{className:"mcms-text-green-700 mcms-mt-1",children:"Your order has been confirmed."})]}):w("div",{className:dt("mcms-bg-white mcms-rounded-2xl mcms-border mcms-border-slate-200 mcms-shadow-sm mcms-overflow-hidden",e),children:[w("div",{className:"mcms-p-6",children:[w("div",{className:"mcms-flex mcms-items-center mcms-gap-3 mcms-mb-6",children:[f("div",{className:"mcms-p-2 mcms-bg-indigo-50 mcms-rounded-lg",children:f(rr,{className:"mcms-w-5 mcms-h-5 mcms-text-indigo-600"})}),w("div",{children:[f("h3",{className:"mcms-font-semibold mcms-text-slate-900",children:"Crypto Payment"}),f("p",{className:"mcms-text-sm mcms-text-slate-500",children:"Pay securely using your wallet"})]})]}),i&&w("div",{className:"mcms-mb-4 mcms-p-3 mcms-bg-red-50 mcms-border mcms-border-red-100 mcms-rounded-lg mcms-flex mcms-gap-3 mcms-text-red-700 mcms-text-sm",children:[f(ir,{className:"mcms-w-4 mcms-h-4 mcms-shrink-0"}),f("p",{children:i})]}),r==="idle"&&f("button",{onClick:o,className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-indigo-600 hover:mcms-bg-indigo-700 mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:"Start Payment"}),(r==="connecting"||r==="initiating"||r==="verifying")&&w("div",{className:"mcms-py-8 mcms-text-center",children:[f(nr,{className:"mcms-w-8 mcms-h-8 mcms-text-indigo-600 mcms-animate-spin mcms-mx-auto mcms-mb-3"}),f("p",{className:"mcms-text-slate-600 mcms-font-medium",children:r==="connecting"?"Connecting wallet...":r==="initiating"?"Preparing transaction...":"Verifying on-chain..."})]}),r==="pending_signature"&&n&&w("div",{className:"mcms-space-y-4",children:[w("div",{className:"mcms-p-4 mcms-bg-slate-50 mcms-rounded-xl mcms-space-y-2",children:[w("div",{className:"mcms-flex mcms-justify-between mcms-text-sm",children:[f("span",{className:"mcms-text-slate-500",children:"Amount to pay"}),w("span",{className:"mcms-font-mono mcms-font-medium mcms-text-slate-900",children:[n.amount," ",n.currency]})]}),w("div",{className:"mcms-flex mcms-justify-between mcms-text-sm",children:[f("span",{className:"mcms-text-slate-500",children:"Order ID"}),f("span",{className:"mcms-font-mono mcms-text-slate-900",children:n.orderId})]}),w("div",{className:"mcms-flex mcms-justify-between mcms-text-sm",children:[f("span",{className:"mcms-text-slate-500",children:"Network"}),f("span",{className:"mcms-text-slate-900 mcms-font-medium",children:n.network})]})]}),w("div",{className:"mcms-space-y-2",children:[f("p",{className:"mcms-text-xs mcms-text-slate-500 mcms-uppercase mcms-font-bold mcms-tracking-wider",children:"Destination Address"}),f("div",{className:"mcms-p-3 mcms-bg-slate-100 mcms-rounded-lg mcms-font-mono mcms-text-xs mcms-break-all mcms-text-slate-600 mcms-border mcms-border-slate-200 mcms-flex mcms-justify-center",children:n.paymentAddress?`${n.paymentAddress.slice(0,6)}...${n.paymentAddress.slice(-4)}`:"Establishing..."})]}),f("div",{className:"mcms-flex mcms-flex-col mcms-gap-2",children:n.network?.toLowerCase().includes("solana")?w("button",{onClick:u,className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-indigo-600 hover:mcms-bg-indigo-700 mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:[f(cr,{className:"mcms-w-4 mcms-h-4"}),"Pay with Phantom"]}):n.network?.toLowerCase().includes("ethereum")||n.network?.toLowerCase().includes("evm")||n.network?.toLowerCase().includes("polygon")?w("button",{onClick:h,className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-orange-500 hover:mcms-bg-orange-600 mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:[f("img",{src:"https://upload.wikimedia.org/wikipedia/commons/3/36/MetaMask_Mirror_Logo.svg",className:"mcms-w-4 mcms-h-4",alt:"MetaMask"}),"Pay with MetaMask"]}):f("button",{onClick:()=>{a("verifying"),setTimeout(()=>c("0x_mock_transaction_hash_generic"),2e3)},className:"mcms-w-full mcms-py-3 mcms-px-4 mcms-bg-slate-900 hover:mcms-bg-black mcms-text-white mcms-font-medium mcms-rounded-xl mcms-transition-colors mcms-flex mcms-items-center mcms-justify-center mcms-gap-2",children:"Confirm in Wallet"})})]})]}),w("div",{className:"mcms-bg-slate-50 mcms-px-6 mcms-py-3 mcms-border-t mcms-border-slate-100 mcms-flex mcms-justify-between mcms-items-center",children:[f("span",{className:"mcms-text-xs mcms-text-slate-400",children:"Powered by Micro-CMS Crypto"}),w("a",{href:"#",className:"mcms-text-xs mcms-text-indigo-600 hover:mcms-text-indigo-700 mcms-font-medium mcms-flex mcms-items-center mcms-gap-1",children:["Help ",f(or,{className:"mcms-w-3 mcms-h-3"})]})]})]})};typeof window<"u"&&(window.Buffer||(window.Buffer=gt.Buffer),window.global||(window.global=window),window.process||(window.process={env:{}}));var yt=e=>{let[t,r]=q("idle"),[n,i]=q(null),[o,c]=q(null),a=wt(async m=>{try{if(r("verifying"),e.provider){let x=await e.provider.verifyPayment(m,e.orderId);if(x.status==="confirmed")r("success"),e.onSuccess?.(x);else throw new Error("Payment not confirmed yet, status: "+x.status);return}let p=await fetch(e.endpoints?.verify||"/api/orders/verify-payment",{method:"POST",headers:{"Content-Type":"application/json",...e.headers||{}},body:JSON.stringify({orderId:o?.orderId||e.orderId,transactionHash:m})});if(!p.ok){let x=await p.json();throw new Error(x.error||"Payment verification failed")}let d=await p.json();if(d.status==="confirmed")r("success"),e.onSuccess?.(d);else throw new Error("Payment not confirmed yet, status: "+d.status)}catch(p){i(p.message),r("error"),e.onError?.(p)}},[e.provider,e.endpoints?.verify,e.orderId,e.onSuccess,e.onError,e.headers,o?.orderId]),u=async()=>{try{if(!o){i("Payment intent not established."),r("error");return}r("connecting");let{useSolanaWallet:m}=await import("./SolanaProvider-ENB75WTB.mjs"),p=m(),d=await p.connect();r("pending_signature");let x=await p.sendPayment(o);r("verifying"),await a(x)}catch(m){i(m.message||"Failed to connect to Phantom or sign transaction."),r("error"),e.onError?.(m instanceof Error?m:new Error(String(m)))}},h=async()=>{try{if(!o){i("Payment intent not established."),r("error");return}r("connecting");let{useEVMWallet:m}=await import("./EVMProvider-XRVRSEAC.mjs"),p=m(),d=await p.connect();r("pending_signature");let x=await p.sendPayment(o);r("verifying"),await a(x)}catch(m){i(m.message||"Failed to connect to MetaMask or sign transaction."),r("error"),e.onError?.(m instanceof Error?m:new Error(String(m)))}},l=wt(async()=>{try{if(r("initiating"),i(null),e.provider){let d=await e.provider.initiatePayment(e.orderId,{amount:e.amount,currency:e.currency});c(d),r("pending_signature");return}let m=await fetch(e.endpoints?.initiate||"/api/orders/initiate",{method:"POST",headers:{"Content-Type":"application/json",...e.headers||{}},body:JSON.stringify({productId:e.orderId,amount:e.amount,currency:e.currency,paymentProvider:"crypto"})});if(!m.ok){let d=await m.json();throw new Error(d.error||"Failed to initiate payment intent")}let p=await m.json();c(p),r("pending_signature")}catch(m){i(m.message),r("error"),e.onError?.(m)}},[e.provider,e.endpoints?.initiate,e.orderId,e.amount,e.currency,e.onError,e.headers]);return{status:t,intent:o,error:n,initiate:l,verify:a,setStatus:r,isSolanaAvailable:!0,handleSolanaPay:u,isEVMAvailable:!0,handleEVMPay:h}};export{Qt as CSS_CONTENT,Br as PaymentWidget,pt as injectStyles,yt as usePayment};
2
2
  /*! Bundled license information:
3
3
 
4
4
  ieee754/index.js: