LavaPack.loadBundle([[6513,{"./core.js":6512,"./helpers.js":6514},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});
/*!
 * https://github.com/Starcounter-Jack/JSON-Patch
 * (c) 2017-2021 Joachim Wester
 * MIT license
 */
var n=e("./helpers.js"),o=e("./core.js"),s=new WeakMap,i=function(e){this.observers=new Map,this.obj=e},a=function(e,t){this.callback=e,this.observer=t};function c(e,t){void 0===t&&(t=!1);var r=s.get(e.object);u(r.value,e.object,e.patches,"",t),e.patches.length&&o.applyPatch(r.value,e.patches);var n=e.patches;return n.length>0&&(e.patches=[],e.callback&&e.callback(n)),n}function u(e,t,r,o,s){if(t!==e){"function"==typeof t.toJSON&&(t=t.toJSON());for(var i=n._objectKeys(t),a=n._objectKeys(e),c=!1,f=a.length-1;f>=0;f--){var l=e[h=a[f]];if(!n.hasOwnProperty(t,h)||t[h]===undefined&&l!==undefined&&!1===Array.isArray(t))Array.isArray(e)===Array.isArray(t)?(s&&r.push({op:"test",path:o+"/"+n.escapePathComponent(h),value:n._deepClone(l)}),r.push({op:"remove",path:o+"/"+n.escapePathComponent(h)}),c=!0):(s&&r.push({op:"test",path:o,value:e}),r.push({op:"replace",path:o,value:t}),!0);else{var d=t[h];"object"==typeof l&&null!=l&&"object"==typeof d&&null!=d&&Array.isArray(l)===Array.isArray(d)?u(l,d,r,o+"/"+n.escapePathComponent(h),s):l!==d&&(s&&r.push({op:"test",path:o+"/"+n.escapePathComponent(h),value:n._deepClone(l)}),r.push({op:"replace",path:o+"/"+n.escapePathComponent(h),value:n._deepClone(d)}))}}if(c||i.length!=a.length)for(f=0;f<i.length;f++){var h=i[f];n.hasOwnProperty(e,h)||t[h]===undefined||r.push({op:"add",path:o+"/"+n.escapePathComponent(h),value:n._deepClone(t[h])})}}}r.unobserve=function(e,t){t.unobserve()},r.observe=function(e,t){var r,o=function(e){return s.get(e)}(e);if(o){var u=function(e,t){return e.observers.get(t)}(o,t);r=u&&u.observer}else o=new i(e),s.set(e,o);if(r)return r;if(r={},o.value=n._deepClone(e),t){r.callback=t,r.next=null;var f=function(){c(r)},l=function(){clearTimeout(r.next),r.next=setTimeout(f)};"undefined"!=typeof window&&(window.addEventListener("mouseup",l),window.addEventListener("keyup",l),window.addEventListener("mousedown",l),window.addEventListener("keydown",l),window.addEventListener("change",l))}return r.patches=[],r.object=e,r.unobserve=function(){c(r),clearTimeout(r.next),function(e,t){e.observers.delete(t.callback)}(o,r),"undefined"!=typeof window&&(window.removeEventListener("mouseup",l),window.removeEventListener("keyup",l),window.removeEventListener("mousedown",l),window.removeEventListener("keydown",l),window.removeEventListener("change",l))},o.observers.set(t,new a(t,r)),r},r.generate=c,r.compare=function(e,t,r){void 0===r&&(r=!1);var n=[];return u(e,t,n,"",r),n}}}},{package:"fast-json-patch",file:"node_modules/fast-json-patch/commonjs/duplex.js"}],[6514,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){
/*!
 * https://github.com/Starcounter-Jack/JSON-Patch
 * (c) 2017-2022 Joachim Wester
 * MIT licensed
 */
var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},n(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var s=Object.prototype.hasOwnProperty;function i(e,t){return s.call(e,t)}function a(e){if(Array.isArray(e)){for(var t=new Array(e.length),r=0;r<t.length;r++)t[r]=""+r;return t}if(Object.keys)return Object.keys(e);var n=[];for(var o in e)i(e,o)&&n.push(o);return n}function c(e){return-1===e.indexOf("/")&&-1===e.indexOf("~")?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function u(e,t){var r;for(var n in e)if(i(e,n)){if(e[n]===t)return c(n)+"/";if("object"==typeof e[n]&&""!=(r=u(e[n],t)))return c(n)+"/"+r}return""}function f(e,t){var r=[e];for(var n in t){var o="object"==typeof t[n]?JSON.stringify(t[n],null,2):t[n];void 0!==o&&r.push(n+": "+o)}return r.join("\n")}Object.defineProperty(r,"hasOwnProperty",{value:i}),r._objectKeys=a,r._deepClone=function(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}},r.isInteger=function(e){for(var t,r=0,n=e.length;r<n;){if(!((t=e.charCodeAt(r))>=48&&t<=57))return!1;r++}return!0},r.escapePathComponent=c,r.unescapePathComponent=function(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")},r._getPathRecursive=u,r.getPath=function(e,t){if(e===t)return"/";var r=u(e,t);if(""===r)throw new Error("Object not found in root");return"/"+r},r.hasUndefined=function e(t){if(t===undefined)return!0;if(t)if(Array.isArray(t)){for(var r=0,n=t.length;r<n;r++)if(e(t[r]))return!0}else if("object"==typeof t)for(var o=a(t),s=o.length,i=0;i<s;i++)if(e(t[o[i]]))return!0;return!1};var l=function(e){function t(t,r,n,o,s){var i=this.constructor,a=e.call(this,f(t,{name:r,index:n,operation:o,tree:s}))||this;return a.name=r,a.index=n,a.operation=o,a.tree=s,Object.setPrototypeOf(a,i.prototype),a.message=f(t,{name:r,index:n,operation:o,tree:s}),a}return o(t,e),t}(Error);r.PatchError=l}}},{package:"fast-json-patch",file:"node_modules/fast-json-patch/commonjs/helpers.js"}],[6515,{"./commonjs/core.js":6512,"./commonjs/duplex.js":6513,"./commonjs/helpers.js":6514},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=e("./commonjs/core.js");Object.assign(r,n);var o=e("./commonjs/duplex.js");Object.assign(r,o);var s=e("./commonjs/helpers.js");r.JsonPatchError=s.PatchError,r.deepClone=s._deepClone,r.escapePathComponent=s.escapePathComponent,r.unescapePathComponent=s.unescapePathComponent}}},{package:"fast-json-patch",file:"node_modules/fast-json-patch/index.js"}],[652,{"@metamask/utils":3935},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils");const o=r.version=200;r.migrate=async(e,t)=>{e.meta.version=o,function(e,t){if(!(0,n.hasProperty)(e,"PreferencesController")||!(0,n.isObject)(e.PreferencesController))return;if(!(0,n.hasProperty)(e.PreferencesController,"preferences")||!(0,n.isObject)(e.PreferencesController.preferences))return;(0,n.hasProperty)(e.PreferencesController.preferences,"showDefaultAddress")&&!1===e.PreferencesController.preferences.showDefaultAddress&&(e.PreferencesController.preferences.showDefaultAddress=!0,t.add("PreferencesController"))}(e.data,t)}}}},{package:"$root$",file:"app/scripts/migrations/200.ts"}],[6520,{"@firebase/app":978},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n=e("@firebase/app");Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===n[e]||Object.defineProperty(r,e,{enumerable:!0,get:function(){return n[e]}}))});
/**
 * @license
 * Copyright 2020 Google LLC
 *
 * 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
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * @license
 * Copyright 2020 Google LLC
 *
 * 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
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
(0,n.registerVersion)("firebase","11.2.0","app")}}},{package:"@metamask/notification-services-controller>firebase",file:"node_modules/firebase/app/dist/esm/index.esm.js"}],[6521,{"@firebase/messaging":982},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n=e("@firebase/messaging");Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===n[e]||Object.defineProperty(r,e,{enumerable:!0,get:function(){return n[e]}}))})}}},{package:"@metamask/notification-services-controller>firebase",file:"node_modules/firebase/messaging/dist/esm/index.esm.js"}],[6522,{"@firebase/messaging/sw":983},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n=e("@firebase/messaging/sw");Object.keys(n).forEach(function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===n[e]||Object.defineProperty(r,e,{enumerable:!0,get:function(){return n[e]}}))})}}},{package:"@metamask/notification-services-controller>firebase",file:"node_modules/firebase/messaging/sw/dist/esm/index.esm.js"}],[653,{"@metamask/utils":3935},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils");const o=r.version=201;r.migrate=async(e,t)=>{e.meta.version=o,function(e,t){if(!(0,n.hasProperty)(e,"SnapsRegistry")||!(0,n.isObject)(e.SnapsRegistry))return;const{SnapsRegistry:r}=e;e.SnapRegistryController=r,delete e.SnapsRegistry,t.add("SnapRegistryController"),t.add("SnapsRegistry")}(e.data,t)}}}},{package:"$root$",file:"app/scripts/migrations/201.ts"}],[654,{"@metamask/utils":3935},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils");const o=r.version=202;r.migrate=async(e,t)=>{e.meta.version=o,(0,n.hasProperty)(e.data,"PreferencesController")&&(0,n.isObject)(e.data.PreferencesController)&&(0,n.hasProperty)(e.data.PreferencesController,"useBlockie")&&(delete e.data.PreferencesController.useBlockie,t.add("PreferencesController"))}}}},{package:"$root$",file:"app/scripts/migrations/202.ts"}],[655,{"@metamask/utils":3935},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils");const o=r.version=203;r.migrate=async(e,t)=>{if(e.meta.version=o,!(0,n.hasProperty)(e.data,"PreferencesController")||!(0,n.isObject)(e.data.PreferencesController))return;const{PreferencesController:r}=e.data;(0,n.hasProperty)(r,"currentLocale")&&"es"===r.currentLocale&&(r.currentLocale="es_419",t.add("PreferencesController"))}}}},{package:"$root$",file:"app/scripts/migrations/203.ts"}],[6553,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r){let n;return n=(null==r?void 0:r.registry)?r.registry.endsWith("/")?r.registry:`${r.registry}/`:"https://registry.npmjs.org/",`${n}${e}/-/${function(e){if("@"!==e[0])return e;return e.split("/")[1]}(e)}-${function(e){const t=e.indexOf("+");return-1===t?e:e.substring(0,t)}(t)}.tgz`}}}},{package:"@metamask/snaps-controllers>get-npm-tarball-url",file:"node_modules/get-npm-tarball-url/lib/index.js"}],[656,{"@metamask/utils":3935},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils");const o=r.version=204;r.migrate=async(e,t)=>{if(e.meta.version=o,!(0,n.hasProperty)(e.data,"PreferencesController")||!(0,n.isObject)(e.data.PreferencesController))return;const{PreferencesController:r}=e.data;if(!(0,n.hasProperty)(r,"preferences")||!(0,n.isObject)(r.preferences))return;const{preferences:s}=r;!0!==s.showExtensionInFullSizeView&&!0!==s.useSidePanelAsDefault&&(s.useSidePanelAsDefault=!0,r.showSidePanelMigrationToast=!0,t.add("PreferencesController"))}}}},{package:"$root$",file:"app/scripts/migrations/204.ts"}],[6567,{"@ethereumjs/rlp":6569,"@metamask/eth-sig-util":2401,"aes-js":6027,bech32:6131,"bignumber.js":6585,"bn.js":6138,bs58check:6587,buffer:6189,cbor:6212,"cbor-bigdecimal":6588,"crc-32":6273,elliptic:6376,"hash.js/lib/hash/ripemd.js":6763,"lodash/inRange.js":7073,"lodash/isEmpty.js":7079,"lodash/isInteger.js":7082,ox:6675,secp256k1:6676,uuid:8038,viem:8226,zod:6679},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(r){(function(){function n(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o,s=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,u=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,l=(e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of c(t))f.call(e,o)||o===r||i(e,o,{get:()=>t[o],enumerable:!(n=a(t,o))||n.enumerable});return e},d=(e,t,r)=>(r=null!=e?s(u(e)):{},l(!t&&e&&e.__esModule?r:i(r,"default",{value:e,enumerable:!0}),e)),h={};((e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})})(h,{BTC_LEGACY_XPUB_PATH:()=>te,BTC_SEGWIT_ZPUB_PATH:()=>ne,BTC_WRAPPED_SEGWIT_YPUB_PATH:()=>re,Calldata:()=>k,Client:()=>Un,Constants:()=>R,Utils:()=>dt,addAddressTags:()=>eo,connect:()=>bo,fetchActiveWallets:()=>mo,fetchAddress:()=>Ln,fetchAddressTags:()=>to,fetchAddresses:()=>Dn,fetchAddressesByDerivationPath:()=>Yn,fetchBip44ChangeAddresses:()=>Zn,fetchBtcLegacyAddresses:()=>Mn,fetchBtcLegacyChangeAddresses:()=>Hn,fetchBtcSegwitAddresses:()=>Gn,fetchBtcSegwitChangeAddresses:()=>qn,fetchBtcWrappedSegwitAddresses:()=>Fn,fetchBtcWrappedSegwitChangeAddresses:()=>$n,fetchBtcXpub:()=>Jn,fetchBtcYpub:()=>Xn,fetchBtcZpub:()=>Qn,fetchLedgerLegacyAddresses:()=>Kn,fetchLedgerLiveAddresses:()=>Wn,fetchSolanaAddresses:()=>Vn,getClient:()=>fe,pair:()=>yo,parseDerivationPath:()=>me,removeAddressTags:()=>ro,setup:()=>go,sign:()=>io,signAuthorization:()=>co,signAuthorizationList:()=>uo,signBtcLegacyTx:()=>fo,signBtcSegwitTx:()=>lo,signBtcWrappedSegwitTx:()=>ho,signMessage:()=>ao,signSolanaTx:()=>po}),t.exports=(o=h,l(i({},"__esModule",{value:!0}),o));var p=e("ox"),m=e("viem");function g(e){return`0x${r.from(p.Hash.keccak256(r.from(e))).toString("hex").slice(0,8)}`}function b(e){if("string"!=typeof e||10!==e.length&&8!==e.length)throw new Error("`sig` must be a hex string with 4 bytes of data.");return 8===e.length&&(e=`0x${e}`),e}function y(e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];let o=O[n[1]];if(n[2]&&(o=`${o}${8*n[2]}`),n[3].length>0&&n[3].forEach(e=>{o=0===n[3][e]?`${o}[]`:`${o}[${n[3][e]}]`}),n[4]){const e=y(n[4]);o=`${o}(${e.join(",")})`}t.push(o)}return t}function w(e){if(I(e))return P(e);if(e.indexOf(",")>-1)return e.slice(0,e.indexOf(","));if(e.indexOf(")")>-1)return e.slice(0,e.indexOf(")"));throw new Error(_)}function E(e){if(!I(e))return[v(e)];const t={szBytes:0,typeIdx:O.indexOf("tuple"),arraySzs:[]};let r=P(e,!1);const n=e.slice(r.length);t.arraySzs=S(n),r=r.slice(1);let o=[];for(;r.length>0;){const e=w(r);r=r.slice(e.length+1),o=o.concat(E(e))}if(!o.length)throw new Error(_);return[t,o]}function v(e){const t={szBytes:0,typeIdx:0,arraySzs:[]};let r=!1;if(O.forEach((n,o)=>{if(e.indexOf(n)>-1&&!r){t.typeIdx=o,t.arraySzs=S(e);const s=t.arraySzs.length>0?e.indexOf("["):e.length,i=e.slice(n.length,s);if(parseInt(i)&&(t.szBytes=parseInt(i)/8,t.szBytes>32))throw new Error(_);r=!0}}),!r)throw new Error(_);return t}function x(e,t="",r=[],n=!1){if(!n){const n=e.name||"";r.push(n),t+=n}return e.inputs&&(t+="(",e.inputs.forEach(e=>{const n=function(e){if(!e.type)throw new Error("No type in input");const t=[e.name],{typeIdx:r,szBytes:n,arraySzs:o}=function(e){const t={szBytes:0,typeIdx:0,arraySzs:[]};let r;O.forEach((n,o)=>{e.indexOf(n)>-1&&!r&&(r=n,t.typeIdx=o)}),t.arraySzs=S(e);const n=t.arraySzs.length>0?e.indexOf("["):e.length;if(["uint","int","bytes"].indexOf(r)>-1){const o=parseInt(e.slice(r.length,n))||0;if(o>256)throw new Error("Invalid param size");t.szBytes=o/8}else t.szBytes=0;return t}(e.type);return t.push(r),t.push(n),t.push(o),t}(e);if(e.type.indexOf("tuple")>-1&&e.components){const r=x({inputs:e.components},t,[],!0);t=r.canonicalName,t+=`${e.type.slice(5)},`,n.push(r.def)}else t+=e.type,t+=",";r.push(n)}),","===t[t.length-1]&&(t=t.slice(0,t.length-1)),t+=")"),{def:r,canonicalName:t}}function B(e,t=""){const r=[];let n=0;return e.forEach((e,o)=>{Array.isArray(e)?r[r.length-1].push(B(e,`${o}-`)):r.push([`#${t}${o+1-n}`,e.typeIdx,e.szBytes,e.arraySzs]),e.typeIdx===O.indexOf("tuple")&&(n+=1)}),r}function S(e){if("string"!=typeof e)throw new Error("Invalid type");const t=[];let r=e;for(;r.length>0;){const e=r.indexOf("[");if(e<0)return t;const n=r.slice(e),o=n.indexOf("]");if(o<0)throw new Error("Bad param type");const s=n.slice(1,o);0===s.length?t.push(0):t.push(parseInt(s)),r=n.slice(o+1)}return t}function P(e,t=!0){let r=0,n=!1;for(let o=0;o<e.length;o++){"("===e[o]?(r+=1,n=!0):")"===e[o]&&(r-=1);let s=","===e[o+1]||")"===e[o+1]||o===e.length-1;if(t||"["!==e[o+1]||(s=!0),!r&&n&&s)return e.slice(0,o+1)}throw new Error(_)}function I(e){return"("===e[0]}function T(e){return"bytes"===O[e[1]]}function A(e){return T(e)&&0===e[3].length}function j(e){return T(e)&&1===e[3].length&&0===e[3][0]}var _="Could not parse canonical function name.",O=[null,"address","bool","uint","int","bytes","string","tuple","nestedDef"],k={EVM:{type:1,parsers:{parseSolidityJSONABI:function(e,t){e=b(e);const r=t.filter(e=>"function"===e.type).find(t=>g(x(t).canonicalName)===e);if(r){return{def:x(r).def}}throw new Error("Unable to find matching function in ABI")},parseCanonicalName:function(e,t){if((e=b(e))!==g(t))throw new Error("Name does not match provided sig.");const r=[],n=t.indexOf("(");if(n<0)throw new Error(_);r.push(t.slice(0,n)),t=t.slice(n+1);let o=[];for(;t.length>1;){const e=w(t);o=o.concat(E(e)),t=t.slice(e.length+1)}const s=B(o);return r.concat(s)}},processors:{getNestedCalldata:function(e,t){const n=[],o=e.slice(1),s=y(o),i="0x"+t.slice(4).toString("hex"),a=s.map(e=>e.startsWith("tuple(")?e.replace("tuple",""):e),c=(0,m.parseAbiParameters)(a.join(","));function u(e){return(e.length-4)%32==0}return(0,m.decodeAbiParameters)(c,i).forEach((e,t)=>{if(T(o[t])){let s=!0;if(j(o[t]))Array.isArray(e)?e.forEach(e=>{if("string"!=typeof e||!e.startsWith("0x"))return void(s=!1);u(r.from(e.slice(2),"hex"))||(s=!1)}):s=!1;else if(A(o[t]))if("string"==typeof e&&e.startsWith("0x")){const t=e,n=r.from(t.slice(2),"hex");s=u(n)}else s=!1;else s=!1;n.push(s?e:null)}else n.push(null)}),n},replaceNestedDefs:function(e,t){for(let r=0;r<t.length;r++){const n=j(e[1+r]),o=A(e[1+r]);if(null!==t[r]&&(n||o)){e[1+r][1]=O.indexOf("nestedDef");const o=n?t[r]:[t[r]];e[1+r]=e[1+r].concat([o])}}return e}}}},N={aesIv:[109,121,115,101,99,114,101,116,112,97,115,115,119,111,114,100],addrStrLen:129,pairingStatus:{notPaired:0,paired:1},responseMsg:{0:"",128:"Invalid Request",129:"Unsupported Version",130:"Device Busy",131:"Timeout waiting for user",132:"Request declined by user",133:"Pairing failed",134:"Pairing is currently disabled",135:"Automated signing is currently disabled",136:"Device Error",137:"Device Timeout",138:"Active wallet does not match request",139:"Device Locked",140:"Feature Disabled",141:"Record already exists on device",142:"Request failed - needs resync"},msgSizes:{header:8,checksum:4,secure:{payload:{request:{connect:66,encrypted:1733},response:{connect:215,encrypted:3457}},data:{request:{connect:65,encrypted:{encryptedData:1728,0:99,1:54,3:1680,4:0,7:9,8:1391,9:405,12:1025,13:506}},response:{encrypted:{encryptedData:1728,0:0,1:1290,3:1090,4:142,7:1395,8:0,9:0,12:1608,13:1646}}}}}},R={GET_ADDR_FLAGS:{SECP256K1_PUB:3,ED25519_PUB:4,BLS12_381_G1_PUB:5,SECP256K1_XPUB:6},SIGNING:{HASHES:{NONE:0,KECCAK256:1,SHA256:2},CURVES:{SECP256K1:0,ED25519:1,BLS12_381_G2:2},ENCODINGS:{NONE:1,SOLANA:2,EVM:4,ETH_DEPOSIT:5,EIP7702_AUTH:6,EIP7702_AUTH_LIST:7},BLS_DST:{BLS_DST_NUL:1,BLS_DST_POP:2}},ENC_DATA:{SCHEMAS:{BLS_KEYSTORE_EIP2335_PBKDF_V4:0}},ETH_CONSENSUS_SPEC:{NETWORKS:{MAINNET_GENESIS:{networkName:"mainnet",forkVersion:r.alloc(4),validatorsRoot:r.alloc(32)}},DOMAINS:{DEPOSIT:r.from("03000000","hex"),VOLUNTARY_EXIT:r.from("04000000","hex")}}},C={ETH:"ETH",BTC:"BTC",ETH_MSG:"ETH_MSG"},U=2147483648,D={PURPOSES:{ETH:U+44,BTC_LEGACY:U+44,BTC_WRAPPED_SEGWIT:U+49,BTC_SEGWIT:U+84},COINS:{ETH:U+60,BTC:U,BTC_TESTNET:U+1}},L={address:1,bool:2,uint8:3,uint16:4,uint24:5,uint32:6,uint40:7,uint48:8,uint56:9,uint64:10,uint72:11,uint80:12,uint88:13,uint96:14,uint104:15,uint112:16,uint120:17,uint128:18,uint136:19,uint144:20,uint152:21,uint160:22,uint168:23,uint176:24,uint184:25,uint192:26,uint200:27,uint208:28,uint216:29,uint224:30,uint232:31,uint240:32,uint248:33,uint256:34,int8:35,int16:36,int24:37,int32:38,int40:39,int48:40,int56:41,int64:42,int72:43,int80:44,int88:45,int96:46,int104:47,int112:48,int120:49,int128:50,int136:51,int144:52,int152:53,int160:54,int168:55,int176:56,int184:57,int192:58,int200:59,int208:60,int216:61,int224:62,int232:63,int240:64,int248:65,int256:66,uint:67,bytes1:69,bytes2:70,bytes3:71,bytes4:72,bytes5:73,bytes6:74,bytes7:75,bytes8:76,bytes9:77,bytes10:78,bytes11:79,bytes12:80,bytes13:81,bytes14:82,bytes15:83,bytes16:84,bytes17:85,bytes18:86,bytes19:87,bytes20:88,bytes21:89,bytes22:90,bytes23:91,bytes24:92,bytes25:93,bytes26:94,bytes27:95,bytes28:96,bytes29:97,bytes30:98,bytes31:99,bytes32:100,bytes:101,string:102},z={SIGN_PERSONAL:{str:"signPersonal",enumIdx:0},TYPED_DATA:{str:"typedData",enumIdx:1,rawDataMaxLen:1629,typeCodes:L}};var M,G,F,H=/^[\x00-\x7F]+$/,q=10,$={1:{name:"ethereum",baseUrl:"https://api.etherscan.io",apiRoute:"api?module=contract&action=getabi"},137:{name:"polygon",baseUrl:"https://api.polygonscan.com",apiRoute:"api?module=contract&action=getabi"},56:{name:"binance",baseUrl:"https://api.bscscan.com",apiRoute:"api?module=contract&action=getabi"},42220:{name:"celo",baseUrl:"https://api.celoscan.io",apiRoute:"api?module=contract&action=getabi"},43114:{name:"avalanche",baseUrl:"https://api.snowtrace.io",apiRoute:"api?module=contract&action=getabi"}},V=r.alloc(32),W={internal:{uid:V,external:!1,name:r.alloc(0),capabilities:0},external:{uid:V,external:!0,name:r.alloc(0),capabilities:0}},K=[U+44,U+60,U,0,0],Z=[U+44,U+0,U,0,0],Y=[U+44,U+0,U,0,0],J=[U+84,U,U,0,0],X=[U+84,U,U,1,0],Q=[U+49,U,U,0,0],ee=[U+49,U,U,0,0],te="44'/0'/0'",re="49'/0'/0'",ne="84'/0'/0'",oe=[U+44,U+501,U,U],se=[U+49,U+60,U,0,0],ie=[U+49,U+60,U,0],ae=()=>F,ce=e=>{F=e},ue=async e=>{const t=await G();if(!t)throw new Error("Client not initialized");return ae()||ce(Promise.resolve()),ce(ae().then(async()=>await e(t).catch(e=>{throw ce(Promise.resolve()),e}).then(e=>(M(t.getStateData()),e)))),ae()},fe=async()=>{const e=G?await G():void 0;if(!e)throw new Error("Client not initialized");return e},le=e=>async t=>{if(!t)return;const n=(e=>r.from(e).toString("base64"))(t);await e(n)},de=e=>async()=>{const t=await e();if(!t)return;const n=(e=>r.from(e,"base64").toString())(t);if(!n)return;const o=new Un({stateData:n});if(!o)throw new Error("Client not initialized");return o},he=(e,t=0,r=4)=>{const n=[...e];return t>0&&(n[r]=e[r]+t),n},pe=e=>"string"!=typeof e&&"types"in e&&"domain"in e&&"primaryType"in e&&"message"in e;function me(e){if(!e)return[];return ge(e.split("/").filter(Boolean))}function ge(e){return e.map(e=>{const t=e.toLowerCase();if("x"===t)return 0;if("x'"===t)return U;if(e.endsWith("'"))return parseInt(e.slice(0,-1))+U;const r=parseInt(e);if(isNaN(r))throw new Error(`Invalid part in derivation path: ${e}`);return r})}var be,ye=e("@ethereumjs/rlp"),we=d(e("aes-js"),1),Ee=d(e("bignumber.js"),1),ve=e("bn.js"),xe=e("buffer"),Be=d(e("crc-32"),1),Se=d(e("elliptic"),1),Pe=e("ox"),Ie=d(e("lodash/inRange.js"),1),Te=d(e("lodash/isInteger.js"),1),Ae=d(e("secp256k1"),1),je=e("viem"),_e=d(e("lodash/isEmpty.js"),1),Oe=e=>{if("number"!=typeof e||!tt(e))throw new Error("Must be an integer between 0 and 15 inclusive");return e},ke=e=>{if(!e)throw new Error("The number of addresses is required.");if(e>q)throw new Error("You may only request 10 addresses at once.");return e},Ne=e=>{if(!e)throw new Error("Start path is required");if(e.length<1||e.length>5)throw new Error("Path must include between 1 and 5 indices");return e},Re=e=>{if("ECONNABORTED"===e.code&&"ETIME"===e.errno)throw new Error("Timeout waiting for device. Please ensure it is connected to the internet and try again in a minute.");throw new Error(`Failed to make request to device:\n${e.message}`)},Ce=e=>{if(!e||null===e)throw new Error("No active wallet.");return e},Ue=e=>({appName:(e=>{if(!e)throw new Error("Name is required.");if(e.length<5||e.length>24)throw new Error("Invalid length for name provided. Must be 5-24 characters.");return e})(e.getAppName()),ephemeralPub:De(e.ephemeralPub),sharedSecret:Le(e.sharedSecret),url:(e=>{if(!e)throw new Error("URL does not exist. Please reconnect.");try{new URL(e)}catch(e){throw console.error("Invalid URL format:",e),new Error("Invalid URL provided. Please use a valid URL.")}return e})(e.url),fwConstants:(e=>{if(!e)throw new Error("Firmware constants do not exist. Please reconnect.");return e})(e.getFwConstants()),fwVersion:(e=>{if(!e)throw new Error("Firmware version does not exist. Please reconnect.");if("number"!=typeof e.fix||"number"!=typeof e.minor||"number"!=typeof e.major)throw new Error("Firmware version improperly formatted. Please reconnect.");return e})(e.getFwVersion()),key:ze(e.key)}),De=e=>{if(!e)throw new Error("`ephemeralPub` (ephemeral public key) is required. Please reconnect.");return e},Le=e=>{if(!e)throw new Error("Shared secret required. Please reconnect.");return e},ze=e=>{if(!e)throw new Error("Key is required. Please reconnect.");return e},Me=Se.default.ec,{ecdsaRecover:Ge}=Ae.default,{COINS:Fe,PURPOSES:He}=D,qe=function(e){return Be.default.buf(e)>>>0},$e=function(e,t){const r=[],n=Math.ceil(e.length/t);let o=0;for(let s=0;s<n;s++)r.push(e.slice(o,o+t)),o+=t;return r};var Ve=function(e,t=!0){try{if(null===e||("number"==typeof e&&0===e||"bigint"==typeof e&&0n===e)&&!0===t)return xe.Buffer.alloc(0);const r="number"==typeof e||"bigint"==typeof e||"string"==typeof e&&function(e){const t=new Ee.default(e).toFixed().split(".").join(""),r=new String(e);return t.slice(0,8)===r.slice(0,8)}(e);let n;if(r){const t="bigint"==typeof e?e.toString(10):e;n=new Ee.default(t).toString(16)}else if("string"==typeof e&&"0x"===e.slice(0,2))n=e.slice(2);else{if(xe.Buffer.isBuffer(e))return e;n=e.toString()}return n.length%2>0&&(n=`0${n}`),"00"!==n||r?xe.Buffer.from(n,"hex"):xe.Buffer.alloc(0)}catch(t){throw new Error(`Cannot convert ${e.toString()} to hex buffer (${t.message})`)}},We=function(e,t){const r=xe.Buffer.alloc(t);return e.length<t?(e.copy(r,t-e.length),r):e.slice(-t)},Ke=function(e,t){const r=xe.Buffer.from(N.aesIv),n=new we.default.ModeOfOperation.cbc(t,r);return xe.Buffer.from(n.decrypt(e))},Ze=function(e){if(48!==e[0]||2!==e[2])throw new Error("Failed to decode DER signature");let t=3;const r=e[t];t++;const n=e.slice(t,t+r);if(t+=r,2!==e[t])throw new Error("Failed to decode DER signature");t++;const o=e[t];t++;return{r:n,s:e.slice(t,t+o)}},Ye=function(e){return void 0===be&&(be=new Me("p256")),be.keyFromPrivate(e,"hex")},Je=function(e){void 0===be&&(be=new Me("p256"));const t=xe.Buffer.isBuffer(e)?e.toString("hex"):e;return be.keyFromPublic(t,"hex")},Xe=function(e,t){const r=xe.Buffer.alloc(24);let n=0;if(t&&e.length>5)throw new Error("Signer path must be <=5 indices.");if(!t&&5!==e.length)throw new Error("Your Lattice firmware only supports 5-index derivation paths. Please upgrade.");r.writeUInt32LE(e.length,n),n+=4;for(let t=0;t<5;t++)t<e.length?r.writeUInt32LE(e[t],n):r.writeUInt32LE(0,n),n+=4;return r},Qe=function(e,t){return Object.keys(t).some(r=>t[r]===e)},et=function(e){const t=xe.Buffer.alloc(e);for(let r=0;r<e;r++)t[r]=Math.round(255*Math.random());return t},tt=e=>(0,Te.default)(e)&&(0,Ie.default)(e,0,16);function rt(e,t){let r;if(e.length>1&&console.warn("WARNING: There are multiple results. Using the first one."),e.sort((e,t)=>new Date(e.created_at).getTime()-new Date(t.created_at).getTime()).find(e=>{try{return r=k.EVM.parsers.parseCanonicalName(t,e.text_signature),!!r}catch(e){return console.error("Failed to parse canonical name:",e),!1}}),r)return r;throw new Error("Could not find definition for selector")}async function nt(e,t){try{if(globalThis.caches&&globalThis.Request){const r=await caches.open("gp-calldata"),n=new Request(e,t),o=await r.match(n);if(o)return o;{const e=await fetch(n,t),o=e.clone(),s=await e.json();return e.ok&&((e=>{try{const t=JSON.parse(e.result);return!(0,_e.default)(t)}catch(e){return console.error("Invalid block explorer response:",e),!1}})(s)||(e=>{try{return!(0,_e.default)(e.results)}catch(e){return console.error("Invalid 4byte response:",e),!1}})(s))?(await r.put(n,o),r.match(n)):e}}return fetch(e,t)}catch(e){throw console.error(e),e}}async function ot(e){const t=`https://www.4byte.directory/api/v1/signatures/?hex_signature=0x${e}`;return await fetch(t).then(e=>e.json()).then(e=>{if(e&&e.results)return e.results;throw new Error("No results found")}).catch(e=>{throw new Error(`Fetching data from 4byte failed: ${e.message}`)})}function st(e){return xe.Buffer.from(ye.RLP.encode(e))}async function it(e,t){const r=k.EVM.processors.getNestedCalldata(e,t),n=await async function(e){const t=[];for await(const r of e)if(null!==r)if(Array.isArray(r)){const e=[];let n=!0;for await(const t of r)try{const r=t.slice(2,10),n=rt(await ot(r),r);e.push(n)}catch(t){console.error("Failed to fetch nested 4byte data:",t),n=!1,e.push(null)}n?t.push(e):t.push(null)}else try{const e=r.slice(2,10),n=rt(await ot(e),e);t.push(n)}catch(e){console.error("Failed to fetch nested definition:",e),t.push(null)}else t.push(null);return t}(r);for await(const[e]of n.entries())if(Array.isArray(n[e])&&"string"!=typeof n[e][0])for await(const[t]of n[e].entries())null!==n[e][t]&&(n[e][t]=await it(n[e][t],xe.Buffer.from(r[e][t].slice(2),"hex")));else null!==n[e]&&(n[e]=await it(n[e],xe.Buffer.from(r[e].slice(2),"hex")));return k.EVM.processors.replaceNestedDefs(e,n)}async function at(e,t,r,n=!0){try{if(!e||e.length<2)throw new Error("Data is either undefined or less than two bytes");const o="string"==typeof e&&"0x"===e.slice(0,2)?xe.Buffer.from(e.slice(2),"hex"):xe.Buffer.from(e,"hex");if(0===o.length)return{def:null,abi:null};if(o.length<4)throw new Error("Data must contain at least 4 bytes of data to define the selector");const s=xe.Buffer.from(o.slice(0,4)).toString("hex"),i=Number(r),a=$[i],c=a||await async function(e){try{const t=await fetch("https://gridplus.github.io/chains/chains.json").then(e=>e.json());return t?t[e]:void 0}catch(e){console.warn("Fetching external networks failed.\n",e)}}(i);try{if(c){const e=await async function(e,t){const r=function({supportedChain:e,address:t}){return`${e.baseUrl}/${e.apiRoute}&address=${t}`}({address:e,supportedChain:t});return nt(r).then(e=>e.json()).then(e=>{if(!e||!e.result)throw new Error("Server response was malformed");try{return JSON.parse(e.result)}catch{throw new Error(`Invalid JSON in response: ${e.result.substring(0,50)}`)}}).catch(e=>{throw console.log(e),new Error("Fetching data from external network failed")})}(t,c);let r=k.EVM.parsers.parseSolidityJSONABI(s,e).def;return n&&(r=await it(r,o)),{abi:e,def:st(r)}}throw new Error(`Chain (id: ${i}) is not supported`)}catch(e){console.warn(e.message,"\n","Falling back to 4byte")}const u=await ot(s);let f=rt(u,s);return n&&(f=await it(f,o)),{abi:u,def:st(f)}}catch(e){console.warn(`Fetching calldata failed: ${e.message}`)}return{def:null,abi:null}}var ct=(e,t,r)=>{const n="string"==typeof e?xe.Buffer.from(e):e,o="string"==typeof t?xe.Buffer.from(t):t,s="string"==typeof r?xe.Buffer.from(r):r,i=xe.Buffer.concat([n,o,s]);return xe.Buffer.from(Pe.Hash.sha256(i))},ut=function(e,t){let r,n,o,s=!1;if(!xe.Buffer.isBuffer(e)&&"string"!=typeof e)throw new Error("Unsupported transaction format. Expected Buffer or hex string.");{const t=xe.Buffer.isBuffer(e)?`0x${e.toString("hex")}`:e,i=xe.Buffer.isBuffer(e)?e:xe.Buffer.from(e.slice(2),"hex");n=xe.Buffer.from(Pe.Hash.keccak256(i));try{const e=(0,je.parseTransaction)(t);if(o=e.type,void 0!==e.chainId&&null!==e.chainId&&(r=e.chainId.toString(),"legacy"===o&&(s=!0)),"legacy"===o&&!s){const e=ye.RLP.decode(i);if(e.length>=9){const t=e[6];t&&t.length>0&&(r=new ve.BN(t).toString(),s=!0)}}}catch(t){console.error("Failed to parse transaction, trying legacy format:",t);try{const t=xe.Buffer.isBuffer(e)?e:xe.Buffer.from(e.slice(2),"hex"),n=ye.RLP.decode(t);if(o="legacy",n.length>=9){const e=n[6];e&&e.length>0&&(r=new ve.BN(e).toString(),s=!0)}}catch{throw new Error("Could not recover V. Bad transaction data.")}}}const i=xe.Buffer.isBuffer(t.sig.r)?t.sig.r:xe.Buffer.from(t.sig.r.slice(2),"hex"),a=xe.Buffer.isBuffer(t.sig.s)?t.sig.s:xe.Buffer.from(t.sig.s.slice(2),"hex"),c=new Uint8Array(xe.Buffer.concat([i,a])),u=t.pubkey;if(!u)throw new Error("Response did not include a public key.");let f;if(xe.Buffer.isBuffer(u))f=xe.Buffer.from(u);else if(u instanceof Uint8Array)f=xe.Buffer.from(u);else if("string"==typeof u){const e=u.startsWith("0x")?u.slice(2):u;f=xe.Buffer.from(e,"hex")}else f=xe.Buffer.from(u);64===f.length&&(f=xe.Buffer.concat([xe.Buffer.from([4]),f]));const l=33===f.length&&(2===f[0]||3===f[0]),d=65===f.length&&4===f[0];if(!l&&!d)throw new Error("Unsupported public key format returned by device.");const h=xe.Buffer.from(Ge(c,0,n,l)),p=xe.Buffer.from(Ge(c,1,n,l)),m=f.toString("hex"),g=h.toString("hex"),b=p.toString("hex");let y;if(m===g)y=0;else{if(m!==b)throw new Error("Failed to recover V parameter. Bad signature or transaction data.");y=1}const w=ft(y,{chainId:r,useEIP155:s,type:o});return xe.Buffer.isBuffer(w)?0===w.length?new ve.BN(0):new ve.BN(w.toString("hex"),16):w},ft=function(e,t={}){const{chainId:r,useEIP155:n,type:o}=t;return 1===o||2===o||4===o||"eip2930"===o||"eip1559"===o||"eip7702"===o?Ve(e,!0):n&&r?new ve.BN(r).muln(2).addn(35).addn(e):new ve.BN(e).addn(27)},lt=function(e,t,r){if("object"==typeof e&&e&&"messageHash"in e)return lt(e.messageHash,e.signature,e.publicKey);if(t&&t.sig&&t.pubkey&&!r)return lt(e,t.sig,t.pubkey);if(!t||!r)throw new Error("Response with sig and pubkey required for legacy format");if(!t.r||!t.s)throw new Error("Response with sig and pubkey required for legacy format");let n=e;if("object"==typeof e&&e&&"function"==typeof e.getMessageToSign){const t=e._type;if(null!=t)n=e.getMessageToSign(!0);else{const t=ye.RLP.encode(e.getMessageToSign(!1));n=xe.Buffer.from(Pe.Hash.keccak256(t))}}else xe.Buffer.isBuffer(e)&&32!==e.length&&(n=xe.Buffer.from(Pe.Hash.keccak256(e)));const o=e=>{if(!e)throw new Error("Invalid data");if(xe.Buffer.isBuffer(e))return e;if(e instanceof Uint8Array)return xe.Buffer.from(e);if("string"==typeof e)return xe.Buffer.from(e.replace(/^0x/i,""),"hex");throw new Error("Invalid data type")},s=o(n),i=o(t.r),a=o(t.s),c=o(r),u=32===s.length?s:xe.Buffer.from(Pe.Hash.keccak256(s)),f=new Uint8Array(xe.Buffer.concat([i,a])),l=new Uint8Array(u),d=33===c.length;for(let e=0;e<=1;e++)try{const t=Ge(f,e,l,d);if(xe.Buffer.from(t).equals(c))return e}catch{continue}throw new Error("Failed to recover Y parity. Bad signature or transaction data.")},dt={fetchCalldataDecoder:at,generateAppSecret:ct,getV:ut,getYParity:lt,convertRecoveryToV:ft},ht=e("ox"),pt=e("bech32"),mt=d(e("bs58check"),1),gt=e("ox"),bt=e("hash.js/lib/hash/ripemd.js"),yt=r.from("01","hex"),{PURPOSES:wt,COINS:Et}=D,vt=0,xt=169,Bt=118,St=135,Pt=136,It=172,Tt=208,At=240;function jt(e,t){return r.concat([e,t])}function _t(e){const t=r.alloc(4);return t.writeUInt32LE(e,0),t}function Ot(e){let t;return e<253?(t=r.alloc(1),t.writeUInt8(e,0)):e<=65535?(t=r.alloc(3),t.writeUInt8(253,0),t.writeUInt16LE(e,1)):e<4294967295?(t=r.alloc(5),t.writeUInt8(254,0),t.writeUInt32LE(e,1)):(t=r.alloc(9),t.writeUInt8(255,0),t.writeUInt32LE(e>>>0,1),t.writeUInt32LE(e/4294967296|0,5)),t}function kt(e,t,n){"number"==typeof e&&(e=e.toString(16));const o=r.alloc(8),s=e.length%2==0?e.toString(16):`0${e.toString(16)}`;return r.from(s,"hex").reverse().copy(o,0),o.copy(t,n),o}function Nt(e){let t,n;try{t=mt.default.decode(e)[0],n=r.from(mt.default.decode(e).slice(1))}catch(o){console.error("Failed to decode base58 address, trying bech32:",o);try{const o=pt.bech32.decode(e);if("bc"===o.prefix)t=Tt;else{if("tb"!==o.prefix)throw new Error("Unsupported prefix: must be bc or tb.");t=At}if(0!==o.words[0])throw new Error(`Unsupported segwit version: must be 0, got ${o.words[0]}`);if(33!==o.words.length){const t=53===o.words.length;throw new Error(`Unsupported address${t?" (P2WSH not supported)":""}: ${e}`)}n=r.from(pt.bech32.fromWords(o.words.slice(1)))}catch(t){throw new Error(`Unable to decode address: ${e}: ${t.message}`)}}return{versionByte:t,pkh:n}}function Rt(e){if(e.length<2)throw new Error("Path must be >1 index");const t=e[0],r=e[1];if(t===wt.BTC_SEGWIT&&r===Et.BTC)return Tt;if(t===wt.BTC_SEGWIT&&r===Et.BTC_TESTNET)return At;if(t===wt.BTC_WRAPPED_SEGWIT&&r===Et.BTC)return 5;if(t===wt.BTC_WRAPPED_SEGWIT&&r===Et.BTC_TESTNET)return 196;if(t===wt.BTC_LEGACY&&r===Et.BTC)return 0;if(t===wt.BTC_LEGACY&&r===Et.BTC_TESTNET)return 111;throw new Error("Invalid Bitcoin path provided. Cannot determine address format.")}function Ct(e){switch(e.signerPath[0]){case wt.BTC_LEGACY:return 1;case wt.BTC_WRAPPED_SEGWIT:return 3;case wt.BTC_SEGWIT:return 4;default:throw new Error(`Unsupported path purpose (${e.signerPath[0]}): cannot determine BTC script type.`)}}var Ut={buildBitcoinTxRequest:function(e){const{prevOuts:t,recipient:n,value:o,changePath:s,fee:i}=e;if(!s)throw new Error("No changePath provided.");if(5!==s.length)throw new Error("Please provide a full change path.");const a=r.alloc(59+69*t.length);let c=0;const u=Rt(s);a.writeUInt8(u,0),c++,a.writeUInt32LE(s.length,c),c+=4;for(let e=0;e<s.length;e++)a.writeUInt32LE(s[e],c),c+=4;a.writeUInt32LE(i,c),c+=4;const f=Nt(n);a.writeUInt8(f.versionByte,c),c++,f.pkh.copy(a,c),c+=f.pkh.length,kt(o,a,c),c+=8,a.writeUInt8(t.length,c),c++;let l=0;return t.forEach(e=>{if(!e.signerPath||5!==e.signerPath.length)throw new Error("Full recipient path not specified ");a.writeUInt32LE(e.signerPath.length,c),c+=4;for(let t=0;t<e.signerPath.length;t++)a.writeUInt32LE(e.signerPath[t],c),c+=4;a.writeUInt32LE(e.index,c),c+=4,kt(e.value,a,c),c+=8,l+=e.value;const t=Ct(e);a.writeUInt8(t,c),c++,r.isBuffer(e.txHash)||(e.txHash=r.from(e.txHash,"hex")),e.txHash.copy(a,c),c+=e.txHash.length}),{payload:a,schema:0,origData:e,changeData:{value:l-(o+i)}}},serializeTx:function(e){const{inputs:t,outputs:n,lockTime:o=0}=e;let s=r.alloc(4),i=0;const a=function(e){let t=!1;return e.forEach(e=>{e.signerPath[0]!==wt.BTC_SEGWIT&&e.signerPath[0]!==wt.BTC_WRAPPED_SEGWIT||(t=!0)}),t}(t);s.writeUInt32LE(2,i),i+=4,a&&(s=jt(s,r.from("00","hex")),s=jt(s,r.from("01","hex")));const c=Ot(t.length);s=jt(s,c),i+=c.length,t.forEach(e=>{s=jt(s,e.hash.reverse()),i+=e.hash.length;const t=_t(e.index);s=jt(s,t),i+=t.length;const n=Ct(e);if(3===n){const t=function(e){const t=r.alloc(22),n=r.from(gt.Hash.sha256(e)),o=r.from((0,bt.ripemd160)().update(n).digest("hex"),"hex");return t.writeUInt8(vt,0),t.writeUInt8(o.length,1),o.copy(t,2),t}(e.pubkey),n=Ot(t.length),o=r.concat([n,t]),a=Ot(o.length);s=jt(s,a),i+=a.length,s=jt(s,o),i+=o.length}else if(1===n){const t=function(e,t){const n=Ot((e=r.concat([e,yt])).length),o=Ot(t.length),s=r.concat([n,e,o,t]),i=Ot(s.length);return r.concat([i,s])}(e.sig,e.pubkey);s=jt(s,t),i+=t.length}else if(4===n){const e=r.from("00","hex");s=jt(s,e),i+=1}const o=_t(4294967295);s=jt(s,o),i+=o.length});const u=Ot(n.length);if(s=jt(s,u),i+=u.length,n.forEach(e=>{const t=function(e){const t=r.alloc(8);return kt(e,t,0),t}(e.value);s=jt(s,t),i+=t.length;const n=function(e){const t=Nt(e);switch(t.versionByte){case Tt:case At:return function(e){const t=r.alloc(2+e.length);return t.writeUInt8(vt,0),t.writeUInt8(e.length,1),e.copy(t,2),t}(t.pkh);case 5:case 196:return function(e){const t=r.alloc(3+e.length);let n=0;return t.writeUInt8(xt,n),n++,t.writeUInt8(e.length,n),n++,e.copy(t,n),n+=e.length,t.writeUInt8(St,n),n++,t}(t.pkh);case 0:case 111:return function(e){const t=r.alloc(5+e.length);let n=0;return t.writeUInt8(Bt,n),n++,t.writeUInt8(xt,n),n++,t.writeUInt8(e.length,n),n++,e.copy(t,n),n+=e.length,t.writeUInt8(Pt,n),n++,t.writeUInt8(It,n),n++,t}(t.pkh);default:throw new Error(`Unknown version byte: ${t.versionByte}. Cannot build BTC transaction.`)}}(e.recipient),o=Ot(n.length);s=jt(s,o),i+=o.length,s=jt(s,n),i+=n.length}),a){const e=[],n=[];for(let r=0;r<t.length;r++)e.push(t[r].sig),n.push(t[r].pubkey);const o=function(e,t){let n=r.alloc(0);const o=r.alloc(1);o.writeUInt8(2,0);for(let s=0;s<e.length;s++){const i=r.concat([e[s],yt]),a=Ot(i.length),c=t[s],u=Ot(c.length);n=r.concat([n,o,a,i,u,c])}return n}(e,n);s=jt(s,o),i+=o.length}return r.concat([s,_t(o)]).toString("hex")},getBitcoinAddress:function(e,t){let n=null,o=null;if(t===Tt?(n="bc",o=0):t===At&&(n="tb",o=0),null!==n&&null!==o){const t=pt.bech32.toWords(e);return t.unshift(o),pt.bech32.encode(n,t)}return mt.default.encode(r.concat([r.from([t]),e]))},getAddressFormat:Rt},Dt=d(e("bignumber.js"),1),Lt=e("@metamask/eth-sig-util"),zt=e("ox"),Mt=e("@ethereumjs/rlp"),Gt=d(e("secp256k1"),1),Ft=d(e("cbor"),1),Ht=d(e("cbor-bigdecimal"),1),qt=e("viem"),$t=0,Vt=1,Wt=2,Kt=4,Zt=5,Yt=e("ox"),Jt=e("@ethereumjs/rlp"),Xt=e("viem"),Qt=function(e){const{signerPath:t,curveType:n,hashType:o,encodingType:s=null,decoder:i=null,omitPubkey:a=!1,fwConstants:c,blsDst:u=R.SIGNING.BLS_DST.BLS_DST_NUL}=e,{extraDataFrameSz:f,extraDataMaxFrames:l,prehashAllowed:d,genericSigning:h,varAddrPathSzAllowed:p}=c,{curveTypes:m,encodingTypes:g,hashTypes:b,baseDataSz:y,baseReqSz:w,calldataDecoding:E}=h,v=rr(e.payload,s,g),{encoding:x}=v;let{payloadBuf:B}=v;const S=B;let P=B.length;const I=y+l*f;if(!P)throw new Error("Payload could not be handled.");if(!(h&&f&&l&&d))throw new Error("Unsupported. Please update your Lattice firmware.");if(!Qe(n,m))throw new Error("Unsupported curve type.");if(!Qe(o,b))throw new Error("Unsupported hash type.");const T=i&&E&&i.length<=E.maxSz,A=T&&B.length+i.length<=I;if(T&&A){const e=r.alloc(8+i.length);e.writeUInt32LE(E.reserved,0),e.writeUInt32LE(i.length,4),r.from(i).copy(e,8),B=r.concat([B,e])}if(n===m.ED25519){if(o!==b.NONE)throw new Error("Signing on ed25519 requires unhashed message");t.forEach(e=>{if(e<U)throw new Error("Signing on ed25519 requires all signer path indices be hardened.")})}else if(n===m.BLS12_381_G2){const e=r.alloc(4);e.writeUInt32LE(u),B=r.concat([e,B]),P+=e.length}const j=r.alloc(w);let _=0;j.writeUInt32LE(x,_),_+=4,j.writeUInt8(o,_),_+=1,j.writeUInt8(n,_),_+=1;const O=Xe(t,p);O.copy(j,_),_+=O.length,j.writeUInt8(a?1:0,_),_+=1;const k=[];let N=null,C=!1;if(B.length>y)if(d&&B.length>I){j.writeUInt16LE(B.length,_),_+=2,C=!0;const e=B.slice(0,P);if(o===b.NONE)throw new Error("Message too large to send and could not be prehashed (hashType=NONE).");if(o===b.KECCAK256)N=r.from(Yt.Hash.keccak256(e));else{if(o!==b.SHA256)throw new Error("Unsupported hash type.");N=r.from(Yt.Hash.sha256(e))}}else{$e(B.slice(y),f).forEach(e=>{const t=r.alloc(4);t.writeUInt32LE(e.length,0),k.push(r.concat([t,e]))})}C||(j.writeUInt16LE(P,_),_+=2);return(N||B).copy(j,_),{payload:j,extraDataPayloads:k,schema:5,curveType:n,encodingType:s,hashType:o,omitPubkey:a,origPayloadBuf:S}};function er(e,t){if(t&&32===t.length&&t.some(e=>0!==e))return t;if(e.hashType===R.SIGNING.HASHES.SHA256)return r.from(Yt.Hash.sha256(e.origPayloadBuf));if(e.hashType===R.SIGNING.HASHES.KECCAK256)return r.from(Yt.Hash.keccak256(e.origPayloadBuf));throw new Error("Unsupported hash type for message hash computation.")}function tr(e,t,r){if(t.encodingType===R.SIGNING.ENCODINGS.EVM)try{const n=`0x${t.origPayloadBuf.toString("hex")}`,o=(0,Xt.parseTransaction)(n),s={chainId:o.chainId,to:o.to??void 0,value:o.value??0n,data:o.data??"0x",nonce:o.nonce??0n,gas:o.gas??o.gasLimit??0n};void 0!==o.maxFeePerGas&&(s.maxFeePerGas=o.maxFeePerGas),void 0!==o.maxPriorityFeePerGas&&(s.maxPriorityFeePerGas=o.maxPriorityFeePerGas),void 0!==o.gasPrice&&(s.gasPrice=o.gasPrice),void 0!==o.accessList&&(s.accessList=o.accessList),void 0!==o.authorizationList&&(s.authorizationList=o.authorizationList),void 0!==o.type&&null!==o.type&&(s.type=o.type);const i="legacy"===o.type||void 0===o.type?{v:e,r:r.sig.r,s:r.sig.s}:{yParity:Number(e),r:r.sig.r,s:r.sig.s};r.viemTx=(0,Xt.serializeTransaction)(s,i)}catch(e){console.debug("Failed to build viemTx from response",e)}}var rr=function(e,t,n){if(t||(t=R.SIGNING.ENCODINGS.NONE),!Qe(t,n))throw new Error("Encoding not supported by Lattice firmware. You may want to update.");let o;if(!e)throw new Error("No payload included");return o="string"==typeof e&&"0x"===e.slice(0,2)?r.from(e.slice(2),"hex"):r.from(e),{payloadBuf:o,encoding:t}},nr=e("zod"),or=e("viem"),sr=nr.z.union([nr.z.string().regex(/^(0x[0-9a-fA-F]+|[0-9]+)$/,"Invalid number format"),nr.z.number(),nr.z.bigint()]).transform((e,t)=>{try{const r="string"==typeof e&&(0,or.isHex)(e)?(0,or.hexToBigInt)(e):BigInt(e);return r<0n?(t.addIssue({code:nr.z.ZodIssueCode.custom,message:"Value must be non-negative"}),nr.z.NEVER):r}catch{return t.addIssue({code:nr.z.ZodIssueCode.custom,message:"Invalid numeric value"}),nr.z.NEVER}}),ir=sr.refine(e=>e>=0n,{message:"Gas values must be non-negative"}),ar=nr.z.union([nr.z.string(),nr.z.number()]).transform(e=>"string"==typeof e&&(0,or.isHex)(e)?Number((0,or.hexToBigInt)(e)):Number(e)).refine(e=>Number.isInteger(e)&&e>0,{message:"Chain ID must be a positive integer"}),cr=nr.z.string().refine(or.isAddress,"Invalid address").transform(e=>(0,or.getAddress)(e)),ur=nr.z.string().refine(or.isHex,"Data must be a valid hex string").default("0x"),fr=nr.z.union([nr.z.string().regex(/^(0x[0-9a-fA-F]+|[0-9]+)$/,"Invalid nonce format"),nr.z.number().int().nonnegative(),nr.z.bigint()]).transform((e,t)=>{try{const r="string"==typeof e?(0,or.isHex)(e)?(0,or.hexToBigInt)(e):BigInt(e):"number"==typeof e?BigInt(e):e;if(r<0n)return t.addIssue({code:nr.z.ZodIssueCode.custom,message:"Nonce must be non-negative"}),nr.z.NEVER;return r>BigInt(Number.MAX_SAFE_INTEGER)?(t.addIssue({code:nr.z.ZodIssueCode.custom,message:"Nonce exceeds JavaScript safe integer range"}),nr.z.NEVER):Number(r)}catch{return t.addIssue({code:nr.z.ZodIssueCode.custom,message:"Invalid nonce value"}),nr.z.NEVER}}),lr=nr.z.object({address:cr,storageKeys:nr.z.array(nr.z.string().refine(or.isHex,"Storage key must be a hex string"))}),dr=nr.z.object({chainId:nr.z.number().int().positive(),address:cr,nonce:nr.z.number().int().nonnegative(),yParity:nr.z.number().optional().default(0),r:nr.z.string().refine(or.isHex).optional(),s:nr.z.string().refine(or.isHex).optional()}),hr=nr.z.object({to:cr.optional(),value:sr.optional(),data:ur,nonce:fr.optional(),gas:ir.optional(),gasLimit:ir.optional(),chainId:ar.optional().default(1),accessList:nr.z.array(lr).optional()}),pr=hr.extend({type:nr.z.union([nr.z.literal("legacy"),nr.z.literal($t)]).optional(),gasPrice:ir}),mr=hr.extend({type:nr.z.union([nr.z.literal("eip2930"),nr.z.literal(Vt)]),gasPrice:ir}),gr=hr.extend({type:nr.z.union([nr.z.literal("eip1559"),nr.z.literal(Wt)]),maxFeePerGas:ir,maxPriorityFeePerGas:ir}),br=hr.extend({type:nr.z.union([nr.z.literal("eip7702"),nr.z.literal(Kt),nr.z.literal(Zt)]),maxFeePerGas:ir,maxPriorityFeePerGas:ir,authorizationList:nr.z.array(dr).min(1)}),yr=nr.z.any().refine(e=>{try{return JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t),!0}catch{return!1}},{message:"Circular reference detected in transaction object"}).transform(e=>(e.gasLimit&&(e.gas=e.gasLimit),null!==e.data&&void 0!==e.data&&""!==e.data||(e.data="0x"),e.authorization&&(e.authorizationList=[e.authorization]),e)).transform(e=>{const t=!!e.authorizationList,r=!!e.maxFeePerGas||!!e.maxPriorityFeePerGas,n=!!e.accessList,o=!!e.gasPrice;let s="legacy",i=pr;if("eip7702"===e.type||4===e.type||5===e.type||t?(s="eip7702",i=br):"eip1559"===e.type||2===e.type||r?(s="eip1559",i=gr):("eip2930"===e.type||1===e.type||n)&&(s="eip2930",i=mr),"legacy"===s&&!o)throw new Error("Legacy transactions require a `gasPrice` field.");const a=i.parse(e);return a.type=s,"legacy"===s&&void 0===a.gas&&(a.gas=21000n),"legacy"!==s&&"eip2930"!==s&&delete a.gasPrice,"eip1559"!==s&&"eip7702"!==s&&(delete a.maxFeePerGas,delete a.maxPriorityFeePerGas),delete a.gasLimit,"eip7702"!==s&&delete a.authorizationList,a}),{ecdsaRecover:wr}=Gt.default;(0,Ht.default)(Ft.default);function Er(e){if(null==e)return e;if("string"==typeof e){const t=e.trim();if(/^0x[0-9a-fA-F]+$/.test(t))try{const e=BigInt(t);return e<=BigInt(Number.MAX_SAFE_INTEGER)&&e>=BigInt(Number.MIN_SAFE_INTEGER)?Number(e):e.toString(10)}catch{return t}return t}if("bigint"==typeof e){const t=Number(e);return Number.isSafeInteger(t)?t:e.toString(10)}if(Dt.default.isBigNumber(e)){const t=Number(e.toString(10));return Number.isSafeInteger(t)?t:e.toString(10)}if(e&&"object"==typeof e&&"function"==typeof e.toString&&e.constructor&&"BN"===e.constructor.name&&"function"==typeof e.toArray){const t=e.toString(10),r=Number(t);return Number.isSafeInteger(r)?r:t}if(r.isBuffer(e)||e instanceof Uint8Array)return`0x${r.from(e).toString("hex")}`;if(Array.isArray(e))return e.map(e=>Er(e));if("object"==typeof e){const t={};for(const[r,n]of Object.entries(e))t[r]=Er(n);return t}return e}function vr(e){return void 0===e?e:Br?Br(e):xr(e)}function xr(e){if(null===e||"object"!=typeof e)return e;if(r.isBuffer(e))return r.from(e);if(e instanceof Uint8Array)return new Uint8Array(e);if(Array.isArray(e))return e.map(e=>xr(e));if(Dt.default.isBigNumber(e))return new Dt.default(e);if(e&&"object"==typeof e&&"BN"===e.constructor?.name&&"function"==typeof e.clone)return e.clone();if(e instanceof Date)return new Date(e.getTime());const t={};for(const[r,n]of Object.entries(e))t[r]=xr(n);return t}var Br="undefined"!=typeof globalThis&&"function"==typeof globalThis.structuredClone?globalThis.structuredClone:null;function Sr(e){let t=e[0];for(;e.length>0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e}function Pr(e,t,n,o={}){try{const s=new Uint8Array(e),i=r.isBuffer(n)?n:Ve(n,!1);if(20!==i.length)throw new Error("Invalid signer address provided.");let a=0;const c=We(t.r,32);t.r=c;const u=We(t.s,32);t.s=u;const f=new Uint8Array(r.concat([c,u]));let l=wr(f,a,s,!1).slice(1);const d=i.toString("hex"),h=[];let p=Ir(l);if(h.push(p),p===d)return t.v=Tr(a,o),t;if(a=1,l=wr(f,a,s,!1).slice(1),p=Ir(l),h.push(p),p===d)return t.v=Tr(a,o),t;throw new Error(`Invalid Ethereum signature returned. expected=${d}, recovered=${h.join(",")}`)}catch(e){if(e instanceof Error)throw e;throw new Error(String(e))}}function Ir(e){return r.from(zt.Hash.keccak256(e)).slice(-20).toString("hex")}function Tr(e,t={}){const n=ft(e,t);return r.isBuffer(n)?n:Ve(`0x${n.toString(16)}`)}var Ar={mainnet:1,roptsten:3,rinkeby:4,kovan:42,goerli:5};function jr(e){let t,n;if(t=!0===_r(e)?Ve(e):Ve(`0x${new Dt.default(e).toString(16)}`),t.length>8)throw new Error("ChainID provided is too large.");return t.length<=2||4===t.length||8===t.length?t:(3===t.length?(n=r.alloc(4),n.writeUInt32BE(e)):t.length<=8&&(n=r.alloc(8),t.copy(n,8-t.length)),n)}function _r(e){if("string"!=typeof e)return!1;if("0x"!==e.slice(0,2))return!1;try{return!1===new Dt.default(e,16).isNaN()}catch(e){return console.error("Invalid chain ID hex string:",e),!1}}function Or(e,t){const{ethMaxMsgSz:n,extraDataFrameSz:o,extraDataMaxFrames:s}=t.fwConstants,i=n,a=o>0&&s>0,c=[];if(e.length>i){const t=i+s*o;if(!a)throw new Error(`Your message is ${e.length} bytes, but can only be a maximum of ${i}`);if(a&&e.length>t)throw new Error(`Your message is ${e.length} bytes, but can only be a maximum of ${t}`);$e(e.slice(i),o).forEach(e=>{const t=r.alloc(4);t.writeUInt32LE(e.length,0),c.push(r.concat([t,e]))})}return c}function kr(e,t,r,n=!1){return r[t].forEach(t=>{const o=t.type.indexOf("[")>-1,s=o?t.type.slice(0,t.type.indexOf("[")):t.type,i=Object.keys(r).indexOf(s)>-1;if(i&&Array.isArray(e))for(let o=0;o<e.length;o++)e[o][t.name]=kr(e[o][t.name],s,r,n);else if(i)e[t.name]=kr(e[t.name],s,r,n);else if(Array.isArray(e))for(let r=0;r<e.length;r++)if(o)for(let o=0;o<e[r][t.name].length;o++)e[r][t.name][o]=Nr(e[r][t.name][o],s,n);else e[r][t.name]=Nr(e[r][t.name],s,n);else if(o)for(let r=0;r<e[t.name].length;r++)e[t.name][r]=Nr(e[t.name][r],s,n);else e[t.name]=Nr(e[t.name],s,n)}),e}function Nr(e,t,n=!1){if("bytes"===t)e=Ve(e),n&&(e=`0x${e.toString("hex")}`);else if("bytes"===t.slice(0,5)){const o=parseInt(t.slice(5));if(0===(e=Ve(e)).length&&(e=r.alloc(o)),e.length!==o)throw new Error(`Expected ${t} type, but got ${e.length} bytes`);n&&(e=`0x${e.toString("hex")}`)}else if("address"===t){if(0===(e=Ve(e)).length&&(e=r.alloc(20)),20!==e.length)throw new Error(`Address type must be 20 bytes, but got ${e.length} bytes`);n&&(e=`0x${e.toString("hex")}`)}else if(z.TYPED_DATA.typeCodes[t]&&-1===t.indexOf("uint")&&t.indexOf("int")>-1)if(n){e=new Dt.default(e).toFixed()}else e=new Dt.default(e);else if(z.TYPED_DATA.typeCodes[t]&&(t.indexOf("uint")>-1||t.indexOf("int")>-1)){let t=Ve(e);0===t.length&&(t=r.from("00","hex")),e=n?`0x${t.toString("hex")}`:new Dt.default(t.toString("hex"),16)}else"bool"===t&&(e=!0===e?1:0);return e}function Rr(e){return r.from(`Ethereum Signed Message:\n${e.toString()}`,"utf-8")}function Cr(e,t){return t?r.concat([r.from([t]),r.from(Mt.RLP.encode(e))]):r.from(Mt.RLP.encode(e))}var Ur=e=>{const t=yr.parse(e);return{...t,to:t.to,data:t.data,gas:t.gas,value:t.value,nonce:t.nonce,chainId:t.chainId,gasPrice:"gasPrice"in t?t.gasPrice:void 0,maxFeePerGas:"maxFeePerGas"in t?t.maxFeePerGas:void 0,maxPriorityFeePerGas:"maxPriorityFeePerGas"in t?t.maxPriorityFeePerGas:void 0,accessList:"accessList"in t?t.accessList:void 0,authorizationList:"authorizationList"in t?t.authorizationList:void 0}},Dr=function(e){const t=Ur(e),n=(0,qt.serializeTransaction)(t);return r.from(n.slice(2),"hex")},Lr=function(e){if(!e.payload||!e.protocol||!e.signerPath)throw new Error("You must provide `payload`, `signerPath`, and `protocol` arguments in the messsage request");if(e.signerPath.length>5||e.signerPath.length<2)throw new Error("Please provide a signer path with 2-5 indices");const t={schema:3,payload:null,input:e,msg:null};switch(e.protocol){case"signPersonal":return function(e,t){const n=t.fwConstants.ethMaxMsgSz,o=t.fwConstants.varAddrPathSzAllowed,s=24+n+4;let i=0;e.payload=r.alloc(s),e.payload.writeUInt8(z.SIGN_PERSONAL,0),i+=1;const a=Xe(t.signerPath,o);a.copy(e.payload,i),i+=a.length;let c=t.payload,u=!1;if("string"==typeof t.payload)if("0x"===t.payload.slice(0,2))c=Ve(t.payload),u=!1===H.test(r.from(t.payload.slice(2),"hex").toString());else{if(!1===function(e,t=!1){if("string"!=typeof e)return!1;const r=t?[32,10]:[];for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(r.indexOf(n)<0&&(n<32||n>127))return!1}return!0}(t.payload))throw new Error("Currently, the Lattice can only display ASCII strings.");c=r.from(t.payload)}else if("boolean"==typeof t.displayHex)u=t.displayHex;else{if(!t.payload.toString)throw new Error("Unsupported input data type");u=!1===H.test(t.payload.toString())}const f=t.fwConstants;let l=n+f.extraDataMaxFrames*f.extraDataFrameSz;f.personalSignHeaderSz&&(l-=f.personalSignHeaderSz);if(f.ethMsgPreHashAllowed&&c.length>l){e.payload.writeUInt8(u,i),i+=1,e.payload.writeUInt16LE(c.length,i),i+=2;const t=r.from(zt.Hash.keccak256(r.concat([Rr(c.length),c])));t.copy(e.payload,i),e.prehash=t}else{const r=Or(c,t);e.extraDataPayloads=r,e.msg=c,e.payload.writeUInt8(u,i),i+=1,e.payload.writeUInt16LE(c.length,i),i+=2,c.copy(e.payload,i)}return e}(t,e);case"eip712":if(!e.fwConstants.eip712Supported)throw new Error("EIP712 is not supported by your Lattice firmware version. Please upgrade.");return function(e,t){const{ethMaxMsgSz:n,varAddrPathSzAllowed:o,eip712MaxTypeParams:s}=t.fwConstants,{TYPED_DATA:i}=z,a=24+n+4;let c=0;e.payload=r.alloc(a),e.payload.writeUInt8(i.enumIdx,0),c+=1;const u=Xe(t.signerPath,o);u.copy(e.payload,c),c+=u.length;const f=vr(t.payload);if(!f.primaryType||!f.types[f.primaryType])throw new Error("primaryType must be specified and the type must be included.");if(!f.message||!f.domain)throw new Error("message and domain must be specified.");if(0>Object.keys(f.types).indexOf("EIP712Domain"))throw new Error("EIP712Domain type must be defined.");const l=vr(f);l.message=kr(vr(f.message),vr(f.primaryType),vr(f.types),!0),l.domain=kr(vr(f.domain),"EIP712Domain",vr(f.types),!0),e.validationPayload=l,f.domain=kr(f.domain,"EIP712Domain",f.types,!1),f.message=kr(f.message,f.primaryType,f.types,!1);const d=r.from(Ft.default.encode(f)),h=t.fwConstants,p=n+h.extraDataMaxFrames*h.extraDataFrameSz;let m=d.length>p;if(Object.keys(f.types).forEach(e=>{f.types[e].length>s&&(m=!0)}),h.ethMsgPreHashAllowed&&m){e.payload.writeUInt16LE(d.length,c),c+=2;const t=Lt.TypedDataUtils.eip712Hash(e.validationPayload,Lt.SignTypedDataVersion.V4);r.from(t).copy(e.payload,c),e.prehash=t}else{const r=Or(d,t);e.extraDataPayloads=r,e.payload.writeUInt16LE(d.length,c),c+=2,d.copy(e.payload,c),c+=d.length,e.payload=e.payload.slice(0,c)}return e}(t,e);default:throw new Error("Unsupported protocol")}},zr=function(e,t){const{signer:n,sig:o}=e,{input:s,msg:i,prehash:a=null}=t;if("signPersonal"===s.protocol){return Pr(a||r.from(zt.Hash.keccak256(r.concat([Rr(i.length),i]))),o,n,{chainId:1,useEIP155:!1})}if("eip712"===s.protocol){const e=t.validationPayload||t.input.payload,r=t.validationPayload?vr(t.validationPayload):Er(e),i=Lt.TypedDataUtils.eip712Hash(r,Lt.SignTypedDataVersion.V4),c=a||i;let u=s.payload.domain?.chainId||r.domain?.chainId;return"string"==typeof u?u=u.startsWith("0x")?parseInt(u,16):parseInt(u,10):"bigint"==typeof u&&(u=Number(u)),Pr(c,o,n,{chainId:u,useEIP155:!1})}throw new Error("Unsupported protocol")},Mr=function(e){try{let{chainId:t=1}=e;const{signerPath:n,eip155:o=null,fwConstants:s,type:i=null}=e,{contractDeployKey:a,extraDataFrameSz:c,extraDataMaxFrames:u,prehashAllowed:f}=s,l=c>0&&u>0,d=s.ethMaxDataSz,h=s.varAddrPathSzAllowed;if("number"!=typeof t&&!1===_r(t)&&(t=Ar[t]),!t)throw new Error("Unsupported chain ID or name");if(!n)throw new Error("`signerPath` not provided");if(null===e.to&&!a)throw new Error("Contract deployment not supported. Please update your Lattice firmware.");const p=null===e.to&&a,m=s.allowedEthTxTypes&&s.allowedEthTxTypes.indexOf(2)>-1,g=s.allowedEthTxTypes&&s.allowedEthTxTypes.indexOf(1)>-1,b=m&&(2===i||"eip1559"===i),y=g&&(1===i||"eip2930"===i);if(null!==i&&!b&&!y)throw new Error("Unsupported Ethereum transaction type");let w=function(e){switch(e){case 3:case 4:return!1;default:return!0}}(t);null!==o&&"boolean"==typeof o?w=o:(b||y)&&(w=!1),e.value||(e.value=0);const E=[],v=Ve(t),x=Ve(e.nonce);let B;const S=Ve(e.gasLimit);let P,I;p?(P=r.alloc(0),I=Ve(a)):(P=Ve(e.to),I=Ve(e.to));const T=Ve(e.value),A=Ve(e.data);let j,_;if((b||y)&&E.push(v),E.push(x),b){if(!e.maxPriorityFeePerGas)throw new Error("EIP1559 transactions must include `maxPriorityFeePerGas`");j=Ve(e.maxPriorityFeePerGas),E.push(j),_=Ve(e.maxFeePerGas),E.push(_),B=_}else B=Ve(e.gasPrice),E.push(B);E.push(S),E.push(P),E.push(T),E.push(A);let O=!1;if(b||y){const t=[];Array.isArray(e.accessList)&&e.accessList.forEach(e=>{const r=[];e.storageKeys.forEach(e=>{r.push(Ve(e))}),t.push([Ve(e.address),r]),O=!0}),E.push(t)}else!0===w&&(E.push(v),E.push(Ve(null)),E.push(Ve(null)));const k=122,N=r.alloc(d+k);let R,C=0;N.writeUInt8(Number(w),C),C++;let U=0;if(!0===function(e){const t=jr(e);return 1!==t.length||255===t.readUInt8(0)}(t)){if(R=jr(t),U=R.length,U>8)throw new Error("ChainID provided is too large.");N.writeUInt8(255,C),C++}else{if(R=Ve(t),1!==R.length)throw new Error("Error parsing chainID");R.copy(N,C),C+=R.length}const D=Xe(n,h);if(D.copy(N,C),C+=D.length,x.length>4)throw new Error("Nonce too large");if(x.copy(N,C+(4-x.length)),C+=4,B.length>8)throw new Error("Gas price too large");if(B.copy(N,C+(8-B.length)),C+=8,S.length>4)throw new Error("Gas limit too large");if(S.copy(N,C+(4-S.length)),C+=4,20!==I.length)throw new Error("Invalid `to` address");if(I.copy(N,C),C+=20,T.length>32)throw new Error("Value too large");T.copy(N,C+(32-T.length)),C+=32;let L=!1;if(s.allowedEthTxTypes)if(O&&(L=!0),N.writeUInt8(L?1:0,C),C+=1,b){if(N.writeUInt8(2,C),C+=1,j.length>8)throw new Error("maxPriorityFeePerGasBytes too large");j.copy(N,C+(8-j.length)),C+=8}else y?(N.writeUInt8(1,C),C+=1,C+=8):C+=9;const z=[];let M=null;const G=A.length||0,F=U>0?U+1:0,H=r.alloc(G+F);if(F>0&&(H.writeUInt8(U,0),R.copy(H,1)),A.copy(H,F),G>d){const e=G+F,t=d+u*c;if(f&&e>t)M=r.from(zt.Hash.keccak256(Cr(E,i)));else{if(!l||l&&e>t)throw new Error(`Data field too large (got ${A.length}; must be <=${t-F} bytes)`);$e(H.slice(d),c).forEach(e=>{const t=r.alloc(4);t.writeUInt32LE(e.length,0),z.push(r.concat([t,e]))})}}else L&&(M=r.from(zt.Hash.keccak256(Cr(E,i))));return N.writeUInt16BE(A.length,C),C+=2,U>0&&(N.writeUInt8(U,C),C++,R.copy(N,C),C+=U),M?(M.copy(N,C),C+=d):(A.slice(0,d).copy(N,C),C+=d),{rawTx:E,type:i,payload:N.slice(0,C),extraDataPayloads:z,schema:1,chainId:t,useEIP155:w,signerPath:n}}catch(e){return{err:e.message}}},Gr=function(e,t,n){const o=Pr(r.from(zt.Hash.keccak256(Cr(e.rawTx,e.type))),t,n,e),s=e.useEIP155?e.rawTx.slice(0,-3):e.rawTx;s.push(o.v),s.push(Sr(o.r)),s.push(Sr(o.s));const i=r.from(Mt.RLP.encode(s)),a=e.type?r.concat([r.from([e.type]),i]):i;return e.type===Kt||e.type===Zt?a.toString("hex"):{rawTx:a.toString("hex"),sigWithV:o}},Fr=function(e){return zt.Hash.keccak256(r.from(e,"hex"))},Hr=Dr,qr=class extends Error{constructor(e,t){const r=(({responseCode:e,errorMessage:t})=>{const r=[];return e&&r.push(`${N.responseMsg[e]}`),t&&(r.push("Error Message: "),r.push(t)),r.join("\n")})({responseCode:e,errorMessage:t});super(r),this.responseCode=e,this.errorMessage=t,this.name="LatticeResponseError",this.responseCode=e,this.errorMessage=t}},$r=(e,t=!1)=>{const n=e.getPublic().encode("hex",!1),o=r.from(n,"hex");if(!0===t){const e=o.slice(1,33).reverse(),t=o.slice(33,65).reverse();return r.concat([o[0],e,t])}return o},Vr=function(e){let t="m";return e.forEach(e=>{t+=e>=U?`/${e-U}'`:`/${e}`}),t},Wr=async({url:e,payload:t,timeout:r=6e4})=>async function(e,t){const{timeout:r=8e3}=t,n=new AbortController,o=setTimeout(()=>n.abort(),r),s=await fetch(e,{...t,signal:n.signal});return clearTimeout(o),s}(e,{method:"POST",body:JSON.stringify({data:t}),headers:{"Content-Type":"application/json"},timeout:r}).catch(Re).then(e=>e.json()).then(e=>{if(!e||!e.message)throw new Error("Invalid response");if(200!==e.status)throw new Error(`Error code ${e.status}: ${e.message}`);const{data:t,errorMessage:r,responseCode:n}=function(e){const t={errorMessage:null,data:null},r=xe.Buffer.from(e,"hex");let n=0;const o=r.readUInt8(n);if(n++,1!==o)return t.errorMessage="Incorrect protocol version. Please update your SDK",t;const s=r.readUInt8(n);if(n++,0!==s)return t.errorMessage="Incorrect response from Lattice1",t;r.readUInt32BE(n),n+=4;const i=r.readUInt16BE(n);n+=2;const a=r.slice(n,n+i);n+=i;const c=a.readUInt8(0);if(0!==c){const e=N.responseMsg[c];return t.errorMessage=`[Lattice] ${e||"Unknown Error"}`,t.responseCode=c,t}return t.data=a.slice(1,a.length),r.readUInt32BE(n)!==qe(r.slice(0,r.length-4))?(t.errorMessage="Invalid checksum from device response",t.data=null,t):t}(e.message);if(r||n)throw new qr(n,r);return t});var Kr=(e,t)=>(r,n)=>Zr({fn:r,params:{...n,client:e},retries:t,client:e}),Zr=async({fn:e,params:t,retries:r,client:n})=>e({...t}).catch(async o=>{if(o instanceof qr){const i=o.errorMessage,a=o.responseCode;if((i||a)&&r){if((e=>130===e||137===e)(a))await(s=3e3,new Promise(e=>setTimeout(e,s)));else if((e=>138===e)(a)&&!n.skipRetryOnWrongWallet)await n.fetchActiveWallet();else{if(!(e=>142===e)(a))throw o;await n.connect(n.deviceId)}return Zr({fn:e,params:t,retries:r-1,client:n})}}var s;throw o}),{msgSizes:Yr}=N,{secure:Jr}=Yr;async function Xr({url:e,pubkey:t}){const n=function(e){const t=r.alloc(Jr.data.request.connect);return e.pubkey.copy(t,0),t}({pubkey:t}),o=en(et(4),1,n),s=await Wr({url:e,payload:o});if(s.length!==Jr.payload.response.connect-1)throw new Error("Wrong Lattice response message size.");return s}async function Qr({data:e,requestType:t,sharedSecret:n,ephemeralPub:o,url:s}){const i=et(4),a=function({data:e,requestType:t,ephemeralPub:n,sharedSecret:o}){if(e.length>Jr.data.request.encrypted.encryptedData)throw new Error("Encrypted request data too large");De(n);const s=Jr.data.request.encrypted[t];if(e.length!==s)throw new Error(`Invalid request datasize (wanted ${s}, got ${e.length})`);const i=r.alloc(1+s);i[0]=t,e.copy(i,1);const a=qe(i),c=r.alloc(Jr.data.request.encrypted.encryptedData);i.copy(c,0),c.writeUInt32LE(a,i.length);const u=function(e,t){const r=xe.Buffer.from(N.aesIv),n=new we.default.ModeOfOperation.cbc(t,r),o=e.length%16==0?e:we.default.padding.pkcs7.pad(e);return xe.Buffer.from(n.encrypt(o))}(c,o),f=(e=>{const t=r.from(ht.Hash.sha256(e));return parseInt(t.slice(0,4).toString("hex"),16)})(o),l=r.alloc(Jr.payload.request.encrypted-1);return l.writeUInt32LE(f),u.copy(l,4),l}({data:e,requestType:t,ephemeralPub:o,sharedSecret:n}),c=en(i,2,a),u=await Wr({url:s,payload:c});if(u.length!==Jr.payload.response.encrypted-1)throw new Error("Wrong Lattice response message size.");return function({encPayloadData:e,requestType:t,sharedSecret:r}){const n=Ke(e,r),o=65,s=o+Jr.data.response.encrypted[t],i={ephemeralPub:n.slice(0,o),data:n.slice(o,s),checksum:n.readUInt32BE(s)},a=qe(n.slice(0,s));if(i.checksum!==a)throw new Error("Checksum mismatch in decrypted Lattice data");const c=Jr.data.response.encrypted[t];if(i.data.length!==c)throw new Error("Incorrect response data returned from Lattice");const u=Je(i.ephemeralPub);return{decryptedData:i.data,newEphemeralPub:u}}({encPayloadData:u.slice(0,Jr.data.response.encrypted.encryptedData),requestType:t,sharedSecret:n})}function en(e,t,n){if(4!==e.length)throw new Error("msgId must be four bytes");if(1!==t&&2!==t)throw new Error("Invalid Lattice secure request type");const o=1===t&&n.length===Jr.payload.request.connect-1,s=2===t&&n.length===Jr.payload.request.encrypted-1;let i,a=Yr.header+Yr.checksum;const c={requestType:t,data:n};if(o)i=Jr.payload.request.connect;else{if(!s)throw new Error("Invalid Lattice secure request payload size");i=Jr.payload.request.encrypted}a+=i;const u={header:{version:1,type:2,id:e,len:i},payload:c},f=r.alloc(a);let l=0;if(f.writeUInt8(u.header.version,l),l+=1,f.writeUInt8(u.header.type,l),l+=1,u.header.id.copy(f,l),l+=u.header.id.length,f.writeUInt16BE(u.header.len,l),l+=2,f.writeUInt8(u.payload.requestType,l),l+=1,u.payload.data.copy(f,l),l+=u.payload.data.length,f.writeUInt32BE(qe(f.slice(0,l)),l),l+=4,l!==a)throw new Error("Failed to build request message");return f}async function tn({client:e,records:t,type:r,caseSensitive:n}){const{url:o,sharedSecret:s,ephemeralPub:i,fwConstants:a}=Ue(e);rn({records:t,fwConstants:a});const c=nn({records:t,type:r,caseSensitive:n,fwConstants:a}),{decryptedData:u,newEphemeralPub:f}=await Qr({data:c,requestType:8,sharedSecret:s,ephemeralPub:i,url:o});return e.mutate({ephemeralPub:f}),u}var rn=({records:e,fwConstants:t})=>{((e,t)=>{if(!t||!t.kvActionsAllowed)throw new Error("Unsupported. Please update firmware.");if("object"!=typeof e||Object.keys(e).length<1)throw new Error("One or more key-value mapping must be provided in `records` param.");if(Object.keys(e).length>t.kvActionMaxNum)throw new Error(`Too many keys provided. Please only provide up to ${t.kvActionMaxNum}.`)})(e,t)},nn=({records:e,type:t,caseSensitive:n,fwConstants:o})=>{const s=r.alloc(1+139*o.kvActionMaxNum);s.writeUInt8(Object.keys(e).length,0);let i=1;return Object.entries(e).forEach(([e,a])=>{const{key:c,val:u}=(({key:e,val:t},r)=>{if("string"!=typeof e||String(e).length>r.kvKeyMaxStrSz)throw new Error(`Key ${e} too large. Must be <=${r.kvKeyMaxStrSz} characters.`);if("string"!=typeof t||String(t).length>r.kvValMaxStrSz)throw new Error(`Value ${t} too large. Must be <=${r.kvValMaxStrSz} characters.`);if(0===String(e).length||0===String(t).length)throw new Error("Keys and values must be >0 characters.");if(!H.test(e)||!H.test(t))throw new Error("Unicode characters are not supported.");return{key:e,val:t}})({key:e,val:a},o);s.writeUInt32LE(0,i),i+=4,s.writeUInt32LE(t,i),i+=4,s.writeUInt8(n?1:0,i),i+=1,s.writeUInt8(String(c).length+1,i),i+=1,r.from(String(c)).copy(s,i),i+=o.kvKeyMaxStrSz+1,s.writeUInt8(String(u).length+1,i),i+=1,r.from(String(u)).copy(s,i),i+=o.kvValMaxStrSz+1}),s};async function on({client:e,id:t}){const{deviceId:r,key:n,baseUrl:o}=sn({deviceId:t,key:e.key,baseUrl:e.baseUrl}),s=`${o}/${r}`,i=await Xr({url:s,pubkey:e.publicKey}),{isPaired:a,fwVersion:c,activeWallets:u,ephemeralPub:f}=await an(i,n);return e.mutate({deviceId:r,ephemeralPub:f,url:s,isPaired:a,fwVersion:c,activeWallets:u}),a&&!(e=>((e,t)=>{const{major:r,minor:n,fix:o}=e,{major:s,minor:i,fix:a}=t;return r>s||r>=s&&n>i||r>=s&&n>=i&&o>=a})(e,{major:0,minor:14,fix:1}))(e.getFwVersion())&&await e.fetchActiveWallet(),a}var sn=({deviceId:e,key:t,baseUrl:r})=>{const n=(e=>{if(!e)throw new Error("No device ID has been stored. Please connect with your device ID first.");return e})(e),o=ze(t),s=(e=>{if(!e)throw new Error("Base URL is required.");try{new URL(e)}catch(e){throw console.error("Invalid Base URL format:",e),new Error("Invalid Base URL provided. Please use a valid URL.")}return e})(r);return{deviceId:n,key:o,baseUrl:s}},an=(e,t)=>{let n=0;const o=e.readUInt8(n)===N.pairingStatus.paired;n++;const s=e.slice(n,n+65).toString("hex");n+=65;const i=Je(s),a=e.slice(n,n+4);if(n+=4,o){const s=e.slice(n,n+160);n+=160;const c=((e,t)=>r.from(e.derive(t.getPublic()).toArray("be",32)))(t,i),u=Ke(s,c);if(0!==u[u.length-2]||0!==u[u.length-1])throw new Error("Failed to connect to Lattice.");const f=(e=>{let t=0;const r={internal:{uid:void 0,capabilities:void 0,name:void 0,external:!1},external:{uid:void 0,capabilities:void 0,name:void 0,external:!0}};return r.internal.uid=e.slice(t,t+32),t+=71,r.external.uid=e.slice(t,t+32),r})(u);return{isPaired:o,fwVersion:a,activeWallets:f,ephemeralPub:i}}return{isPaired:o,fwVersion:a,activeWallets:void 0,ephemeralPub:i}},cn=e("uuid"),{ENC_DATA:un}=R,fn="Unknown encrypted data export type requested. Exiting.",ln={CIPHERTEXT:32,SALT:32,CHECKSUM:32,IV:16,PUBKEY:48};async function dn({client:e,schema:t,params:r}){const{url:n,sharedSecret:o,ephemeralPub:s,fwVersion:i}=Ue(e),a=Ce(e.getActiveWallet());hn({params:r});const c=pn({schema:t,params:r,fwVersion:i,activeWallet:a}),{decryptedData:u,newEphemeralPub:f}=await Qr({data:c,requestType:12,sharedSecret:o,ephemeralPub:s,url:n});return e.mutate({ephemeralPub:f}),mn({data:u,schema:t,params:r})}var hn=({params:e})=>{Ne(e.path)},pn=({schema:e,params:t,fwVersion:n,activeWallet:o})=>{if(n.major<1&&n.minor<17)throw new Error("Firmware version >=v0.17.0 is required for encrypted data export.");if(e!==un.SCHEMAS.BLS_KEYSTORE_EIP2335_PBKDF_V4)throw new Error(fn);t.walletUID=o.uid;const s=r.alloc(1025);let i=0;if(s.writeUInt8(e,i),i+=1,e===un.SCHEMAS.BLS_KEYSTORE_EIP2335_PBKDF_V4){t.walletUID.copy(s,i),i+=t.walletUID.length,s.writeUInt8(t.path.length,i),i+=1;for(let e=0;e<5;e++)e<=t.path.length&&s.writeUInt32LE(t.path[e],i),i+=4;return t.c&&s.writeUInt32LE(t.c,i),i+=4,s}throw new Error(fn)},mn=({data:e,schema:t,params:r})=>{let n=0;if(t===un.SCHEMAS.BLS_KEYSTORE_EIP2335_PBKDF_V4){const t={},{CIPHERTEXT:o,SALT:s,CHECKSUM:i,IV:a,PUBKEY:c}=ln,u=4+o+s+i+a+c,f=e.readUInt32LE(n);if(n+=4,f!==u)throw new Error("Invalid data returned from Lattice. Expected EIP2335 data.");return t.iterations=e.readUInt32LE(n),n+=4,t.cipherText=e.slice(n,n+o),n+=o,t.salt=e.slice(n,n+s),n+=s,t.checksum=e.slice(n,n+i),n+=i,t.iv=e.slice(n,n+a),n+=a,t.pubkey=e.slice(n,n+c),n+=c,gn(t,r.path)}throw new Error(fn)},gn=(e,t)=>{try{const{iterations:n,salt:o,checksum:s,iv:i,cipherText:a,pubkey:c}=e;return r.from(JSON.stringify({version:4,uuid:(0,cn.v4)(),path:Vr(t),pubkey:c.toString("hex"),crypto:{kdf:{function:"pbkdf2",params:{dklen:32,c:n,prf:"hmac-sha256",salt:o.toString("hex")},message:""},checksum:{function:"sha256",params:{},message:s.toString("hex")},cipher:{function:"aes-128-ctr",params:{iv:i.toString("hex")},message:a.toString("hex")}}}))}catch(e){throw Error(`Failed to format EIP2335 return data: ${e.toString()}`)}};async function bn({client:e}){const{url:t,sharedSecret:n,ephemeralPub:o}=Ue(e),{decryptedData:s,newEphemeralPub:i}=await Qr({data:r.alloc(0),requestType:4,sharedSecret:n,ephemeralPub:o,url:t}),a=(e=>{if(!e||e?.internal?.uid?.equals(V)&&e?.external?.uid?.equals(V))throw new Error("No active wallet.");return e})(yn(s));return e.mutate({ephemeralPub:i,activeWallets:a}),a}var yn=e=>{const t={internal:{uid:V,external:!1,name:r.alloc(0),capabilities:0},external:{uid:V,external:!0,name:r.alloc(0),capabilities:0}};let n=0;return t.internal.uid=e.slice(n,n+32),t.internal.capabilities=e.readUInt32BE(n+32),t.internal.name=e.slice(n+36,n+71),n+=71,t.external.uid=e.slice(n,n+32),t.external.capabilities=e.readUInt32BE(n+32),t.external.name=e.slice(n+36,n+71),t};async function wn({client:e,startPath:t,n:r,flag:n,iterIdx:o}){const{url:s,sharedSecret:i,ephemeralPub:a,fwConstants:c}=Ue(e),u=Ce(e.getActiveWallet()),{startPath:f,n:l,flag:d}=En({startPath:t,n:r,flag:n}),h=vn({startPath:f,n:l,flag:d,fwConstants:c,wallet:u,iterIdx:o}),{decryptedData:p,newEphemeralPub:m}=await Qr({data:h,requestType:1,sharedSecret:i,ephemeralPub:a,url:s});return e.mutate({ephemeralPub:m}),xn(p,d)}var En=({startPath:e,n:t,flag:r})=>({startPath:Ne(e),n:ke(t),flag:Oe(r)}),vn=({startPath:e,n:t,flag:n,fwConstants:o,wallet:s,iterIdx:i})=>{if(!((o.getAddressFlags||[]).indexOf(n)>-1&&(4===n||3===n||5===n))&&!(6===n)&&!function(e,t){const r=[He.ETH,He.BTC_LEGACY,He.BTC_WRAPPED_SEGWIT,He.BTC_SEGWIT],n=[Fe.ETH,Fe.BTC,Fe.BTC_TESTNET];return!((e[1]===Fe.BTC||e[1]===Fe.BTC_TESTNET)&&e[0]!==He.BTC_WRAPPED_SEGWIT&&!t.allowBtcLegacyAndSegwitAddrs)&&r.indexOf(e[0])>=0&&(n.indexOf(e[1])>=0||[60,61,966,700,9006,9e3,1007,553,178,137,37310,108,40,889,1987,820,6060,1620,1313114,76,246529,246785,1001,227,916,464,2221,344,73799,246].indexOf(e[1]-U)>0)}(e,o))throw new Error("Derivation path or flag is not supported. Try updating Lattice firmware.");if(e.length<2||e.length>5)throw new Error("Derivation path must include 2-5 indices.");if(i<0||i>5)throw new Error("Iteration index must be between 0 and 5.");if(i>e.length)throw new Error("Iteration index cannot be greater than path depth.");const a=r.alloc(54);let c=0;s.uid.copy(a,c),c+=32;const u=(15&i)<<4|15&e.length;a.writeUInt8(u,c),c+=1;for(let t=0;t<5;t++){const r=t<e.length?e[t]:0;a.writeUInt32BE(r,c),c+=4}const f=15&t,l=(15&n)<<4;return a.writeUInt8(f|l,c),a},xn=(e,t)=>{let r=0;const n=4===t?113:65,o=[],s=3===t||4===t||5===t;s&&(r+=1);const i=N.msgSizes.secure.data.response.encrypted[1];for(;r<i;)if(s){const s=e.slice(r,r+n),i=s.every(e=>0===e);i||4!==t?i||5!==t?i||o.push(s):o.push(s.slice(0,48)):o.push(s.slice(0,32)),r+=n}else{const t=e.slice(r,r+N.addrStrLen);r+=N.addrStrLen;const n=t.indexOf(0);if(n>0){const e=t.slice(0,n).toString().replace(/[\x00-\x1F\x7F-\x9F]/g,"");o.push(e)}}return o};async function Bn({client:e,type:t,n:r,start:n}){const{url:o,sharedSecret:s,ephemeralPub:i,fwConstants:a}=Ue(e),{type:c,n:u,start:f}=Sn({type:t,n:r,start:n,fwConstants:a}),l=Pn({type:c,n:u,start:f}),{decryptedData:d,newEphemeralPub:h}=await Qr({data:l,requestType:7,sharedSecret:s,ephemeralPub:i,url:o});return e.mutate({ephemeralPub:h}),In(d,a)}var Sn=({fwConstants:e,n:t,type:r,start:n})=>{if(!e.kvActionsAllowed)throw new Error("Unsupported. Please update firmware.");if(!t||t<1)throw new Error("You must request at least one record.");if(t>e.kvActionMaxNum)throw new Error(`You may only request up to ${e.kvActionMaxNum} records at once.`);if(0!==r&&!r)throw new Error("You must specify a type.");if(0!==n&&!n)throw new Error("You must specify a type.");return{fwConstants:e,n:t,type:r,start:n}},Pn=({type:e,n:t,start:n})=>{const o=r.alloc(9);return o.writeUInt32LE(e,0),o.writeUInt8(t,4),o.writeUInt32LE(n,5),o},In=(e,t)=>{let r=0;const n=e.readUInt32BE(r);r+=4;const o=parseInt(e.slice(r,r+1).toString("hex"),16);if(r+=1,o>t.kvActionMaxNum)throw new Error("Too many records fetched. Firmware error.");const s=[];for(let n=0;n<o;n++){const n={};n.id=e.readUInt32BE(r),r+=4,n.type=e.readUInt32BE(r),r+=4,n.caseSensitive=1===parseInt(e.slice(r,r+1).toString("hex"),16),r+=1;const o=parseInt(e.slice(r,r+1).toString("hex"),16);r+=1,n.key=e.slice(r,r+o-1).toString(),r+=t.kvKeyMaxStrSz+1;const i=parseInt(e.slice(r,r+1).toString("hex"),16);r+=1,n.val=e.slice(r,r+i-1).toString(),r+=t.kvValMaxStrSz+1,s.push(n)}return{records:s,total:n,fetched:o}};async function Tn({client:e,pairingSecret:t}){const{url:r,sharedSecret:n,ephemeralPub:o,appName:s,key:i}=Ue(e),a=An({pairingSecret:t,key:i,appName:s}),{newEphemeralPub:c}=await Qr({data:a,requestType:0,sharedSecret:n,ephemeralPub:o,url:r});return e.mutate({ephemeralPub:c,isPaired:!0}),await e.fetchActiveWallet(),e.hasActiveWallet()}var An=({key:e,pairingSecret:t,appName:n})=>{const o=$r(e),s=r.alloc(25);t.length>0&&s.write(n);const i=ct(o,s,r.from(t)),a=function(e){const t=xe.Buffer.alloc(74);return xe.Buffer.from(e.toDER()).copy(t),t}(e.sign(i));return r.concat([s,a])};async function jn({client:e,type:t,ids:r}){const{url:n,sharedSecret:o,ephemeralPub:s,fwConstants:i}=Ue(e),{type:a,ids:c}=_n({fwConstants:i,type:t,ids:r}),u=On({type:a,ids:c,fwConstants:i}),{decryptedData:f,newEphemeralPub:l}=await Qr({data:u,requestType:9,sharedSecret:o,ephemeralPub:s,url:n});return e.mutate({ephemeralPub:l}),f}var _n=({fwConstants:e,type:t,ids:r})=>{if(!e.kvActionsAllowed)throw new Error("Unsupported. Please update firmware.");if(!Array.isArray(r)||r.length<1)throw new Error("You must include one or more `ids` to removed.");if(r.length>e.kvRemoveMaxNum)throw new Error(`Only up to ${e.kvRemoveMaxNum} records may be removed at once.`);if(0!==t&&!t)throw new Error("You must specify a type.");return{type:t,ids:r}},On=({fwConstants:e,type:t,ids:n})=>{const o=r.alloc(5+4*e.kvRemoveMaxNum);o.writeUInt32LE(t,0),o.writeUInt8(n.length,4);for(let e=0;e<n.length;e++){const t=parseInt(n[e]);o.writeUInt32LE(t,5+4*e)}return o},kn=e("ox");async function Nn({client:e,data:t,currency:r,cachedData:n,nextCode:o}){try{const{url:s,sharedSecret:i,ephemeralPub:a,fwConstants:c}=Ue(e),u=Ce(e.getActiveWallet()),{requestData:f,isGeneric:l}=(({data:e,currency:t,fwConstants:r})=>{if("ETH"===t&&(e=>e.genericSigning&&e.genericSigning.encodingTypes&&e.genericSigning.encodingTypes.EVM)(r)){let t;console.log("Using the legacy ETH signing path. This will soon be deprecated. Please switch to general signing request.");try{t=Hr(e)}catch(e){throw console.error("Failed to convert legacy Ethereum transaction:",e),new Error("Could not convert legacy request. Please switch to a general signing request. See gridplus-sdk docs for more information.")}return e={fwConstants:r,encodingType:R.SIGNING.ENCODINGS.EVM,curveType:R.SIGNING.CURVES.SECP256K1,hashType:R.SIGNING.HASHES.KECCAK256,signerPath:e.signerPath,payload:t},{requestData:Qt({...e,fwConstants:r}),isGeneric:!0}}return"ETH"===t?{requestData:Mr({...e,fwConstants:r}),isGeneric:!1}:"ETH_MSG"===t?{requestData:Lr({...e,fwConstants:r}),isGeneric:!1}:"BTC"===t?{requestData:Ut.buildBitcoinTxRequest({...e,fwConstants:r}),isGeneric:!1}:{requestData:Qt({...e,fwConstants:r}),isGeneric:!0}})({data:t,currency:r,fwConstants:c}),{payload:d,hasExtraPayloads:h}=Rn({fwConstants:c,wallet:u,requestData:f,cachedData:n,nextCode:o}),{decryptedData:p,newEphemeralPub:m}=await Qr({data:d,requestType:3,sharedSecret:i,ephemeralPub:a,url:s});if(e.mutate({ephemeralPub:m}),h)return e.sign({data:t,currency:r,cachedData:f,nextCode:p.slice(0,8)});return Cn({data:p,request:f,isGeneric:l,currency:r})}catch(e){throw console.error("Error signing transaction:",{message:e.message,payload:JSON.stringify({data:t,currency:r},(e,t)=>"bigint"==typeof t?t.toString():t)}),e}}var Rn=({fwConstants:e,wallet:t,requestData:n,cachedData:o,nextCode:s})=>{let i,a,c=0;const u=n;if(o&&s){const e=o,t=e.extraDataPayloads.shift();if(!t)throw new Error("No cached extra payload available for multipart sign request.");u.extraDataPayloads&&(u.extraDataPayloads=e.extraDataPayloads),i=r.concat([s,t]),a=4,c=Number((e.extraDataPayloads?.length??0)>0)}else i=u.payload,a=u.schema,c=Number((u.extraDataPayloads?.length??0)>0);const f=r.alloc(2+e.reqMaxDataSz);let l=0;return f.writeUInt8(c,l),l+=1,f.writeUInt8(a,l),l+=1,t.uid?.copy(f,l),l+=t.uid?.length??0,i.copy(f,l),{payload:f,hasExtraPayloads:c}},Cn=({data:e,request:t,isGeneric:n,currency:o})=>{let s=0;if(o===C.BTC){const n=t,o=20,i=760,a=Ut.getAddressFormat(n.origData.changePath),c=e.slice(s,s+o);s+=o;const u=Ut.getBitcoinAddress(c,a),f=33,l=[],d=[];let h=0;for(;s<e.length&&48===e[s];){const t=s,r=s+2+e[s+1];d.push(e.slice(t,r)),s+=74;const n=h*f+i,o=(h+1)*f+i;l.push(e.slice(n,o)),h+=1}const p={inputs:[],outputs:[]};p.outputs.push({value:n.origData.value,recipient:n.origData.recipient}),n.changeData?.value&&n.changeData.value>0&&p.outputs.push({value:n.changeData.value,recipient:u});for(let e=0;e<d.length;e++)p.inputs.push({hash:n.origData.prevOuts[e].txHash,index:n.origData.prevOuts[e].index,sig:d[e],pubkey:l[e],signerPath:n.origData.prevOuts[e].signerPath});const m=Ut.serializeTx(p),g=m,b=r.from(kn.Hash.sha256(r.from(g,"hex")));return{tx:m,txHash:`0x${r.from(kn.Hash.sha256(b)).toString("hex")}`,changeRecipient:u,sigs:d}}if(o!==C.ETH||n){if(o===C.ETH_MSG){const r=Ze(e.slice(s,s+2+e[s+1]));s+=74;const n=e.slice(s,s+20),o=zr({signer:n,sig:r},t);return{sig:{v:BigInt(`0x${o.v.toString("hex")}`),r:`0x${o.r.toString("hex")}`,s:`0x${o.s.toString("hex")}`},signer:`0x${n.toString("hex")}`}}return function(e,t,n){const o={pubkey:null,sig:null};let s;if(n.curveType===R.SIGNING.CURVES.SECP256K1){if(n.omitPubkey)t+=65;else{const n=e.readUInt8(t);if(t+=1,2===n||3===n)o.pubkey=r.alloc(33),o.pubkey.writeUInt8(n,0),e.slice(t,t+32).copy(o.pubkey,1);else{if(4!==n)throw new Error("Bad compression byte in signing response.");o.pubkey=r.alloc(65),o.pubkey.writeUInt8(n,0),e.slice(t).copy(o.pubkey,1)}t+=64}const i=2+e[t+1],a=e.slice(t,t+i),c=Ze(a),u=We(c.r,32),f=We(c.s,32);if(o.sig={r:`0x${u.toString("hex")}`,s:`0x${f.toString("hex")}`},t+=i,e.length>=t+32&&(s=r.from(e.slice(t,t+32)),t+=32),n.encodingType===R.SIGNING.ENCODINGS.EVM){const e=ut(n.origPayloadBuf,o);o.sig.v=BigInt(e.toString()),tr(o.sig.v,n,o)}else if(n.hashType===R.SIGNING.HASHES.KECCAK256&&n.encodingType!==R.SIGNING.ENCODINGS.EVM){let e=!1;try{let t=n.origPayloadBuf;t[0]<=127&&(t=t.slice(1));const r=Jt.RLP.decode(t);e=Array.isArray(r)&&r.length>=6}catch{e=!1}if(e)try{const e=ut(n.origPayloadBuf,o);o.sig.v=BigInt(e.toString()),tr(o.sig.v,n,o)}catch(e){console.error("Failed to get V from transaction, using fallback:",e);const t=er(n,s),r=lt({messageHash:t,signature:o.sig,publicKey:o.pubkey});o.sig.v=BigInt(27+r)}else{const e=er(n,s),t=lt({messageHash:e,signature:o.sig,publicKey:o.pubkey});o.sig.v=BigInt(27+t)}}}else if(n.curveType===R.SIGNING.CURVES.ED25519)n.omitPubkey||(o.pubkey=r.alloc(32),e.slice(t,t+32).copy(o.pubkey)),t+=32,o.sig={r:`0x${e.slice(t,t+32).toString("hex")}`,s:`0x${e.slice(t+32,t+64).toString("hex")}`},t+=64;else{if(n.curveType!==R.SIGNING.CURVES.BLS12_381_G2)throw new Error("Unsupported curve.");n.omitPubkey||(o.pubkey=r.alloc(48),e.slice(t,t+48).copy(o.pubkey)),t+=48,o.sig=r.alloc(96),e.slice(t,t+96).copy(o.sig),t+=96}return o}(e,s,t)}{const r=Ze(e.slice(s,s+2+e[s+1]));s+=74;const n=e.slice(s,s+20),o=Gr(t,r,n);if("string"==typeof o)return{tx:`0x${o}`,txHash:`0x${Fr(o)}`,sig:{v:0n,r:"0x",s:"0x"},signer:`0x${n.toString("hex")}`};return{tx:`0x${o.rawTx}`,txHash:`0x${Fr(o.rawTx)}`,sig:{v:BigInt(`0x${o.sigWithV.v.toString("hex")}`),r:`0x${o.sigWithV.r.toString("hex")}`,s:`0x${o.sigWithV.s.toString("hex")}`},signer:`0x${n.toString("hex")}`}}},Un=class{constructor({baseUrl:e,name:t,privKey:r,stateData:o,timeout:s,retryCount:i,skipRetryOnWrongWallet:a,deviceId:c,setStoredClient:u}){n(this,"isPaired",void 0),n(this,"timeout",void 0),n(this,"baseUrl",void 0),n(this,"url",void 0),n(this,"name",void 0),n(this,"key",void 0),n(this,"privKey",void 0),n(this,"retryCount",void 0),n(this,"fwVersion",void 0),n(this,"skipRetryOnWrongWallet",void 0),n(this,"_ephemeralPub",void 0),n(this,"deviceId",void 0),n(this,"activeWallets",void 0),n(this,"retryWrapper",void 0),n(this,"setStoredClient",void 0),this.name=t||"Unknown",this.baseUrl=e||"https://signing.gridpl.us",this.deviceId=c,this.isPaired=!1,this.activeWallets=W,this.timeout=s||6e4,this.retryCount=i||3,this.skipRetryOnWrongWallet=a||!1,this.privKey=r||et(32),this.key=Ye(this.privKey),this.retryWrapper=Kr(this,this.retryCount),this.setStoredClient=u?le(u):void 0,o&&this.unpackAndApplyStateData(o)}get publicKey(){return $r(this.key)}getAppName(){return this.name}getDeviceId(){return this.deviceId}get sharedSecret(){return r.from(this.key.derive(this.ephemeralPub.getPublic()).toArray("be",32))}get ephemeralPub(){return this._ephemeralPub}set ephemeralPub(e){De(e),this._ephemeralPub=e}async connect(e){return this.retryWrapper(on,{id:e})}async pair(e){return this.retryWrapper(Tn,{pairingSecret:e})}async getAddresses({startPath:e,n:t=1,flag:r=0,iterIdx:n=0}){return this.retryWrapper(wn,{startPath:e,n:t,flag:r,iterIdx:n})}async sign({data:e,currency:t,cachedData:r,nextCode:n}){return this.retryWrapper(Nn,{data:e,currency:t,cachedData:r,nextCode:n})}async fetchActiveWallet(){return this.retryWrapper(bn)}async addKvRecords({type:e=0,records:t,caseSensitive:r=!1}){return this.retryWrapper(tn,{type:e,records:t,caseSensitive:r})}async getKvRecords({type:e=0,n:t=1,start:r=0}){return this.retryWrapper(Bn,{type:e,n:t,start:r})}async removeKvRecords({type:e=0,ids:t=[]}){return this.retryWrapper(jn,{type:e,ids:t})}async fetchEncryptedData(e){return this.retryWrapper(dn,e)}getActiveWallet(){return this.activeWallets.external.uid&&!V.equals(this.activeWallets.external.uid)?this.activeWallets.external:this.activeWallets.internal.uid&&!V.equals(this.activeWallets.internal.uid)?this.activeWallets.internal:void 0}hasActiveWallet(){return!!this.getActiveWallet()}resetActiveWallets(){this.activeWallets=W}getStateData(){return this.packStateData()}getFwConstants(){return function(e){const t={extraDataFrameSz:0,extraDataMaxFrames:0,genericSigning:{}};function r(e,t){return e[2]>t[0]||e[2]===t[0]&&e[1]>t[1]||e[2]===t[0]&&e[1]===t[1]&&e[0]>t[2]||e[2]===t[0]&&e[1]===t[1]&&e[0]===t[2]}const n=0===e.length;return!n&&r(e,[0,10,4])||!n&&r(e,[0,10,0])?(t.reqMaxDataSz=1678,t.ethMaxGasPrice=2e13,t.addrFlagsAllowed=!0):(t.reqMaxDataSz=1152,t.ethMaxGasPrice=5e11,t.addrFlagsAllowed=!1),t.ethMaxDataSz=t.reqMaxDataSz-128,t.ethMaxMsgSz=t.ethMaxDataSz,t.eip712MaxTypeParams=18,!n&&r(e,[0,10,4])&&(t.extraDataFrameSz=1500,t.extraDataMaxFrames=1),!n&&r(e,[0,10,5])&&(t.varAddrPathSzAllowed=!0,t.eip712Supported=!0),!n&&r(e,[0,10,8])&&(t.prehashAllowed=!0),!n&&r(e,[0,10,10])&&(t.ethMsgPreHashAllowed=!0),!n&&r(e,[0,11,0])&&(t.allowedEthTxTypes=[1,2],t.ethMaxDataSz-=10,t.ethMaxMsgSz=t.ethMaxDataSz),!n&&r(e,[0,11,2])&&(t.personalSignHeaderSz=72),!n&&r(e,[0,12,0])&&(t.kvActionsAllowed=!0,t.kvKeyMaxStrSz=63,t.kvValMaxStrSz=63,t.kvActionMaxNum=10,t.kvRemoveMaxNum=100),!n&&r(e,[0,13,0])&&(t.allowBtcLegacyAndSegwitAddrs=!0,t.contractDeployKey="0x08002e0fec8e6acf00835f43c9764f7364fa3f42"),!n&&r(e,[0,14,0])&&(t.abiCategorySz=32,t.abiMaxRmv=200,t.genericSigning.baseReqSz=1552,t.genericSigning.baseDataSz=1519,t.genericSigning.hashTypes=R.SIGNING.HASHES,t.genericSigning.curveTypes=R.SIGNING.CURVES,t.genericSigning.encodingTypes={NONE:R.SIGNING.ENCODINGS.NONE,SOLANA:R.SIGNING.ENCODINGS.SOLANA},t.getAddressFlags=[R.GET_ADDR_FLAGS.ED25519_PUB,R.GET_ADDR_FLAGS.SECP256K1_PUB],t.eip712MaxTypeParams=36),!n&&r(e,[0,15,0])&&(t.genericSigning.encodingTypes.EVM=R.SIGNING.ENCODINGS.EVM,t.ethMaxDataSz=1519,t.maxDecoderBufSz=1600,t.genericSigning.calldataDecoding={reserved:2895728,maxSz:1024}),!n&&r(e,[0,17,0])&&(t.getAddressFlags.push(R.GET_ADDR_FLAGS.BLS12_381_G1_PUB),t.genericSigning.encodingTypes.ETH_DEPOSIT=R.SIGNING.ENCODINGS.ETH_DEPOSIT),!n&&r(e,[0,18,0])&&(t.genericSigning.encodingTypes={...t.genericSigning.encodingTypes,EIP7702_AUTH:R.SIGNING.ENCODINGS.EIP7702_AUTH,EIP7702_AUTH_LIST:R.SIGNING.ENCODINGS.EIP7702_AUTH_LIST}),t}(this.fwVersion??r.alloc(0))}getFwVersion(){return this.fwVersion&&this.fwVersion.length>=3?{fix:this.fwVersion[0],minor:this.fwVersion[1],major:this.fwVersion[2]}:{fix:0,minor:0,major:0}}mutate({deviceId:e,ephemeralPub:t,url:r,isPaired:n,fwVersion:o,activeWallets:s}){void 0!==e&&(this.deviceId=e),void 0!==t&&(this.ephemeralPub=t),void 0!==r&&(this.url=r),void 0!==n&&(this.isPaired=n),void 0!==o&&(this.fwVersion=o),void 0!==s&&(this.activeWallets=s),this.setStoredClient&&this.setStoredClient(this.getStateData())}packStateData(){try{const e={activeWallets:{internal:{uid:this.activeWallets.internal.uid?.toString("hex"),name:this.activeWallets.internal.name?.toString(),capabilities:this.activeWallets.internal.capabilities},external:{uid:this.activeWallets.external.uid?.toString("hex"),name:this.activeWallets.external.name?.toString(),capabilities:this.activeWallets.external.capabilities}},ephemeralPub:this.ephemeralPub?.getPublic()?.encode("hex",!1),fwVersion:this.fwVersion?.toString("hex"),deviceId:this.deviceId,name:this.name,baseUrl:this.baseUrl,privKey:this.privKey.toString("hex"),retryCount:this.retryCount,timeout:this.timeout};return JSON.stringify(e)}catch(e){return console.warn("Could not pack state data:",e),null}}unpackAndApplyStateData(e){try{const t=JSON.parse(e),n={uid:r.from(t.activeWallets.internal.uid,"hex"),name:t.activeWallets.internal.name?r.from(t.activeWallets.internal.name):null,capabilities:t.activeWallets.internal.capabilities,external:!1},o={uid:r.from(t.activeWallets.external.uid,"hex"),name:t.activeWallets.external.name?r.from(t.activeWallets.external.name):null,capabilities:t.activeWallets.external.capabilities,external:!0},s=r.from(t.ephemeralPub,"hex"),i=r.from(t.fwVersion,"hex"),a=r.from(t.privKey,"hex");this.activeWallets.internal=n,this.activeWallets.external=o,this.ephemeralPub=Je(s),this.fwVersion=i,this.deviceId=t.deviceId,this.name=t.name,this.baseUrl=t.baseUrl,this.url=`${this.baseUrl}/${this.deviceId}`,this.privKey=a,this.key=Ye(this.privKey),this.retryCount=t.retryCount,this.timeout=t.timeout,this.retryWrapper=Kr(this,this.retryCount)}catch(e){console.warn("Could not apply state data:",e)}}},Dn=async e=>{let t=[],r=0;const n=e?.n||q;for(;r<n;){const o=Math.min(q,n-r),s=he(K,r);await ue(n=>n.getAddresses({startPath:s,...e,n:o}).then(e=>{e.length>0&&(t=[...t,...e],r+=e.length)}))}return t},Ln=async(e=0)=>Dn({startPath:"number"==typeof e?he(K,e):e,n:1}).then(e=>e[0]);function zn(e){return async({n:t,startPathIndex:r}={n:q,startPathIndex:0})=>Dn({startPath:he(e,r),n:t})}var Mn=zn(Z),Gn=zn(J),Fn=zn(Q),Hn=zn(Y),qn=zn(X),$n=zn(ee),Vn=async({n:e,startPathIndex:t}={n:q,startPathIndex:0})=>Dn({startPath:he(oe,t,2),n:e,flag:4}),Wn=async({n:e,startPathIndex:t}={n:q,startPathIndex:0})=>{const r=[];for(let n=0;n<e;n++)r.push(ue(e=>e.getAddresses({startPath:he(se,t+n,2),n:1}).then(e=>e.map(e=>`${e}`))));return Promise.all(r)},Kn=async({n:e,startPathIndex:t}={n:q,startPathIndex:0})=>{const r=[];for(let n=0;n<e;n++)r.push(ue(e=>e.getAddresses({startPath:he(ie,t+n,3),n:1}).then(e=>e.map(e=>`${e}`))));return Promise.all(r)},Zn=async({n:e=10,startPathIndex:t=0}={})=>{const r=[];for(let n=0;n<e;n++)r.push(ue(e=>{const r=[44+U,501+U,t+n+U,0+U];return e.getAddresses({startPath:r,n:1,flag:4}).then(e=>e.map(e=>`${e}`))}));return Promise.all(r)};async function Yn(e,{n:t=1,startPathIndex:r=0,flag:n}={}){const o=e.split("/").filter(Boolean),s=ge(o),i=function(e){if(e.length>=2&&e[1]===501+U)return R.GET_ADDR_FLAGS.ED25519_PUB}(s),a=o.findIndex(e=>e.toLowerCase().includes("x"));if(-1===a)return ue(e=>e.getAddresses({startPath:s,flag:n||i,n:t}));const c=[];for(let e=0;e<t;e++){const t=[...s];t[a]=t[a]+r+e;const o=await ue(e=>e.getAddresses({startPath:t,flag:n||i,n:1}));c.push(...o)}return c}async function Jn(){return(await Yn(te,{flag:6}))[0]}async function Xn(){return(await Yn(re,{flag:6}))[0]}async function Qn(){return(await Yn(ne,{flag:6}))[0]}var eo=async e=>{const t=e.reduce((e,t)=>{const r=Object.keys(t)[0];return e[r]=t[r],e},{});return ue(e=>e.addKvRecords({records:t}))},to=async({n:e=10,start:t=0}={})=>{const r=[];let n=e,o=t;for(;n>0;)await ue(e=>e.getKvRecords({start:o,n:n>q?q:n}).then(async e=>{r.push(...e.records),o=e.fetched+o,n=e.total-o}));return r},ro=async e=>{const t=e.map(e=>`${e.id}`);return ue(e=>e.removeKvRecords({ids:t}))},no=e("@ethereumjs/rlp"),oo=e("ox"),so=e("viem");var io=async(e,t)=>{const n="string"==typeof(o=e)||o instanceof Uint8Array||r.isBuffer(o);var o;const s=n?function(e){if("string"==typeof e)return e.startsWith("0x")?e:`0x${e}`;return r.from(e)}(e):(0,so.serializeTransaction)(e);let i,a=R.SIGNING.ENCODINGS.EVM;if(!n&&"eip7702"===e.type){const t=e;a=t.authorizationList&&t.authorizationList.length>0?R.SIGNING.ENCODINGS.EIP7702_AUTH_LIST:R.SIGNING.ENCODINGS.EIP7702_AUTH}!n&&"data"in e&&"to"in e&&"chainId"in e&&(i=await async function({data:e,to:t,chainId:r}){try{const n=await fe();Ue(n);const o=n.getFwVersion(),s=o.major>0||o.minor>=16,{def:i}=await at(e,t,r,s);return i}catch(e){return void console.warn("Failed to fetch ABI:",e)}}({data:e.data,to:e.to,chainId:e.chainId}));const c={signerPath:K,curveType:R.SIGNING.CURVES.SECP256K1,hashType:R.SIGNING.HASHES.KECCAK256,encodingType:a,payload:s,decoder:i};return ue(e=>e.sign({data:c,...t}))};function ao(e,t){const r={data:{signerPath:K,curveType:R.SIGNING.CURVES.SECP256K1,hashType:R.SIGNING.HASHES.KECCAK256,protocol:pe(e)?"eip712":"signPersonal",payload:e},currency:t?.currency??C.ETH_MSG,...t??{}};return ue(e=>e.sign(r))}var co=async(e,t)=>{const n=r.from([5]),o="address"in e?e.address:e.contractAddress,s=r.concat([n,r.from(no.RLP.encode([e.chainId,o,e.nonce]))]),i={signerPath:K,curveType:R.SIGNING.CURVES.SECP256K1,hashType:R.SIGNING.HASHES.KECCAK256,encodingType:R.SIGNING.ENCODINGS.EIP7702_AUTH,payload:s},a=await ue(e=>e.sign({data:i,...t}));if(a.sig&&a.pubkey){const t=r.from(oo.Hash.keccak256(s)),n=lt(t,a.sig,a.pubkey),i=r.isBuffer(a.sig.r)?`0x${a.sig.r.toString("hex")}`:a.sig.r,c=r.isBuffer(a.sig.s)?`0x${a.sig.s.toString("hex")}`:a.sig.s;return{address:o,chainId:e.chainId,nonce:e.nonce,yParity:n,r:i,s:c}}throw new Error("Failed to get signature from device")},uo=async e=>{const t=(0,so.serializeTransaction)(e),r={signerPath:K,curveType:R.SIGNING.CURVES.SECP256K1,hashType:R.SIGNING.HASHES.KECCAK256,encodingType:R.SIGNING.ENCODINGS.EIP7702_AUTH_LIST,payload:t};return await ue(e=>e.sign({data:r}))},fo=async e=>{const t={data:{signerPath:Z,...e},currency:C.BTC};return ue(e=>e.sign(t))},lo=async e=>{const t={data:{signerPath:J,...e},currency:C.BTC};return ue(e=>e.sign(t))},ho=async e=>{const t={data:{signerPath:Q,...e},currency:C.BTC};return ue(e=>e.sign(t))},po=async(e,t)=>{const r={data:{signerPath:oe,curveType:R.SIGNING.CURVES.ED25519,hashType:R.SIGNING.HASHES.NONE,encodingType:R.SIGNING.ENCODINGS.SOLANA,payload:e,...t}};return ue(e=>e.sign(r))},mo=async()=>ue(e=>e.fetchActiveWallet()),go=async e=>{if(!e.getStoredClient)throw new Error("Client data getter required");var t;if(t=de(e.getStoredClient),G=t,!e.setStoredClient)throw new Error("Client data setter required");if((e=>{M=e})(le(e.setStoredClient)),"deviceId"in e&&"password"in e&&"name"in e){const t=e.appSecret||dt.generateAppSecret(e.deviceId,e.password,e.name),r=new Un({deviceId:e.deviceId,privKey:t,name:e.name,baseUrl:e.baseUrl});return r.connect(e.deviceId).then(async e=>(await M(r.getStateData()),e))}{const e=await G();if(!e)throw new Error("Client not initialized");const t=e.getDeviceId();return!e.ephemeralPub&&t?bo(t):(await M(e.getStateData()),Promise.resolve(!0))}},bo=async e=>ue(t=>t.connect(e)),yo=async e=>ue(t=>t.pair(e))}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"eth-lattice-keyring>gridplus-sdk",file:"node_modules/gridplus-sdk/dist/index.cjs"}],[6568,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.EthereumJSError=r.DEFAULT_ERROR_CODE=void 0,r.EthereumJSErrorWithoutCode=function(e,t){return new n({code:r.DEFAULT_ERROR_CODE},e,t)},r.DEFAULT_ERROR_CODE="ETHEREUMJS_DEFAULT_ERROR_CODE";class n extends Error{constructor(e,t,r){super(t??e.code),this.type=e,r!==undefined&&(this.stack=r)}getMetadata(){return this.type}toObject(){return{type:this.getMetadata(),message:this.message??"",stack:this.stack??"",className:this.constructor.name}}}r.EthereumJSError=n}}},{package:"eth-lattice-keyring>gridplus-sdk>@ethereumjs/rlp",file:"node_modules/gridplus-sdk/node_modules/@ethereumjs/rlp/dist/cjs/errors.js"}],[6569,{"./errors.js":6568},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=Object.create?function(e,t,r,n){n===undefined&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]},o=function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.RLP=r.utils=void 0,r.hexToBytes=p,r.encode=E,r.decode=v;const s=e("./errors.js");function i(e){if(0===e[0])throw(0,s.EthereumJSErrorWithoutCode)("invalid RLP: extra zeros");return function(e){const t=Number.parseInt(e,16);if(Number.isNaN(t))throw(0,s.EthereumJSErrorWithoutCode)("Invalid byte sequence");return t}(l(e))}function a(e,t){if(e<56)return Uint8Array.from([e+t]);const r=b(e),n=b(t+55+r.length/2);return Uint8Array.from(p(n+r))}function c(e,t,r){if(r>e.length)throw(0,s.EthereumJSErrorWithoutCode)("invalid RLP (safeSlice): end slice of Uint8Array out-of-bounds");return e.slice(t,r)}function u(e){let t,r,n,o,a;const f=[],l=e[0];if(l<=127)return{data:e.slice(0,1),remainder:e.subarray(1)};if(l<=183){if(t=l-127,n=128===l?Uint8Array.from([]):c(e,1,t),2===t&&n[0]<128)throw(0,s.EthereumJSErrorWithoutCode)("invalid RLP encoding: invalid prefix, single byte < 0x80 are not prefixed");return{data:n,remainder:e.subarray(t)}}if(l<=191){if(r=l-182,e.length-1<r)throw(0,s.EthereumJSErrorWithoutCode)("invalid RLP: not enough bytes for string length");if(t=i(c(e,1,r)),t<=55)throw(0,s.EthereumJSErrorWithoutCode)("invalid RLP: expected string length to be greater than 55");return n=c(e,r,t+r),{data:n,remainder:e.subarray(t+r)}}if(l<=247){for(t=l-191,o=c(e,1,t);o.length;)a=u(o),f.push(a.data),o=a.remainder;return{data:f,remainder:e.subarray(t)}}{if(r=l-246,t=i(c(e,1,r)),t<56)throw(0,s.EthereumJSErrorWithoutCode)("invalid RLP: encoded list too short");const n=r+t;if(n>e.length)throw(0,s.EthereumJSErrorWithoutCode)("invalid RLP: total length is larger than the data");for(o=c(e,r,n);o.length;)a=u(o),f.push(a.data),o=a.remainder;return{data:f,remainder:e.subarray(n)}}}o(e("./errors.js"),r);const f=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function l(e){let t="";for(let r=0;r<e.length;r++)t+=f[e[r]];return t}const d={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function h(e){return e>=d._0&&e<=d._9?e-d._0:e>=d._A&&e<=d._F?e-(d._A-10):e>=d._a&&e<=d._f?e-(d._a-10):void 0}function p(e){if("0x"===e.slice(0,2)&&(e=e.slice(0,2)),"string"!=typeof e)throw(0,s.EthereumJSErrorWithoutCode)("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw(0,s.EthereumJSErrorWithoutCode)("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,o=0;t<r;t++,o+=2){const r=h(e.charCodeAt(o)),i=h(e.charCodeAt(o+1));if(r===undefined||i===undefined){const t=e[o]+e[o+1];throw(0,s.EthereumJSErrorWithoutCode)('hex string expected, got non-hex character "'+t+'" at index '+o)}n[t]=16*r+i}return n}function m(...e){if(1===e.length)return e[0];const t=e.reduce((e,t)=>e+t.length,0),r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.length}return r}function g(e){return(new TextEncoder).encode(e)}function b(e){if(e<0)throw(0,s.EthereumJSErrorWithoutCode)("Invalid integer as argument, must be unsigned!");const t=e.toString(16);return t.length%2?`0${t}`:t}function y(e){return e.length>=2&&"0"===e[0]&&"x"===e[1]}function w(e){if(e instanceof Uint8Array)return e;if("string"==typeof e)return y(e)?p((t="string"!=typeof(r=e)?r:y(r)?r.slice(2):r).length%2?`0${t}`:t):g(e);var t,r;if("number"==typeof e||"bigint"==typeof e)return e?p(b(e)):Uint8Array.from([]);if(null===e||e===undefined)return Uint8Array.from([]);throw(0,s.EthereumJSErrorWithoutCode)("toBytes: received unsupported type "+typeof e)}function E(e){if(Array.isArray(e)){const t=[];let r=0;for(let n=0;n<e.length;n++){const o=E(e[n]);t.push(o),r+=o.length}return m(a(r,192),...t)}const t=w(e);return 1===t.length&&t[0]<128?t:m(a(t.length,128),t)}function v(e,t=!1){if(null==e||0===e.length)return Uint8Array.from([]);const r=u(w(e));if(t)return{data:r.data,remainder:r.remainder.slice()};if(0!==r.remainder.length)throw(0,s.EthereumJSErrorWithoutCode)("invalid RLP: remainder must be zero");return r.data}r.utils={bytesToHex:l,concatBytes:m,hexToBytes:p,utf8ToBytes:g},r.RLP={encode:E,decode:v}}}},{package:"eth-lattice-keyring>gridplus-sdk>@ethereumjs/rlp",file:"node_modules/gridplus-sdk/node_modules/@ethereumjs/rlp/dist/cjs/index.js"}],[657,{"@metamask/utils":3935},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils");const o=r.version=205;r.migrate=async(e,t)=>{if(e.meta.version=o,!(0,n.hasProperty)(e.data,"GatorPermissionsController")||!(0,n.isObject)(e.data.GatorPermissionsController))return;const{GatorPermissionsController:r}=e.data,s=r;((0,n.hasProperty)(s,"grantedPermissions")||(0,n.hasProperty)(s,"gatorPermissionsMapSerialized")||(0,n.hasProperty)(s,"isGatorPermissionsEnabled")||(0,n.hasProperty)(s,"gatorPermissionsProviderSnapId"))&&(delete s.gatorPermissionsMapSerialized,delete s.isGatorPermissionsEnabled,delete s.gatorPermissionsProviderSnapId,Array.isArray(s.grantedPermissions)&&s.grantedPermissions.forEach(e=>{(0,n.isObject)(e)&&((0,n.hasProperty)(e,"status")||(e.status=(0,n.hasProperty)(e,"revocationMetadata")?"Revoked":"Active"))}),t.add("GatorPermissionsController"))}}}},{package:"$root$",file:"app/scripts/migrations/205.ts"}],[6570,{"./abstract/weierstrass.js":6579,"@noble/hashes/hmac":5206,"@noble/hashes/utils":5215},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getHash=i,r.createCurve=function(e,t){const r=t=>(0,s.weierstrass)({...e,...i(t)});return{...r(t),create:r}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/hmac"),o=e("@noble/hashes/utils"),s=e("./abstract/weierstrass.js");function i(e){return{hash:e,hmac:(t,...r)=>(0,n.hmac)(e,t,(0,o.concatBytes)(...r)),randomBytes:o.randomBytes}}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/_shortw_utils.js"}],[6571,{"./hash-to-curve.js":6574,"./modular.js":6575,"./utils.js":6578,"./weierstrass.js":6579},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.bls=function(e){const{Fp:t,Fr:r,Fp2:l,Fp6:d,Fp12:h}=e.fields,p=e.params.xNegative,m=e.params.twistType,g=(0,i.weierstrassPoints)({n:r.ORDER,...e.G1}),b=Object.assign(g,(0,n.createHasher)(g.ProjectivePoint,e.G1.mapToCurve,{...e.htfDefaults,...e.G1.htfDefaults})),y=(0,i.weierstrassPoints)({n:r.ORDER,...e.G2}),w=Object.assign(y,(0,n.createHasher)(y.ProjectivePoint,e.G2.mapToCurve,{...e.htfDefaults,...e.G2.htfDefaults}));let E;if("multiplicative"===m)E=(e,t,r,n,o,s)=>h.mul014(n,e,l.mul(t,o),l.mul(r,s));else{if("divisive"!==m)throw new Error("bls: unknown twist type");E=(e,t,r,n,o,s)=>h.mul034(n,l.mul(r,s),l.mul(t,o),e)}const v=l.div(l.ONE,l.mul(l.ONE,u));function x(e,t,r,n){const o=l.sqr(r),s=l.sqr(n),i=l.mulByB(l.mul(s,f)),a=l.mul(i,f),c=l.sub(l.sub(l.sqr(l.add(r,n)),s),o),u=l.sub(i,o),d=l.mul(l.sqr(t),f),h=l.neg(c);return e.push([u,d,h]),{Rx:t=l.mul(l.mul(l.mul(l.sub(o,a),t),r),v),Ry:r=l.sub(l.sqr(l.mul(l.add(o,a),v)),l.mul(l.sqr(i),f)),Rz:n=l.mul(o,c)}}function B(e,t,r,n,o,s){const i=l.sub(r,l.mul(s,n)),a=l.sub(t,l.mul(o,n)),c=l.sub(l.mul(i,o),l.mul(a,s)),f=l.neg(i),d=a;e.push([c,f,d]);const h=l.sqr(a),p=l.mul(h,a),m=l.mul(h,t),g=l.add(l.sub(p,l.mul(m,u)),l.mul(l.sqr(i),n));return{Rx:t=l.mul(a,g),Ry:r=l.sub(l.mul(l.sub(m,g),i),l.mul(p,r)),Rz:n=l.mul(n,p)}}const S=function(e){const t=[];for(;e>c;e>>=c)(e&c)===a?t.unshift(0):(e&f)===f?(t.unshift(-1),e+=c):t.unshift(1);return t}(e.params.ateLoopSize),P=(0,s.memoized)(t=>{const r=t,{x:n,y:o}=r.toAffine(),s=n,i=o,a=l.neg(o);let c=s,u=i,f=l.ONE;const d=[];for(const e of S){const t=[];({Rx:c,Ry:u,Rz:f}=x(t,c,u,f)),e&&({Rx:c,Ry:u,Rz:f}=B(t,c,u,f,s,-1===e?a:i)),d.push(t)}if(e.postPrecompute){const t=d[d.length-1];e.postPrecompute(c,u,f,s,i,B.bind(null,t))}return d});function I(e,t=!1){let r=h.ONE;if(e.length){const t=e[0][0].length;for(let n=0;n<t;n++){r=h.sqr(r);for(const[t,o,s]of e)for(const[e,i,a]of t[n])r=E(e,i,a,r,o,s)}}return p&&(r=h.conjugate(r)),t?h.finalExponentiate(r):r}function T(e,t=!0){const r=[];b.ProjectivePoint.normalizeZ(e.map(({g1:e})=>e)),w.ProjectivePoint.normalizeZ(e.map(({g2:e})=>e));for(const{g1:t,g2:n}of e){if(t.equals(b.ProjectivePoint.ZERO)||n.equals(w.ProjectivePoint.ZERO))throw new Error("pairing is not available for ZERO point");t.assertValidity(),n.assertValidity();const e=t.toAffine();r.push([P(n),e.x,e.y])}return I(r,t)}const A={randomPrivateKey:()=>{const t=(0,o.getMinHashLength)(r.ORDER);return(0,o.mapHashToField)(e.randomBytes(t),r.ORDER)},calcPairingPrecomputes:P},{ShortSignature:j}=e.G1,{Signature:_}=e.G2;function O(e){return e instanceof b.ProjectivePoint?e:b.ProjectivePoint.fromHex(e)}function k(e,t){return e instanceof b.ProjectivePoint?e:b.hashToCurve((0,s.ensureBytes)("point",e),t)}function N(e){return e instanceof w.ProjectivePoint?e:_.fromHex(e)}function R(e,t){return e instanceof w.ProjectivePoint?e:w.hashToCurve((0,s.ensureBytes)("point",e),t)}function C(e){if(!Array.isArray(e)||0===e.length)throw new Error("expected non-empty array")}return b.ProjectivePoint.BASE._setWindowSize(4),{getPublicKey:function(e){return b.ProjectivePoint.fromPrivateKey(e).toRawBytes(!0)},getPublicKeyForShortSignatures:function(e){return w.ProjectivePoint.fromPrivateKey(e).toRawBytes(!0)},sign:function(e,t,r){const n=R(e,r);n.assertValidity();const o=n.multiply(b.normPrivateKeyToScalar(t));return e instanceof w.ProjectivePoint?o:_.toRawBytes(o)},signShortSignature:function(e,t,r){const n=k(e,r);n.assertValidity();const o=n.multiply(b.normPrivateKeyToScalar(t));return e instanceof b.ProjectivePoint?o:j.toRawBytes(o)},verify:function(e,t,r,n){const o=O(r),s=R(t,n),i=b.ProjectivePoint.BASE,a=N(e),c=T([{g1:o.negate(),g2:s},{g1:i,g2:a}]);return h.eql(c,h.ONE)},verifyBatch:function(e,t,r,n){if(C(t),r.length!==t.length)throw new Error("amount of public keys and messages should be equal");const o=N(e),s=t.map(e=>R(e,n)),i=r.map(O),a=new Map;for(let e=0;e<i.length;e++){const t=i[e],r=s[e];let n=a.get(r);n===undefined&&(n=[],a.set(r,n)),n.push(t)}const c=[];try{for(const[e,t]of a){const r=t.reduce((e,t)=>e.add(t));c.push({g1:r,g2:e})}return c.push({g1:b.ProjectivePoint.BASE.negate(),g2:o}),h.eql(T(c),h.ONE)}catch{return!1}},verifyShortSignature:function(e,t,r,n){const o=N(r),s=k(t,n),i=w.ProjectivePoint.BASE,a=O(e),c=T([{g1:s,g2:o},{g1:a,g2:i.negate()}]);return h.eql(c,h.ONE)},aggregatePublicKeys:function(e){C(e);const t=e.map(O).reduce((e,t)=>e.add(t),b.ProjectivePoint.ZERO);if(e[0]instanceof b.ProjectivePoint)return t.assertValidity(),t;return t.toRawBytes(!0)},aggregateSignatures:function(e){C(e);const t=e.map(N).reduce((e,t)=>e.add(t),w.ProjectivePoint.ZERO);if(e[0]instanceof w.ProjectivePoint)return t.assertValidity(),t;return _.toRawBytes(t)},aggregateShortSignatures:function(e){C(e);const t=e.map(O).reduce((e,t)=>e.add(t),b.ProjectivePoint.ZERO);if(e[0]instanceof b.ProjectivePoint)return t.assertValidity(),t;return j.toRawBytes(t)},millerLoopBatch:I,pairing:function(e,t,r=!0){return T([{g1:e,g2:t}],r)},pairingBatch:T,G1:b,G2:w,Signature:_,ShortSignature:j,fields:{Fr:r,Fp:t,Fp2:l,Fp6:d,Fp12:h},params:{ateLoopSize:e.params.ateLoopSize,r:e.params.r,G1b:e.G1.b,G2b:e.G2.b},utils:A}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./hash-to-curve.js"),o=e("./modular.js"),s=e("./utils.js"),i=e("./weierstrass.js"),a=BigInt(0),c=BigInt(1),u=BigInt(2),f=BigInt(3)}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/bls.js"}],[6572,{"./modular.js":6575,"./utils.js":6578},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.wNAF=function(e,t){return{constTimeNegate:a,hasPrecomputes:e=>1!==m(e),unsafeLadder(t,r,n=e.ZERO){let o=t;for(;r>s;)r&i&&(n=n.add(o)),o=o.double(),r>>=i;return n},precomputeWindow(e,r){const{windows:n,windowSize:o}=u(r,t),s=[];let i=e,a=i;for(let e=0;e<n;e++){a=i,s.push(a);for(let e=1;e<o;e++)a=a.add(i),s.push(a);i=a.double()}return s},wNAF(r,n,o){let s=e.ZERO,i=e.BASE;const c=u(r,t);for(let e=0;e<c.windows;e++){const{nextN:t,offset:r,isZero:u,isNeg:l,isNegF:d,offsetF:h}=f(o,e,c);o=t,u?i=i.add(a(d,n[h])):s=s.add(a(l,n[r]))}return{p:s,f:i}},wNAFUnsafe(r,n,o,i=e.ZERO){const a=u(r,t);for(let e=0;e<a.windows&&o!==s;e++){const{nextN:t,offset:r,isZero:s,isNeg:c}=f(o,e,a);if(o=t,!s){const e=n[r];i=i.add(c?e.negate():e)}}return i},getPrecomputes(e,t,r){let n=h.get(t);return n||(n=this.precomputeWindow(t,e),1!==e&&h.set(t,r(n))),n},wNAFCached(e,t,r){const n=m(e);return this.wNAF(n,this.getPrecomputes(n,e,r),t)},wNAFCachedUnsafe(e,t,r,n){const o=m(e);return 1===o?this.unsafeLadder(e,t,n):this.wNAFUnsafe(o,this.getPrecomputes(o,e,r),t,n)},setWindowSize(e,r){c(r,t),p.set(e,r),h.delete(e)}}},r.pippenger=function(e,t,r,n){l(r,e),d(n,t);const s=r.length,i=n.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const a=e.ZERO,c=(0,o.bitLen)(BigInt(s));let u=1;c>12?u=c-3:c>4?u=c-2:c>0&&(u=2);const f=(0,o.bitMask)(u),h=new Array(Number(f)+1).fill(a),p=Math.floor((t.BITS-1)/u)*u;let m=a;for(let e=p;e>=0;e-=u){h.fill(a);for(let t=0;t<i;t++){const o=n[t],s=Number(o>>BigInt(e)&f);h[s]=h[s].add(r[t])}let t=a;for(let e=h.length-1,r=a;e>0;e--)r=r.add(h[e]),t=t.add(r);if(m=m.add(t),0!==e)for(let e=0;e<u;e++)m=m.double()}return m},r.precomputeMSMUnsafe=function(e,t,r,n){c(n,t.BITS),l(r,e);const s=e.ZERO,i=2**n-1,a=Math.ceil(t.BITS/n),u=(0,o.bitMask)(n),f=r.map(e=>{const t=[];for(let r=0,n=e;r<i;r++)t.push(n),n=n.add(e);return t});return e=>{if(d(e,t),e.length>r.length)throw new Error("array of scalars must be smaller than array of points");let o=s;for(let t=0;t<a;t++){if(o!==s)for(let e=0;e<n;e++)o=o.double();const r=BigInt(a*n-(t+1)*n);for(let t=0;t<e.length;t++){const n=e[t],s=Number(n>>r&u);s&&(o=o.add(f[t][s-1]))}}return o}},r.validateBasic=function(e){return(0,n.validateField)(e.Fp),(0,o.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,n.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./modular.js"),o=e("./utils.js"),s=BigInt(0),i=BigInt(1);function a(e,t){const r=t.negate();return e?r:t}function c(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function u(e,t){c(e,t);const r=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:(0,o.bitMask)(e),maxNumber:r,shiftBy:BigInt(e)}}function f(e,t,r){const{windowSize:n,mask:o,maxNumber:s,shiftBy:a}=r;let c=Number(e&o),u=e>>a;c>n&&(c-=s,u+=i);const f=t*n;return{nextN:u,offset:f+Math.abs(c)-1,isZero:0===c,isNeg:c<0,isNegF:t%2!=0,offsetF:f}}function l(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((e,r)=>{if(!(e instanceof t))throw new Error("invalid point at index "+r)})}function d(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((e,r)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+r)})}const h=new WeakMap,p=new WeakMap;function m(e){return p.get(e)||1}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/curve.js"}],[6573,{"./curve.js":6572,"./modular.js":6575,"./utils.js":6578},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.twistedEdwards=function(e){const t=function(e){const t=(0,n.validateBasic)(e);return(0,s.validateObject)(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:r,n:l,prehash:d,hash:h,randomBytes:p,nByteLength:m,h:g}=t,b=c<<BigInt(8*m)-a,y=r.create,w=(0,o.Field)(t.n,t.nBitLength);if(!function(e,n){const o=r.sqr(e),s=r.sqr(n),i=r.add(r.mul(t.a,o),s),a=r.add(r.ONE,r.mul(t.d,r.mul(o,s)));return r.eql(i,a)}(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const E=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:r.sqrt(e*r.inv(t))}}catch(e){return{isValid:!1,value:i}}}),v=t.adjustScalarBytes||(e=>e),x=t.domain||((e,t,r)=>{if((0,s.abool)("phflag",r),t.length||r)throw new Error("Contexts/pre-hash are not supported");return e});function B(e,t,r=!1){const n=r?a:i;(0,s.aInRange)("coordinate "+e,t,n,b)}function S(e){if(!(e instanceof T))throw new Error("ExtendedPoint expected")}const P=(0,s.memoized)((e,t)=>{const{ex:n,ey:o,ez:s}=e,c=e.is0();null==t&&(t=c?u:r.inv(s));const f=y(n*t),l=y(o*t),d=y(s*t);if(c)return{x:i,y:a};if(d!==a)throw new Error("invZ was invalid");return{x:f,y:l}}),I=(0,s.memoized)(e=>{const{a:r,d:n}=t;if(e.is0())throw new Error("bad point: ZERO");const{ex:o,ey:s,ez:i,et:a}=e,c=y(o*o),u=y(s*s),f=y(i*i),l=y(f*f),d=y(c*r);if(y(f*y(d+u))!==y(l+y(n*y(c*u))))throw new Error("bad point: equation left != right (1)");if(y(o*s)!==y(i*a))throw new Error("bad point: equation left != right (2)");return!0});class T{constructor(e,t,r,n){B("x",e),B("y",t),B("z",r,!0),B("t",n),this.ex=e,this.ey=t,this.ez=r,this.et=n,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof T)throw new Error("extended point not allowed");const{x:t,y:r}=e||{};return B("x",t),B("y",r),new T(t,r,a,y(t*r))}static normalizeZ(e){const t=(0,o.FpInvertBatch)(r,e.map(e=>e.ez));return e.map((e,r)=>e.toAffine(t[r])).map(T.fromAffine)}static msm(e,t){return(0,n.pippenger)(T,w,e,t)}_setWindowSize(e){_.setWindowSize(this,e)}assertValidity(){I(this)}equals(e){S(e);const{ex:t,ey:r,ez:n}=this,{ex:o,ey:s,ez:i}=e,a=y(t*i),c=y(o*n),u=y(r*i),f=y(s*n);return a===c&&u===f}is0(){return this.equals(T.ZERO)}negate(){return new T(y(-this.ex),this.ey,this.ez,y(-this.et))}double(){const{a:e}=t,{ex:r,ey:n,ez:o}=this,s=y(r*r),i=y(n*n),a=y(c*y(o*o)),u=y(e*s),f=r+n,l=y(y(f*f)-s-i),d=u+i,h=d-a,p=u-i,m=y(l*h),g=y(d*p),b=y(l*p),w=y(h*d);return new T(m,g,w,b)}add(e){S(e);const{a:r,d:n}=t,{ex:o,ey:s,ez:i,et:a}=this,{ex:c,ey:u,ez:f,et:l}=e,d=y(o*c),h=y(s*u),p=y(a*n*l),m=y(i*f),g=y((o+s)*(c+u)-d-h),b=m-p,w=m+p,E=y(h-r*d),v=y(g*b),x=y(w*E),B=y(g*E),P=y(b*w);return new T(v,x,P,B)}subtract(e){return this.add(e.negate())}wNAF(e){return _.wNAFCached(this,e,T.normalizeZ)}multiply(e){const t=e;(0,s.aInRange)("scalar",t,a,l);const{p:r,f:n}=this.wNAF(t);return T.normalizeZ([r,n])[0]}multiplyUnsafe(e,t=T.ZERO){const r=e;return(0,s.aInRange)("scalar",r,i,l),r===i?j:this.is0()||r===a?this:_.wNAFCachedUnsafe(this,r,T.normalizeZ,t)}isSmallOrder(){return this.multiplyUnsafe(g).is0()}isTorsionFree(){return _.unsafeLadder(this,l).is0()}toAffine(e){return P(this,e)}clearCofactor(){const{h:e}=t;return e===a?this:this.multiplyUnsafe(e)}static fromHex(e,n=!1){const{d:o,a:c}=t,u=r.BYTES;e=(0,s.ensureBytes)("pointHex",e,u),(0,s.abool)("zip215",n);const f=e.slice(),l=e[u-1];f[u-1]=-129&l;const d=(0,s.bytesToNumberLE)(f),h=n?b:r.ORDER;(0,s.aInRange)("pointHex.y",d,i,h);const p=y(d*d),m=y(p-a),g=y(o*p-c);let{isValid:w,value:v}=E(m,g);if(!w)throw new Error("Point.fromHex: invalid y coordinate");const x=(v&a)===a,B=!!(128&l);if(!n&&v===i&&B)throw new Error("Point.fromHex: x=0 and x_0=1");return B!==x&&(v=y(-v)),T.fromAffine({x:v,y:d})}static fromPrivateKey(e){const{scalar:t}=N(e);return A.multiply(t)}toRawBytes(){const{x:e,y:t}=this.toAffine(),n=(0,s.numberToBytesLE)(t,r.BYTES);return n[n.length-1]|=e&a?128:0,n}toHex(){return(0,s.bytesToHex)(this.toRawBytes())}}T.BASE=new T(t.Gx,t.Gy,a,y(t.Gx*t.Gy)),T.ZERO=new T(i,a,a,i);const{BASE:A,ZERO:j}=T,_=(0,n.wNAF)(T,8*m);function O(e){return(0,o.mod)(e,l)}function k(e){return O((0,s.bytesToNumberLE)(e))}function N(e){const t=r.BYTES;e=(0,s.ensureBytes)("private key",e,t);const n=(0,s.ensureBytes)("hashed private key",h(e),2*t),o=v(n.slice(0,t));return{head:o,prefix:n.slice(t,2*t),scalar:k(o)}}function R(e){const{head:t,prefix:r,scalar:n}=N(e),o=A.multiply(n),s=o.toRawBytes();return{head:t,prefix:r,scalar:n,point:o,pointBytes:s}}function C(e=Uint8Array.of(),...t){const r=(0,s.concatBytes)(...t);return k(h(x(r,(0,s.ensureBytes)("context",e),!!d)))}const U=f;A._setWindowSize(8);return{CURVE:t,getPublicKey:function(e){return R(e).pointBytes},sign:function(e,t,n={}){e=(0,s.ensureBytes)("message",e),d&&(e=d(e));const{prefix:o,scalar:a,pointBytes:c}=R(t),u=C(n.context,o,e),f=A.multiply(u).toRawBytes(),h=O(u+C(n.context,f,c,e)*a);(0,s.aInRange)("signature.s",h,i,l);const p=(0,s.concatBytes)(f,(0,s.numberToBytesLE)(h,r.BYTES));return(0,s.ensureBytes)("result",p,2*r.BYTES)},verify:function(e,t,n,o=U){const{context:i,zip215:a}=o,c=r.BYTES;e=(0,s.ensureBytes)("signature",e,2*c),t=(0,s.ensureBytes)("message",t),n=(0,s.ensureBytes)("publicKey",n,c),a!==undefined&&(0,s.abool)("zip215",a),d&&(t=d(t));const u=(0,s.bytesToNumberLE)(e.slice(c,2*c));let f,l,h;try{f=T.fromHex(n,a),l=T.fromHex(e.slice(0,c),a),h=A.multiplyUnsafe(u)}catch(e){return!1}if(!a&&f.isSmallOrder())return!1;const p=C(i,l.toRawBytes(),f.toRawBytes(),t);return l.add(f.multiplyUnsafe(p)).subtract(h).clearCofactor().equals(T.ZERO)},ExtendedPoint:T,utils:{getExtendedPublicKey:R,randomPrivateKey:()=>p(r.BYTES),precompute:(e=8,t=T.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)}}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./curve.js"),o=e("./modular.js"),s=e("./utils.js"),i=BigInt(0),a=BigInt(1),c=BigInt(2),u=BigInt(8),f={zip215:!0}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/edwards.js"}],[6574,{"./modular.js":6575,"./utils.js":6578},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.expand_message_xmd=u,r.expand_message_xof=f,r.hash_to_field=l,r.isogenyMap=function(e,t){const r=t.map(e=>Array.from(e).reverse());return(t,o)=>{const[s,i,a,c]=r.map(r=>r.reduce((r,n)=>e.add(e.mul(r,t),n))),[u,f]=(0,n.FpInvertBatch)(e,[i,c],!0);return t=e.mul(s,u),o=e.mul(o,e.mul(a,f)),{x:t,y:o}}},r.createHasher=function(e,t,r){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");function n(r){return e.fromAffine(t(r))}function o(t){const r=t.clearCofactor();return r.equals(e.ZERO)?e.ZERO:(r.assertValidity(),r)}return{defaults:r,hashToCurve(e,t){const s=l(e,2,{...r,DST:r.DST,...t}),i=n(s[0]),a=n(s[1]);return o(i.add(a))},encodeToCurve:(e,t)=>o(n(l(e,1,{...r,DST:r.encodeDST,...t})[0])),mapToCurve(e){if(!Array.isArray(e))throw new Error("expected array of bigints");for(const t of e)if("bigint"!=typeof t)throw new Error("expected array of bigints");return o(n(e))}}};const n=e("./modular.js"),o=e("./utils.js"),s=o.bytesToNumberBE;function i(e,t){if(c(e),c(t),e<0||e>=1<<8*t)throw new Error("invalid I2OSP input: "+e);const r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=255&e,e>>>=8;return new Uint8Array(r)}function a(e,t){const r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e[n]^t[n];return r}function c(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function u(e,t,r,n){(0,o.abytes)(e),(0,o.abytes)(t),c(r),t.length>255&&(t=n((0,o.concatBytes)((0,o.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:s,blockLen:u}=n,f=Math.ceil(r/s);if(r>65535||f>255)throw new Error("expand_message_xmd: invalid lenInBytes");const l=(0,o.concatBytes)(t,i(t.length,1)),d=i(0,u),h=i(r,2),p=new Array(f),m=n((0,o.concatBytes)(d,e,h,i(0,1),l));p[0]=n((0,o.concatBytes)(m,i(1,1),l));for(let e=1;e<=f;e++){const t=[a(m,p[e-1]),i(e+1,1),l];p[e]=n((0,o.concatBytes)(...t))}return(0,o.concatBytes)(...p).slice(0,r)}function f(e,t,r,n,s){if((0,o.abytes)(e),(0,o.abytes)(t),c(r),t.length>255){const e=Math.ceil(2*n/8);t=s.create({dkLen:e}).update((0,o.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return s.create({dkLen:r}).update(e).update(i(r,2)).update(t).update(i(t.length,1)).digest()}function l(e,t,r){(0,o.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:i,k:a,m:l,hash:d,expand:h,DST:p}=r;(0,o.abytes)(e),c(t);const m="string"==typeof p?(0,o.utf8ToBytes)(p):p,g=i.toString(2).length,b=Math.ceil((g+a)/8),y=t*l*b;let w;if("xmd"===h)w=u(e,m,y,d);else if("xof"===h)w=f(e,m,y,a,d);else{if("_internal_pass"!==h)throw new Error('expand must be "xmd" or "xof"');w=e}const E=new Array(t);for(let e=0;e<t;e++){const t=new Array(l);for(let r=0;r<l;r++){const o=b*(r+e*l),a=w.subarray(o,o+b);t[r]=(0,n.mod)(s(a),i)}E[e]=t}return E}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/hash-to-curve.js"}],[6575,{"./utils.js":6578,"@noble/hashes/utils":5215},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.isNegativeLE=void 0,r.mod=d,r.pow=function(e,t,r){return w(B(r),e,t)},r.pow2=function(e,t,r){let n=e;for(;t-- >s;)n*=n,n%=r;return n},r.invert=h,r.tonelliShanks=g,r.FpSqrt=b,r.validateField=function(e){const t=y.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,o.validateObject)(e,t)},r.FpPow=w,r.FpInvertBatch=E,r.FpDiv=function(e,t,r){return e.mul(t,"bigint"==typeof r?h(r,e.ORDER):e.inv(r))},r.FpLegendre=v,r.FpIsSquare=function(e,t){return 1===v(e,t)},r.nLength=x,r.Field=B,r.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);return e.isOdd(r)?r:e.neg(r)},r.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);return e.isOdd(r)?e.neg(r):r},r.hashToPrivateScalar=function(e,t,r=!1){const n=(e=(0,o.ensureBytes)("privateHash",e)).length,s=x(t).nByteLength+8;if(s<24||n<s||n>1024)throw new Error("hashToPrivateScalar: expected "+s+"-1024 bytes of input, got "+n);return d(r?(0,o.bytesToNumberLE)(e):(0,o.bytesToNumberBE)(e),t-i)+i},r.getFieldBytesLength=S,r.getMinHashLength=P,r.mapHashToField=function(e,t,r=!1){const n=e.length,s=S(t),a=P(t);if(n<16||n<a||n>1024)throw new Error("expected "+a+"-1024 bytes of input, got "+n);const c=d(r?(0,o.bytesToNumberLE)(e):(0,o.bytesToNumberBE)(e),t-i)+i;return r?(0,o.numberToBytesLE)(c,s):(0,o.numberToBytesBE)(c,s)};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/utils"),o=e("./utils.js"),s=BigInt(0),i=BigInt(1),a=BigInt(2),c=BigInt(3),u=BigInt(4),f=BigInt(5),l=BigInt(8);function d(e,t){const r=e%t;return r>=s?r:t+r}function h(e,t){if(e===s)throw new Error("invert: expected non-zero number");if(t<=s)throw new Error("invert: expected positive modulus, got "+t);let r=d(e,t),n=t,o=s,a=i,c=i,u=s;for(;r!==s;){const e=n/r,t=n%r,s=o-c*e,i=a-u*e;n=r,r=t,o=c,a=u,c=s,u=i}if(n!==i)throw new Error("invert: does not exist");return d(o,t)}function p(e,t){const r=(e.ORDER+i)/u,n=e.pow(t,r);if(!e.eql(e.sqr(n),t))throw new Error("Cannot find square root");return n}function m(e,t){const r=(e.ORDER-f)/l,n=e.mul(t,a),o=e.pow(n,r),s=e.mul(t,o),i=e.mul(e.mul(s,a),o),c=e.mul(s,e.sub(i,e.ONE));if(!e.eql(e.sqr(c),t))throw new Error("Cannot find square root");return c}function g(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-i,r=0;for(;t%a===s;)t/=a,r++;let n=a;const o=B(e);for(;1===v(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===r)return p;let c=o.pow(n,t);const u=(t+i)/a;return function(e,n){if(e.is0(n))return n;if(1!==v(e,n))throw new Error("Cannot find square root");let o=r,s=e.mul(e.ONE,c),a=e.pow(n,t),f=e.pow(n,u);for(;!e.eql(a,e.ONE);){if(e.is0(a))return e.ZERO;let t=1,r=e.sqr(a);for(;!e.eql(r,e.ONE);)if(t++,r=e.sqr(r),t===o)throw new Error("Cannot find square root");const n=i<<BigInt(o-t-1),c=e.pow(s,n);o=t,s=e.sqr(c),a=e.mul(a,s),f=e.mul(f,c)}return f}}function b(e){return e%u===c?p:e%l===f?m:g(e)}r.isNegativeLE=(e,t)=>(d(e,t)&i)===i;const y=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function w(e,t,r){if(r<s)throw new Error("invalid exponent, negatives unsupported");if(r===s)return e.ONE;if(r===i)return t;let n=e.ONE,o=t;for(;r>s;)r&i&&(n=e.mul(n,o)),o=e.sqr(o),r>>=i;return n}function E(e,t,r=!1){const n=new Array(t.length).fill(r?e.ZERO:undefined),o=t.reduce((t,r,o)=>e.is0(r)?t:(n[o]=t,e.mul(t,r)),e.ONE),s=e.inv(o);return t.reduceRight((t,r,o)=>e.is0(r)?t:(n[o]=e.mul(t,n[o]),e.mul(t,r)),s),n}function v(e,t){const r=(e.ORDER-i)/a,n=e.pow(t,r),o=e.eql(n,e.ONE),s=e.eql(n,e.ZERO),c=e.eql(n,e.neg(e.ONE));if(!o&&!s&&!c)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function x(e,t){t!==undefined&&(0,n.anumber)(t);const r=t!==undefined?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function B(e,t,r=!1,n={}){if(e<=s)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:a,nByteLength:c}=x(e,t);if(c>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let u;const f=Object.freeze({ORDER:e,isLE:r,BITS:a,BYTES:c,MASK:(0,o.bitMask)(a),ZERO:s,ONE:i,create:t=>d(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return s<=t&&t<e},is0:e=>e===s,isOdd:e=>(e&i)===i,neg:t=>d(-t,e),eql:(e,t)=>e===t,sqr:t=>d(t*t,e),add:(t,r)=>d(t+r,e),sub:(t,r)=>d(t-r,e),mul:(t,r)=>d(t*r,e),pow:(e,t)=>w(f,e,t),div:(t,r)=>d(t*h(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>h(t,e),sqrt:n.sqrt||(t=>(u||(u=b(e)),u(f,t))),toBytes:e=>r?(0,o.numberToBytesLE)(e,c):(0,o.numberToBytesBE)(e,c),fromBytes:e=>{if(e.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+e.length);return r?(0,o.bytesToNumberLE)(e):(0,o.bytesToNumberBE)(e)},invertBatch:e=>E(f,e),cmov:(e,t,r)=>r?t:e});return Object.freeze(f)}function S(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function P(e){const t=S(e);return t+Math.ceil(t/2)}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/modular.js"}],[6576,{"./modular.js":6575,"./utils.js":6578},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.montgomery=function(e){const t=(d=e,(0,o.validateObject)(d,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...d})),{P:r,type:c,adjustScalarBytes:u,powPminus2:f}=t,l="x25519"===c;var d;if(!l&&"x448"!==c)throw new Error("invalid type");const h=l?255:448,p=l?32:56,m=l?BigInt(9):BigInt(5),g=l?BigInt(121665):BigInt(39081),b=l?a**BigInt(254):a**BigInt(447),y=l?BigInt(8)*a**BigInt(251)-i:BigInt(4)*a**BigInt(445)-i,w=b+y+i,E=e=>(0,n.mod)(e,r),v=x(m);function x(e){return(0,o.numberToBytesLE)(E(e),p)}function B(e,t){const n=function(e,t){(0,o.aInRange)("u",e,s,r),(0,o.aInRange)("scalar",t,b,w);const n=t,a=e;let c=i,u=s,l=e,d=i,p=s;for(let e=BigInt(h-1);e>=s;e--){const t=n>>e&i;p^=t,({x_2:c,x_3:l}=P(p,c,l)),({x_2:u,x_3:d}=P(p,u,d)),p=t;const r=c+u,o=E(r*r),s=c-u,f=E(s*s),h=o-f,m=l+d,b=E((l-d)*r),y=E(m*s),w=b+y,v=b-y;l=E(w*w),d=E(a*E(v*v)),c=E(o*f),u=E(h*(o+E(g*h)))}({x_2:c,x_3:l}=P(p,c,l)),({x_2:u,x_3:d}=P(p,u,d));const m=f(u);return E(c*m)}(function(e){const t=(0,o.ensureBytes)("u coordinate",e,p);return l&&(t[31]&=127),E((0,o.bytesToNumberLE)(t))}(t),function(e){return(0,o.bytesToNumberLE)(u((0,o.ensureBytes)("scalar",e,p)))}(e));if(n===s)throw new Error("invalid private or public key received");return x(n)}function S(e){return B(e,v)}function P(e,t,r){const n=E(e*(t-r));return{x_2:t=E(t-n),x_3:r=E(r+n)}}return{scalarMult:B,scalarMultBase:S,getSharedSecret:(e,t)=>B(e,t),getPublicKey:e=>S(e),utils:{randomPrivateKey:()=>t.randomBytes(p)},GuBytes:v.slice()}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./modular.js"),o=e("./utils.js"),s=BigInt(0),i=BigInt(1),a=BigInt(2)}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/montgomery.js"}],[6577,{"./modular.js":6575,"./utils.js":6578},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.psiFrobenius=function(e,t,r){const n=t.pow(r,(e.ORDER-i)/c),o=t.pow(r,(e.ORDER-i)/a);function s(e,r){return[t.mul(t.frobeniusMap(e,1),n),t.mul(t.frobeniusMap(r,1),o)]}const u=t.pow(r,(e.ORDER**a-i)/c),f=t.pow(r,(e.ORDER**a-i)/a);if(!t.eql(f,t.neg(t.ONE)))throw new Error("psiFrobenius: PSI2_Y!==-1");function l(e,r){return[t.mul(e,u),t.neg(r)]}const d=e=>(t,r)=>{const n=r.toAffine(),o=e(n.x,n.y);return t.fromAffine({x:o[0],y:o[1]})},h=d(s),p=d(l);return{psi:s,psi2:l,G2psi:h,G2psi2:p,PSI_X:n,PSI_Y:o,PSI2_X:u,PSI2_Y:f}},r.tower12=function(e){const{ORDER:t}=e,r=n.Field(t),c=r.create(e.NONRESIDUE||BigInt(-1)),f=r.div(r.ONE,a),l=u(r,c,r.ORDER,2)[0],d=({c0:e,c1:t},{c0:n,c1:o})=>({c0:r.add(e,n),c1:r.add(t,o)}),h=({c0:e,c1:t},{c0:n,c1:o})=>({c0:r.sub(e,n),c1:r.sub(t,o)}),p=({c0:e,c1:t},n)=>{if("bigint"==typeof n)return{c0:r.mul(e,n),c1:r.mul(t,n)};const{c0:o,c1:s}=n;let i=r.mul(e,o),a=r.mul(t,s);return{c0:r.sub(i,a),c1:r.sub(r.mul(r.add(e,t),r.add(o,s)),r.add(i,a))}},m=({c0:e,c1:t})=>{const n=r.add(e,t),o=r.sub(e,t),s=r.add(e,e);return{c0:r.mul(n,o),c1:r.mul(s,t)}},g=e=>{if(2!==e.length)throw new Error("invalid tuple");const t=e.map(e=>r.create(e));return{c0:t[0],c1:t[1]}},b=t*t,y=g(e.FP2_NONRESIDUE),w={ORDER:b,isLE:r.isLE,NONRESIDUE:y,BITS:(0,o.bitLen)(b),BYTES:Math.ceil((0,o.bitLen)(b)/8),MASK:(0,o.bitMask)((0,o.bitLen)(b)),ZERO:{c0:r.ZERO,c1:r.ZERO},ONE:{c0:r.ONE,c1:r.ZERO},create:e=>e,isValid:({c0:e,c1:t})=>"bigint"==typeof e&&"bigint"==typeof t,is0:({c0:e,c1:t})=>r.is0(e)&&r.is0(t),eql:({c0:e,c1:t},{c0:n,c1:o})=>r.eql(e,n)&&r.eql(t,o),neg:({c0:e,c1:t})=>({c0:r.neg(e),c1:r.neg(t)}),pow:(e,t)=>n.FpPow(w,e,t),invertBatch:e=>n.FpInvertBatch(w,e),add:d,sub:h,mul:p,sqr:m,addN:d,subN:h,mulN:p,sqrN:m,div:(e,t)=>w.mul(e,"bigint"==typeof t?r.inv(r.create(t)):w.inv(t)),inv:({c0:e,c1:t})=>{const n=r.inv(r.create(e*e+t*t));return{c0:r.mul(n,r.create(e)),c1:r.mul(n,r.create(-t))}},sqrt:t=>{if(e.Fp2sqrt)return e.Fp2sqrt(t);const{c0:o,c1:s}=t;if(r.is0(s))return 1===n.FpLegendre(r,o)?w.create({c0:r.sqrt(o),c1:r.ZERO}):w.create({c0:r.ZERO,c1:r.sqrt(r.div(o,c))});const i=r.sqrt(r.sub(r.sqr(o),r.mul(r.sqr(s),c)));let a=r.mul(r.add(i,o),f);-1===n.FpLegendre(r,a)&&(a=r.sub(a,i));const u=r.sqrt(a),l=w.create({c0:u,c1:r.div(r.mul(s,f),u)});if(!w.eql(w.sqr(l),t))throw new Error("Cannot find square root");const d=l,h=w.neg(d),{re:p,im:m}=w.reim(d),{re:g,im:b}=w.reim(h);return m>b||m===b&&p>g?d:h},isOdd:e=>{const{re:t,im:r}=w.reim(e);return BigInt(t%a||t===s&&r%a)==i},fromBytes(e){if(e.length!==w.BYTES)throw new Error("fromBytes invalid length="+e.length);return{c0:r.fromBytes(e.subarray(0,r.BYTES)),c1:r.fromBytes(e.subarray(r.BYTES))}},toBytes:({c0:e,c1:t})=>(0,o.concatBytes)(r.toBytes(e),r.toBytes(t)),cmov:({c0:e,c1:t},{c0:n,c1:o},s)=>({c0:r.cmov(e,n,s),c1:r.cmov(t,o,s)}),reim:({c0:e,c1:t})=>({re:e,im:t}),mulByNonresidue:({c0:e,c1:t})=>w.mul({c0:e,c1:t},y),mulByB:e.Fp2mulByB,fromBigTuple:g,frobeniusMap:({c0:e,c1:t},n)=>({c0:e,c1:r.mul(t,l[n%2])})},E=({c0:e,c1:t,c2:r},{c0:n,c1:o,c2:s})=>({c0:w.add(e,n),c1:w.add(t,o),c2:w.add(r,s)}),v=({c0:e,c1:t,c2:r},{c0:n,c1:o,c2:s})=>({c0:w.sub(e,n),c1:w.sub(t,o),c2:w.sub(r,s)}),x=({c0:e,c1:t,c2:r},n)=>{if("bigint"==typeof n)return{c0:w.mul(e,n),c1:w.mul(t,n),c2:w.mul(r,n)};const{c0:o,c1:s,c2:i}=n,a=w.mul(e,o),c=w.mul(t,s),u=w.mul(r,i);return{c0:w.add(a,w.mulByNonresidue(w.sub(w.mul(w.add(t,r),w.add(s,i)),w.add(c,u)))),c1:w.add(w.sub(w.mul(w.add(e,t),w.add(o,s)),w.add(a,c)),w.mulByNonresidue(u)),c2:w.sub(w.add(c,w.mul(w.add(e,r),w.add(o,i))),w.add(a,u))}},B=({c0:e,c1:t,c2:r})=>{let n=w.sqr(e),o=w.mul(w.mul(e,t),a),s=w.mul(w.mul(t,r),a),i=w.sqr(r);return{c0:w.add(w.mulByNonresidue(s),n),c1:w.add(w.mulByNonresidue(i),o),c2:w.sub(w.sub(w.add(w.add(o,w.sqr(w.add(w.sub(e,t),r))),s),n),i)}},[S,P]=u(w,y,r.ORDER,6,2,3),I={ORDER:w.ORDER,isLE:w.isLE,BITS:3*w.BITS,BYTES:3*w.BYTES,MASK:(0,o.bitMask)(3*w.BITS),ZERO:{c0:w.ZERO,c1:w.ZERO,c2:w.ZERO},ONE:{c0:w.ONE,c1:w.ZERO,c2:w.ZERO},create:e=>e,isValid:({c0:e,c1:t,c2:r})=>w.isValid(e)&&w.isValid(t)&&w.isValid(r),is0:({c0:e,c1:t,c2:r})=>w.is0(e)&&w.is0(t)&&w.is0(r),neg:({c0:e,c1:t,c2:r})=>({c0:w.neg(e),c1:w.neg(t),c2:w.neg(r)}),eql:({c0:e,c1:t,c2:r},{c0:n,c1:o,c2:s})=>w.eql(e,n)&&w.eql(t,o)&&w.eql(r,s),sqrt:o.notImplemented,div:(e,t)=>I.mul(e,"bigint"==typeof t?r.inv(r.create(t)):I.inv(t)),pow:(e,t)=>n.FpPow(I,e,t),invertBatch:e=>n.FpInvertBatch(I,e),add:E,sub:v,mul:x,sqr:B,addN:E,subN:v,mulN:x,sqrN:B,inv:({c0:e,c1:t,c2:r})=>{let n=w.sub(w.sqr(e),w.mulByNonresidue(w.mul(r,t))),o=w.sub(w.mulByNonresidue(w.sqr(r)),w.mul(e,t)),s=w.sub(w.sqr(t),w.mul(e,r)),i=w.inv(w.add(w.mulByNonresidue(w.add(w.mul(r,o),w.mul(t,s))),w.mul(e,n)));return{c0:w.mul(i,n),c1:w.mul(i,o),c2:w.mul(i,s)}},fromBytes:e=>{if(e.length!==I.BYTES)throw new Error("fromBytes invalid length="+e.length);return{c0:w.fromBytes(e.subarray(0,w.BYTES)),c1:w.fromBytes(e.subarray(w.BYTES,2*w.BYTES)),c2:w.fromBytes(e.subarray(2*w.BYTES))}},toBytes:({c0:e,c1:t,c2:r})=>(0,o.concatBytes)(w.toBytes(e),w.toBytes(t),w.toBytes(r)),cmov:({c0:e,c1:t,c2:r},{c0:n,c1:o,c2:s},i)=>({c0:w.cmov(e,n,i),c1:w.cmov(t,o,i),c2:w.cmov(r,s,i)}),fromBigSix:e=>{if(!Array.isArray(e)||6!==e.length)throw new Error("invalid Fp6 usage");return{c0:w.fromBigTuple(e.slice(0,2)),c1:w.fromBigTuple(e.slice(2,4)),c2:w.fromBigTuple(e.slice(4,6))}},frobeniusMap:({c0:e,c1:t,c2:r},n)=>({c0:w.frobeniusMap(e,n),c1:w.mul(w.frobeniusMap(t,n),S[n%6]),c2:w.mul(w.frobeniusMap(r,n),P[n%6])}),mulByFp2:({c0:e,c1:t,c2:r},n)=>({c0:w.mul(e,n),c1:w.mul(t,n),c2:w.mul(r,n)}),mulByNonresidue:({c0:e,c1:t,c2:r})=>({c0:w.mulByNonresidue(r),c1:e,c2:t}),mul1:({c0:e,c1:t,c2:r},n)=>({c0:w.mulByNonresidue(w.mul(r,n)),c1:w.mul(e,n),c2:w.mul(t,n)}),mul01({c0:e,c1:t,c2:r},n,o){let s=w.mul(e,n),i=w.mul(t,o);return{c0:w.add(w.mulByNonresidue(w.sub(w.mul(w.add(t,r),o),i)),s),c1:w.sub(w.sub(w.mul(w.add(n,o),w.add(e,t)),s),i),c2:w.add(w.sub(w.mul(w.add(e,r),n),s),i)}}},T=u(w,y,r.ORDER,12,1,6)[0],A=({c0:e,c1:t},{c0:r,c1:n})=>({c0:I.add(e,r),c1:I.add(t,n)}),j=({c0:e,c1:t},{c0:r,c1:n})=>({c0:I.sub(e,r),c1:I.sub(t,n)}),_=({c0:e,c1:t},r)=>{if("bigint"==typeof r)return{c0:I.mul(e,r),c1:I.mul(t,r)};let{c0:n,c1:o}=r,s=I.mul(e,n),i=I.mul(t,o);return{c0:I.add(s,I.mulByNonresidue(i)),c1:I.sub(I.mul(I.add(e,t),I.add(n,o)),I.add(s,i))}},O=({c0:e,c1:t})=>{let r=I.mul(e,t);return{c0:I.sub(I.sub(I.mul(I.add(I.mulByNonresidue(t),e),I.add(e,t)),r),I.mulByNonresidue(r)),c1:I.add(r,r)}};const k={ORDER:w.ORDER,isLE:I.isLE,BITS:2*I.BITS,BYTES:2*I.BYTES,MASK:(0,o.bitMask)(2*I.BITS),ZERO:{c0:I.ZERO,c1:I.ZERO},ONE:{c0:I.ONE,c1:I.ZERO},create:e=>e,isValid:({c0:e,c1:t})=>I.isValid(e)&&I.isValid(t),is0:({c0:e,c1:t})=>I.is0(e)&&I.is0(t),neg:({c0:e,c1:t})=>({c0:I.neg(e),c1:I.neg(t)}),eql:({c0:e,c1:t},{c0:r,c1:n})=>I.eql(e,r)&&I.eql(t,n),sqrt:o.notImplemented,inv:({c0:e,c1:t})=>{let r=I.inv(I.sub(I.sqr(e),I.mulByNonresidue(I.sqr(t))));return{c0:I.mul(e,r),c1:I.neg(I.mul(t,r))}},div:(e,t)=>k.mul(e,"bigint"==typeof t?r.inv(r.create(t)):k.inv(t)),pow:(e,t)=>n.FpPow(k,e,t),invertBatch:e=>n.FpInvertBatch(k,e),add:A,sub:j,mul:_,sqr:O,addN:A,subN:j,mulN:_,sqrN:O,fromBytes:e=>{if(e.length!==k.BYTES)throw new Error("fromBytes invalid length="+e.length);return{c0:I.fromBytes(e.subarray(0,I.BYTES)),c1:I.fromBytes(e.subarray(I.BYTES))}},toBytes:({c0:e,c1:t})=>(0,o.concatBytes)(I.toBytes(e),I.toBytes(t)),cmov:({c0:e,c1:t},{c0:r,c1:n},o)=>({c0:I.cmov(e,r,o),c1:I.cmov(t,n,o)}),fromBigTwelve:e=>({c0:I.fromBigSix(e.slice(0,6)),c1:I.fromBigSix(e.slice(6,12))}),frobeniusMap(e,t){const{c0:r,c1:n,c2:o}=I.frobeniusMap(e.c1,t),s=T[t%12];return{c0:I.frobeniusMap(e.c0,t),c1:I.create({c0:w.mul(r,s),c1:w.mul(n,s),c2:w.mul(o,s)})}},mulByFp2:({c0:e,c1:t},r)=>({c0:I.mulByFp2(e,r),c1:I.mulByFp2(t,r)}),conjugate:({c0:e,c1:t})=>({c0:e,c1:I.neg(t)}),mul014:({c0:e,c1:t},r,n,o)=>{let s=I.mul01(e,r,n),i=I.mul1(t,o);return{c0:I.add(I.mulByNonresidue(i),s),c1:I.sub(I.sub(I.mul01(I.add(t,e),r,w.add(n,o)),s),i)}},mul034:({c0:e,c1:t},r,n,o)=>{const s=I.create({c0:w.mul(e.c0,r),c1:w.mul(e.c1,r),c2:w.mul(e.c2,r)}),i=I.mul01(t,n,o),a=I.mul01(I.add(e,t),w.add(r,n),o);return{c0:I.add(I.mulByNonresidue(i),s),c1:I.sub(a,I.add(s,i))}},_cyclotomicSquare:e.Fp12cyclotomicSquare,_cyclotomicExp:e.Fp12cyclotomicExp,finalExponentiate:e.Fp12finalExponentiate};return{Fp:r,Fp2:w,Fp6:I,Fp4Square:function(e,t){const r=w.sqr(e),n=w.sqr(t);return{first:w.add(w.mulByNonresidue(n),r),second:w.sub(w.sub(w.sqr(w.add(e,t)),r),n)}},Fp12:k}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./modular.js"),o=e("./utils.js"),s=BigInt(0),i=BigInt(1),a=BigInt(2),c=BigInt(3);function u(e,t,r,n,o=1,s){const a=BigInt(s===undefined?n:s),c=r**BigInt(n),u=[];for(let s=0;s<o;s++){const o=BigInt(s+1),f=[];for(let s=0,u=i;s<n;s++){const n=(o*u-o)/a%c;f.push(e.pow(t,n)),u*=r}u.push(f)}return u}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/tower.js"}],[6578,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
Object.defineProperty(r,"__esModule",{value:!0}),r.notImplemented=r.bitMask=void 0,r.isBytes=s,r.abytes=i,r.abool=function(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)},r.numberToHexUnpadded=a,r.hexToNumber=c,r.bytesToHex=l,r.hexToBytes=p,r.bytesToNumberBE=function(e){return c(l(e))},r.bytesToNumberLE=function(e){return i(e),c(l(Uint8Array.from(e).reverse()))},r.numberToBytesBE=m,r.numberToBytesLE=function(e,t){return m(e,t).reverse()},r.numberToVarBytesBE=function(e){return p(a(e))},r.ensureBytes=function(e,t,r){let n;if("string"==typeof t)try{n=p(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!s(t))throw new Error(e+" must be hex string or Uint8Array");n=Uint8Array.from(t)}const o=n.length;if("number"==typeof r&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n},r.concatBytes=g,r.equalBytes=function(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return 0===r},r.utf8ToBytes=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))},r.inRange=y,r.aInRange=function(e,t,r,n){if(!y(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)},r.bitLen=function(e){let t;for(t=0;e>n;e>>=o,t+=1);return t},r.bitGet=function(e,t){return e>>BigInt(t)&o},r.bitSet=function(e,t,r){return e|(r?o:n)<<BigInt(t)},r.createHmacDrbg=function(e,t,r){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=w(e),o=w(e),s=0;const i=()=>{n.fill(1),o.fill(0),s=0},a=(...e)=>r(o,n,...e),c=(e=w(0))=>{o=a(E([0]),e),n=a(),0!==e.length&&(o=a(E([1]),e),n=a())},u=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const r=[];for(;e<t;){n=a();const t=n.slice();r.push(t),e+=n.length}return g(...r)};return(e,t)=>{i(),c(e);let r=undefined;for(;!(r=t(u()));)c();return i(),r}},r.validateObject=function(e,t,r={}){const n=(t,r,n)=>{const o=v[r];if("function"!=typeof o)throw new Error("invalid validator function");const s=e[t];if(!(n&&s===undefined||o(s,e)))throw new Error("param "+String(t)+" is invalid. Expected "+r+", got "+s)};for(const[e,r]of Object.entries(t))n(e,r,!1);for(const[e,t]of Object.entries(r))n(e,t,!0);return e},r.memoized=function(e){const t=new WeakMap;return(r,...n)=>{const o=t.get(r);if(o!==undefined)return o;const s=e(r,...n);return t.set(r,s),s}};const n=BigInt(0),o=BigInt(1);function s(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function i(e){if(!s(e))throw new Error("Uint8Array expected")}function a(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function c(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?n:BigInt("0x"+e)}const u="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,f=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function l(e){if(i(e),u)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=f[e[r]];return t}const d={_0:48,_9:57,A:65,F:70,a:97,f:102};function h(e){return e>=d._0&&e<=d._9?e-d._0:e>=d.A&&e<=d.F?e-(d.A-10):e>=d.a&&e<=d.f?e-(d.a-10):void 0}function p(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(u)return Uint8Array.fromHex(e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,o=0;t<r;t++,o+=2){const r=h(e.charCodeAt(o)),s=h(e.charCodeAt(o+1));if(r===undefined||s===undefined){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}n[t]=16*r+s}return n}function m(e,t){return p(e.toString(16).padStart(2*t,"0"))}function g(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];i(n),t+=n.length}const r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const o=e[t];r.set(o,n),n+=o.length}return r}const b=e=>"bigint"==typeof e&&n<=e;function y(e,t,r){return b(e)&&b(t)&&b(r)&&t<=e&&e<r}r.bitMask=e=>(o<<BigInt(e))-o;const w=e=>new Uint8Array(e),E=e=>Uint8Array.from(e);const v={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||s(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};r.notImplemented=()=>{throw new Error("not implemented")}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/utils.js"}],[6579,{"./curve.js":6572,"./modular.js":6575,"./utils.js":6578},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.DER=r.DERErr=void 0,r.weierstrassPoints=p,r.weierstrass=function(e){const t=function(e){const t=(0,n.validateBasic)(e);return(0,s.validateObject)(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:a,n:l,nByteLength:d,nBitLength:h}=t,m=a.BYTES+1,g=2*a.BYTES+1;function b(e){return(0,o.mod)(e,l)}function y(e){return(0,o.invert)(e,l)}const{ProjectivePoint:w,normPrivateKeyToScalar:E,weierstrassEquation:v,isWithinCurveOrder:x}=p({...t,toBytes(e,t,r){const n=t.toAffine(),o=a.toBytes(n.x),i=s.concatBytes;return(0,s.abool)("isCompressed",r),r?i(Uint8Array.from([t.hasEvenY()?2:3]),o):i(Uint8Array.from([4]),o,a.toBytes(n.y))},fromBytes(e){const t=e.length,r=e[0],n=e.subarray(1);if(t!==m||2!==r&&3!==r){if(t===g&&4===r){return{x:a.fromBytes(n.subarray(0,a.BYTES)),y:a.fromBytes(n.subarray(a.BYTES,2*a.BYTES))}}throw new Error("invalid Point, expected length of "+m+", or uncompressed "+g+", got "+t)}{const e=(0,s.bytesToNumberBE)(n);if(!(0,s.inRange)(e,f,a.ORDER))throw new Error("Point is not on curve");const t=v(e);let o;try{o=a.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return!(1&~r)!==((o&f)===f)&&(o=a.neg(o)),{x:e,y:o}}}});function B(e){return e>l>>f}const S=(e,t,r)=>(0,s.bytesToNumberBE)(e.slice(t,r));class P{constructor(e,t,r){(0,s.aInRange)("r",e,f,l),(0,s.aInRange)("s",t,f,l),this.r=e,this.s=t,null!=r&&(this.recovery=r),Object.freeze(this)}static fromCompact(e){const t=d;return e=(0,s.ensureBytes)("compactSignature",e,2*t),new P(S(e,0,t),S(e,t,2*t))}static fromDER(e){const{r:t,s:n}=r.DER.toSig((0,s.ensureBytes)("DER",e));return new P(t,n)}assertValidity(){}addRecoveryBit(e){return new P(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:n,recovery:o}=this,i=j((0,s.ensureBytes)("msgHash",e));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const u=2===o||3===o?r+t.n:r;if(u>=a.ORDER)throw new Error("recovery id 2 or 3 invalid");const f=1&o?"03":"02",l=w.fromHex(f+c(u,a.BYTES)),d=y(u),h=b(-i*d),p=b(n*d),m=w.BASE.multiplyAndAddUnsafe(l,h,p);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return B(this.s)}normalizeS(){return this.hasHighS()?new P(this.r,b(-this.s),this.recovery):this}toDERRawBytes(){return(0,s.hexToBytes)(this.toDERHex())}toDERHex(){return r.DER.hexFromSig(this)}toCompactRawBytes(){return(0,s.hexToBytes)(this.toCompactHex())}toCompactHex(){const e=d;return c(this.r,e)+c(this.s,e)}}const I={isValidPrivateKey(e){try{return E(e),!0}catch(e){return!1}},normPrivateKeyToScalar:E,randomPrivateKey:()=>{const e=(0,o.getMinHashLength)(t.n);return(0,o.mapHashToField)(t.randomBytes(e),t.n)},precompute:(e=8,t=w.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function T(e){if("bigint"==typeof e)return!1;if(e instanceof w)return!0;const r=(0,s.ensureBytes)("key",e).length,n=a.BYTES,o=n+1,i=2*n+1;return t.allowedPrivateKeyLengths||d===o?undefined:r===o||r===i}const A=t.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=(0,s.bytesToNumberBE)(e),r=8*e.length-h;return r>0?t>>BigInt(r):t},j=t.bits2int_modN||function(e){return b(A(e))},_=(0,s.bitMask)(h);function O(e){return(0,s.aInRange)("num < 2^"+h,e,u,_),(0,s.numberToBytesBE)(e,d)}function k(e,r,n=N){if(["recovered","canonical"].some(e=>e in n))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:c}=t;let{lowS:l,prehash:d,extraEntropy:h}=n;null==l&&(l=!0),e=(0,s.ensureBytes)("msgHash",e),i(n),d&&(e=(0,s.ensureBytes)("prehashed msgHash",o(e)));const p=j(e),m=E(r),g=[O(m),O(p)];if(null!=h&&!1!==h){const e=!0===h?c(a.BYTES):h;g.push((0,s.ensureBytes)("extraEntropy",e))}const v=(0,s.concatBytes)(...g),S=p;return{seed:v,k2sig:function(e){const t=A(e);if(!x(t))return;const r=y(t),n=w.BASE.multiply(t).toAffine(),o=b(n.x);if(o===u)return;const s=b(r*b(S+o*m));if(s===u)return;let i=(n.x===o?0:2)|Number(n.y&f),a=s;return l&&B(s)&&(a=function(e){return B(e)?b(-e):e}(s),i^=1),new P(o,a,i)}}}const N={lowS:t.lowS,prehash:!1},R={lowS:t.lowS,prehash:!1};return w.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return w.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,r=!0){if(!0===T(e))throw new Error("first arg must be private key");if(!1===T(t))throw new Error("second arg must be public key");return w.fromHex(t).multiply(E(e)).toRawBytes(r)},sign:function(e,r,n=N){const{seed:o,k2sig:i}=k(e,r,n),a=t;return(0,s.createHmacDrbg)(a.hash.outputLen,a.nByteLength,a.hmac)(o,i)},verify:function(e,n,o,a=R){const c=e;n=(0,s.ensureBytes)("msgHash",n),o=(0,s.ensureBytes)("publicKey",o);const{lowS:u,prehash:f,format:l}=a;if(i(a),"strict"in a)throw new Error("options.strict was renamed to lowS");if(l!==undefined&&"compact"!==l&&"der"!==l)throw new Error("format must be compact or der");const d="string"==typeof c||(0,s.isBytes)(c),h=!d&&!l&&"object"==typeof c&&null!==c&&"bigint"==typeof c.r&&"bigint"==typeof c.s;if(!d&&!h)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let p,m=undefined;try{if(h&&(m=new P(c.r,c.s)),d){try{"compact"!==l&&(m=P.fromDER(c))}catch(e){if(!(e instanceof r.DER.Err))throw e}m||"der"===l||(m=P.fromCompact(c))}p=w.fromHex(o)}catch(e){return!1}if(!m)return!1;if(u&&m.hasHighS())return!1;f&&(n=t.hash(n));const{r:g,s:E}=m,v=j(n),x=y(E),B=b(v*x),S=b(g*x),I=w.BASE.multiplyAndAddUnsafe(p,B,S)?.toAffine();if(!I)return!1;return b(I.x)===g},ProjectivePoint:w,Signature:P,utils:I}},r.SWUFpSqrtRatio=m,r.mapToCurveSimpleSWU=function(e,t){if((0,o.validateField)(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=m(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let s,i,a,c,u,f,l,d;s=e.sqr(n),s=e.mul(s,t.Z),i=e.sqr(s),i=e.add(i,s),a=e.add(i,e.ONE),a=e.mul(a,t.B),c=e.cmov(t.Z,e.neg(i),!e.eql(i,e.ZERO)),c=e.mul(c,t.A),i=e.sqr(a),f=e.sqr(c),u=e.mul(f,t.A),i=e.add(i,u),i=e.mul(i,a),f=e.mul(f,c),u=e.mul(f,t.B),i=e.add(i,u),l=e.mul(s,a);const{isValid:h,value:p}=r(i,f);d=e.mul(s,n),d=e.mul(d,p),l=e.cmov(l,a,h),d=e.cmov(d,p,h);const m=e.isOdd(n)===e.isOdd(d);d=e.cmov(e.neg(d),d,m);const g=(0,o.FpInvertBatch)(e,[c],!0)[0];return l=e.mul(l,g),{x:l,y:d}}};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("./curve.js"),o=e("./modular.js"),s=e("./utils.js");function i(e){e.lowS!==undefined&&(0,s.abool)("lowS",e.lowS),e.prehash!==undefined&&(0,s.abool)("prehash",e.prehash)}class a extends Error{constructor(e=""){super(e)}}function c(e,t){return(0,s.bytesToHex)((0,s.numberToBytesBE)(e,t))}r.DERErr=a,r.DER={Err:a,_tlv:{encode:(e,t)=>{const{Err:n}=r.DER;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const o=t.length/2,i=(0,s.numberToHexUnpadded)(o);if(i.length/2&128)throw new n("tlv.encode: long form length too big");const a=o>127?(0,s.numberToHexUnpadded)(i.length/2|128):"";return(0,s.numberToHexUnpadded)(e)+a+i+t},decode(e,t){const{Err:n}=r.DER;let o=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[o++]!==e)throw new n("tlv.decode: wrong tlv");const s=t[o++];let i=0;if(!!(128&s)){const e=127&s;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const r=t.subarray(o,o+e);if(r.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===r[0])throw new n("tlv.decode(long): zero leftmost byte");for(const e of r)i=i<<8|e;if(o+=e,i<128)throw new n("tlv.decode(long): not minimal encoding")}else i=s;const a=t.subarray(o,o+i);if(a.length!==i)throw new n("tlv.decode: wrong value length");return{v:a,l:t.subarray(o+i)}}},_int:{encode(e){const{Err:t}=r.DER;if(e<u)throw new t("integer: negative integers are not allowed");let n=(0,s.numberToHexUnpadded)(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=r.DER;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return(0,s.bytesToNumberBE)(e)}},toSig(e){const{Err:t,_int:n,_tlv:o}=r.DER,i=(0,s.ensureBytes)("signature",e),{v:a,l:c}=o.decode(48,i);if(c.length)throw new t("invalid signature: left bytes after parsing");const{v:u,l:f}=o.decode(2,a),{v:l,l:d}=o.decode(2,f);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(u),s:n.decode(l)}},hexFromSig(e){const{_tlv:t,_int:n}=r.DER,o=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,o)}};const u=BigInt(0),f=BigInt(1),l=BigInt(2),d=BigInt(3),h=BigInt(4);function p(e){const t=function(e){const t=(0,n.validateBasic)(e);(0,s.validateObject)(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:r,Fp:o,a:i}=t;if(r){if(!o.eql(i,o.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}(e),{Fp:r}=t,i=(0,o.Field)(t.n,t.nBitLength),a=t.toBytes||((e,t,n)=>{const o=t.toAffine();return(0,s.concatBytes)(Uint8Array.from([4]),r.toBytes(o.x),r.toBytes(o.y))}),c=t.fromBytes||(e=>{const t=e.subarray(1);return{x:r.fromBytes(t.subarray(0,r.BYTES)),y:r.fromBytes(t.subarray(r.BYTES,2*r.BYTES))}});function l(e){const{a:n,b:o}=t,s=r.sqr(e),i=r.mul(s,e);return r.add(r.add(i,r.mul(e,n)),o)}function p(e,t){const n=r.sqr(t),o=l(e);return r.eql(n,o)}if(!p(t.Gx,t.Gy))throw new Error("bad curve params: generator point");const m=r.mul(r.pow(t.a,d),h),g=r.mul(r.sqr(t.b),BigInt(27));if(r.is0(r.add(m,g)))throw new Error("bad curve params: a or b");function b(e){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:a}=t;if(r&&"bigint"!=typeof e){if((0,s.isBytes)(e)&&(e=(0,s.bytesToHex)(e)),"string"!=typeof e||!r.includes(e.length))throw new Error("invalid private key");e=e.padStart(2*n,"0")}let c;try{c="bigint"==typeof e?e:(0,s.bytesToNumberBE)((0,s.ensureBytes)("private key",e,n))}catch(t){throw new Error("invalid private key, expected hex or "+n+" bytes, got "+typeof e)}return i&&(c=(0,o.mod)(c,a)),(0,s.aInRange)("private key",c,f,a),c}function y(e){if(!(e instanceof v))throw new Error("ProjectivePoint expected")}const w=(0,s.memoized)((e,t)=>{const{px:n,py:o,pz:s}=e;if(r.eql(s,r.ONE))return{x:n,y:o};const i=e.is0();null==t&&(t=i?r.ONE:r.inv(s));const a=r.mul(n,t),c=r.mul(o,t),u=r.mul(s,t);if(i)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}}),E=(0,s.memoized)(e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:n,y:o}=e.toAffine();if(!r.isValid(n)||!r.isValid(o))throw new Error("bad point: x or y not FE");if(!p(n,o))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class v{constructor(e,t,n){if(null==e||!r.isValid(e))throw new Error("x required");if(null==t||!r.isValid(t)||r.is0(t))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required");this.px=e,this.py=t,this.pz=n,Object.freeze(this)}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof v)throw new Error("projective point not allowed");const o=e=>r.eql(e,r.ZERO);return o(t)&&o(n)?v.ZERO:new v(t,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=(0,o.FpInvertBatch)(r,e.map(e=>e.pz));return e.map((e,r)=>e.toAffine(t[r])).map(v.fromAffine)}static fromHex(e){const t=v.fromAffine(c((0,s.ensureBytes)("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return v.BASE.multiply(b(e))}static msm(e,t){return(0,n.pippenger)(v,i,e,t)}_setWindowSize(e){S.setWindowSize(this,e)}assertValidity(){E(this)}hasEvenY(){const{y:e}=this.toAffine();if(r.isOdd)return!r.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){y(e);const{px:t,py:n,pz:o}=this,{px:s,py:i,pz:a}=e,c=r.eql(r.mul(t,a),r.mul(s,o)),u=r.eql(r.mul(n,a),r.mul(i,o));return c&&u}negate(){return new v(this.px,r.neg(this.py),this.pz)}double(){const{a:e,b:n}=t,o=r.mul(n,d),{px:s,py:i,pz:a}=this;let c=r.ZERO,u=r.ZERO,f=r.ZERO,l=r.mul(s,s),h=r.mul(i,i),p=r.mul(a,a),m=r.mul(s,i);return m=r.add(m,m),f=r.mul(s,a),f=r.add(f,f),c=r.mul(e,f),u=r.mul(o,p),u=r.add(c,u),c=r.sub(h,u),u=r.add(h,u),u=r.mul(c,u),c=r.mul(m,c),f=r.mul(o,f),p=r.mul(e,p),m=r.sub(l,p),m=r.mul(e,m),m=r.add(m,f),f=r.add(l,l),l=r.add(f,l),l=r.add(l,p),l=r.mul(l,m),u=r.add(u,l),p=r.mul(i,a),p=r.add(p,p),l=r.mul(p,m),c=r.sub(c,l),f=r.mul(p,h),f=r.add(f,f),f=r.add(f,f),new v(c,u,f)}add(e){y(e);const{px:n,py:o,pz:s}=this,{px:i,py:a,pz:c}=e;let u=r.ZERO,f=r.ZERO,l=r.ZERO;const h=t.a,p=r.mul(t.b,d);let m=r.mul(n,i),g=r.mul(o,a),b=r.mul(s,c),w=r.add(n,o),E=r.add(i,a);w=r.mul(w,E),E=r.add(m,g),w=r.sub(w,E),E=r.add(n,s);let x=r.add(i,c);return E=r.mul(E,x),x=r.add(m,b),E=r.sub(E,x),x=r.add(o,s),u=r.add(a,c),x=r.mul(x,u),u=r.add(g,b),x=r.sub(x,u),l=r.mul(h,E),u=r.mul(p,b),l=r.add(u,l),u=r.sub(g,l),l=r.add(g,l),f=r.mul(u,l),g=r.add(m,m),g=r.add(g,m),b=r.mul(h,b),E=r.mul(p,E),g=r.add(g,b),b=r.sub(m,b),b=r.mul(h,b),E=r.add(E,b),m=r.mul(g,E),f=r.add(f,m),m=r.mul(x,E),u=r.mul(w,u),u=r.sub(u,m),m=r.mul(w,g),l=r.mul(x,l),l=r.add(l,m),new v(u,f,l)}subtract(e){return this.add(e.negate())}is0(){return this.equals(v.ZERO)}wNAF(e){return S.wNAFCached(this,e,v.normalizeZ)}multiplyUnsafe(e){const{endo:n,n:o}=t;(0,s.aInRange)("scalar",e,u,o);const i=v.ZERO;if(e===u)return i;if(this.is0()||e===f)return this;if(!n||S.hasPrecomputes(this))return S.wNAFCachedUnsafe(this,e,v.normalizeZ);let{k1neg:a,k1:c,k2neg:l,k2:d}=n.splitScalar(e),h=i,p=i,m=this;for(;c>u||d>u;)c&f&&(h=h.add(m)),d&f&&(p=p.add(m)),m=m.double(),c>>=f,d>>=f;return a&&(h=h.negate()),l&&(p=p.negate()),p=new v(r.mul(p.px,n.beta),p.py,p.pz),h.add(p)}multiply(e){const{endo:n,n:o}=t;let i,a;if((0,s.aInRange)("scalar",e,f,o),n){const{k1neg:t,k1:o,k2neg:s,k2:c}=n.splitScalar(e);let{p:u,f:f}=this.wNAF(o),{p:l,f:d}=this.wNAF(c);u=S.constTimeNegate(t,u),l=S.constTimeNegate(s,l),l=new v(r.mul(l.px,n.beta),l.py,l.pz),i=u.add(l),a=f.add(d)}else{const{p:t,f:r}=this.wNAF(e);i=t,a=r}return v.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,r){const n=v.BASE,o=(e,t)=>t!==u&&t!==f&&e.equals(n)?e.multiply(t):e.multiplyUnsafe(t),s=o(this,t).add(o(e,r));return s.is0()?undefined:s}toAffine(e){return w(this,e)}isTorsionFree(){const{h:e,isTorsionFree:r}=t;if(e===f)return!0;if(r)return r(v,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:r}=t;return e===f?this:r?r(v,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return(0,s.abool)("isCompressed",e),this.assertValidity(),a(v,this,e)}toHex(e=!0){return(0,s.abool)("isCompressed",e),(0,s.bytesToHex)(this.toRawBytes(e))}}v.BASE=new v(t.Gx,t.Gy,r.ONE),v.ZERO=new v(r.ZERO,r.ONE,r.ZERO);const{endo:x,nBitLength:B}=t,S=(0,n.wNAF)(v,x?Math.ceil(B/2):B);return{CURVE:t,ProjectivePoint:v,normPrivateKeyToScalar:b,weierstrassEquation:l,isWithinCurveOrder:function(e){return(0,s.inRange)(e,f,t.n)}}}function m(e,t){const r=e.ORDER;let n=u;for(let e=r-f;e%l===u;e/=l)n+=f;const o=n,s=l<<o-f-f,i=s*l,a=(r-f)/i,c=(a-f)/l,p=i-f,m=s,g=e.pow(t,a),b=e.pow(t,(a+f)/l);let y=(t,r)=>{let n=g,s=e.pow(r,p),i=e.sqr(s);i=e.mul(i,r);let a=e.mul(t,i);a=e.pow(a,c),a=e.mul(a,s),s=e.mul(a,r),i=e.mul(a,t);let u=e.mul(i,s);a=e.pow(u,m);let d=e.eql(a,e.ONE);s=e.mul(i,b),a=e.mul(u,n),i=e.cmov(s,i,d),u=e.cmov(a,u,d);for(let t=o;t>f;t--){let r=t-l;r=l<<r-f;let o=e.pow(u,r);const a=e.eql(o,e.ONE);s=e.mul(i,n),n=e.mul(n,n),o=e.mul(u,n),i=e.cmov(s,i,a),u=e.cmov(o,u,a)}return{isValid:d,value:i}};if(e.ORDER%h===d){const r=(e.ORDER-d)/h,n=e.sqrt(e.neg(t));y=(t,o)=>{let s=e.sqr(o);const i=e.mul(t,o);s=e.mul(s,i);let a=e.pow(s,r);a=e.mul(a,i);const c=e.mul(a,n),u=e.mul(e.sqr(a),o),f=e.eql(u,t);return{isValid:f,value:e.cmov(c,a,f)}}}return y}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/abstract/weierstrass.js"}],[658,{"@metamask/utils":3935,"ethereumjs-util":6454},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils"),o=e("ethereumjs-util");const s=r.version=206,i=["0x1079","0xa5bf"],a=(0,o.zeroAddress)();r.migrate=async(e,t)=>{if(e.meta.version=s,!(0,n.hasProperty)(e.data,"TokenBalancesController")||!(0,n.isObject)(e.data.TokenBalancesController))return;const{TokenBalancesController:r}=e.data;if(!(0,n.hasProperty)(r,"tokenBalances")||!(0,n.isObject)(r.tokenBalances))return;const{tokenBalances:o}=r;let c=!1;Object.values(o).forEach(e=>{(0,n.isObject)(e)&&i.forEach(t=>{t in e&&(0,n.isObject)(e[t])&&e[t][a]&&"0x0"!==e[t][a]&&(e[t][a]="0x0",c=!0)})}),c&&t.add("TokenBalancesController")}}}},{package:"$root$",file:"app/scripts/migrations/206.ts"}],[6580,{"./abstract/bls.js":6571,"./abstract/hash-to-curve.js":6574,"./abstract/modular.js":6575,"./abstract/tower.js":6577,"./abstract/utils.js":6578,"./abstract/weierstrass.js":6579,"@noble/hashes/sha2":5211,"@noble/hashes/utils":5215},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.bls12_381=void 0;
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/sha2"),o=e("@noble/hashes/utils"),s=e("./abstract/bls.js"),i=e("./abstract/modular.js"),a=e("./abstract/utils.js"),c=e("./abstract/hash-to-curve.js"),u=e("./abstract/tower.js"),f=e("./abstract/weierstrass.js"),l=BigInt(0),d=BigInt(1),h=BigInt(2),p=BigInt(3),m=BigInt(4),g=BigInt("0xd201000000010000"),b=(0,a.bitLen)(g),{Fp:y,Fp2:w,Fp6:E,Fp4Square:v,Fp12:x}=(0,u.tower12)({ORDER:BigInt("0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab"),FP2_NONRESIDUE:[d,d],Fp2mulByB:({c0:e,c1:t})=>{const r=y.mul(e,m),n=y.mul(t,m);return{c0:y.sub(r,n),c1:y.add(r,n)}},Fp12cyclotomicSquare:({c0:e,c1:t})=>{const{c0:r,c1:n,c2:o}=e,{c0:s,c1:i,c2:a}=t,{first:c,second:u}=v(r,i),{first:f,second:l}=v(s,o),{first:d,second:p}=v(n,a),m=w.mulByNonresidue(p);return{c0:E.create({c0:w.add(w.mul(w.sub(c,r),h),c),c1:w.add(w.mul(w.sub(f,n),h),f),c2:w.add(w.mul(w.sub(d,o),h),d)}),c1:E.create({c0:w.add(w.mul(w.add(m,s),h),m),c1:w.add(w.mul(w.add(u,i),h),u),c2:w.add(w.mul(w.add(l,a),h),l)})}},Fp12cyclotomicExp(e,t){let r=x.ONE;for(let n=b-1;n>=0;n--)r=x._cyclotomicSquare(r),(0,a.bitGet)(t,n)&&(r=x.mul(r,e));return r},Fp12finalExponentiate:e=>{const t=g,r=x.div(x.frobeniusMap(e,6),e),n=x.mul(x.frobeniusMap(r,2),r),o=x.conjugate(x._cyclotomicExp(n,t)),s=x.mul(x.conjugate(x._cyclotomicSquare(n)),o),i=x.conjugate(x._cyclotomicExp(s,t)),a=x.conjugate(x._cyclotomicExp(i,t)),c=x.mul(x.conjugate(x._cyclotomicExp(a,t)),x._cyclotomicSquare(o)),u=x.conjugate(x._cyclotomicExp(c,t)),f=x.frobeniusMap(x.mul(o,a),2),l=x.frobeniusMap(x.mul(i,n),3),d=x.frobeniusMap(x.mul(c,x.conjugate(n)),1),h=x.mul(x.mul(u,x.conjugate(s)),n);return x.mul(x.mul(x.mul(f,l),d),h)}}),B=(0,i.Field)(BigInt("0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001")),S=(0,c.isogenyMap)(w,[[["0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97d6"],["0x0","0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71a"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71e","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38d"],["0x171d6541fa38ccfaed6dea691f5fb614cb14b4e7f4e810aa22d6108f142b85757098e38d0f671c7188e2aaaaaaaa5ed1","0x0"]],[["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa63"],["0xc","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa9f"],["0x1","0x0"]],[["0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706","0x1530477c7ab4113b59a4c18b076d11930f7da5d4a07f649bf54439d87d27e500fc8c25ebf8c92f6812cfc71c71c6d706"],["0x0","0x5c759507e8e333ebb5b7a9a47d7ed8532c52d39fd3a042a88b58423c50ae15d5c2638e343d9c71c6238aaaaaaaa97be"],["0x11560bf17baa99bc32126fced787c88f984f87adf7ae0c7f9a208c6b4f20a4181472aaa9cb8d555526a9ffffffffc71c","0x8ab05f8bdd54cde190937e76bc3e447cc27c3d6fbd7063fcd104635a790520c0a395554e5c6aaaa9354ffffffffe38f"],["0x124c9ad43b6cf79bfbf7043de3811ad0761b0f37a1e26286b0e977c69aa274524e79097a56dc4bd9e1b371c71c718b10","0x0"]],[["0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa8fb"],["0x0","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffa9d3"],["0x12","0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaa99"],["0x1","0x0"]]].map(e=>e.map(e=>w.fromBigTuple(e.map(BigInt))))),P=(0,c.isogenyMap)(y,[["0x11a05f2b1e833340b809101dd99815856b303e88a2d7005ff2627b56cdb4e2c85610c2d5f2e62d6eaeac1662734649b7","0x17294ed3e943ab2f0588bab22147a81c7c17e75b2f6a8417f565e33c70d1e86b4838f2a6f318c356e834eef1b3cb83bb","0xd54005db97678ec1d1048c5d10a9a1bce032473295983e56878e501ec68e25c958c3e3d2a09729fe0179f9dac9edcb0","0x1778e7166fcc6db74e0609d307e55412d7f5e4656a8dbf25f1b33289f1b330835336e25ce3107193c5b388641d9b6861","0xe99726a3199f4436642b4b3e4118e5499db995a1257fb3f086eeb65982fac18985a286f301e77c451154ce9ac8895d9","0x1630c3250d7313ff01d1201bf7a74ab5db3cb17dd952799b9ed3ab9097e68f90a0870d2dcae73d19cd13c1c66f652983","0xd6ed6553fe44d296a3726c38ae652bfb11586264f0f8ce19008e218f9c86b2a8da25128c1052ecaddd7f225a139ed84","0x17b81e7701abdbe2e8743884d1117e53356de5ab275b4db1a682c62ef0f2753339b7c8f8c8f475af9ccb5618e3f0c88e","0x80d3cf1f9a78fc47b90b33563be990dc43b756ce79f5574a2c596c928c5d1de4fa295f296b74e956d71986a8497e317","0x169b1f8e1bcfa7c42e0c37515d138f22dd2ecb803a0c5c99676314baf4bb1b7fa3190b2edc0327797f241067be390c9e","0x10321da079ce07e272d8ec09d2565b0dfa7dccdde6787f96d50af36003b14866f69b771f8c285decca67df3f1605fb7b","0x6e08c248e260e70bd1e962381edee3d31d79d7e22c837bc23c0bf1bc24c6b68c24b1b80b64d391fa9c8ba2e8ba2d229"],["0x8ca8d548cff19ae18b2e62f4bd3fa6f01d5ef4ba35b48ba9c9588617fc8ac62b558d681be343df8993cf9fa40d21b1c","0x12561a5deb559c4348b4711298e536367041e8ca0cf0800c0126c2588c48bf5713daa8846cb026e9e5c8276ec82b3bff","0xb2962fe57a3225e8137e629bff2991f6f89416f5a718cd1fca64e00b11aceacd6a3d0967c94fedcfcc239ba5cb83e19","0x3425581a58ae2fec83aafef7c40eb545b08243f16b1655154cca8abc28d6fd04976d5243eecf5c4130de8938dc62cd8","0x13a8e162022914a80a6f1d5f43e7a07dffdfc759a12062bb8d6b44e833b306da9bd29ba81f35781d539d395b3532a21e","0xe7355f8e4e667b955390f7f0506c6e9395735e9ce9cad4d0a43bcef24b8982f7400d24bc4228f11c02df9a29f6304a5","0x772caacf16936190f3e0c63e0596721570f5799af53a1894e2e073062aede9cea73b3538f0de06cec2574496ee84a3a","0x14a7ac2a9d64a8b230b3f5b074cf01996e7f63c21bca68a81996e1cdf9822c580fa5b9489d11e2d311f7d99bbdcc5a5e","0xa10ecf6ada54f825e920b3dafc7a3cce07f8d1d7161366b74100da67f39883503826692abba43704776ec3a79a1d641","0x95fc13ab9e92ad4476d6e3eb3a56680f682b4ee96f7d03776df533978f31c1593174e4b4b7865002d6384d168ecdd0a","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"],["0x90d97c81ba24ee0259d1f094980dcfa11ad138e48a869522b52af6c956543d3cd0c7aee9b3ba3c2be9845719707bb33","0x134996a104ee5811d51036d776fb46831223e96c254f383d0f906343eb67ad34d6c56711962fa8bfe097e75a2e41c696","0xcc786baa966e66f4a384c86a3b49942552e2d658a31ce2c344be4b91400da7d26d521628b00523b8dfe240c72de1f6","0x1f86376e8981c217898751ad8746757d42aa7b90eeb791c09e4a3ec03251cf9de405aba9ec61deca6355c77b0e5f4cb","0x8cc03fdefe0ff135caf4fe2a21529c4195536fbe3ce50b879833fd221351adc2ee7f8dc099040a841b6daecf2e8fedb","0x16603fca40634b6a2211e11db8f0a6a074a7d0d4afadb7bd76505c3d3ad5544e203f6326c95a807299b23ab13633a5f0","0x4ab0b9bcfac1bbcb2c977d027796b3ce75bb8ca2be184cb5231413c4d634f3747a87ac2460f415ec961f8855fe9d6f2","0x987c8d5333ab86fde9926bd2ca6c674170a05bfe3bdd81ffd038da6c26c842642f64550fedfe935a15e4ca31870fb29","0x9fc4018bd96684be88c9e221e4da1bb8f3abd16679dc26c1e8b6e6a1f20cabe69d65201c78607a360370e577bdba587","0xe1bba7a1186bdb5223abde7ada14a23c42a0ca7915af6fe06985e7ed1e4d43b9b3f7055dd4eba6f2bafaaebca731c30","0x19713e47937cd1be0dfd0b8f1d43fb93cd2fcbcb6caf493fd1183e416389e61031bf3a5cce3fbafce813711ad011c132","0x18b46a908f36f6deb918c143fed2edcc523559b8aaf0c2462e6bfe7f911f643249d9cdf41b44d606ce07c8a4d0074d8e","0xb182cac101b9399d155096004f53f447aa7b12a3426b08ec02710e807b4633f06c851c1919211f20d4c04f00b971ef8","0x245a394ad1eca9b72fc00ae7be315dc757b3b080d4c158013e6632d3c40659cc6cf90ad1c232a6442d9d3f5db980133","0x5c129645e44cf1102a159f748c4a3fc5e673d81d7e86568d9ab0f5d396a7ce46ba1049b6579afb7866b1e715475224b","0x15e6be4e990f03ce4ea50b3b42df2eb5cb181d8f84965a3957add4fa95af01b2b665027efec01c7704b456be69c8b604"],["0x16112c4c3a9c98b252181140fad0eae9601a6de578980be6eec3232b5be72e7a07f3688ef60c206d01479253b03663c1","0x1962d75c2381201e1a0cbd6c43c348b885c84ff731c4d59ca4a10356f453e01f78a4260763529e3532f6102c2e49a03d","0x58df3306640da276faaae7d6e8eb15778c4855551ae7f310c35a5dd279cd2eca6757cd636f96f891e2538b53dbf67f2","0x16b7d288798e5395f20d23bf89edb4d1d115c5dbddbcd30e123da489e726af41727364f2c28297ada8d26d98445f5416","0xbe0e079545f43e4b00cc912f8228ddcc6d19c9f0f69bbb0542eda0fc9dec916a20b15dc0fd2ededda39142311a5001d","0x8d9e5297186db2d9fb266eaac783182b70152c65550d881c5ecd87b6f0f5a6449f38db9dfa9cce202c6477faaf9b7ac","0x166007c08a99db2fc3ba8734ace9824b5eecfdfa8d0cf8ef5dd365bc400a0051d5fa9c01a58b1fb93d1a1399126a775c","0x16a3ef08be3ea7ea03bcddfabba6ff6ee5a4375efa1f4fd7feb34fd206357132b920f5b00801dee460ee415a15812ed9","0x1866c8ed336c61231a1be54fd1d74cc4f9fb0ce4c6af5920abc5750c4bf39b4852cfe2f7bb9248836b233d9d55535d4a","0x167a55cda70a6e1cea820597d94a84903216f763e13d87bb5308592e7ea7d4fbc7385ea3d529b35e346ef48bb8913f55","0x4d2f259eea405bd48f010a01ad2911d9c6dd039bb61a6290e591b36e636a5c871a5c29f4f83060400f8b49cba8f6aa8","0xaccbb67481d033ff5852c1e48c50c477f94ff8aefce42d28c0f9a88cea7913516f968986f7ebbea9684b529e2561092","0xad6b9514c767fe3c3613144b45f1496543346d98adf02267d5ceef9a00d9b8693000763e3b90ac11e99b138573345cc","0x2660400eb2e4f3b628bdd0d53cd76f2bf565b94e72927c1cb748df27942480e420517bd8714cc80d1fadc1326ed06f7","0xe0fa1d816ddc03e6b24255e0d7819c171c40f65e273b853324efcd6356caa205ca2f570f13497804415473a1d634b8f","0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(e=>BigInt(e)))),I=(0,f.mapToCurveSimpleSWU)(w,{A:w.create({c0:y.create(l),c1:y.create(BigInt(240))}),B:w.create({c0:y.create(BigInt(1012)),c1:y.create(BigInt(1012))}),Z:w.create({c0:y.create(BigInt(-2)),c1:y.create(BigInt(-1))})}),T=(0,f.mapToCurveSimpleSWU)(y,{A:y.create(BigInt("0x144698a3b8e9433d693a02c96d4982b0ea985383ee66a8d8e8981aefd881ac98936f8da0e0f97f5cf428082d584c1d")),B:y.create(BigInt("0x12e2908d11688030018b12e8753eee3b2016c1f0f24f4070a0b9c14fcef35ef55a23215a316ceaa5d1cc48e98e172be0")),Z:y.create(BigInt(11))}),{G2psi:A,G2psi2:j}=(0,u.psiFrobenius)(y,w,w.div(w.ONE,w.NONRESIDUE)),_=Object.freeze({DST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",encodeDST:"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_",p:y.ORDER,m:2,k:128,expand:"xmd",hash:n.sha256}),O=N(y.toBytes(l),{infinity:!0,compressed:!0});function k(e){const t=224&(e=e.slice())[0],r=!!(t>>7&1),n=!!(t>>6&1),o=!!(t>>5&1);return e[0]&=31,{compressed:r,infinity:n,sort:o,value:e}}function N(e,t){if(224&e[0])throw new Error("setMask: non-empty mask");return t.compressed&&(e[0]|=128),t.infinity&&(e[0]|=64),t.sort&&(e[0]|=32),e}function R(e){e.assertValidity();const t=e.equals(r.bls12_381.G1.ProjectivePoint.ZERO),{x:n,y:o}=e.toAffine();if(t)return O.slice();const s=y.ORDER,i=Boolean(o*h/s);return N((0,a.numberToBytesBE)(n,y.BYTES),{compressed:!0,sort:i})}function C(e){e.assertValidity();const t=y.BYTES;if(e.equals(r.bls12_381.G2.ProjectivePoint.ZERO))return(0,a.concatBytes)(O,(0,a.numberToBytesBE)(l,t));const{x:n,y:o}=e.toAffine(),{re:s,im:i}=w.reim(n),{re:c,im:u}=w.reim(o),f=Boolean((u>l?u*h:c*h)/y.ORDER&d),p=s;return(0,a.concatBytes)(N((0,a.numberToBytesBE)(i,t),{sort:f,compressed:!0}),(0,a.numberToBytesBE)(p,t))}r.bls12_381=(0,s.bls)({fields:{Fp:y,Fp2:w,Fp6:E,Fp12:x,Fr:B},G1:{Fp:y,h:BigInt("0x396c8c005555e1568c00aaab0000aaab"),Gx:BigInt("0x17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb"),Gy:BigInt("0x08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"),a:y.ZERO,b:m,htfDefaults:{..._,m:1,DST:"BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_"},wrapPrivateKey:!0,allowInfinityPoint:!0,isTorsionFree:(e,t)=>{const r=BigInt("0x5f19672fdf76ce51ba69c6076a0f77eaddb3a93be6f89688de17d813620a00022e01fffffffefffe"),n=new e(y.mul(t.px,r),t.py,t.pz);return t.multiplyUnsafe(g).negate().multiplyUnsafe(g).equals(n)},clearCofactor:(e,t)=>t.multiplyUnsafe(g).add(t),mapToCurve:e=>{const{x:t,y:r}=T(y.create(e[0]));return P(t,r)},fromBytes:e=>{const{compressed:t,infinity:n,sort:o,value:s}=k(e);if(48===s.length&&t){const e=y.ORDER,t=(0,a.bytesToNumberBE)(s),i=y.create(t&y.MASK);if(n){if(i!==l)throw new Error("G1: non-empty compressed point at infinity");return{x:l,y:l}}const c=y.add(y.pow(i,p),y.create(r.bls12_381.params.G1b));let u=y.sqrt(c);if(!u)throw new Error("invalid compressed G1 point");return u*h/e!==BigInt(o)&&(u=y.neg(u)),{x:y.create(i),y:y.create(u)}}if(96!==s.length||t)throw new Error("invalid point G1, expected 48/96 bytes");{const e=(0,a.bytesToNumberBE)(s.subarray(0,y.BYTES)),t=(0,a.bytesToNumberBE)(s.subarray(y.BYTES));if(n){if(e!==l||t!==l)throw new Error("G1: non-empty point at infinity");return r.bls12_381.G1.ProjectivePoint.ZERO.toAffine()}return{x:y.create(e),y:y.create(t)}}},toBytes:(e,t,r)=>{const n=t.equals(e.ZERO),{x:o,y:s}=t.toAffine();if(r){if(n)return O.slice();const e=y.ORDER,t=Boolean(s*h/e);return N((0,a.numberToBytesBE)(o,y.BYTES),{compressed:!0,sort:t})}if(n){return(0,a.concatBytes)(new Uint8Array([64]),new Uint8Array(2*y.BYTES-1))}return(0,a.concatBytes)((0,a.numberToBytesBE)(o,y.BYTES),(0,a.numberToBytesBE)(s,y.BYTES))},ShortSignature:{fromHex(e){const{infinity:t,sort:n,value:o}=k((0,a.ensureBytes)("signatureHex",e,48)),s=y.ORDER,i=(0,a.bytesToNumberBE)(o);if(t)return r.bls12_381.G1.ProjectivePoint.ZERO;const c=y.create(i&y.MASK),u=y.add(y.pow(c,p),y.create(r.bls12_381.params.G1b));let f=y.sqrt(u);if(!f)throw new Error("invalid compressed G1 point");const l=BigInt(n);f*h/s!==l&&(f=y.neg(f));const d=r.bls12_381.G1.ProjectivePoint.fromAffine({x:c,y:f});return d.assertValidity(),d},toRawBytes:e=>R(e),toHex:e=>(0,a.bytesToHex)(R(e))}},G2:{Fp:w,h:BigInt("0x5d543a95414e7f1091d50792876a202cd91de4547085abaa68a205b2e5a7ddfa628f1cb4d9e82ef21537e293a6691ae1616ec6e786f0c70cf1c38e31c7238e5"),Gx:w.fromBigTuple([BigInt("0x024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"),BigInt("0x13e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e")]),Gy:w.fromBigTuple([BigInt("0x0ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801"),BigInt("0x0606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be")]),a:w.ZERO,b:w.fromBigTuple([m,m]),hEff:BigInt("0xbc69f08f2ee75b3584c6a0ea91b352888e2a8e9145ad7689986ff031508ffe1329c2f178731db956d82bf015d1212b02ec0ec69d7477c1ae954cbc06689f6a359894c0adebbf6b4e8020005aaa95551"),htfDefaults:{..._},wrapPrivateKey:!0,allowInfinityPoint:!0,mapToCurve:e=>{const{x:t,y:r}=I(w.fromBigTuple(e));return S(t,r)},isTorsionFree:(e,t)=>t.multiplyUnsafe(g).negate().equals(A(e,t)),clearCofactor:(e,t)=>{const r=g;let n=t.multiplyUnsafe(r).negate(),o=A(e,t),s=t.double();s=j(e,s),s=s.subtract(o),o=n.add(o),o=o.multiplyUnsafe(r).negate(),s=s.add(o),s=s.subtract(n);return s.subtract(t)},fromBytes:e=>{const{compressed:t,infinity:n,sort:o,value:s}=k(e);if(!t&&!n&&o||!t&&n&&o||o&&n&&t)throw new Error("invalid encoding flag: "+(224&e[0]));const i=y.BYTES,c=(e,t,r)=>(0,a.bytesToNumberBE)(e.slice(t,r));if(96===s.length&&t){const e=r.bls12_381.params.G2b,t=y.ORDER;if(n){if(s.reduce((e,t)=>0!==e?t+1:t,0)>0)throw new Error("invalid compressed G2 point");return{x:w.ZERO,y:w.ZERO}}const a=c(s,0,i),u=c(s,i,2*i),f=w.create({c0:y.create(u),c1:y.create(a)}),m=w.add(w.pow(f,p),e);let g=w.sqrt(m);const b=g.c1===l?g.c0*h/t:g.c1*h/t?d:l;return g=o&&b>0?g:w.neg(g),{x:f,y:g}}if(192!==s.length||t)throw new Error("invalid point G2, expected 96/192 bytes");{if(n){if(s.reduce((e,t)=>0!==e?t+1:t,0)>0)throw new Error("invalid uncompressed G2 point");return{x:w.ZERO,y:w.ZERO}}const e=c(s,0,i),t=c(s,i,2*i),r=c(s,2*i,3*i),o=c(s,3*i,4*i);return{x:w.fromBigTuple([t,e]),y:w.fromBigTuple([o,r])}}},toBytes:(e,t,r)=>{const{BYTES:n,ORDER:o}=y,s=t.equals(e.ZERO),{x:i,y:c}=t.toAffine();if(r){if(s)return(0,a.concatBytes)(O,(0,a.numberToBytesBE)(l,n));const e=Boolean(c.c1===l?c.c0*h/o:c.c1*h/o);return(0,a.concatBytes)(N((0,a.numberToBytesBE)(i.c1,n),{compressed:!0,sort:e}),(0,a.numberToBytesBE)(i.c0,n))}{if(s)return(0,a.concatBytes)(new Uint8Array([64]),new Uint8Array(4*n-1));const{re:e,im:t}=w.reim(i),{re:r,im:o}=w.reim(c);return(0,a.concatBytes)((0,a.numberToBytesBE)(t,n),(0,a.numberToBytesBE)(e,n),(0,a.numberToBytesBE)(o,n),(0,a.numberToBytesBE)(r,n))}},Signature:{fromHex(e){const{infinity:t,sort:n,value:o}=k((0,a.ensureBytes)("signatureHex",e)),s=y.ORDER,i=o.length/2;if(48!==i&&96!==i)throw new Error("invalid compressed signature length, must be 96 or 192");const c=(0,a.bytesToNumberBE)(o.slice(0,i)),u=(0,a.bytesToNumberBE)(o.slice(i));if(t)return r.bls12_381.G2.ProjectivePoint.ZERO;const f=y.create(c&y.MASK),d=y.create(u),m=w.create({c0:d,c1:f}),g=w.add(w.pow(m,p),r.bls12_381.params.G2b);let b=w.sqrt(g);if(!b)throw new Error("Failed to find a square root");const{re:E,im:v}=w.reim(b),x=BigInt(n);(v>l&&v*h/s!==x||v===l&&E*h/s!==x)&&(b=w.neg(b));const B=r.bls12_381.G2.ProjectivePoint.fromAffine({x:m,y:b});return B.assertValidity(),B},toRawBytes:e=>C(e),toHex:e=>(0,a.bytesToHex)(C(e))}},params:{ateLoopSize:g,r:B.ORDER,xNegative:!0,twistType:"multiplicative"},htfDefaults:_,hash:n.sha256,randomBytes:o.randomBytes})}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/bls12-381.js"}],[6581,{"./abstract/curve.js":6572,"./abstract/edwards.js":6573,"./abstract/hash-to-curve.js":6574,"./abstract/modular.js":6575,"./abstract/montgomery.js":6576,"./abstract/utils.js":6578,"@noble/hashes/sha2":5211,"@noble/hashes/utils":5215},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.hash_to_ristretto255=r.hashToRistretto255=r.RistrettoPoint=r.encodeToCurve=r.hashToCurve=r.ed25519_hasher=r.edwardsToMontgomery=r.x25519=r.ed25519ph=r.ed25519ctx=r.ed25519=r.ED25519_TORSION_SUBGROUP=void 0,r.edwardsToMontgomeryPub=P,r.edwardsToMontgomeryPriv=function(e){const t=B.hash(e.subarray(0,32));return B.adjustScalarBytes(t).subarray(0,32)};
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/sha2"),o=e("@noble/hashes/utils"),s=e("./abstract/curve.js"),i=e("./abstract/edwards.js"),a=e("./abstract/hash-to-curve.js"),c=e("./abstract/modular.js"),u=e("./abstract/montgomery.js"),f=e("./abstract/utils.js"),l=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),d=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),h=BigInt(0),p=BigInt(1),m=BigInt(2),g=BigInt(3),b=BigInt(5),y=BigInt(8);function w(e){const t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=l,i=e*e%s*e%s,a=(0,c.pow2)(i,m,s)*i%s,u=(0,c.pow2)(a,p,s)*e%s,f=(0,c.pow2)(u,b,s)*u%s,d=(0,c.pow2)(f,t,s)*f%s,h=(0,c.pow2)(d,r,s)*d%s,g=(0,c.pow2)(h,n,s)*h%s,y=(0,c.pow2)(g,o,s)*g%s,w=(0,c.pow2)(y,o,s)*g%s,E=(0,c.pow2)(w,t,s)*f%s;return{pow_p_5_8:(0,c.pow2)(E,m,s)*e%s,b2:i}}function E(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function v(e,t){const r=l,n=(0,c.mod)(t*t*t,r),o=w(e*(0,c.mod)(n*n*t,r)).pow_p_5_8;let s=(0,c.mod)(e*n*o,r);const i=(0,c.mod)(t*s*s,r),a=s,u=(0,c.mod)(s*d,r),f=i===e,h=i===(0,c.mod)(-e,r),p=i===(0,c.mod)(-e*d,r);return f&&(s=a),(h||p)&&(s=u),(0,c.isNegativeLE)(s,r)&&(s=(0,c.mod)(-s,r)),{isValid:f||h,value:s}}r.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];const x=(()=>(0,c.Field)(l,undefined,!0))(),B=(()=>({a:x.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:x,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:y,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:n.sha512,randomBytes:o.randomBytes,adjustScalarBytes:E,uvRatio:v}))();function S(e,t,r){if(t.length>255)throw new Error("Context is too big");return(0,o.concatBytes)((0,o.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,t.length]),t,e)}function P(e){const{y:t}=r.ed25519.ExtendedPoint.fromHex(e),n=BigInt(1);return x.toBytes(x.create((n+t)*x.inv(n-t)))}r.ed25519=(0,i.twistedEdwards)(B),r.ed25519ctx=(0,i.twistedEdwards)({...B,domain:S}),r.ed25519ph=(0,i.twistedEdwards)(Object.assign({},B,{domain:S,prehash:n.sha512})),r.x25519=(0,u.montgomery)({P:l,type:"x25519",powPminus2:e=>{const t=l,{pow_p_5_8:r,b2:n}=w(e);return(0,c.mod)((0,c.pow2)(r,g,t)*n,t)},adjustScalarBytes:E,randomBytes:o.randomBytes}),r.edwardsToMontgomery=P;const I=(()=>(x.ORDER+g)/y)(),T=(()=>x.pow(m,I))(),A=(()=>x.sqrt(x.neg(x.ONE)))();const j=(()=>(0,c.FpSqrtEven)(x,x.neg(BigInt(486664))))();function _(e){const{xMn:t,xMd:r,yMn:n,yMd:o}=function(e){const t=(x.ORDER-b)/y,r=BigInt(486662);let n=x.sqr(e);n=x.mul(n,m);let o=x.add(n,x.ONE),s=x.neg(r),i=x.sqr(o),a=x.mul(i,o),c=x.mul(n,r);c=x.mul(c,s),c=x.add(c,i),c=x.mul(c,s);let u=x.sqr(a);i=x.sqr(u),u=x.mul(u,a),u=x.mul(u,c),i=x.mul(i,u);let f=x.pow(i,t);f=x.mul(f,u);let l=x.mul(f,A);i=x.sqr(f),i=x.mul(i,a);let d=x.eql(i,c),h=x.cmov(l,f,d),g=x.mul(s,n),w=x.mul(f,e);w=x.mul(w,T);let E=x.mul(w,A),v=x.mul(c,n);i=x.sqr(w),i=x.mul(i,a);let B=x.eql(i,v),S=x.cmov(E,w,B);i=x.sqr(h),i=x.mul(i,a);let P=x.eql(i,c),I=x.cmov(g,s,P),j=x.cmov(S,h,P),_=x.isOdd(j);return j=x.cmov(j,x.neg(j),P!==_),{xMn:I,xMd:o,yMn:j,yMd:p}}(e);let s=x.mul(t,o);s=x.mul(s,j);let i=x.mul(r,n),a=x.sub(t,r),u=x.add(t,r),f=x.mul(i,u),l=x.eql(f,x.ZERO);s=x.cmov(s,x.ZERO,l),i=x.cmov(i,x.ONE,l),a=x.cmov(a,x.ONE,l),u=x.cmov(u,x.ONE,l);const[d,h]=(0,c.FpInvertBatch)(x,[i,u],!0);return{x:x.mul(s,d),y:x.mul(a,h)}}function O(e){if(!(e instanceof G))throw new Error("RistrettoPoint expected")}r.ed25519_hasher=(0,a.createHasher)(r.ed25519.ExtendedPoint,e=>_(e[0]),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:x.ORDER,m:1,k:128,expand:"xmd",hash:n.sha512}),r.hashToCurve=r.ed25519_hasher.hashToCurve,r.encodeToCurve=r.ed25519_hasher.encodeToCurve;const k=d,N=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),R=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),C=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),U=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),D=e=>v(p,e),L=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),z=e=>r.ed25519.CURVE.Fp.create((0,f.bytesToNumberLE)(e)&L);function M(e){const{d:t}=r.ed25519.CURVE,n=r.ed25519.CURVE.Fp.ORDER,o=r.ed25519.CURVE.Fp.create,s=o(k*e*e),i=o((s+p)*C);let a=BigInt(-1);const u=o((a-t*s)*o(s+t));let{isValid:f,value:l}=v(i,u),d=o(l*e);(0,c.isNegativeLE)(d,n)||(d=o(-d)),f||(l=d),f||(a=s);const h=o(a*(s-p)*U-u),m=l*l,g=o((l+l)*u),b=o(h*N),y=o(p-m),w=o(p+m);return new r.ed25519.ExtendedPoint(o(g*w),o(y*b),o(b*w),o(g*y))}class G{constructor(e){this.ep=e}static fromAffine(e){return new G(r.ed25519.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=(0,f.ensureBytes)("ristrettoHash",e,64);const t=M(z(e.slice(0,32))),r=M(z(e.slice(32,64)));return new G(t.add(r))}static fromHex(e){e=(0,f.ensureBytes)("ristrettoHex",e,32);const{a:t,d:n}=r.ed25519.CURVE,o=r.ed25519.CURVE.Fp.ORDER,s=r.ed25519.CURVE.Fp.create,i="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=z(e);if(!(0,f.equalBytes)((0,f.numberToBytesLE)(a,32),e)||(0,c.isNegativeLE)(a,o))throw new Error(i);const u=s(a*a),l=s(p+t*u),d=s(p-t*u),m=s(l*l),g=s(d*d),b=s(t*n*m-g),{isValid:y,value:w}=D(s(b*g)),E=s(w*d),v=s(w*E*b);let x=s((a+a)*E);(0,c.isNegativeLE)(x,o)&&(x=s(-x));const B=s(l*v),S=s(x*B);if(!y||(0,c.isNegativeLE)(S,o)||B===h)throw new Error(i);return new G(new r.ed25519.ExtendedPoint(x,B,p,S))}static msm(e,t){const n=(0,c.Field)(r.ed25519.CURVE.n,r.ed25519.CURVE.nBitLength);return(0,s.pippenger)(G,n,e,t)}toRawBytes(){let{ex:e,ey:t,ez:n,et:o}=this.ep;const s=r.ed25519.CURVE.Fp.ORDER,i=r.ed25519.CURVE.Fp.create,a=i(i(n+t)*i(n-t)),u=i(e*t),l=i(u*u),{value:d}=D(i(a*l)),h=i(d*a),p=i(d*u),m=i(h*p*o);let g;if((0,c.isNegativeLE)(o*m,s)){let r=i(t*k),n=i(e*k);e=r,t=n,g=i(h*R)}else g=p;(0,c.isNegativeLE)(e*m,s)&&(t=i(-t));let b=i((n-t)*g);return(0,c.isNegativeLE)(b,s)&&(b=i(-b)),(0,f.numberToBytesLE)(b,32)}toHex(){return(0,f.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(e){O(e);const{ex:t,ey:n}=this.ep,{ex:o,ey:s}=e.ep,i=r.ed25519.CURVE.Fp.create,a=i(t*s)===i(n*o),c=i(n*s)===i(t*o);return a||c}add(e){return O(e),new G(this.ep.add(e.ep))}subtract(e){return O(e),new G(this.ep.subtract(e.ep))}multiply(e){return new G(this.ep.multiply(e))}multiplyUnsafe(e){return new G(this.ep.multiplyUnsafe(e))}double(){return new G(this.ep.double())}negate(){return new G(this.ep.negate())}}r.RistrettoPoint=(G.BASE||(G.BASE=new G(r.ed25519.ExtendedPoint.BASE)),G.ZERO||(G.ZERO=new G(r.ed25519.ExtendedPoint.ZERO)),G);r.hashToRistretto255=(e,t)=>{const r=t.DST,s="string"==typeof r?(0,o.utf8ToBytes)(r):r,i=(0,a.expand_message_xmd)(e,s,64,n.sha512);return G.hashToCurve(i)},r.hash_to_ristretto255=r.hashToRistretto255}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/ed25519.js"}],[6582,{"./_shortw_utils.js":6570,"./abstract/hash-to-curve.js":6574,"./abstract/modular.js":6575,"./abstract/weierstrass.js":6579,"@noble/hashes/sha2":5211},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.p521_hasher=r.secp521r1=r.p521=r.p384_hasher=r.secp384r1=r.p384=r.p256_hasher=r.secp256r1=r.p256=void 0;
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/sha2"),o=e("./_shortw_utils.js"),s=e("./abstract/hash-to-curve.js"),i=e("./abstract/modular.js"),a=e("./abstract/weierstrass.js"),c=(0,i.Field)(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),u=c.create(BigInt("-3")),f=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b");r.p256=(0,o.createCurve)({a:u,b:f,Fp:c,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},n.sha256),r.secp256r1=r.p256;const l=(()=>(0,a.mapToCurveSimpleSWU)(c,{A:u,B:f,Z:c.create(BigInt("-10"))}))();r.p256_hasher=(0,s.createHasher)(r.secp256r1.ProjectivePoint,e=>l(e[0]),{DST:"P256_XMD:SHA-256_SSWU_RO_",encodeDST:"P256_XMD:SHA-256_SSWU_NU_",p:c.ORDER,m:1,k:128,expand:"xmd",hash:n.sha256});const d=(0,i.Field)(BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff")),h=d.create(BigInt("-3")),p=BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef");r.p384=(0,o.createCurve)({a:h,b:p,Fp:d,n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),h:BigInt(1),lowS:!1},n.sha384),r.secp384r1=r.p384;const m=(()=>(0,a.mapToCurveSimpleSWU)(d,{A:h,B:p,Z:d.create(BigInt("-12"))}))();r.p384_hasher=(0,s.createHasher)(r.secp384r1.ProjectivePoint,e=>m(e[0]),{DST:"P384_XMD:SHA-384_SSWU_RO_",encodeDST:"P384_XMD:SHA-384_SSWU_NU_",p:d.ORDER,m:1,k:192,expand:"xmd",hash:n.sha384});const g=(0,i.Field)(BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")),b=g.create(BigInt("-3")),y=BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00");r.p521=(0,o.createCurve)({a:b,b:y,Fp:g,n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),h:BigInt(1),lowS:!1,allowedPrivateKeyLengths:[130,131,132]},n.sha512),r.secp521r1=r.p521;const w=(()=>(0,a.mapToCurveSimpleSWU)(g,{A:b,B:y,Z:g.create(BigInt("-4"))}))();r.p521_hasher=(0,s.createHasher)(r.secp521r1.ProjectivePoint,e=>w(e[0]),{DST:"P521_XMD:SHA-512_SSWU_RO_",encodeDST:"P521_XMD:SHA-512_SSWU_NU_",p:g.ORDER,m:1,k:256,expand:"xmd",hash:n.sha512})}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/nist.js"}],[6583,{"./nist.js":6582},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.encodeToCurve=r.hashToCurve=r.secp256r1=r.p256=void 0;const n=e("./nist.js");r.p256=n.p256,r.secp256r1=n.p256,r.hashToCurve=n.p256_hasher.hashToCurve,r.encodeToCurve=n.p256_hasher.encodeToCurve}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/p256.js"}],[6584,{"./_shortw_utils.js":6570,"./abstract/hash-to-curve.js":6574,"./abstract/modular.js":6575,"./abstract/utils.js":6578,"./abstract/weierstrass.js":6579,"@noble/hashes/sha2":5211,"@noble/hashes/utils":5215},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.encodeToCurve=r.hashToCurve=r.secp256k1_hasher=r.schnorr=r.secp256k1=void 0;
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const n=e("@noble/hashes/sha2"),o=e("@noble/hashes/utils"),s=e("./_shortw_utils.js"),i=e("./abstract/hash-to-curve.js"),a=e("./abstract/modular.js"),c=e("./abstract/utils.js"),u=e("./abstract/weierstrass.js"),f=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),l=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),d=BigInt(0),h=BigInt(1),p=BigInt(2),m=(e,t)=>(e+t/p)/t;function g(e){const t=f,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),u=BigInt(88),l=e*e*e%t,d=l*l*e%t,h=(0,a.pow2)(d,r,t)*d%t,m=(0,a.pow2)(h,r,t)*d%t,g=(0,a.pow2)(m,p,t)*l%t,y=(0,a.pow2)(g,o,t)*g%t,w=(0,a.pow2)(y,s,t)*y%t,E=(0,a.pow2)(w,c,t)*w%t,v=(0,a.pow2)(E,u,t)*E%t,x=(0,a.pow2)(v,c,t)*w%t,B=(0,a.pow2)(x,r,t)*d%t,S=(0,a.pow2)(B,i,t)*y%t,P=(0,a.pow2)(S,n,t)*l%t,I=(0,a.pow2)(P,p,t);if(!b.eql(b.sqr(I),e))throw new Error("Cannot find square root");return I}const b=(0,a.Field)(f,undefined,undefined,{sqrt:g});r.secp256k1=(0,s.createCurve)({a:d,b:BigInt(7),Fp:b,n:l,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=l,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-h*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,i=BigInt("0x100000000000000000000000000000000"),c=m(s*e,t),u=m(-n*e,t);let f=(0,a.mod)(e-c*r-u*o,t),d=(0,a.mod)(-c*n-u*s,t);const p=f>i,g=d>i;if(p&&(f=t-f),g&&(d=t-d),f>i||d>i)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:p,k1:f,k2neg:g,k2:d}}}},n.sha256);const y={};function w(e,...t){let r=y[e];if(r===undefined){const t=(0,n.sha256)(Uint8Array.from(e,e=>e.charCodeAt(0)));r=(0,c.concatBytes)(t,t),y[e]=r}return(0,n.sha256)((0,c.concatBytes)(r,...t))}const E=e=>e.toRawBytes(!0).slice(1),v=e=>(0,c.numberToBytesBE)(e,32),x=e=>(0,a.mod)(e,f),B=e=>(0,a.mod)(e,l),S=(()=>r.secp256k1.ProjectivePoint)();function P(e){let t=r.secp256k1.utils.normPrivateKeyToScalar(e),n=S.fromPrivateKey(t);return{scalar:n.hasEvenY()?t:B(-t),bytes:E(n)}}function I(e){(0,c.aInRange)("x",e,h,f);const t=x(e*e);let r=g(x(t*e+BigInt(7)));r%p!==d&&(r=x(-r));const n=new S(e,r,h);return n.assertValidity(),n}const T=c.bytesToNumberBE;function A(...e){return B(T(w("BIP0340/challenge",...e)))}function j(e){return P(e).bytes}function _(e,t,r=(0,o.randomBytes)(32)){const n=(0,c.ensureBytes)("message",e),{bytes:s,scalar:i}=P(t),a=(0,c.ensureBytes)("auxRand",r,32),u=v(i^T(w("BIP0340/aux",a))),f=w("BIP0340/nonce",u,s,n),l=B(T(f));if(l===d)throw new Error("sign failed: k is zero");const{bytes:h,scalar:p}=P(l),m=A(h,s,n),g=new Uint8Array(64);if(g.set(h,0),g.set(v(B(p+m*i)),32),!O(g,n,s))throw new Error("sign: Invalid signature produced");return g}function O(e,t,r){const n=(0,c.ensureBytes)("signature",e,64),o=(0,c.ensureBytes)("message",t),s=(0,c.ensureBytes)("publicKey",r,32);try{const e=I(T(s)),t=T(n.subarray(0,32));if(!(0,c.inRange)(t,h,f))return!1;const r=T(n.subarray(32,64));if(!(0,c.inRange)(r,h,l))return!1;const d=A(v(t),E(e),o),p=(i=e,a=r,u=B(-d),S.BASE.multiplyAndAddUnsafe(i,a,u));return!(!p||!p.hasEvenY()||p.toAffine().x!==t)}catch(e){return!1}var i,a,u}r.schnorr={getPublicKey:j,sign:_,verify:O,utils:{randomPrivateKey:r.secp256k1.utils.randomPrivateKey,lift_x:I,pointToBytes:E,numberToBytesBE:c.numberToBytesBE,bytesToNumberBE:c.bytesToNumberBE,taggedHash:w,mod:a.mod}};const k=(()=>(0,i.isogenyMap)(b,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(e=>BigInt(e)))))(),N=(()=>(0,u.mapToCurveSimpleSWU)(b,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:b.create(BigInt("-11"))}))();r.secp256k1_hasher=(0,i.createHasher)(r.secp256k1.ProjectivePoint,e=>{const{x:t,y:r}=N(b.create(e[0]));return k(t,r)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:b.ORDER,m:1,k:128,expand:"xmd",hash:n.sha256}),r.hashToCurve=r.secp256k1_hasher.hashToCurve,r.encodeToCurve=r.secp256k1_hasher.encodeToCurve}}},{package:"eth-lattice-keyring>gridplus-sdk>ox>@noble/curves",file:"node_modules/gridplus-sdk/node_modules/@noble/curves/secp256k1.js"}],[6585,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){!function(e){var r,n=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,o=Math.ceil,s=Math.floor,i="[BigNumber Error] ",a=i+"Number primitive has more than 15 significant digits: ",c=1e14,u=14,f=9007199254740991,l=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e7,h=1e9;function p(e){var t=0|e;return e>0||e===t?t:t-1}function m(e){for(var t,r,n=1,o=e.length,s=e[0]+"";n<o;){for(t=e[n++]+"",r=u-t.length;r--;t="0"+t);s+=t}for(o=s.length;48===s.charCodeAt(--o););return s.slice(0,o+1||1)}function g(e,t){var r,n,o=e.c,s=t.c,i=e.s,a=t.s,c=e.e,u=t.e;if(!i||!a)return null;if(r=o&&!o[0],n=s&&!s[0],r||n)return r?n?0:-a:i;if(i!=a)return i;if(r=i<0,n=c==u,!o||!s)return n?0:!o^r?1:-1;if(!n)return c>u^r?1:-1;for(a=(c=o.length)<(u=s.length)?c:u,i=0;i<a;i++)if(o[i]!=s[i])return o[i]>s[i]^r?1:-1;return c==u?0:c>u^r?1:-1}function b(e,t,r,n){if(e<t||e>r||e!==s(e))throw Error(i+(n||"Argument")+("number"==typeof e?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function y(e){var t=e.c.length-1;return p(e.e/u)==t&&e.c[t]%2!=0}function w(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function E(e,t,r){var n,o;if(t<0){for(o=r+".";++t;o+=r);e=o+e}else if(++t>(n=e.length)){for(o=r,t-=n;--t;o+=r);e+=o}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}r=function e(t){var r,v,x,B,S,P,I,T,A,j,_=q.prototype={constructor:q,toString:null,valueOf:null},O=new q(1),k=20,N=4,R=-7,C=21,U=-1e7,D=1e7,L=!1,z=1,M=0,G={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},F="0123456789abcdefghijklmnopqrstuvwxyz",H=!0;function q(e,t){var r,o,i,c,l,d,h,p,m=this;if(!(m instanceof q))return new q(e,t);if(null==t){if(e&&!0===e._isBigNumber)return m.s=e.s,void(!e.c||e.e>D?m.c=m.e=null:e.e<U?m.c=[m.e=0]:(m.e=e.e,m.c=e.c.slice()));if((d="number"==typeof e)&&0*e==0){if(m.s=1/e<0?(e=-e,-1):1,e===~~e){for(c=0,l=e;l>=10;l/=10,c++);return void(c>D?m.c=m.e=null:(m.e=c,m.c=[e]))}p=String(e)}else{if(!n.test(p=String(e)))return x(m,p,d);m.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(c=p.indexOf("."))>-1&&(p=p.replace(".","")),(l=p.search(/e/i))>0?(c<0&&(c=l),c+=+p.slice(l+1),p=p.substring(0,l)):c<0&&(c=p.length)}else{if(b(t,2,F.length,"Base"),10==t&&H)return K(m=new q(e),k+m.e+1,N);if(p=String(e),d="number"==typeof e){if(0*e!=0)return x(m,p,d,t);if(m.s=1/e<0?(p=p.slice(1),-1):1,q.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(a+e)}else m.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(r=F.slice(0,t),c=l=0,h=p.length;l<h;l++)if(r.indexOf(o=p.charAt(l))<0){if("."==o){if(l>c){c=h;continue}}else if(!i&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){i=!0,l=-1,c=0;continue}return x(m,String(e),d,t)}d=!1,(c=(p=v(p,t,10,m.s)).indexOf("."))>-1?p=p.replace(".",""):c=p.length}for(l=0;48===p.charCodeAt(l);l++);for(h=p.length;48===p.charCodeAt(--h););if(p=p.slice(l,++h)){if(h-=l,d&&q.DEBUG&&h>15&&(e>f||e!==s(e)))throw Error(a+m.s*e);if((c=c-l-1)>D)m.c=m.e=null;else if(c<U)m.c=[m.e=0];else{if(m.e=c,m.c=[],l=(c+1)%u,c<0&&(l+=u),l<h){for(l&&m.c.push(+p.slice(0,l)),h-=u;l<h;)m.c.push(+p.slice(l,l+=u));l=u-(p=p.slice(l)).length}else l-=h;for(;l--;p+="0");m.c.push(+p)}}else m.c=[m.e=0]}function $(e,t,r,n){var o,s,i,a,c;if(null==r?r=N:b(r,0,8),!e.c)return e.toString();if(o=e.c[0],i=e.e,null==t)c=m(e.c),c=1==n||2==n&&(i<=R||i>=C)?w(c,i):E(c,i,"0");else if(s=(e=K(new q(e),t,r)).e,a=(c=m(e.c)).length,1==n||2==n&&(t<=s||s<=R)){for(;a<t;c+="0",a++);c=w(c,s)}else if(t-=i+(2===n&&s>i),c=E(c,s,"0"),s+1>a){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=s-a)>0)for(s+1==a&&(c+=".");t--;c+="0");return e.s<0&&o?"-"+c:c}function V(e,t){for(var r,n,o=1,s=new q(e[0]);o<e.length;o++)(!(n=new q(e[o])).s||(r=g(s,n))===t||0===r&&s.s===t)&&(s=n);return s}function W(e,t,r){for(var n=1,o=t.length;!t[--o];t.pop());for(o=t[0];o>=10;o/=10,n++);return(r=n+r*u-1)>D?e.c=e.e=null:r<U?e.c=[e.e=0]:(e.e=r,e.c=t),e}function K(e,t,r,n){var i,a,f,d,h,p,m,g=e.c,b=l;if(g){e:{for(i=1,d=g[0];d>=10;d/=10,i++);if((a=t-i)<0)a+=u,f=t,h=g[p=0],m=s(h/b[i-f-1]%10);else if((p=o((a+1)/u))>=g.length){if(!n)break e;for(;g.length<=p;g.push(0));h=m=0,i=1,f=(a%=u)-u+1}else{for(h=d=g[p],i=1;d>=10;d/=10,i++);m=(f=(a%=u)-u+i)<0?0:s(h/b[i-f-1]%10)}if(n=n||t<0||null!=g[p+1]||(f<0?h:h%b[i-f-1]),n=r<4?(m||n)&&(0==r||r==(e.s<0?3:2)):m>5||5==m&&(4==r||n||6==r&&(a>0?f>0?h/b[i-f]:0:g[p-1])%10&1||r==(e.s<0?8:7)),t<1||!g[0])return g.length=0,n?(t-=e.e+1,g[0]=b[(u-t%u)%u],e.e=-t||0):g[0]=e.e=0,e;if(0==a?(g.length=p,d=1,p--):(g.length=p+1,d=b[u-a],g[p]=f>0?s(h/b[i-f]%b[f])*d:0),n)for(;;){if(0==p){for(a=1,f=g[0];f>=10;f/=10,a++);for(f=g[0]+=d,d=1;f>=10;f/=10,d++);a!=d&&(e.e++,g[0]==c&&(g[0]=1));break}if(g[p]+=d,g[p]!=c)break;g[p--]=0,d=1}for(a=g.length;0===g[--a];g.pop());}e.e>D?e.c=e.e=null:e.e<U&&(e.c=[e.e=0])}return e}function Z(e){var t,r=e.e;return null===r?e.toString():(t=m(e.c),t=r<=R||r>=C?w(t,r):E(t,r,"0"),e.s<0?"-"+t:t)}return q.clone=e,q.ROUND_UP=0,q.ROUND_DOWN=1,q.ROUND_CEIL=2,q.ROUND_FLOOR=3,q.ROUND_HALF_UP=4,q.ROUND_HALF_DOWN=5,q.ROUND_HALF_EVEN=6,q.ROUND_HALF_CEIL=7,q.ROUND_HALF_FLOOR=8,q.EUCLID=9,q.config=q.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(i+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(b(r=e[t],0,h,t),k=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(b(r=e[t],0,8,t),N=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(b(r[0],-h,0,t),b(r[1],0,h,t),R=r[0],C=r[1]):(b(r,-h,h,t),R=-(C=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)b(r[0],-h,-1,t),b(r[1],1,h,t),U=r[0],D=r[1];else{if(b(r,-h,h,t),!r)throw Error(i+t+" cannot be zero: "+r);U=-(D=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(i+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw L=!r,Error(i+"crypto unavailable");L=r}else L=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(b(r=e[t],0,9,t),z=r),e.hasOwnProperty(t="POW_PRECISION")&&(b(r=e[t],0,h,t),M=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(i+t+" not an object: "+r);G=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(i+t+" invalid: "+r);H="0123456789"==r.slice(0,10),F=r}}return{DECIMAL_PLACES:k,ROUNDING_MODE:N,EXPONENTIAL_AT:[R,C],RANGE:[U,D],CRYPTO:L,MODULO_MODE:z,POW_PRECISION:M,FORMAT:G,ALPHABET:F}},q.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!q.DEBUG)return!0;var t,r,n=e.c,o=e.e,a=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===a||-1===a)&&o>=-h&&o<=h&&o===s(o)){if(0===n[0]){if(0===o&&1===n.length)return!0;break e}if((t=(o+1)%u)<1&&(t+=u),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||r>=c||r!==s(r))break e;if(0!==r)return!0}}}else if(null===n&&null===o&&(null===a||1===a||-1===a))return!0;throw Error(i+"Invalid BigNumber: "+e)},q.maximum=q.max=function(){return V(arguments,-1)},q.minimum=q.min=function(){return V(arguments,1)},q.random=(B=9007199254740992,S=Math.random()*B&2097151?function(){return s(Math.random()*B)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,a,c,f=0,d=[],p=new q(O);if(null==e?e=k:b(e,0,h),a=o(e/u),L)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(a*=2));f<a;)(c=131072*t[f]+(t[f+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[f]=r[0],t[f+1]=r[1]):(d.push(c%1e14),f+=2);f=a/2}else{if(!crypto.randomBytes)throw L=!1,Error(i+"crypto unavailable");for(t=crypto.randomBytes(a*=7);f<a;)(c=281474976710656*(31&t[f])+1099511627776*t[f+1]+4294967296*t[f+2]+16777216*t[f+3]+(t[f+4]<<16)+(t[f+5]<<8)+t[f+6])>=9e15?crypto.randomBytes(7).copy(t,f):(d.push(c%1e14),f+=7);f=a/7}if(!L)for(;f<a;)(c=S())<9e15&&(d[f++]=c%1e14);for(a=d[--f],e%=u,a&&e&&(c=l[u-e],d[f]=s(a/c)*c);0===d[f];d.pop(),f--);if(f<0)d=[n=0];else{for(n=-1;0===d[0];d.splice(0,1),n-=u);for(f=1,c=d[0];c>=10;c/=10,f++);f<u&&(n-=u-f)}return p.e=n,p.c=d,p}),q.sum=function(){for(var e=1,t=arguments,r=new q(t[0]);e<t.length;)r=r.plus(t[e++]);return r},v=function(){var e="0123456789";function t(e,t,r,n){for(var o,s,i=[0],a=0,c=e.length;a<c;){for(s=i.length;s--;i[s]*=t);for(i[0]+=n.indexOf(e.charAt(a++)),o=0;o<i.length;o++)i[o]>r-1&&(null==i[o+1]&&(i[o+1]=0),i[o+1]+=i[o]/r|0,i[o]%=r)}return i.reverse()}return function(n,o,s,i,a){var c,u,f,l,d,h,p,g,b=n.indexOf("."),y=k,w=N;for(b>=0&&(l=M,M=0,n=n.replace(".",""),h=(g=new q(o)).pow(n.length-b),M=l,g.c=t(E(m(h.c),h.e,"0"),10,s,e),g.e=g.c.length),f=l=(p=t(n,o,s,a?(c=F,e):(c=e,F))).length;0==p[--l];p.pop());if(!p[0])return c.charAt(0);if(b<0?--f:(h.c=p,h.e=f,h.s=i,p=(h=r(h,g,y,w,s)).c,d=h.r,f=h.e),b=p[u=f+y+1],l=s/2,d=d||u<0||null!=p[u+1],d=w<4?(null!=b||d)&&(0==w||w==(h.s<0?3:2)):b>l||b==l&&(4==w||d||6==w&&1&p[u-1]||w==(h.s<0?8:7)),u<1||!p[0])n=d?E(c.charAt(1),-y,c.charAt(0)):c.charAt(0);else{if(p.length=u,d)for(--s;++p[--u]>s;)p[u]=0,u||(++f,p=[1].concat(p));for(l=p.length;!p[--l];);for(b=0,n="";b<=l;n+=c.charAt(p[b++]));n=E(n,f,c.charAt(0))}return n}}(),r=function(){function e(e,t,r){var n,o,s,i,a=0,c=e.length,u=t%d,f=t/d|0;for(e=e.slice();c--;)a=((o=u*(s=e[c]%d)+(n=f*s+(i=e[c]/d|0)*u)%d*d+a)/r|0)+(n/d|0)+f*i,e[c]=o%r;return a&&(e=[a].concat(e)),e}function t(e,t,r,n){var o,s;if(r!=n)s=r>n?1:-1;else for(o=s=0;o<r;o++)if(e[o]!=t[o]){s=e[o]>t[o]?1:-1;break}return s}function r(e,t,r,n){for(var o=0;r--;)e[r]-=o,o=e[r]<t[r]?1:0,e[r]=o*n+e[r]-t[r];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,o,i,a,f){var l,d,h,m,g,b,y,w,E,v,x,B,S,P,I,T,A,j=n.s==o.s?1:-1,_=n.c,O=o.c;if(!(_&&_[0]&&O&&O[0]))return new q(n.s&&o.s&&(_?!O||_[0]!=O[0]:O)?_&&0==_[0]||!O?0*j:j/0:NaN);for(E=(w=new q(j)).c=[],j=i+(d=n.e-o.e)+1,f||(f=c,d=p(n.e/u)-p(o.e/u),j=j/u|0),h=0;O[h]==(_[h]||0);h++);if(O[h]>(_[h]||0)&&d--,j<0)E.push(1),m=!0;else{for(P=_.length,T=O.length,h=0,j+=2,(g=s(f/(O[0]+1)))>1&&(O=e(O,g,f),_=e(_,g,f),T=O.length,P=_.length),S=T,x=(v=_.slice(0,T)).length;x<T;v[x++]=0);A=O.slice(),A=[0].concat(A),I=O[0],O[1]>=f/2&&I++;do{if(g=0,(l=t(O,v,T,x))<0){if(B=v[0],T!=x&&(B=B*f+(v[1]||0)),(g=s(B/I))>1)for(g>=f&&(g=f-1),y=(b=e(O,g,f)).length,x=v.length;1==t(b,v,y,x);)g--,r(b,T<y?A:O,y,f),y=b.length,l=1;else 0==g&&(l=g=1),y=(b=O.slice()).length;if(y<x&&(b=[0].concat(b)),r(v,b,x,f),x=v.length,-1==l)for(;t(O,v,T,x)<1;)g++,r(v,T<x?A:O,x,f),x=v.length}else 0===l&&(g++,v=[0]);E[h++]=g,v[0]?v[x++]=_[S]||0:(v=[_[S]],x=1)}while((S++<P||null!=v[0])&&j--);m=null!=v[0],E[0]||E.splice(0,1)}if(f==c){for(h=1,j=E[0];j>=10;j/=10,h++);K(w,i+(w.e=h+d*u-1)+1,a,m)}else w.e=d,w.r=+m;return w}}(),P=/^(-?)0([xbo])(?=\w[\w.]*$)/i,I=/^([^.]+)\.$/,T=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,j=/^\s*\+(?=[\w.])|^\s+|\s+$/g,x=function(e,t,r,n){var o,s=r?t:t.replace(j,"");if(A.test(s))e.s=isNaN(s)?null:s<0?-1:1;else{if(!r&&(s=s.replace(P,function(e,t,r){return o="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=o?e:t}),n&&(o=n,s=s.replace(I,"$1").replace(T,"0.$1")),t!=s))return new q(s,o);if(q.DEBUG)throw Error(i+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},_.absoluteValue=_.abs=function(){var e=new q(this);return e.s<0&&(e.s=1),e},_.comparedTo=function(e,t){return g(this,new q(e,t))},_.decimalPlaces=_.dp=function(e,t){var r,n,o,s=this;if(null!=e)return b(e,0,h),null==t?t=N:b(t,0,8),K(new q(s),e+s.e+1,t);if(!(r=s.c))return null;if(n=((o=r.length-1)-p(this.e/u))*u,o=r[o])for(;o%10==0;o/=10,n--);return n<0&&(n=0),n},_.dividedBy=_.div=function(e,t){return r(this,new q(e,t),k,N)},_.dividedToIntegerBy=_.idiv=function(e,t){return r(this,new q(e,t),0,1)},_.exponentiatedBy=_.pow=function(e,t){var r,n,a,c,f,l,d,h,p=this;if((e=new q(e)).c&&!e.isInteger())throw Error(i+"Exponent not an integer: "+Z(e));if(null!=t&&(t=new q(t)),f=e.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!e.c||!e.c[0])return h=new q(Math.pow(+Z(p),f?e.s*(2-y(e)):+Z(e))),t?h.mod(t):h;if(l=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new q(NaN);(n=!l&&p.isInteger()&&t.isInteger())&&(p=p.mod(t))}else{if(e.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||f&&p.c[1]>=24e7:p.c[0]<8e13||f&&p.c[0]<=9999975e7)))return c=p.s<0&&y(e)?-0:0,p.e>-1&&(c=1/c),new q(l?1/c:c);M&&(c=o(M/u+2))}for(f?(r=new q(.5),l&&(e.s=1),d=y(e)):d=(a=Math.abs(+Z(e)))%2,h=new q(O);;){if(d){if(!(h=h.times(p)).c)break;c?h.c.length>c&&(h.c.length=c):n&&(h=h.mod(t))}if(a){if(0===(a=s(a/2)))break;d=a%2}else if(K(e=e.times(r),e.e+1,1),e.e>14)d=y(e);else{if(0===(a=+Z(e)))break;d=a%2}p=p.times(p),c?p.c&&p.c.length>c&&(p.c.length=c):n&&(p=p.mod(t))}return n?h:(l&&(h=O.div(h)),t?h.mod(t):c?K(h,M,N,undefined):h)},_.integerValue=function(e){var t=new q(this);return null==e?e=N:b(e,0,8),K(t,t.e+1,e)},_.isEqualTo=_.eq=function(e,t){return 0===g(this,new q(e,t))},_.isFinite=function(){return!!this.c},_.isGreaterThan=_.gt=function(e,t){return g(this,new q(e,t))>0},_.isGreaterThanOrEqualTo=_.gte=function(e,t){return 1===(t=g(this,new q(e,t)))||0===t},_.isInteger=function(){return!!this.c&&p(this.e/u)>this.c.length-2},_.isLessThan=_.lt=function(e,t){return g(this,new q(e,t))<0},_.isLessThanOrEqualTo=_.lte=function(e,t){return-1===(t=g(this,new q(e,t)))||0===t},_.isNaN=function(){return!this.s},_.isNegative=function(){return this.s<0},_.isPositive=function(){return this.s>0},_.isZero=function(){return!!this.c&&0==this.c[0]},_.minus=function(e,t){var r,n,o,s,i=this,a=i.s;if(t=(e=new q(e,t)).s,!a||!t)return new q(NaN);if(a!=t)return e.s=-t,i.plus(e);var f=i.e/u,l=e.e/u,d=i.c,h=e.c;if(!f||!l){if(!d||!h)return d?(e.s=-t,e):new q(h?i:NaN);if(!d[0]||!h[0])return h[0]?(e.s=-t,e):new q(d[0]?i:3==N?-0:0)}if(f=p(f),l=p(l),d=d.slice(),a=f-l){for((s=a<0)?(a=-a,o=d):(l=f,o=h),o.reverse(),t=a;t--;o.push(0));o.reverse()}else for(n=(s=(a=d.length)<(t=h.length))?a:t,a=t=0;t<n;t++)if(d[t]!=h[t]){s=d[t]<h[t];break}if(s&&(o=d,d=h,h=o,e.s=-e.s),(t=(n=h.length)-(r=d.length))>0)for(;t--;d[r++]=0);for(t=c-1;n>a;){if(d[--n]<h[n]){for(r=n;r&&!d[--r];d[r]=t);--d[r],d[n]+=c}d[n]-=h[n]}for(;0==d[0];d.splice(0,1),--l);return d[0]?W(e,d,l):(e.s=3==N?-1:1,e.c=[e.e=0],e)},_.modulo=_.mod=function(e,t){var n,o,s=this;return e=new q(e,t),!s.c||!e.s||e.c&&!e.c[0]?new q(NaN):!e.c||s.c&&!s.c[0]?new q(s):(9==z?(o=e.s,e.s=1,n=r(s,e,0,3),e.s=o,n.s*=o):n=r(s,e,0,z),(e=s.minus(n.times(e))).c[0]||1!=z||(e.s=s.s),e)},_.multipliedBy=_.times=function(e,t){var r,n,o,s,i,a,f,l,h,m,g,b,y,w,E,v=this,x=v.c,B=(e=new q(e,t)).c;if(!(x&&B&&x[0]&&B[0]))return!v.s||!e.s||x&&!x[0]&&!B||B&&!B[0]&&!x?e.c=e.e=e.s=null:(e.s*=v.s,x&&B?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=p(v.e/u)+p(e.e/u),e.s*=v.s,(f=x.length)<(m=B.length)&&(y=x,x=B,B=y,o=f,f=m,m=o),o=f+m,y=[];o--;y.push(0));for(w=c,E=d,o=m;--o>=0;){for(r=0,g=B[o]%E,b=B[o]/E|0,s=o+(i=f);s>o;)r=((l=g*(l=x[--i]%E)+(a=b*l+(h=x[i]/E|0)*g)%E*E+y[s]+r)/w|0)+(a/E|0)+b*h,y[s--]=l%w;y[s]=r}return r?++n:y.splice(0,1),W(e,y,n)},_.negated=function(){var e=new q(this);return e.s=-e.s||null,e},_.plus=function(e,t){var r,n=this,o=n.s;if(t=(e=new q(e,t)).s,!o||!t)return new q(NaN);if(o!=t)return e.s=-t,n.minus(e);var s=n.e/u,i=e.e/u,a=n.c,f=e.c;if(!s||!i){if(!a||!f)return new q(o/0);if(!a[0]||!f[0])return f[0]?e:new q(a[0]?n:0*o)}if(s=p(s),i=p(i),a=a.slice(),o=s-i){for(o>0?(i=s,r=f):(o=-o,r=a),r.reverse();o--;r.push(0));r.reverse()}for((o=a.length)-(t=f.length)<0&&(r=f,f=a,a=r,t=o),o=0;t;)o=(a[--t]=a[t]+f[t]+o)/c|0,a[t]=c===a[t]?0:a[t]%c;return o&&(a=[o].concat(a),++i),W(e,a,i)},_.precision=_.sd=function(e,t){var r,n,o,s=this;if(null!=e&&e!==!!e)return b(e,1,h),null==t?t=N:b(t,0,8),K(new q(s),e,t);if(!(r=s.c))return null;if(n=(o=r.length-1)*u+1,o=r[o]){for(;o%10==0;o/=10,n--);for(o=r[0];o>=10;o/=10,n++);}return e&&s.e+1>n&&(n=s.e+1),n},_.shiftedBy=function(e){return b(e,-9007199254740991,f),this.times("1e"+e)},_.squareRoot=_.sqrt=function(){var e,t,n,o,s,i=this,a=i.c,c=i.s,u=i.e,f=k+4,l=new q("0.5");if(1!==c||!a||!a[0])return new q(!c||c<0&&(!a||a[0])?NaN:a?i:1/0);if(0==(c=Math.sqrt(+Z(i)))||c==1/0?(((t=m(a)).length+u)%2==0&&(t+="0"),c=Math.sqrt(+t),u=p((u+1)/2)-(u<0||u%2),n=new q(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):n=new q(c+""),n.c[0])for((c=(u=n.e)+f)<3&&(c=0);;)if(s=n,n=l.times(s.plus(r(i,s,f,1))),m(s.c).slice(0,c)===(t=m(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(t=t.slice(c-3,c+1))&&(o||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(K(n,n.e+k+2,1),e=!n.times(n).eq(i));break}if(!o&&(K(s,s.e+k+2,0),s.times(s).eq(i))){n=s;break}f+=4,c+=4,o=1}return K(n,n.e+k+1,N,e)},_.toExponential=function(e,t){return null!=e&&(b(e,0,h),e++),$(this,e,t,1)},_.toFixed=function(e,t){return null!=e&&(b(e,0,h),e=e+this.e+1),$(this,e,t)},_.toFormat=function(e,t,r){var n,o=this;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=G;else if("object"!=typeof r)throw Error(i+"Argument not an object: "+r);if(n=o.toFixed(e,t),o.c){var s,a=n.split("."),c=+r.groupSize,u=+r.secondaryGroupSize,f=r.groupSeparator||"",l=a[0],d=a[1],h=o.s<0,p=h?l.slice(1):l,m=p.length;if(u&&(s=c,c=u,u=s,m-=s),c>0&&m>0){for(s=m%c||c,l=p.substr(0,s);s<m;s+=c)l+=f+p.substr(s,c);u>0&&(l+=f+p.slice(s)),h&&(l="-"+l)}n=d?l+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?d.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):d):l}return(r.prefix||"")+n+(r.suffix||"")},_.toFraction=function(e){var t,n,o,s,a,c,f,d,h,p,g,b,y=this,w=y.c;if(null!=e&&(!(f=new q(e)).isInteger()&&(f.c||1!==f.s)||f.lt(O)))throw Error(i+"Argument "+(f.isInteger()?"out of range: ":"not an integer: ")+Z(f));if(!w)return new q(y);for(t=new q(O),h=n=new q(O),o=d=new q(O),b=m(w),a=t.e=b.length-y.e-1,t.c[0]=l[(c=a%u)<0?u+c:c],e=!e||f.comparedTo(t)>0?a>0?t:h:f,c=D,D=1/0,f=new q(b),d.c[0]=0;p=r(f,t,0,1),1!=(s=n.plus(p.times(o))).comparedTo(e);)n=o,o=s,h=d.plus(p.times(s=h)),d=s,t=f.minus(p.times(s=t)),f=s;return s=r(e.minus(n),o,0,1),d=d.plus(s.times(h)),n=n.plus(s.times(o)),d.s=h.s=y.s,g=r(h,o,a*=2,N).minus(y).abs().comparedTo(r(d,n,a,N).minus(y).abs())<1?[h,o]:[d,n],D=c,g},_.toNumber=function(){return+Z(this)},_.toPrecision=function(e,t){return null!=e&&b(e,1,h),$(this,e,t,2)},_.toString=function(e){var t,r=this,n=r.s,o=r.e;return null===o?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(null==e?t=o<=R||o>=C?w(m(r.c),o):E(m(r.c),o,"0"):10===e&&H?t=E(m((r=K(new q(r),k+o+1,N)).c),r.e,"0"):(b(e,2,F.length,"Base"),t=v(E(m(r.c),o,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},_.valueOf=_.toJSON=function(){return Z(this)},_._isBigNumber=!0,null!=t&&q.set(t),q}(),r.default=r.BigNumber=r,"function"==typeof define&&define.amd?define(function(){return r}):void 0!==t&&t.exports?t.exports=r:(e||(e="undefined"!=typeof self&&self?self:window),e.BigNumber=r)}(void 0)}}},{package:"eth-lattice-keyring>gridplus-sdk>bignumber.js",file:"node_modules/gridplus-sdk/node_modules/bignumber.js/bignumber.js"}],[6586,{bs58:6193},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),o=e(r);if(!(n[0]^o[0]|n[1]^o[1]|n[2]^o[2]|n[3]^o[3]))return r}return{encode:function(t){var r=Uint8Array.from(t),n=e(r),s=r.length+4,i=new Uint8Array(s);return i.set(r,0),i.set(n.subarray(0,4),r.length),o.default.encode(i)},decode:function(e){var r=t(o.default.decode(e));if(null==r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=o.default.decodeUnsafe(e);if(null!=r)return t(r)}}};var o=n(e("bs58"))}}},{package:"eth-lattice-keyring>gridplus-sdk>bs58check",file:"node_modules/gridplus-sdk/node_modules/bs58check/src/cjs/base.cjs"}],[6587,{"./base.cjs":6586,"@noble/hashes/sha256":5212},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var o=e("@noble/hashes/sha256"),s=n(e("./base.cjs"));r.default=(0,s.default)(function(e){return(0,o.sha256)((0,o.sha256)(e))})}}},{package:"eth-lattice-keyring>gridplus-sdk>bs58check",file:"node_modules/gridplus-sdk/node_modules/bs58check/src/cjs/index.cjs"}],[6588,{"bignumber.js":6585},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n,o;n=void 0,o=e=>{return t={68:(e,t,r)=>{const{BigNumber:n}=r(905);let o=null;const s=new n("0x20000000000000"),i=new n(2);function a(e,t){if(t.isNaN())return e._pushNaN();if(!t.isFinite())return e._pushInfinity(t.isNegative()?-1/0:1/0);if(t.isInteger())return e._pushJSBigint(BigInt(t.toFixed()));if(!e._pushTag(4)||!e._pushInt(2,4))return!1;const r=t.decimalPlaces(),n=t.shiftedBy(r);return!!e._pushIntNum(-r)&&(n.abs().isLessThan(s)?e._pushIntNum(n.toNumber()):e._pushJSBigint(BigInt(n.toFixed())))}function c(e){return new n(e[1]).shiftedBy(e[0])}function u(e){return i.pow(e[0]).times(e[1])}function f(e){return o=e,o.Encoder.SEMANTIC_TYPES[n.name]=a,o.Tagged.TAGS[4]=c,o.Tagged.TAGS[5]=u,o}f.BigNumber=n,e.exports=f},905:t=>{t.exports=e}},r={},function e(n){var o=r[n];if(void 0!==o)return o.exports;var s=r[n]={exports:{}};return t[n](s,s.exports,e),s.exports}(68);var t,r},"object"==typeof r&&"object"==typeof t?t.exports=o(e("bignumber.js")):"function"==typeof define&&define.amd?define([],o):"object"==typeof r?r.cborBigDecimal=o(e("bignumber.js")):n.cborBigDecimal=o(n.BigNumber)}}},{package:"eth-lattice-keyring>gridplus-sdk>cbor-bigdecimal",file:"node_modules/gridplus-sdk/node_modules/cbor-bigdecimal/dist/cbor-bigdecimal.js"}],[6589,{"./internal/abi.js":6657,abitype:6004},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.format=function(e){return n.formatAbi(e)},r.from=function(e){return o.isSignatures(e)?n.parseAbi(e):e};const n=e("abitype"),o=e("./internal/abi.js")}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Abi.js"}],[659,{"../../../shared/lib/sentry":8614,"@metamask/utils":3935,lodash:7093},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0,r.migrate=f,r.version=void 0;var n=e("@metamask/utils"),o=e("lodash"),s=e("../../../shared/lib/sentry");const i=r.version=207,a="0x531",c="seitrace.com",u="https://seiscan.io/";async function f(e,t){e.meta.version=i;const r=(0,o.cloneDeep)(e),f=new Set;try{!function(e,t){const r=function(e){if(!(0,n.hasProperty)(e,"NetworkController"))return undefined;const t=e.NetworkController;if(!function(e){if(!(0,n.isObject)(e))return!1;if(!(0,n.hasProperty)(e,"networkConfigurationsByChainId")||!(0,n.isObject)(e.networkConfigurationsByChainId))return!1;if(!(0,n.hasProperty)(e,"selectedNetworkClientId")||"string"!=typeof e.selectedNetworkClientId)return!1;return!0}(t))return undefined;return t}(e);if(r===undefined)return e;const{networkConfigurationsByChainId:o}=r;if(!(0,n.hasProperty)(o,a))return e;const s=o[a];if(f=s,!((0,n.isObject)(f)&&(0,n.hasProperty)(f,"chainId")&&"string"==typeof f.chainId&&(0,n.isHexString)(f.chainId)&&(0,n.hasProperty)(f,"blockExplorerUrls")&&Array.isArray(f.blockExplorerUrls)&&f.blockExplorerUrls.every(e=>"string"==typeof e)))return console.warn(`Migration ${i}: Invalid Sei Mainnet network configuration, skip the migration`),e;var f;let l=!1;const d=s.blockExplorerUrls.map(e=>{try{if(new URL(e).hostname===c)return l=!0,u}catch{}return e});l&&(s.blockExplorerUrls=d,t.add("NetworkController"))}(r.data,f),e.data=r.data,f.forEach(e=>t.add(e))}catch(e){console.error(e),(0,s.captureException)(new Error(`Migration #${i}: ${(0,n.getErrorMessage)(e)}`))}}r.default=f}}},{package:"$root$",file:"app/scripts/migrations/207.ts"}],[6590,{"./AbiItem.js":6594,"./AbiParameters.js":6595,"./Hex.js":6621,abitype:6004},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.decode=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r]=e;return[a(t),r]}return e})(),{bytecode:n}=r;if(0===t.inputs?.length)return undefined;const o=r.data.replace(n,"0x");return s.decode(t.inputs,o)},r.encode=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r]=e;return[a(t),r]}return e})(),{bytecode:n,args:o}=r;return i.concat(n,t.inputs?.length&&o?.length?s.encode(t.inputs,o):"0x")},r.format=function(e){return n.formatAbiItem(e)},r.from=function(e){return o.from(e)},r.fromAbi=a;const n=e("abitype"),o=e("./AbiItem.js"),s=e("./AbiParameters.js"),i=e("./Hex.js");function a(e){const t=e.find(e=>"constructor"===e.type);if(!t)throw new o.NotFoundError({name:"constructor"});return t}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiConstructor.js"}],[6591,{"./AbiItem.js":6594,"./AbiParameters.js":6595,"./Hex.js":6621,abitype:6004},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.solidityPanicSelector=r.solidityPanic=r.solidityErrorSelector=r.solidityError=r.panicReasons=void 0,r.decode=function(...e){const[t,r,n={}]=(()=>{if(Array.isArray(e[0])){const[t,r,n,o]=e;return[c(t,r),n,o]}return e})();if(i.size(r)<4)throw new o.InvalidSelectorSizeError({data:r});if(0===t.inputs?.length)return undefined;const a=s.decode(t.inputs,i.slice(r,4),n);if(a&&1===Object.keys(a).length)return Array.isArray(a)?a[0]:Object.values(a)[0];return a},r.encode=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r,...n]=e;return[c(t,r),n]}const[t,...r]=e;return[t,r]})(),n=u(t),o=r.length>0?s.encode(t.inputs,r[0]):undefined;return o?i.concat(n,o):n},r.format=function(e){return n.formatAbiItem(e)},r.from=a,r.fromAbi=c,r.getSelector=u;const n=e("abitype"),o=e("./AbiItem.js"),s=e("./AbiParameters.js"),i=e("./Hex.js");function a(e,t={}){return o.from(e,t)}function c(e,t,n){if("Error"===t)return r.solidityError;if("Panic"===t)return r.solidityPanic;if(i.validate(t,{strict:!1})){const e=i.slice(t,0,4);if(e===r.solidityErrorSelector)return r.solidityError;if(e===r.solidityPanicSelector)return r.solidityPanic}const s=o.fromAbi(e,t,n);if("error"!==s.type)throw new o.NotFoundError({name:t,type:"error"});return s}function u(e){return o.getSelector(e)}r.panicReasons={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},r.solidityError=a({inputs:[{name:"message",type:"string"}],name:"Error",type:"error"}),r.solidityErrorSelector="0x08c379a0",r.solidityPanic=a({inputs:[{name:"reason",type:"uint8"}],name:"Panic",type:"error"}),r.solidityPanicSelector="0x4e487b71"}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiError.js"}],[6592,{"./AbiItem.js":6594,"./AbiParameters.js":6595,"./Address.js":6598,"./Bytes.js":6610,"./Errors.js":6616,"./Hash.js":6619,"./Hex.js":6621,"./internal/cursor.js":6662,"./internal/errors.js":6665,abitype:6004},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.FilterTypeNotSupportedError=r.SelectorTopicMismatchError=r.TopicsMismatchError=r.DataMismatchError=r.InputNotFoundError=r.ArgsMismatchError=void 0,r.assertArgs=function(e,t,r){if(!t||!r)throw new g({abiEvent:e,expected:t,given:r});function n(e,t,r){return"address"===e.type?i.isEqual(t,r):"string"===e.type?u.keccak256(a.fromString(t))===r:"bytes"===e.type?u.keccak256(t)===r:t===r}if(Array.isArray(t)&&Array.isArray(r))for(const[o,s]of r.entries()){if(null===s||s===undefined)continue;const i=e.inputs[o];if(!i)throw new b({abiEvent:e,name:`${o}`});const a=Array.isArray(s)?s:[s];let c=!1;for(const e of a)n(i,e,t[o])&&(c=!0);if(!c)throw new g({abiEvent:e,expected:t,given:r})}if("object"==typeof t&&!Array.isArray(t)&&"object"==typeof r&&!Array.isArray(r))for(const[o,s]of Object.entries(r)){if(null===s||s===undefined)continue;const i=e.inputs.find(e=>e.name===o);if(!i)throw new b({abiEvent:e,name:o});const a=Array.isArray(s)?s:[s];let c=!1;for(const e of a)n(i,e,t[o])&&(c=!0);if(!c)throw new g({abiEvent:e,expected:t,given:r})}},r.decode=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r,n]=e;return[p(t,r),n]}return e})(),{data:n,topics:o}=r,[i,...a]=o,c=m(t);if(i!==c)throw new E({abiEvent:t,actual:i,expected:c});const{inputs:u}=t,d=u?.every(e=>!("name"in e&&e.name));let h=d?[]:{};const g=u.filter(e=>"indexed"in e&&e.indexed);for(let e=0;e<g.length;e++){const r=g[e],n=a[e];if(!n)throw new w({abiEvent:t,param:r});h[d?e:r.name||e]=(()=>{if("string"===r.type||"bytes"===r.type||"tuple"===r.type||r.type.match(/^(.*)\[(\d+)?\]$/))return n;return(s.decode([r],n)||[])[0]})()}const b=u.filter(e=>!("indexed"in e&&e.indexed));if(b.length>0){if(!n||"0x"===n)throw new y({abiEvent:t,data:"0x",parameters:b,size:0});try{const e=s.decode(b,n);if(e)if(d)h=[...h,...e];else for(let t=0;t<b.length;t++){const r=u.indexOf(b[t]);h[b[t].name||r]=e[t]}}catch(e){if(e instanceof s.DataSizeTooSmallError||e instanceof l.PositionOutOfBoundsError)throw new y({abiEvent:t,data:n,parameters:b,size:f.size(n)});throw e}}return Object.values(h).length>0?h:undefined},r.encode=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r,n]=e;return[p(t,r),n]}const[t,r]=e;return[t,r]})();let n=[];if(r&&t.inputs){const e=t.inputs.filter(e=>"indexed"in e&&e.indexed),o=Array.isArray(r)?r:Object.values(r).length>0?e?.map((e,t)=>r[e.name??t])??[]:[];if(o.length>0){const t=(e,t)=>{if("string"===e.type)return u.keccak256(f.fromString(t));if("bytes"===e.type)return u.keccak256(t);if("tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))throw new v(e.type);return s.encode([e],[t])};n=e?.map((e,r)=>Array.isArray(o[r])?o[r].map((n,s)=>t(e,o[r][s])):void 0!==o[r]&&null!==o[r]?t(e,o[r]):null)??[]}}return{topics:[t.hash?t.hash:m(t),...n]}},r.format=h,r.from=function(e,t={}){return o.from(e,t)},r.fromAbi=p,r.getSelector=m;const n=e("abitype"),o=e("./AbiItem.js"),s=e("./AbiParameters.js"),i=e("./Address.js"),a=e("./Bytes.js"),c=e("./Errors.js"),u=e("./Hash.js"),f=e("./Hex.js"),l=e("./internal/cursor.js"),d=e("./internal/errors.js");function h(e){return n.formatAbiItem(e)}function p(e,t,r){const n=o.fromAbi(e,t,r);if("event"!==n.type)throw new o.NotFoundError({name:t,type:"event"});return n}function m(e){return o.getSignatureHash(e)}class g extends c.BaseError{constructor({abiEvent:e,expected:t,given:r}){super("Given arguments do not match the expected arguments.",{metaMessages:[`Event: ${h(e)}`,"Expected Arguments: "+(t?"":"None"),t?(0,d.prettyPrint)(t):undefined,"Given Arguments: "+(r?"":"None"),r?(0,d.prettyPrint)(r):undefined]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.ArgsMismatchError"})}}r.ArgsMismatchError=g;class b extends c.BaseError{constructor({abiEvent:e,name:t}){super(`Parameter "${t}" not found on \`${h(e)}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.InputNotFoundError"})}}r.InputNotFoundError=b;class y extends c.BaseError{constructor({abiEvent:e,data:t,parameters:r,size:n}){super([`Data size of ${n} bytes is too small for non-indexed event parameters.`].join("\n"),{metaMessages:[`Non-indexed Parameters: (${s.format(r)})`,`Data:   ${t} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.DataMismatchError"}),Object.defineProperty(this,"abiEvent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parameters",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiEvent=e,this.data=t,this.parameters=r,this.size=n}}r.DataMismatchError=y;class w extends c.BaseError{constructor({abiEvent:e,param:t}){super([`Expected a topic for indexed event parameter${t.name?` "${t.name}"`:""} for "${h(e)}".`].join("\n")),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.TopicsMismatchError"}),Object.defineProperty(this,"abiEvent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiEvent=e}}r.TopicsMismatchError=w;class E extends c.BaseError{constructor({abiEvent:e,actual:t,expected:r}){super(`topics[0]="${t}" does not match the expected topics[0]="${r}".`,{metaMessages:[`Event: ${h(e)}`,`Selector: ${r}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.SelectorTopicMismatchError"})}}r.SelectorTopicMismatchError=E;class v extends c.BaseError{constructor(e){super(`Filter type "${e}" is not supported.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiEvent.FilterTypeNotSupportedError"})}}r.FilterTypeNotSupportedError=v}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiEvent.js"}],[6593,{"./AbiItem.js":6594,"./AbiParameters.js":6595,"./Hex.js":6621,abitype:6004},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.decodeData=function(...e){const[t,r]=(()=>{if(Array.isArray(e[0])){const[t,r,n]=e;return[a(t,r),n]}return e})(),{overloads:n}=t;if(i.size(r)<4)throw new o.InvalidSelectorSizeError({data:r});if(0===t.inputs?.length)return undefined;const c=n?a([t,...n],r):t;return i.size(r)<=4?undefined:s.decode(c.inputs,i.slice(r,4))},r.decodeResult=function(...e){const[t,r,n={}]=(()=>{if(Array.isArray(e[0])){const[t,r,n,o]=e;return[a(t,r),n,o]}return e})(),o=s.decode(t.outputs,r,n);if(o&&0===Object.keys(o).length)return undefined;if(o&&1===Object.keys(o).length)return Array.isArray(o)?o[0]:Object.values(o)[0];return o},r.encodeData=function(...e){const[t,r=[]]=(()=>{if(Array.isArray(e[0])){const[t,r,n]=e;return[a(t,r,{args:n}),n]}const[t,r]=e;return[t,r]})(),{overloads:n}=t,o=n?a([t,...n],t.name,{args:r}):t,u=c(o),f=r.length>0?s.encode(o.inputs,r):undefined;return f?i.concat(u,f):u},r.encodeResult=function(...e){const[t,r,n={}]=(()=>{if(Array.isArray(e[0])){const[t,r,n,o]=e;return[a(t,r),n,o]}return e})(),{as:o="Array"}=n,i=1===t.outputs.length?[r]:Array.isArray(r)?r:"Object"===o?Object.values(r):[r];return s.encode(t.outputs,i)},r.format=function(e){return n.formatAbiItem(e)},r.from=function(e,t={}){return o.from(e,t)},r.fromAbi=a,r.getSelector=c;const n=e("abitype"),o=e("./AbiItem.js"),s=e("./AbiParameters.js"),i=e("./Hex.js");function a(e,t,r){const n=o.fromAbi(e,t,r);if("function"!==n.type)throw new o.NotFoundError({name:t,type:"function"});return n}function c(e){return o.getSelector(e)}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiFunction.js"}],[6594,{"./Errors.js":6616,"./Hash.js":6619,"./Hex.js":6621,"./internal/abiItem.js":6658,abitype:6004},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidSelectorSizeError=r.NotFoundError=r.AmbiguityError=void 0,r.format=function(e){return n.formatAbiItem(e)},r.from=function(e,t={}){const{prepare:r=!0}=t,o=Array.isArray(e)||"string"==typeof e?n.parseAbiItem(e):e;return{...o,...r?{hash:l(o)}:{}}},r.fromAbi=c,r.getSelector=u,r.getSignature=f,r.getSignatureHash=l;const n=e("abitype"),o=e("./Errors.js"),s=e("./Hash.js"),i=e("./Hex.js"),a=e("./internal/abiItem.js");function c(e,t,r){const{args:n=[],prepare:o=!0}=r??{},s=i.validate(t,{strict:!1}),c=e.filter(e=>s?"function"===e.type||"error"===e.type?u(e)===i.slice(t,0,4):"event"===e.type&&l(e)===t:"name"in e&&e.name===t);if(0===c.length)throw new h({name:t});if(1===c.length)return{...c[0],...o?{hash:l(c[0])}:{}};let f;for(const e of c){if(!("inputs"in e))continue;if(!n||0===n.length){if(!e.inputs||0===e.inputs.length)return{...e,...o?{hash:l(e)}:{}};continue}if(!e.inputs)continue;if(0===e.inputs.length)continue;if(e.inputs.length!==n.length)continue;if(n.every((t,r)=>{const n="inputs"in e&&e.inputs[r];return!!n&&a.isArgOfType(t,n)})){if(f&&"inputs"in f&&f.inputs){const t=a.getAmbiguousTypes(e.inputs,f.inputs,n);if(t)throw new d({abiItem:e,type:t[0]},{abiItem:f,type:t[1]})}f=e}}const p=(()=>{if(f)return f;const[e,...t]=c;return{...e,overloads:t}})();if(!p)throw new h({name:t});return{...p,...o?{hash:l(p)}:{}}}function u(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,r]=e;return c(t,r)}return e[0]})();return i.slice(l(t),0,4)}function f(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,r]=e;return c(t,r)}return e[0]})(),r="string"==typeof t?t:n.formatAbiItem(t);return a.normalizeSignature(r)}function l(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,r]=e;return c(t,r)}return e[0]})();return"string"!=typeof t&&"hash"in t&&t.hash?t.hash:s.keccak256(i.fromString(f(t)))}class d extends o.BaseError{constructor(e,t){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${e.type}\` in \`${a.normalizeSignature(n.formatAbiItem(e.abiItem))}\`, and`,`\`${t.type}\` in \`${a.normalizeSignature(n.formatAbiItem(t.abiItem))}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.AmbiguityError"})}}r.AmbiguityError=d;class h extends o.BaseError{constructor({name:e,data:t,type:r="item"}){super(`ABI ${r}${e?` with name "${e}"`:t?` with data "${t}"`:""} not found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.NotFoundError"})}}r.NotFoundError=h;class p extends o.BaseError{constructor({data:e}){super(`Selector size is invalid. Expected 4 bytes. Received ${i.size(e)} bytes ("${e}").`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.InvalidSelectorSizeError"})}}r.InvalidSelectorSizeError=p}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiItem.js"}],[6595,{"./Address.js":6598,"./Bytes.js":6610,"./Errors.js":6616,"./Hex.js":6621,"./Solidity.js":6639,"./internal/abiParameters.js":6659,"./internal/cursor.js":6662,abitype:6004},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidTypeError=r.InvalidArrayError=r.LengthMismatchError=r.BytesSizeMismatchError=r.ArrayLengthMismatchError=r.ZeroDataError=r.DataSizeTooSmallError=void 0,r.decode=function(e,t,r={}){const{as:n="Array",checksumAddress:o=!1}=r,i="string"==typeof t?s.fromHex(t):t,f=u.create(i);if(0===s.size(i)&&e.length>0)throw new h;if(s.size(i)&&s.size(i)<32)throw new d({data:"string"==typeof t?t:a.fromBytes(t),parameters:e,size:s.size(i)});let l=0;const p="Array"===n?[]:{};for(let t=0;t<e.length;++t){const r=e[t];f.setPosition(l);const[s,i]=c.decodeParameter(f,r,{checksumAddress:o,staticPosition:0});l+=i,"Array"===n?p.push(s):p[r.name??t]=s}return p},r.encode=function(e,t,r){const{checksumAddress:n=!1}=r??{};if(e.length!==t.length)throw new g({expectedLength:e.length,givenLength:t.length});const o=c.prepareParameters({checksumAddress:n,parameters:e,values:t}),s=c.encode(o);return 0===s.length?"0x":s},r.encodePacked=l,r.format=function(e){return n.formatAbiParameters(e)},r.from=function(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?n.parseAbiParameters(e):e};const n=e("abitype"),o=e("./Address.js"),s=e("./Bytes.js"),i=e("./Errors.js"),a=e("./Hex.js"),c=e("./internal/abiParameters.js"),u=e("./internal/cursor.js"),f=e("./Solidity.js");function l(e,t){if(e.length!==t.length)throw new g({expectedLength:e.length,givenLength:t.length});const r=[];for(let n=0;n<e.length;n++){const o=e[n],s=t[n];r.push(l.encode(o,s))}return a.concat(...r)}!function(e){e.encode=function e(t,r,n=!1){if("address"===t){const e=r;return o.assert(e),a.padLeft(e.toLowerCase(),n?32:0)}if("string"===t)return a.fromString(r);if("bytes"===t)return r;if("bool"===t)return a.padLeft(a.fromBoolean(r),n?32:1);const s=t.match(f.integerRegex);if(s){const[e,t,o="256"]=s,i=Number.parseInt(o,10)/8;return a.fromNumber(r,{size:n?32:i,signed:"int"===t})}const i=t.match(f.bytesRegex);if(i){const[e,t]=i;if(Number.parseInt(t,10)!==(r.length-2)/2)throw new m({expectedSize:Number.parseInt(t,10),value:r});return a.padRight(r,n?32:0)}const c=t.match(f.arrayRegex);if(c&&Array.isArray(r)){const[t,n]=c,o=[];for(let t=0;t<r.length;t++)o.push(e(n,r[t],!0));return 0===o.length?"0x":a.concat(...o)}throw new y(t)}}(l||(r.encodePacked=l={}));class d extends i.BaseError{constructor({data:e,parameters:t,size:r}){super(`Data size of ${r} bytes is too small for given parameters.`,{metaMessages:[`Params: (${n.formatAbiParameters(t)})`,`Data:   ${e} (${r} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}r.DataSizeTooSmallError=d;class h extends i.BaseError{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}r.ZeroDataError=h;class p extends i.BaseError{constructor({expectedLength:e,givenLength:t,type:r}){super(`Array length mismatch for type \`${r}\`. Expected: \`${e}\`. Given: \`${t}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}r.ArrayLengthMismatchError=p;class m extends i.BaseError{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${a.size(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}r.BytesSizeMismatchError=m;class g extends i.BaseError{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${t}`].join("\n")),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}r.LengthMismatchError=g;class b extends i.BaseError{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}r.InvalidArrayError=b;class y extends i.BaseError{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}r.InvalidTypeError=y}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AbiParameters.js"}],[6596,{"./Address.js":6598,"./Errors.js":6616,"./Hash.js":6619,"./Hex.js":6621},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidStorageKeySizeError=void 0,r.fromTupleList=function(e){const t=[];for(let r=0;r<e.length;r++){const[o,a]=e[r];o&&n.assert(o,{strict:!1}),t.push({address:o,storageKeys:a.map(e=>s.validate(e)?e:i.trimLeft(e))})}return t},r.toTupleList=function(e){if(!e||0===e.length)return[];const t=[];for(const{address:r,storageKeys:o}of e){for(let e=0;e<o.length;e++)if(32!==i.size(o[e]))throw new a({storageKey:o[e]});r&&n.assert(r,{strict:!1}),t.push([r,o])}return t};const n=e("./Address.js"),o=e("./Errors.js"),s=e("./Hash.js"),i=e("./Hex.js");class a extends o.BaseError{constructor({storageKey:e}){super(`Size for storage key "${e}" is invalid. Expected 32 bytes. Got ${i.size(e)} bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AccessList.InvalidStorageKeySizeError"})}}r.InvalidStorageKeySizeError=a}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AccessList.js"}],[6597,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0})}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AccountProof.js"}],[6598,{"./Bytes.js":6610,"./Caches.js":6611,"./Errors.js":6616,"./Hash.js":6619,"./PublicKey.js":6630},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidChecksumError=r.InvalidInputError=r.InvalidAddressError=void 0,r.assert=u,r.checksum=f,r.from=l,r.fromPublicKey=function(e,t={}){return l(`0x${i.keccak256(`0x${a.toHex(e).slice(4)}`).substring(26)}`,t)},r.isEqual=function(e,t){return u(e,{strict:!1}),u(t,{strict:!1}),e.toLowerCase()===t.toLowerCase()},r.validate=function(e,t={}){const{strict:r=!0}=t??{};try{return u(e,{strict:r}),!0}catch{return!1}};const n=e("./Bytes.js"),o=e("./Caches.js"),s=e("./Errors.js"),i=e("./Hash.js"),a=e("./PublicKey.js"),c=/^0x[a-fA-F0-9]{40}$/;function u(e,t={}){const{strict:r=!0}=t;if(!c.test(e))throw new d({address:e,cause:new h});if(r){if(e.toLowerCase()===e)return;if(f(e)!==e)throw new d({address:e,cause:new p})}}function f(e){if(o.checksum.has(e))return o.checksum.get(e);u(e,{strict:!1});const t=e.substring(2).toLowerCase(),r=i.keccak256(n.fromString(t),{as:"Bytes"}),s=t.split("");for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&s[e]&&(s[e]=s[e].toUpperCase()),(15&r[e>>1])>=8&&s[e+1]&&(s[e+1]=s[e+1].toUpperCase());const a=`0x${s.join("")}`;return o.checksum.set(e,a),a}function l(e,t={}){const{checksum:r=!1}=t;return u(e),r?f(e):e}class d extends s.BaseError{constructor({address:e,cause:t}){super(`Address "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}r.InvalidAddressError=d;class h extends s.BaseError{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}r.InvalidInputError=h;class p extends s.BaseError{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}r.InvalidChecksumError=p}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Address.js"}],[6599,{"./Bytes.js":6610,"./Hex.js":6621},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.ivLength=void 0,r.decrypt=async function(e,t,s={}){const{as:i=("string"==typeof e?"Hex":"Bytes")}=s,a=n.from(e),c=a.slice(0,r.ivLength),u=a.slice(r.ivLength),f=await globalThis.crypto.subtle.decrypt({name:"AES-GCM",iv:c},t,n.from(u)),l=new Uint8Array(f);return"Bytes"===i?l:o.from(l)},r.encrypt=async function(e,t,s={}){const{as:i=("string"==typeof e?"Hex":"Bytes")}=s,a=n.random(r.ivLength),c=await globalThis.crypto.subtle.encrypt({name:"AES-GCM",iv:a},t,n.from(e)),u=n.concat(a,new Uint8Array(c));return"Bytes"===i?u:o.from(u)},r.getKey=async function(e){const{iterations:t=9e5,password:r,salt:o=s(32)}=e,i=await globalThis.crypto.subtle.importKey("raw",n.fromString(r),{name:"PBKDF2"},!1,["deriveBits","deriveKey"]);return await globalThis.crypto.subtle.deriveKey({name:"PBKDF2",salt:o,iterations:t,hash:"SHA-256"},i,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])},r.randomSalt=s;const n=e("./Bytes.js"),o=e("./Hex.js");function s(e=32){return n.random(e)}r.ivLength=16}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/AesGcm.js"}],[66,{"../../../shared/constants/permissions":8440,"../controllers/permissions":30,"@metamask/keyring-api":2701},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function({messenger:e}){return function(t,r,o,s){const a=e.call("AccountsController:getSelectedAccount");if((0,n.isEvmAccountType)(a.type))return o();if(i.includes(t.method))return s(new Error(`Non-EVM account cannot request this method: ${t.method}`));if("wallet_requestPermissions"===t.method&&t?.params&&Array.isArray(t.params)&&t.params.length>0&&t.params[0]){const e=Object.keys(t.params[0]);if(i.some(t=>e.includes(t)))return s(new Error(`Non-EVM account cannot request this method: ${e.toString()}`))}return o()}};var n=e("@metamask/keyring-api"),o=e("../../../shared/constants/permissions"),s=e("../controllers/permissions");const i=[...Object.values(o.RestrictedEthMethods),...s.unrestrictedEthSigningMethods]}}},{package:"$root$",file:"app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts"}],[660,{"@metamask/utils":3935},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.version=r.migrate=void 0;var n=e("@metamask/utils");const o=r.version=208,s=["isRampCardClosed","nftsDetectionNoticeDismissed","showAccountBanner","showBetaHeader","showNetworkBanner","showPermissionsTour","showTestnetMessageInDropdown","surveyLinkLastClickedOrClosed"],i=["accountDetailsAddress","buyView","currentWindowTab","menuOpen","networksTabSelectedRpcUrl","newNftAddedMessage","removeNftMessage","scrollToBottom","shouldClose","showCopyAddressToast","showNewSrpAddedToast","showNftDetectionEnablementToast","showPasswordChangeToast","showTermsOfUsePopup","snapsInstallPrivacyWarningShown","welcomeScreenSeen"];r.migrate=async(e,t)=>{e.meta.version=o;(function(e){if(!(0,n.hasProperty)(e,"AppStateController")||!(0,n.isObject)(e.AppStateController))return!1;const{AppStateController:t}=e;let r=!1;for(const e of s)(0,n.hasProperty)(t,e)&&(delete t[e],r=!0);return r})(e.data)&&t.add("AppStateController");const r=function(e){const t=new Set,r=[{key:"metamask",value:e},{key:"metamask",value:(0,n.hasProperty)(e,"metamask")&&(0,n.isObject)(e.metamask)?e.metamask:undefined},{key:"appState",value:(0,n.hasProperty)(e,"appState")&&(0,n.isObject)(e.appState)?e.appState:undefined}];for(const{key:e,value:o}of r){if(!(0,n.isObject)(o))continue;let r=!1;for(const e of i)(0,n.hasProperty)(o,e)&&(delete o[e],r=!0);r&&t.add(e)}return t}(e.data);for(const e of r)t.add(e)}}}},{package:"$root$",file:"app/scripts/migrations/208.ts"}],[6600,{"./Hash.js":6619,"./Hex.js":6621,"./Rlp.js":6631,"./Signature.js":6637},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.from=a,r.fromRpc=c,r.fromRpcList=function(e){return e.map(c)},r.fromTuple=u,r.fromTupleList=function(e){const t=[];for(const r of e)t.push(u(r));return t},r.getSignPayload=function(e){return f(e,{presign:!0})},r.hash=f,r.toRpc=l,r.toRpcList=function(e){return e.map(l)},r.toTuple=d,r.toTupleList=function(e){if(!e||0===e.length)return[];const t=[];for(const r of e)t.push(d(r));return t};const n=e("./Hash.js"),o=e("./Hex.js"),s=e("./Rlp.js"),i=e("./Signature.js");function a(e,t={}){return"string"==typeof e.chainId?c(e):{...e,...t.signature}}function c(e){const{address:t,chainId:r,nonce:n}=e,o=i.extract(e);return{address:t,chainId:Number(r),nonce:BigInt(n),...o}}function u(e){const[t,r,n,o,s,c]=e;let u={address:r,chainId:"0x"===t?0:Number(t),nonce:"0x"===n?0n:BigInt(n)};return o&&s&&c&&(u={...u,...i.fromTuple([o,s,c])}),a(u)}function f(e,t={}){const{presign:r}=t;return n.keccak256(o.concat("0x05",s.fromHex(d(r?{address:e.address,chainId:e.chainId,nonce:e.nonce}:e))))}function l(e){const{address:t,chainId:r,nonce:n,...s}=e;return{address:t,chainId:o.fromNumber(r),nonce:o.fromNumber(n),...i.toRpc(s)}}function d(e){const{address:t,chainId:r,nonce:n}=e,s=i.extract(e);return[r?o.fromNumber(r):"0x",t,n?o.fromNumber(n):"0x",...s?i.toTuple(s):[]]}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Authorization.js"}],[6601,{"./Bytes.js":6610,"./Hex.js":6621,"./internal/base58.js":6660},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fromBytes=function(e){return s.from(e)},r.fromHex=function(e){return s.from(e)},r.fromString=function(e){return s.from(n.fromString(e))},r.toBytes=function(e){return n.fromHex(i(e))},r.toHex=i,r.toString=function(e){return o.toString(i(e))};const n=e("./Bytes.js"),o=e("./Hex.js"),s=e("./internal/base58.js");function i(e){let t=BigInt(0),r=0,n=!0;for(let o=0;o<e.length;o++){const i=e[o];if(n&&"1"===i?r++:n=!1,"bigint"!=typeof s.alphabetToInteger[i])throw new Error("invalid base58 character: "+i);t*=58n,t+=s.alphabetToInteger[i]}return r?`0x${"0".repeat(2*r)}${t.toString(16)}`:`0x${t.toString(16)}`}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Base58.js"}],[6602,{"./Bytes.js":6610,"./Hex.js":6621},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fromBytes=u,r.fromHex=function(e,t={}){return u(n.fromHex(e),t)},r.fromString=function(e,t={}){return u(n.fromString(e),t)},r.toBytes=f,r.toHex=function(e){return o.fromBytes(f(e))},r.toString=function(e){return n.toString(f(e))};const n=e("./Bytes.js"),o=e("./Hex.js"),s=new TextEncoder,i=new TextDecoder,a=Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[t,e.charCodeAt(0)])),c={...Object.fromEntries(Array.from("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/").map((e,t)=>[e.charCodeAt(0),t])),["=".charCodeAt(0)]:0,["-".charCodeAt(0)]:62,["_".charCodeAt(0)]:63};function u(e,t={}){const{pad:r=!0,url:n=!1}=t,o=new Uint8Array(4*Math.ceil(e.length/3));for(let t=0,r=0;r<e.length;t+=4,r+=3){const n=(e[r]<<16)+(e[r+1]<<8)+(0|e[r+2]);o[t]=a[n>>18],o[t+1]=a[n>>12&63],o[t+2]=a[n>>6&63],o[t+3]=a[63&n]}const s=e.length%3,c=4*Math.floor(e.length/3)+(s&&s+1);let u=i.decode(new Uint8Array(o.buffer,0,c));return r&&1===s&&(u+="=="),r&&2===s&&(u+="="),n&&(u=u.replaceAll("+","-").replaceAll("/","_")),u}function f(e){const t=e.replace(/=+$/,""),r=t.length,n=new Uint8Array(r+3);s.encodeInto(t+"===",n);for(let e=0,r=0;e<t.length;e+=4,r+=3){const t=(c[n[e]]<<18)+(c[n[e+1]]<<12)+(c[n[e+2]]<<6)+c[n[e+3]];n[r]=t>>16,n[r+1]=t>>8&255,n[r+2]=255&t}const o=3*(r>>2)+(r%4&&r%4-1);return new Uint8Array(n.buffer,0,o)}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Base64.js"}],[6603,{"./Bytes.js":6610,"@noble/hashes/blake3":5203},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.create=function(){return{root:{type:"empty"}}},r.insert=function(e,t,r){const n=o.slice(t,0,31),i=o.slice(t,31)[0];if("empty"===e.root.type)return e.root=a(n),void(e.root.values[i]=r);e.root=function e(t,r,n,i,u){let f=t;if("empty"===f.type)return f=a(r),f.values[n]=i,f;const l=c(r);if("stem"===f.type)return o.isEqual(f.stem,r)?(f.values[n]=i,f):s(f,l,c(f.stem),n,i,u);if("internal"===f.type)return 0===l[u]?f.left=e(f.left,r,n,i,u+1):f.right=e(f.right,r,n,i,u+1),f;return{type:"empty"}}(e.root,n,i,r,0)},r.merkelize=function(e){return function e(t){if("empty"===t.type)return new Uint8Array(32).fill(0);if("internal"===t.type){const r=e(t.left),n=e(t.right);return u(o.concat(r,n))}let r=t.values.map(u);for(;r.length>1;){const e=[];for(let t=0;t<r.length;t+=2)e.push(u(o.concat(r[t],r[t+1])));r=e}return u(o.concat(t.stem,new Uint8Array(1).fill(0),r[0]))}(e.root)};const n=e("@noble/hashes/blake3"),o=e("./Bytes.js");function s(e,t,r,n,o,c){if(t[c]===r[c]){const a=i();return 0===t[c]?a.left=s(e,t,r,n,o,c+1):a.right=s(e,t,r,n,o,c+1),a}const u=i(),f=t[c],l=function(e){const t=new Uint8Array(e.length/8);for(let r=0;r<e.length;r+=8){let n=0;for(let t=0;t<8;t++)n|=e[r+t]<<7-t;t[r/8]=n}return t}(t);return 0===f?(u.left=a(l),u.left.values[n]=o,u.right=e):(u.right=a(l),u.right.values[n]=o,u.left=e),u}function i(){return{left:{type:"empty"},right:{type:"empty"},type:"internal"}}function a(e){return{stem:e,values:Array.from({length:256},()=>undefined),type:"stem"}}function c(e){const t=[];for(const r of e)for(let e=0;e<8;e++)t.push(r>>7-e&1);return t}function u(e){return e&&e.some(e=>0!==e)?(0,n.blake3)(e):new Uint8Array(32).fill(0)}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/BinaryStateTree.js"}],[6604,{"./Bytes.js":6610,"./Errors.js":6616,"./Hash.js":6619,"./Hex.js":6621,"./Kzg.js":6624,"./internal/cursor.js":6662},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidVersionedHashVersionError=r.InvalidVersionedHashSizeError=r.EmptyBlobVersionedHashesError=r.EmptyBlobError=r.BlobSizeTooLargeError=r.maxBytesPerTransaction=r.bytesPerBlob=r.fieldElementsPerBlob=r.bytesPerFieldElement=void 0,r.commitmentsToVersionedHashes=u,r.commitmentToVersionedHash=f,r.from=function(e,t={}){const o=t.as??("string"==typeof e?"Hex":"Bytes"),s="string"==typeof e?n.fromHex(e):e,c=n.size(s);if(!c)throw new m;if(c>r.maxBytesPerTransaction)throw new p({maxSize:r.maxBytesPerTransaction,size:c});const u=[];let f=!0,l=0;for(;f;){const e=a.create(new Uint8Array(r.bytesPerBlob));let t=0;for(;t<r.fieldElementsPerBlob;){const n=s.slice(l,l+(r.bytesPerFieldElement-1));if(e.pushByte(0),e.pushBytes(n),n.length<31){e.pushByte(128),f=!1;break}t++,l+=31}u.push(e)}return"Bytes"===o?u.map(e=>e.bytes):u.map(e=>i.fromBytes(e.bytes))},r.sidecarsToVersionedHashes=function(e,t={}){const{version:r}=t,n=t.as??("string"==typeof e[0].blob?"Hex":"Bytes"),o=[];for(const{commitment:t}of e)o.push(f(t,{as:n,version:r}));return o},r.to=l,r.toHex=function(e){return l(e,"Hex")},r.toBytes=function(e){return l(e,"Bytes")},r.toCommitments=d,r.toProofs=h,r.toSidecars=function(e,t){const{kzg:r}=t,n=t.commitments??d(e,{kzg:r}),o=t.proofs??h(e,{commitments:n,kzg:r}),s=[];for(let t=0;t<e.length;t++)s.push({blob:e[t],commitment:n[t],proof:o[t]});return s},r.toVersionedHashes=function(e,t){return u(d(e,t),t)};const n=e("./Bytes.js"),o=e("./Errors.js"),s=e("./Hash.js"),i=e("./Hex.js"),a=e("./internal/cursor.js"),c=e("./Kzg.js");function u(e,t={}){const{version:r}=t,n=t.as??("string"==typeof e[0]?"Hex":"Bytes"),o=[];for(const t of e)o.push(f(t,{as:n,version:r}));return o}function f(e,t={}){const{version:r=1}=t,n=t.as??("string"==typeof e?"Hex":"Bytes"),o=s.sha256(e,{as:"Bytes"});return o.set([r],0),"Bytes"===n?o:i.fromBytes(o)}function l(e,t){const r=t??("string"==typeof e[0]?"Hex":"Bytes"),o="string"==typeof e[0]?e.map(e=>n.fromHex(e)):e,s=o.reduce((e,t)=>e+t.length,0),c=a.create(new Uint8Array(s));let u=!0;for(const e of o){const t=a.create(e);for(;u&&t.position<e.length;){t.incrementPosition(1);let r=31;e.length-t.position<31&&(r=e.length-t.position);for(const e in Array.from({length:r})){const e=t.readByte();if(128===e&&!t.inspectBytes(t.remaining).includes(128)){u=!1;break}c.pushByte(e)}}}const f=c.bytes.slice(0,c.position);return"Hex"===r?i.fromBytes(f):f}function d(e,t){const{kzg:r}=t,o=t.as??("string"==typeof e[0]?"Hex":"Bytes"),s="string"==typeof e[0]?e.map(e=>n.fromHex(e)):e,a=[];for(const e of s)a.push(Uint8Array.from(r.blobToKzgCommitment(e)));return"Bytes"===o?a:a.map(e=>i.fromBytes(e))}function h(e,t){const{kzg:r}=t,o=t.as??("string"==typeof e[0]?"Hex":"Bytes"),s="string"==typeof e[0]?e.map(e=>n.fromHex(e)):e,a="string"==typeof t.commitments[0]?t.commitments.map(e=>n.fromHex(e)):t.commitments,c=[];for(let e=0;e<s.length;e++){const t=s[e],n=a[e];c.push(Uint8Array.from(r.computeBlobKzgProof(t,n)))}return"Bytes"===o?c:c.map(e=>i.fromBytes(e))}r.bytesPerFieldElement=32,r.fieldElementsPerBlob=4096,r.bytesPerBlob=r.bytesPerFieldElement*r.fieldElementsPerBlob,r.maxBytesPerTransaction=6*r.bytesPerBlob-1-1*r.fieldElementsPerBlob*6;class p extends o.BaseError{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Blobs.BlobSizeTooLargeError"})}}r.BlobSizeTooLargeError=p;class m extends o.BaseError{constructor(){super("Blob data must not be empty."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Blobs.EmptyBlobError"})}}r.EmptyBlobError=m;class g extends o.BaseError{constructor(){super("Blob versioned hashes must not be empty."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Blobs.EmptyBlobVersionedHashesError"})}}r.EmptyBlobVersionedHashesError=g;class b extends o.BaseError{constructor({hash:e,size:t}){super(`Versioned hash "${e}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${t}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Blobs.InvalidVersionedHashSizeError"})}}r.InvalidVersionedHashSizeError=b;class y extends o.BaseError{constructor({hash:e,version:t}){super(`Versioned hash "${e}" version is invalid.`,{metaMessages:[`Expected: ${c.versionedHashVersion}`,`Received: ${t}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Blobs.InvalidVersionedHashVersionError"})}}r.InvalidVersionedHashVersionError=y}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Blobs.js"}],[6605,{"./Hex.js":6621,"./Transaction.js":6641,"./Withdrawal.js":6655},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.toRpc=function(e,t={}){const r=e.transactions.map(e=>"string"==typeof e?e:o.toRpc(e));return{baseFeePerGas:"bigint"==typeof e.baseFeePerGas?n.fromNumber(e.baseFeePerGas):undefined,blobGasUsed:"bigint"==typeof e.blobGasUsed?n.fromNumber(e.blobGasUsed):undefined,excessBlobGas:"bigint"==typeof e.excessBlobGas?n.fromNumber(e.excessBlobGas):undefined,extraData:e.extraData,difficulty:"bigint"==typeof e.difficulty?n.fromNumber(e.difficulty):undefined,gasLimit:n.fromNumber(e.gasLimit),gasUsed:n.fromNumber(e.gasUsed),hash:e.hash,logsBloom:e.logsBloom,miner:e.miner,mixHash:e.mixHash,nonce:e.nonce,number:"bigint"==typeof e.number?n.fromNumber(e.number):null,parentBeaconBlockRoot:e.parentBeaconBlockRoot,parentHash:e.parentHash,receiptsRoot:e.receiptsRoot,sealFields:e.sealFields,sha3Uncles:e.sha3Uncles,size:n.fromNumber(e.size),stateRoot:e.stateRoot,timestamp:n.fromNumber(e.timestamp),totalDifficulty:"bigint"==typeof e.totalDifficulty?n.fromNumber(e.totalDifficulty):undefined,transactions:r,transactionsRoot:e.transactionsRoot,uncles:e.uncles,withdrawals:e.withdrawals?.map(s.toRpc),withdrawalsRoot:e.withdrawalsRoot}},r.fromRpc=function(e,t={}){if(!e)return null;const r=e.transactions.map(e=>"string"==typeof e?e:o.fromRpc(e));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):undefined,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):undefined,difficulty:e.difficulty?BigInt(e.difficulty):undefined,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):undefined,gasLimit:BigInt(e.gasLimit??0n),gasUsed:BigInt(e.gasUsed??0n),number:e.number?BigInt(e.number):null,size:BigInt(e.size??0n),stateRoot:e.stateRoot,timestamp:BigInt(e.timestamp??0n),totalDifficulty:BigInt(e.totalDifficulty??0n),transactions:r,withdrawals:e.withdrawals?.map(s.fromRpc)}};const n=e("./Hex.js"),o=e("./Transaction.js"),s=e("./Withdrawal.js")}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Block.js"}],[6606,{"./Hex.js":6621,"./Withdrawal.js":6655},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fromRpc=function(e){return{...e.baseFeePerGas&&{baseFeePerGas:BigInt(e.baseFeePerGas)},...e.blobBaseFee&&{blobBaseFee:BigInt(e.blobBaseFee)},...e.feeRecipient&&{feeRecipient:e.feeRecipient},...e.gasLimit&&{gasLimit:BigInt(e.gasLimit)},...e.number&&{number:BigInt(e.number)},...e.prevRandao&&{prevRandao:BigInt(e.prevRandao)},...e.time&&{time:BigInt(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(o.fromRpc)}}},r.toRpc=function(e){return{..."bigint"==typeof e.baseFeePerGas&&{baseFeePerGas:n.fromNumber(e.baseFeePerGas)},..."bigint"==typeof e.blobBaseFee&&{blobBaseFee:n.fromNumber(e.blobBaseFee)},..."string"==typeof e.feeRecipient&&{feeRecipient:e.feeRecipient},..."bigint"==typeof e.gasLimit&&{gasLimit:n.fromNumber(e.gasLimit)},..."bigint"==typeof e.number&&{number:n.fromNumber(e.number)},..."bigint"==typeof e.prevRandao&&{prevRandao:n.fromNumber(e.prevRandao)},..."bigint"==typeof e.time&&{time:n.fromNumber(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(o.toRpc)}}};const n=e("./Hex.js"),o=e("./Withdrawal.js")}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/BlockOverrides.js"}],[6607,{"./Bytes.js":6610,"./Hash.js":6619,"./Hex.js":6621},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.contains=function(e,t){const r=n.fromHex(e),s=o.keccak256(t,{as:"Bytes"});for(const e of[0,2,4]){const t=s[e+1]+(s[e]<<8)&2047;if(!(r[255-Math.floor(t/8)]&1<<t%8))return!1}return!0},r.validate=function(e){return s.validate(e)&&256===s.size(e)};const n=e("./Bytes.js"),o=e("./Hash.js"),s=e("./Hex.js")}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Bloom.js"}],[6608,{"./Bytes.js":6610,"./Hex.js":6621,"@noble/curves/bls12-381":6580},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.noble=void 0,r.aggregate=function(e){const t="bigint"==typeof e[0]?.x?n.bls12_381.G1:n.bls12_381.G2,r=e.reduce((e,r)=>e.add(new t.ProjectivePoint(r.x,r.y,r.z)),t.ProjectivePoint.ZERO);return{x:r.px,y:r.py,z:r.pz}},r.createKeyPair=function(e={}){const{as:t="Hex",size:r="short-key:long-sig"}=e,n=a({as:t}),o=i({privateKey:n,size:r});return{privateKey:n,publicKey:o}},r.getPublicKey=i,r.randomPrivateKey=a,r.sign=function(e){const{payload:t,privateKey:r,suite:s,size:i="short-key:long-sig"}=e,a=("short-key:long-sig"===i?n.bls12_381.G2:n.bls12_381.G1).hashToCurve(o.from(t),s?{DST:o.fromString(s)}:undefined),c="short-key:long-sig"===i?n.bls12_381.G1:n.bls12_381.G2,u=a.multiply(c.normPrivateKeyToScalar(r.slice(2)));return{x:u.px,y:u.py,z:u.pz}},r.verify=function(e){const{payload:t,suite:r}=e,s=e.publicKey,i=e.signature,a="bigint"==typeof i.x,c=(a?n.bls12_381.G1:n.bls12_381.G2).hashToCurve(o.from(t),r?{DST:o.fromString(r)}:undefined);return n.bls12_381.fields.Fp12.eql(a?n.bls12_381.pairingBatch([{g1:c,g2:new n.bls12_381.G2.ProjectivePoint(s.x,s.y,s.z)},{g1:new n.bls12_381.G1.ProjectivePoint(i.x,i.y,i.z),g2:n.bls12_381.G2.ProjectivePoint.BASE.negate()}]):n.bls12_381.pairingBatch([{g1:new n.bls12_381.G1.ProjectivePoint(s.x,s.y,s.z).negate(),g2:c},{g1:n.bls12_381.G1.ProjectivePoint.BASE,g2:new n.bls12_381.G2.ProjectivePoint(i.x,i.y,i.z)}]),n.bls12_381.fields.Fp12.ONE)};const n=e("@noble/curves/bls12-381"),o=e("./Bytes.js"),s=e("./Hex.js");function i(e){const{privateKey:t,size:r="short-key:long-sig"}=e,o="short-key:long-sig"===r?n.bls12_381.G1:n.bls12_381.G2,{px:i,py:a,pz:c}=o.ProjectivePoint.fromPrivateKey(s.from(t).slice(2));return{x:i,y:a,z:c}}function a(e={}){const{as:t="Hex"}=e,r=n.bls12_381.utils.randomPrivateKey();return"Hex"===t?s.fromBytes(r):r}r.noble=n.bls12_381}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/Bls.js"}],[6609,{"./Hex.js":6621,"@noble/curves/bls12-381":6580},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.toBytes=s,r.toHex=function(e){return o.fromBytes(s(e))},r.fromBytes=i,r.fromHex=function(e,t){return i(o.toBytes(e))};const n=e("@noble/curves/bls12-381"),o=e("./Hex.js");function s(e){return new("bigint"==typeof e.z?n.bls12_381.G1:n.bls12_381.G2).ProjectivePoint(e.x,e.y,e.z).toRawBytes()}function i(e){const t=(48===e.length?n.bls12_381.G1:n.bls12_381.G2).ProjectivePoint.fromHex(e);return{x:t.px,y:t.py,z:t.pz}}}}},{package:"eth-lattice-keyring>gridplus-sdk>ox",file:"node_modules/gridplus-sdk/node_modules/ox/_cjs/core/BlsPoint.js"}]],[],{});