33 lines
122 KiB
JavaScript
Raw Normal View History

2025-04-19 15:38:48 +08:00
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("WalletConnectUtils",[],r):"object"==typeof exports?exports.WalletConnectUtils=r():t.WalletConnectUtils=r()}(this,(function(){return function(t){var r={};function n(e){if(r[e])return r[e].exports;var i=r[e]={i:e,l:!1,exports:{}};return t[e].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,r){if(1&r&&(t=n(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)n.d(e,i,function(r){return t[r]}.bind(null,i));return e},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.p="",n(n.s=29)}([function(t,r,n){"use strict";n.d(r,"f",(function(){return e})),n.d(r,"d",(function(){return i})),n.d(r,"e",(function(){return o})),n.d(r,"c",(function(){return u})),n.d(r,"b",(function(){return s})),n.d(r,"h",(function(){return a})),n.d(r,"g",(function(){return f})),n.d(r,"i",(function(){return h})),n.d(r,"j",(function(){return c})),n.d(r,"a",(function(){return l}));const e="PARSE_ERROR",i="INVALID_REQUEST",o="METHOD_NOT_FOUND",u="INVALID_PARAMS",s="INTERNAL_ERROR",a="SERVER_ERROR",f=[-32700,-32600,-32601,-32602,-32603],h=[-32e3,-32099],c={[e]:{code:-32700,message:"Parse error"},[i]:{code:-32600,message:"Invalid Request"},[o]:{code:-32601,message:"Method not found"},[u]:{code:-32602,message:"Invalid params"},[s]:{code:-32603,message:"Internal error"},[a]:{code:-32e3,message:"Server error"}},l=a},function(t,r,n){"use strict";function e(t){let r=void 0;return"undefined"!=typeof window&&void 0!==window[t]&&(r=window[t]),r}function i(t){const r=e(t);if(!r)throw new Error(t+" is not defined in Window");return r}Object.defineProperty(r,"__esModule",{value:!0}),r.getLocalStorage=r.getLocalStorageOrThrow=r.getCrypto=r.getCryptoOrThrow=r.getLocation=r.getLocationOrThrow=r.getNavigator=r.getNavigatorOrThrow=r.getDocument=r.getDocumentOrThrow=r.getFromWindowOrThrow=r.getFromWindow=void 0,r.getFromWindow=e,r.getFromWindowOrThrow=i,r.getDocumentOrThrow=function(){return i("document")},r.getDocument=function(){return e("document")},r.getNavigatorOrThrow=function(){return i("navigator")},r.getNavigator=function(){return e("navigator")},r.getLocationOrThrow=function(){return i("location")},r.getLocation=function(){return e("location")},r.getCryptoOrThrow=function(){return i("crypto")},r.getCrypto=function(){return e("crypto")},r.getLocalStorageOrThrow=function(){return i("localStorage")},r.getLocalStorage=function(){return e("localStorage")}},function(t,r,n){"use strict";n.d(r,"d",(function(){return i})),n.d(r,"c",(function(){return o})),n.d(r,"e",(function(){return u})),n.d(r,"a",(function(){return s})),n.d(r,"b",(function(){return a})),n.d(r,"g",(function(){return f})),n.d(r,"f",(function(){return h}));var e=n(0);function i(t){return t<=e.i[0]&&t>=e.i[1]}function o(t){return e.g.includes(t)}function u(t){return"number"==typeof t}function s(t){return Object.keys(e.j).includes(t)?e.j[t]:e.j[e.a]}function a(t){const r=Object.values(e.j).find(r=>r.code===t);return r||e.j[e.a]}function f(t){if(void 0===t.error.code)return{valid:!1,error:"Missing code for JSON-RPC error"};if(void 0===t.error.message)return{valid:!1,error:"Missing message for JSON-RPC error"};if(!u(t.error.code))return{valid:!1,error:"Invalid error code type for JSON-RPC: "+t.error.code};if(o(t.error.code)){const r=a(t.error.code);if(r.message!==e.j[e.a].message&&t.error.message===r.message)return{valid:!1,error:"Invalid error code message for JSON-RPC: "+t.error.code}}return{valid:!0}}function h(t,r,n){return t.mes
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)r.hasOwnProperty(n)&&(t[n]=r[n])})(t,r)};function i(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var o=function(){return(o=Object.assign||function(t){for(var r,n=1,e=arguments.length;n<e;n++)for(var i in r=arguments[n])Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i]);return t}).apply(this,arguments)};function u(t,r){var n={};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.indexOf(e)<0&&(n[e]=t[e]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(e=Object.getOwnPropertySymbols(t);i<e.length;i++)r.indexOf(e[i])<0&&(n[e[i]]=t[e[i]])}return n}function s(t,r,n,e){var i,o=arguments.length,u=o<3?r:null===e?e=Object.getOwnPropertyDescriptor(r,n):e;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,r,n,e);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(u=(o<3?i(u):o>3?i(r,n,u):i(r,n))||u);return o>3&&u&&Object.defineProperty(r,n,u),u}function a(t,r){return function(n,e){r(n,e,t)}}function f(t,r){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,r)}function h(t,r,n,e){return new(n||(n=Promise))((function(i,o){function u(t){try{a(e.next(t))}catch(t){o(t)}}function s(t){try{a(e.throw(t))}catch(t){o(t)}}function a(t){t.done?i(t.value):new n((function(r){r(t.value)})).then(u,s)}a((e=e.apply(t,r||[])).next())}))}function c(t,r){var n,e,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,e&&(i=2&o[0]?e.return:o[0]?e.throw||((i=e.return)&&i.call(e),0):e.next)&&!(i=i.call(e,o[1])).done)return i;switch(e=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,e=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=r.call(t,u)}catch(t){o=[6,t],e=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function l(t,r){for(var n in t)r.hasOwnProperty(n)||(r[n]=t[n])}function d(t){var r="function"==typeof Symbol&&t[Symbol.iterator],n=0;return r?r.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function p(t,r){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var e,i,o=n.call(t),u=[];try{for(;(void 0===r||r-- >0)&&!(e=o.next()).done;)u.push(e.value)}catch(t){i={error:t}}finally{try{e&&!e.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return u}function m(){for(var t=[],r=0;r<arguments.length;r++)t=t.concat(p(arguments[r]));return t}function g(t){return this instanceof g?(this.v=t,this):new g(t)}function y(t,r,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,i=n.apply(t,r||[]),o=[];return e={},u("next"),u("throw"),u("return"),e[Symbol.asyncIterator]=function(){return this},e;function u(t){i[t]&&(e[t]=function(r){return new Promise((function(n,e){o.push([t,r,n,e])>1||s(t,r)}))})}function s(t,r){try{(n=i[t](r)).value instanceof g?Promise.resolve(n.value.v).then(a,f):h(o[0][2],n)}catch(t){h(o[0][3],t)}var n}function a(t){s("next",t)}function f(t){s("throw",t)}function h(t,r){t(r),o.shift(),o.length&&s(o[0][0],o[0][1])}}function v(t){var r,n;return r={},e("next"),e("throw",(function(t){throw t})),e("return"),r[Symbol.iterator]=function(){return this},r;function e(e,i){r[e]=t[e]?function(r){return(n=!n)?{value:g(t[e](r)),done:"return"===e}:i?i(r):r}:i}}function
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
var e=n(33),i=n(34),o=n(35);function u(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(t,r){if(u()<r)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=a.prototype:(null===t&&(t=new a(r)),t.length=r),t}function a(t,r,n){if(!(a.TYPED_ARRAY_SUPPORT||this instanceof a))return new a(t,r,n);if("number"==typeof t){if("string"==typeof r)throw new Error("If encoding is specified then the first argument must be a string");return c(this,t)}return f(this,t,r,n)}function f(t,r,n,e){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?function(t,r,n,e){if(r.byteLength,n<0||r.byteLength<n)throw new RangeError("'offset' is out of bounds");if(r.byteLength<n+(e||0))throw new RangeError("'length' is out of bounds");r=void 0===n&&void 0===e?new Uint8Array(r):void 0===e?new Uint8Array(r,n):new Uint8Array(r,n,e);a.TYPED_ARRAY_SUPPORT?(t=r).__proto__=a.prototype:t=l(t,r);return t}(t,r,n,e):"string"==typeof r?function(t,r,n){"string"==typeof n&&""!==n||(n="utf8");if(!a.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var e=0|p(r,n),i=(t=s(t,e)).write(r,n);i!==e&&(t=t.slice(0,i));return t}(t,r,n):function(t,r){if(a.isBuffer(r)){var n=0|d(r.length);return 0===(t=s(t,n)).length||r.copy(t,0,0,n),t}if(r){if("undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return"number"!=typeof r.length||(e=r.length)!=e?s(t,0):l(t,r);if("Buffer"===r.type&&o(r.data))return l(t,r.data)}var e;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,r)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function c(t,r){if(h(r),t=s(t,r<0?0:0|d(r)),!a.TYPED_ARRAY_SUPPORT)for(var n=0;n<r;++n)t[n]=0;return t}function l(t,r){var n=r.length<0?0:0|d(r.length);t=s(t,n);for(var e=0;e<n;e+=1)t[e]=255&r[e];return t}function d(t){if(t>=u())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u().toString(16)+" bytes");return 0|t}function p(t,r){if(a.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var e=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return W(t).length;default:if(e)return H(t).length;r=(""+r).toLowerCase(),e=!0}}function m(t,r,n){var e=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,r,n);case"utf8":case"utf-8":return T(this,r,n);case"ascii":return S(this,r,n);case"latin1":case"binary":return O(this,r,n);case"base64":return E(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,r,n);default:if(e)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),e=!0}}function g(t,r,n){var e=t[r];t[r]=t[n],t[n]=e}function y(t,r,n,e,i){if(0===t.length)return-1;if("string"==typeof n?(e=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof r&&(r=a.from(r,e)),a.isBuffer(r))return 0===r.length?-1:v(t,r,n,e,i);if("number"==typeof r)return r&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,r,n):Uint8Array.prototype.lastIndexOf.call(t,r,n):v(t,[r],n,e,i);throw new TypeError("val must be string, number or Buffer")}function v(t,r,n,e,i){var o,u=1,s=t.length,a=r.length;if(void 0!==e&&("ucs2"===(e=String(e).toLowerCase())||"ucs
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
r.read=function(t,r,n,e,i){var o,u,s=8*i-e-1,a=(1<<s)-1,f=a>>1,h=-7,c=n?i-1:0,l=n?-1:1,d=t[r+c];for(c+=l,o=d&(1<<-h)-1,d>>=-h,h+=s;h>0;o=256*o+t[r+c],c+=l,h-=8);for(u=o&(1<<-h)-1,o>>=-h,h+=e;h>0;u=256*u+t[r+c],c+=l,h-=8);if(0===o)o=1-f;else{if(o===a)return u?NaN:1/0*(d?-1:1);u+=Math.pow(2,e),o-=f}return(d?-1:1)*u*Math.pow(2,o-e)},r.write=function(t,r,n,e,i,o){var u,s,a,f=8*o-i-1,h=(1<<f)-1,c=h>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=e?0:o-1,p=e?1:-1,m=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(s=isNaN(r)?1:0,u=h):(u=Math.floor(Math.log(r)/Math.LN2),r*(a=Math.pow(2,-u))<1&&(u--,a*=2),(r+=u+c>=1?l/a:l*Math.pow(2,1-c))*a>=2&&(u++,a/=2),u+c>=h?(s=0,u=h):u+c>=1?(s=(r*a-1)*Math.pow(2,i),u+=c):(s=r*Math.pow(2,c-1)*Math.pow(2,i),u=0));i>=8;t[n+d]=255&s,d+=p,s/=256,i-=8);for(u=u<<i|s,f+=i;f>0;t[n+d]=255&u,d+=p,u/=256,f-=8);t[n+d-p]|=128*m}},function(t,r){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,r,n){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseTransactionData=r.parsePersonalSign=r.isValidAddress=r.toChecksumAddress=void 0;const e=n(37),i=n(5),o=n(11),u=n(13),s=n(24);function a(t){t=(0,i.removeHexPrefix)(t.toLowerCase());const r=(0,i.removeHexPrefix)((0,e.keccak_256)((0,o.convertUtf8ToBuffer)(t)));let n="";for(let e=0;e<t.length;e++)parseInt(r[e],16)>7?n+=t[e].toUpperCase():n+=t[e];return(0,i.addHexPrefix)(n)}r.toChecksumAddress=a;r.isValidAddress=t=>!!t&&("0x"===t.toLowerCase().substring(0,2)&&(!!/^(0x)?[0-9a-f]{40}$/i.test(t)&&(!(!/^(0x)?[0-9a-f]{40}$/.test(t)&&!/^(0x)?[0-9A-F]{40}$/.test(t))||t===a(t)))),r.parsePersonalSign=function(t){return(0,s.isEmptyArray)(t)||(0,s.isHexString)(t[0])||(t[0]=(0,o.convertUtf8ToHex)(t[0])),t},r.parseTransactionData=function(t){if(void 0!==t.type&&"0"!==t.type)return t;if(void 0===t.from||!(0,r.isValidAddress)(t.from))throw new Error("Transaction object must include a valid 'from' value.");function n(t){let r=t;return("number"==typeof t||"string"==typeof t&&!(0,s.isEmptyString)(t))&&((0,s.isHexString)(t)?"string"==typeof t&&(r=(0,u.sanitizeHex)(t)):r=(0,o.convertNumberToHex)(t)),"string"==typeof r&&(r=(0,u.removeHexLeadingZeros)(r)),r}const e={from:(0,u.sanitizeHex)(t.from),to:void 0===t.to?void 0:(0,u.sanitizeHex)(t.to),gasPrice:void 0===t.gasPrice?"":n(t.gasPrice),gas:void 0===t.gas?void 0===t.gasLimit?"":n(t.gasLimit):n(t.gas),value:void 0===t.value?"":n(t.value),nonce:void 0===t.nonce?"":n(t.nonce),data:void 0===t.data?"":(0,u.sanitizeHex)(t.data)||"0x"},i=["gasPrice","gas","value","nonce"];return Object.keys(e).forEach(t=>{(void 0===e[t]||"string"==typeof e[t]&&!e[t].trim().length)&&i.includes(t)&&delete e[t]}),e}},function(t,r,n){(function(e,i){var o;
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2018
* @license MIT
*/!function(){"use strict";var u="input is invalid type",s="object"==typeof window,a=s?window:{};a.JS_SHA3_NO_WINDOW&&(s=!1);var f=!s&&"object"==typeof self;!a.JS_SHA3_NO_NODE_JS&&"object"==typeof e&&e.versions&&e.versions.node?a=i:f&&(a=self);var h=!a.JS_SHA3_NO_COMMON_JS&&"object"==typeof t&&t.exports,c=n(38),l=!a.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,d="0123456789abcdef".split(""),p=[4,1024,262144,67108864],m=[0,8,16,24],g=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],y=[224,256,384,512],v=[128,256],w=["hex","buffer","arrayBuffer","array","digest"],b={128:168,256:136};!a.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!l||!a.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});for(var M=function(t,r,n){return function(e){return new j(t,r,t).update(e)[n]()}},_=function(t,r,n){return function(e,i){return new j(t,r,i).update(e)[n]()}},R=function(t,r,n){return function(r,e,i,o){return O["cshake"+t].update(r,e,i,o)[n]()}},A=function(t,r,n){return function(r,e,i,o){return O["kmac"+t].update(r,e,i,o)[n]()}},E=function(t,r,n,e){for(var i=0;i<w.length;++i){var o=w[i];t[o]=r(n,e,o)}return t},T=function(t,r){var n=M(t,r,"hex");return n.create=function(){return new j(t,r,t)},n.update=function(t){return n.create().update(t)},E(n,M,t,r)},S=[{name:"keccak",padding:[1,256,65536,16777216],bits:y,createMethod:T},{name:"sha3",padding:[6,1536,393216,100663296],bits:y,createMethod:T},{name:"shake",padding:[31,7936,2031616,520093696],bits:v,createMethod:function(t,r){var n=_(t,r,"hex");return n.create=function(n){return new j(t,r,n)},n.update=function(t,r){return n.create(r).update(t)},E(n,_,t,r)}},{name:"cshake",padding:p,bits:v,createMethod:function(t,r){var n=b[t],e=R(t,0,"hex");return e.create=function(e,i,o){return i||o?new j(t,r,e).bytepad([i,o],n):O["shake"+t].create(e)},e.update=function(t,r,n,i){return e.create(r,n,i).update(t)},E(e,R,t,r)}},{name:"kmac",padding:p,bits:v,createMethod:function(t,r){var n=b[t],e=A(t,0,"hex");return e.create=function(e,i,o){return new U(t,r,i).bytepad(["KMAC",o],n).bytepad([e],n)},e.update=function(t,r,n,i){return e.create(t,n,i).update(r)},E(e,A,t,r)}}],O={},x=[],B=0;B<S.length;++B)for(var P=S[B],N=P.bits,k=0;k<N.length;++k){var C=P.name+"_"+N[k];if(x.push(C),O[C]=P.createMethod(N[k],P.padding),"sha3"!==P.name){var I=P.name+N[k];x.push(I),O[I]=O[C]}}function j(t,r,n){this.blocks=[],this.s=[],this.padding=r,this.outputBits=n,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(t<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=n>>5,this.extraBytes=(31&n)>>3;for(var e=0;e<50;++e)this.s[e]=0}function U(t,r,n){j.call(this,t,r,n)}j.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var r,n=typeof t;if("string"!==n){if("object"!==n)throw new Error(u);if(null===t)throw new Error(u);if(l&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||l&&ArrayBuffer.isView(t)))throw new Error(u);r=!0}for(var e,i,o=this.blocks,s=this.byteCount,a=t.length,f=this.blockCount,h=0,c=this.s;h<a;){if(this.reset)for(this.reset=!1,o[0]=this.block,e=1;e<f+1;++e)o[e]=0;if(r)for(e=this.start;h<a&&e<s;++h)o[e>>2]|=t[h]<<m[3&e++];else for(e=this.start;h<a&&e<s;++h)(i=t.charCodeAt(h))<128?o[e>>2]|=i<<m[3&e++]:i<2048?(o[e>>2]|=(192|i>>6)<<m[3&e++],o[e>>2]|=(128|63&i)<<m[3&e++]):i<55296||i>=57344?(o[e>>2]|=(224|i>>12)<<m[3&e++],o[e>>2]|=(128|i>>6&63)<<m[3&e++],o[e>>2]|=(128|63&i)<<m[3&e++]):(i=65536+((1023&i)<<10|1023&t.charCodeAt(++h)),o[e>>2]|=(240|i>>18)<<m[3&e++],o[e>>2]|=(128|i>>12&63)<<m[3&e++],o[e>>2]|=(128|i>>6&63)<<m[3&e++],o[e>>2]|=(1