erc5630-snap 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # ERC-5630 ECDH Snap
2
+
3
+ Implements the draft ERC-5630 JSON-RPC methods:
4
+
5
+ - `eth_getEncryptionPublicKey` → returns a compressed secp256k1 public key for a given Ethereum account.
6
+ - `eth_performECDH` → returns the 32-byte ECDH shared secret x-coordinate for a given account + ephemeral pubkey.
7
+
8
+ These methods are exposed to dapps via MetaMask Snaps (`wallet_invokeSnap`).
9
+
10
+ ## Install
11
+
12
+ Once published, dapps can request this snap by Snap ID:
13
+
14
+ - `npm:erc5630-snap`
15
+
16
+ DDRP’s demo site has an install/playground UI:
17
+
18
+ - `https://ddrp.io/#/snap`
19
+
20
+ ## Permissions
21
+
22
+ This snap uses:
23
+
24
+ - `snap_dialog` (to show confirmations)
25
+ - `snap_getBip44Entropy` (coinType `60`) to derive MetaMask HD account keys (`m/44'/60'/0'/0/i`)
26
+
27
+ `snap_getBip44Entropy` is a **high-privilege** permission. Only install/build from sources you trust and only approve
28
+ requests from sites you trust.
29
+
30
+ ## Limitations
31
+
32
+ - Only supports MetaMask HD accounts derived under `m/44'/60'/0'/0/i` (scans the first N indices).
33
+ - Imported accounts and hardware wallets are not supported.
package/dist/bundle.js ADDED
@@ -0,0 +1 @@
1
+ (()=>{var t={101(t,e,n){"use strict";e.x2=void 0;const r=n(458),i=n(428),o=n(750),s=n(543),a=n(28),u=n(723);function c(t){if("string"!=typeof t)throw new TypeError("Invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}function f(t){const e=c(t),n=e.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:e,words:n}}function l(t){r.default.bytes(t,16,20,24,28,32)}const h=t=>{const e=8-t.length/4;return new Uint8Array([(0,o.sha256)(t)[0]>>e<<e])};function d(t){if(!Array.isArray(t)||2048!==t.length||"string"!=typeof t[0])throw new Error("Worlist: expected array of 2048 strings");return t.forEach(t=>{if("string"!=typeof t)throw new Error(`Wordlist: non-string element: ${t}`)}),u.utils.chain(u.utils.checksum(1,h),u.utils.radix2(11,!0),u.utils.alphabet(t))}function p(t,e){let n;if("string"==typeof t){const{words:r}=f(t);n=d(e).decode(r)}else n=d(e).decode(Array.from(new Uint16Array(t.buffer)).map(t=>e[t]));return l(n),n}function y(t,e){l(t);const n=d(e).encode(t).map(t=>e.indexOf(t));return new Uint8Array(new Uint16Array(n).buffer)}e.x2=p;const g=t=>c(`mnemonic${t}`);function w(t,e){let n;return n="string"==typeof t?(new TextEncoder).encode(f(t).nfkd):(new TextEncoder).encode(Array.from(new Uint16Array(t.buffer)).map(t=>e[t]).join(" ")),n}},943(t,e){"use strict";e.p=void 0,e.p="abandon\nability\nable\nabout\nabove\nabsent\nabsorb\nabstract\nabsurd\nabuse\naccess\naccident\naccount\naccuse\nachieve\nacid\nacoustic\nacquire\nacross\nact\naction\nactor\nactress\nactual\nadapt\nadd\naddict\naddress\nadjust\nadmit\nadult\nadvance\nadvice\naerobic\naffair\nafford\nafraid\nagain\nage\nagent\nagree\nahead\naim\nair\nairport\naisle\nalarm\nalbum\nalcohol\nalert\nalien\nall\nalley\nallow\nalmost\nalone\nalpha\nalready\nalso\nalter\nalways\namateur\namazing\namong\namount\namused\nanalyst\nanchor\nancient\nanger\nangle\nangry\nanimal\nankle\nannounce\nannual\nanother\nanswer\nantenna\nantique\nanxiety\nany\napart\napology\nappear\napple\napprove\napril\narch\narctic\narea\narena\nargue\narm\narmed\narmor\narmy\naround\narrange\narrest\narrive\narrow\nart\nartefact\nartist\nartwork\nask\naspect\nassault\nasset\nassist\nassume\nasthma\nathlete\natom\nattack\nattend\nattitude\nattract\nauction\naudit\naugust\naunt\nauthor\nauto\nautumn\naverage\navocado\navoid\nawake\naware\naway\nawesome\nawful\nawkward\naxis\nbaby\nbachelor\nbacon\nbadge\nbag\nbalance\nbalcony\nball\nbamboo\nbanana\nbanner\nbar\nbarely\nbargain\nbarrel\nbase\nbasic\nbasket\nbattle\nbeach\nbean\nbeauty\nbecause\nbecome\nbeef\nbefore\nbegin\nbehave\nbehind\nbelieve\nbelow\nbelt\nbench\nbenefit\nbest\nbetray\nbetter\nbetween\nbeyond\nbicycle\nbid\nbike\nbind\nbiology\nbird\nbirth\nbitter\nblack\nblade\nblame\nblanket\nblast\nbleak\nbless\nblind\nblood\nblossom\nblouse\nblue\nblur\nblush\nboard\nboat\nbody\nboil\nbomb\nbone\nbonus\nbook\nboost\nborder\nboring\nborrow\nboss\nbottom\nbounce\nbox\nboy\nbracket\nbrain\nbrand\nbrass\nbrave\nbread\nbreeze\nbrick\nbridge\nbrief\nbright\nbring\nbrisk\nbroccoli\nbroken\nbronze\nbroom\nbrother\nbrown\nbrush\nbubble\nbuddy\nbudget\nbuffalo\nbuild\nbulb\nbulk\nbullet\nbundle\nbunker\nburden\nburger\nburst\nbus\nbusiness\nbusy\nbutter\nbuyer\nbuzz\ncabbage\ncabin\ncable\ncactus\ncage\ncake\ncall\ncalm\ncamera\ncamp\ncan\ncanal\ncancel\ncandy\ncannon\ncanoe\ncanvas\ncanyon\ncapable\ncapital\ncaptain\ncar\ncarbon\ncard\ncargo\ncarpet\ncarry\ncart\ncase\ncash\ncasino\ncastle\ncasual\ncat\ncatalog\ncatch\ncategory\ncattle\ncaught\ncause\ncaution\ncave\nceiling\ncelery\ncement\ncensus\ncentury\ncereal\ncertain\nchair\nchalk\nchampion\nchange\nchaos\nchapter\ncharge\nchase\nchat\ncheap\ncheck\ncheese\nchef\ncherry\nchest\nchicken\nchief\nchild\nchimney\nchoice\nchoose\nchronic\nchuckle\nchunk\nchurn\ncigar\ncinnamon\ncircle\ncitizen\ncity\ncivil\nclaim\nclap\nclarify\nclaw\nclay\nclean\nclerk\nclever\nclick\nclient\ncliff\nclimb\nclinic\nclip\nclock\nclog\nclose\ncloth\ncloud\nclown\nclub\nclump\ncluster\nclutch\ncoach\ncoast\ncoconut\ncode\ncoffee\ncoil\ncoin\ncollect\ncolor\ncolumn\ncombine\ncome\ncomfort\ncomic\ncommon\ncompany\nconcert\nconduct\nconfirm\ncongress\nconnect\nconsider\ncontrol\nconvince\ncook\ncool\ncopper\ncopy\ncoral\ncore\ncorn\ncorrect\ncost\ncotton\ncouch\ncountry\ncouple\ncourse\ncousin\ncover\ncoyote\ncrack\ncradle\ncraft\ncram\ncrane\ncrash\ncrater\ncrawl\ncrazy\ncream\ncredit\ncreek\ncrew\ncricket\ncrime\ncrisp\ncritic\ncrop\ncross\ncrouch\ncrowd\ncrucial\ncruel\ncruise\ncrumble\ncrunch\ncrush\ncry\ncrystal\ncube\nculture\ncup\ncupboard\ncurious\ncurrent\ncurtain\ncurve\ncushion\ncustom\ncute\ncycle\ndad\ndamage\ndamp\ndance\ndanger\ndaring\ndash\ndaughter\ndawn\nday\ndeal\ndebate\ndebris\ndecade\ndecember\ndecide\ndecline\ndecorate\ndecrease\ndeer\ndefense\ndefine\ndefy\ndegree\ndelay\ndeliver\ndemand\ndemise\ndenial\ndentist\ndeny\ndepart\ndepend\ndeposit\ndepth\ndeputy\nderive\ndescribe\ndesert\ndesign\ndesk\ndespair\ndestroy\ndetail\ndetect\ndevelop\ndevice\ndevote\ndiagram\ndial\ndiamond\ndiary\ndice\ndiesel\ndiet\ndiffer\ndigital\ndignity\ndilemma\ndinner\ndinosaur\ndirect\ndirt\ndisagree\ndiscover\ndisease\ndish\ndismiss\ndisorder\ndisplay\ndistance\ndivert\ndivide\ndivorce\ndizzy\ndoctor\ndocument\ndog\ndoll\ndolphin\ndomain\ndonate\ndonkey\ndonor\ndoor\ndose\ndouble\ndove\ndraft\ndragon\ndrama\ndrastic\ndraw\ndream\ndress\ndrift\ndrill\ndrink\ndrip\ndrive\ndrop\ndrum\ndry\nduck\ndumb\ndune\nduring\ndust\ndutch\nduty\ndwarf\ndynamic\neager\neagle\nearly\nearn\nearth\neasily\neast\neasy\necho\necology\neconomy\nedge\nedit\neducate\neffort\negg\neight\neither\nelbow\nelder\nelectric\nelegant\nelement\nelephant\nelevator\nelite\nelse\nembark\nembody\nembrace\nemerge\nemotion\nemploy\nempower\nempty\nenable\nenact\nend\nendless\nendorse\nenemy\nenergy\nenforce\nengage\nengine\nenhance\nenjoy\nenlist\nenough\nenrich\nenroll\nensure\nenter\nentire\nentry\nenvelope\nepisode\nequal\nequip\nera\nerase\nerode\nerosion\nerror\nerupt\nescape\nessay\nessence\nestate\neternal\nethics\nevidence\nevil\nevoke\nevolve\nexact\nexample\nexcess\nexchange\nexcite\nexclude\nexcuse\nexecute\nexercise\nexhaust\nexhibit\nexile\nexist\nexit\nexotic\nexpand\nexpect\nexpire\nexplain\nexpose\nexpress\nextend\nextra\neye\neyebrow\nfabric\nface\nfaculty\nfade\nfaint\nfaith\nfall\nfalse\nfame\nfamily\nfamous\nfan\nfancy\nfantasy\nfarm\nfashion\nfat\nfatal\nfather\nfatigue\nfault\nfavorite\nfeature\nfebruary\nfederal\nfee\nfeed\nfeel\nfemale\nfence\nfestival\nfetch\nfever\nfew\nfiber\nfiction\nfield\nfigure\nfile\nfilm\nfilter\nfinal\nfind\nfine\nfinger\nfinish\nfire\nfirm\nfirst\nfiscal\nfish\nfit\nfitness\nfix\nflag\nflame\nflash\nflat\nflavor\nflee\nflight\nflip\nfloat\nflock\nfloor\nflower\nfluid\nflush\nfly\nfoam\nfocus\nfog\nfoil\nfold\nfollow\nfood\nfoot\nforce\nforest\nforget\nfork\nfortune\nforum\nforward\nfossil\nfoster\nfound\nfox\nfragile\nframe\nfrequent\nfresh\nfriend\nfringe\nfrog\nfront\nfrost\nfrown\nfrozen\nfruit\nfuel\nfun\nfunny\nfurnace\nfury\nfuture\ngadget\ngain\ngalaxy\ngallery\ngame\ngap\ngarage\ngarbage\ngarden\ngarlic\ngarment\ngas\ngasp\ngate\ngather\ngauge\ngaze\ngeneral\ngenius\ngenre\ngentle\ngenuine\ngesture\nghost\ngiant\ngift\ngiggle\nginger\ngiraffe\ngirl\ngive\nglad\nglance\nglare\nglass\nglide\nglimpse\nglobe\ngloom\nglory\nglove\nglow\nglue\ngoat\ngoddess\ngold\ngood\ngoose\ngorilla\ngospel\ngossip\ngovern\ngown\ngrab\ngrace\ngrain\ngrant\ngrape\ngrass\ngravity\ngreat\ngreen\ngrid\ngrief\ngrit\ngrocery\ngroup\ngrow\ngrunt\nguard\nguess\nguide\nguilt\nguitar\ngun\ngym\nhabit\nhair\nhalf\nhammer\nhamster\nhand\nhappy\nharbor\nhard\nharsh\nharvest\nhat\nhave\nhawk\nhazard\nhead\nhealth\nheart\nheavy\nhedgehog\nheight\nhello\nhelmet\nhelp\nhen\nhero\nhidden\nhigh\nhill\nhint\nhip\nhire\nhistory\nhobby\nhockey\nhold\nhole\nholiday\nhollow\nhome\nhoney\nhood\nhope\nhorn\nhorror\nhorse\nhospital\nhost\nhotel\nhour\nhover\nhub\nhuge\nhuman\nhumble\nhumor\nhundred\nhungry\nhunt\nhurdle\nhurry\nhurt\nhusband\nhybrid\nice\nicon\nidea\nidentify\nidle\nignore\nill\nillegal\nillness\nimage\nimitate\nimmense\nimmune\nimpact\nimpose\nimprove\nimpulse\ninch\ninclude\nincome\nincrease\nindex\nindicate\nindoor\nindustry\ninfant\ninflict\ninform\ninhale\ninherit\ninitial\ninject\ninjury\ninmate\ninner\ninnocent\ninput\ninquiry\ninsane\ninsect\ninside\ninspire\ninstall\nintact\ninterest\ninto\ninvest\ninvite\ninvolve\niron\nisland\nisolate\nissue\nitem\nivory\njacket\njaguar\njar\njazz\njealous\njeans\njelly\njewel\njob\njoin\njoke\njourney\njoy\njudge\njuice\njump\njungle\njunior\njunk\njust\nkangaroo\nkeen\nkeep\nketchup\nkey\nkick\nkid\nkidney\nkind\nkingdom\nkiss\nkit\nkitchen\nkite\nkitten\nkiwi\nknee\nknife\nknock\nknow\nlab\nlabel\nlabor\nladder\nlady\nlake\nlamp\nlanguage\nlaptop\nlarge\nlater\nlatin\nlaugh\nlaundry\nlava\nlaw\nlawn\nlawsuit\nlayer\nlazy\nleader\nleaf\nlearn\nleave\nlecture\nleft\nleg\nlegal\nlegend\nleisure\nlemon\nlend\nlength\nlens\nleopard\nlesson\nletter\nlevel\nliar\nliberty\nlibrary\nlicense\nlife\nlift\nlight\nlike\nlimb\nlimit\nlink\nlion\nliquid\nlist\nlittle\nlive\nlizard\nload\nloan\nlobster\nlocal\nlock\nlogic\nlonely\nlong\nloop\nlottery\nloud\nlounge\nlove\nloyal\nlucky\nluggage\nlumber\nlunar\nlunch\nluxury\nlyrics\nmachine\nmad\nmagic\nmagnet\nmaid\nmail\nmain\nmajor\nmake\nmammal\nman\nmanage\nmandate\nmango\nmansion\nmanual\nmaple\nmarble\nmarch\nmargin\nmarine\nmarket\nmarriage\nmask\nmass\nmaster\nmatch\nmaterial\nmath\nmatrix\nmatter\nmaximum\nmaze\nmeadow\nmean\nmeasure\nmeat\nmechanic\nmedal\nmedia\nmelody\nmelt\nmember\nmemory\nmention\nmenu\nmercy\nmerge\nmerit\nmerry\nmesh\nmessage\nmetal\nmethod\nmiddle\nmidnight\nmilk\nmillion\nmimic\nmind\nminimum\nminor\nminute\nmiracle\nmirror\nmisery\nmiss\nmistake\nmix\nmixed\nmixture\nmobile\nmodel\nmodify\nmom\nmoment\nmonitor\nmonkey\nmonster\nmonth\nmoon\nmoral\nmore\nmorning\nmosquito\nmother\nmotion\nmotor\nmountain\nmouse\nmove\nmovie\nmuch\nmuffin\nmule\nmultiply\nmuscle\nmuseum\nmushroom\nmusic\nmust\nmutual\nmyself\nmystery\nmyth\nnaive\nname\nnapkin\nnarrow\nnasty\nnation\nnature\nnear\nneck\nneed\nnegative\nneglect\nneither\nnephew\nnerve\nnest\nnet\nnetwork\nneutral\nnever\nnews\nnext\nnice\nnight\nnoble\nnoise\nnominee\nnoodle\nnormal\nnorth\nnose\nnotable\nnote\nnothing\nnotice\nnovel\nnow\nnuclear\nnumber\nnurse\nnut\noak\nobey\nobject\noblige\nobscure\nobserve\nobtain\nobvious\noccur\nocean\noctober\nodor\noff\noffer\noffice\noften\noil\nokay\nold\nolive\nolympic\nomit\nonce\none\nonion\nonline\nonly\nopen\nopera\nopinion\noppose\noption\norange\norbit\norchard\norder\nordinary\norgan\norient\noriginal\norphan\nostrich\nother\noutdoor\nouter\noutput\noutside\noval\noven\nover\nown\nowner\noxygen\noyster\nozone\npact\npaddle\npage\npair\npalace\npalm\npanda\npanel\npanic\npanther\npaper\nparade\nparent\npark\nparrot\nparty\npass\npatch\npath\npatient\npatrol\npattern\npause\npave\npayment\npeace\npeanut\npear\npeasant\npelican\npen\npenalty\npencil\npeople\npepper\nperfect\npermit\nperson\npet\nphone\nphoto\nphrase\nphysical\npiano\npicnic\npicture\npiece\npig\npigeon\npill\npilot\npink\npioneer\npipe\npistol\npitch\npizza\nplace\nplanet\nplastic\nplate\nplay\nplease\npledge\npluck\nplug\nplunge\npoem\npoet\npoint\npolar\npole\npolice\npond\npony\npool\npopular\nportion\nposition\npossible\npost\npotato\npottery\npoverty\npowder\npower\npractice\npraise\npredict\nprefer\nprepare\npresent\npretty\nprevent\nprice\npride\nprimary\nprint\npriority\nprison\nprivate\nprize\nproblem\nprocess\nproduce\nprofit\nprogram\nproject\npromote\nproof\nproperty\nprosper\nprotect\nproud\nprovide\npublic\npudding\npull\npulp\npulse\npumpkin\npunch\npupil\npuppy\npurchase\npurity\npurpose\npurse\npush\nput\npuzzle\npyramid\nquality\nquantum\nquarter\nquestion\nquick\nquit\nquiz\nquote\nrabbit\nraccoon\nrace\nrack\nradar\nradio\nrail\nrain\nraise\nrally\nramp\nranch\nrandom\nrange\nrapid\nrare\nrate\nrather\nraven\nraw\nrazor\nready\nreal\nreason\nrebel\nrebuild\nrecall\nreceive\nrecipe\nrecord\nrecycle\nreduce\nreflect\nreform\nrefuse\nregion\nregret\nregular\nreject\nrelax\nrelease\nrelief\nrely\nremain\nremember\nremind\nremove\nrender\nrenew\nrent\nreopen\nrepair\nrepeat\nreplace\nreport\nrequire\nrescue\nresemble\nresist\nresource\nresponse\nresult\nretire\nretreat\nreturn\nreunion\nreveal\nreview\nreward\nrhythm\nrib\nribbon\nrice\nrich\nride\nridge\nrifle\nright\nrigid\nring\nriot\nripple\nrisk\nritual\nrival\nriver\nroad\nroast\nrobot\nrobust\nrocket\nromance\nroof\nrookie\nroom\nrose\nrotate\nrough\nround\nroute\nroyal\nrubber\nrude\nrug\nrule\nrun\nrunway\nrural\nsad\nsaddle\nsadness\nsafe\nsail\nsalad\nsalmon\nsalon\nsalt\nsalute\nsame\nsample\nsand\nsatisfy\nsatoshi\nsauce\nsausage\nsave\nsay\nscale\nscan\nscare\nscatter\nscene\nscheme\nschool\nscience\nscissors\nscorpion\nscout\nscrap\nscreen\nscript\nscrub\nsea\nsearch\nseason\nseat\nsecond\nsecret\nsection\nsecurity\nseed\nseek\nsegment\nselect\nsell\nseminar\nsenior\nsense\nsentence\nseries\nservice\nsession\nsettle\nsetup\nseven\nshadow\nshaft\nshallow\nshare\nshed\nshell\nsheriff\nshield\nshift\nshine\nship\nshiver\nshock\nshoe\nshoot\nshop\nshort\nshoulder\nshove\nshrimp\nshrug\nshuffle\nshy\nsibling\nsick\nside\nsiege\nsight\nsign\nsilent\nsilk\nsilly\nsilver\nsimilar\nsimple\nsince\nsing\nsiren\nsister\nsituate\nsix\nsize\nskate\nsketch\nski\nskill\nskin\nskirt\nskull\nslab\nslam\nsleep\nslender\nslice\nslide\nslight\nslim\nslogan\nslot\nslow\nslush\nsmall\nsmart\nsmile\nsmoke\nsmooth\nsnack\nsnake\nsnap\nsniff\nsnow\nsoap\nsoccer\nsocial\nsock\nsoda\nsoft\nsolar\nsoldier\nsolid\nsolution\nsolve\nsomeone\nsong\nsoon\nsorry\nsort\nsoul\nsound\nsoup\nsource\nsouth\nspace\nspare\nspatial\nspawn\nspeak\nspecial\nspeed\nspell\nspend\nsphere\nspice\nspider\nspike\nspin\nspirit\nsplit\nspoil\nsponsor\nspoon\nsport\nspot\nspray\nspread\nspring\nspy\nsquare\nsqueeze\nsquirrel\nstable\nstadium\nstaff\nstage\nstairs\nstamp\nstand\nstart\nstate\nstay\nsteak\nsteel\nstem\nstep\nstereo\nstick\nstill\nsting\nstock\nstomach\nstone\nstool\nstory\nstove\nstrategy\nstreet\nstrike\nstrong\nstruggle\nstudent\nstuff\nstumble\nstyle\nsubject\nsubmit\nsubway\nsuccess\nsuch\nsudden\nsuffer\nsugar\nsuggest\nsuit\nsummer\nsun\nsunny\nsunset\nsuper\nsupply\nsupreme\nsure\nsurface\nsurge\nsurprise\nsurround\nsurvey\nsuspect\nsustain\nswallow\nswamp\nswap\nswarm\nswear\nsweet\nswift\nswim\nswing\nswitch\nsword\nsymbol\nsymptom\nsyrup\nsystem\ntable\ntackle\ntag\ntail\ntalent\ntalk\ntank\ntape\ntarget\ntask\ntaste\ntattoo\ntaxi\nteach\nteam\ntell\nten\ntenant\ntennis\ntent\nterm\ntest\ntext\nthank\nthat\ntheme\nthen\ntheory\nthere\nthey\nthing\nthis\nthought\nthree\nthrive\nthrow\nthumb\nthunder\nticket\ntide\ntiger\ntilt\ntimber\ntime\ntiny\ntip\ntired\ntissue\ntitle\ntoast\ntobacco\ntoday\ntoddler\ntoe\ntogether\ntoilet\ntoken\ntomato\ntomorrow\ntone\ntongue\ntonight\ntool\ntooth\ntop\ntopic\ntopple\ntorch\ntornado\ntortoise\ntoss\ntotal\ntourist\ntoward\ntower\ntown\ntoy\ntrack\ntrade\ntraffic\ntragic\ntrain\ntransfer\ntrap\ntrash\ntravel\ntray\ntreat\ntree\ntrend\ntrial\ntribe\ntrick\ntrigger\ntrim\ntrip\ntrophy\ntrouble\ntruck\ntrue\ntruly\ntrumpet\ntrust\ntruth\ntry\ntube\ntuition\ntumble\ntuna\ntunnel\nturkey\nturn\nturtle\ntwelve\ntwenty\ntwice\ntwin\ntwist\ntwo\ntype\ntypical\nugly\numbrella\nunable\nunaware\nuncle\nuncover\nunder\nundo\nunfair\nunfold\nunhappy\nuniform\nunique\nunit\nuniverse\nunknown\nunlock\nuntil\nunusual\nunveil\nupdate\nupgrade\nuphold\nupon\nupper\nupset\nurban\nurge\nusage\nuse\nused\nuseful\nuseless\nusual\nutility\nvacant\nvacuum\nvague\nvalid\nvalley\nvalve\nvan\nvanish\nvapor\nvarious\nvast\nvault\nvehicle\nvelvet\nvendor\nventure\nvenue\nverb\nverify\nversion\nvery\nvessel\nveteran\nviable\nvibrant\nvicious\nvictory\nvideo\nview\nvillage\nvintage\nviolin\nvirtual\nvirus\nvisa\nvisit\nvisual\nvital\nvivid\nvocal\nvoice\nvoid\nvolcano\nvolume\nvote\nvoyage\nwage\nwagon\nwait\nwalk\nwall\nwalnut\nwant\nwarfare\nwarm\nwarrior\nwash\nwasp\nwaste\nwater\nwave\nway\nwealth\nweapon\nwear\nweasel\nweather\nweb\nwedding\nweekend\nweird\nwelcome\nwest\nwet\nwhale\nwhat\nwheat\nwheel\nwhen\nwhere\nwhip\nwhisper\nwide\nwidth\nwife\nwild\nwill\nwin\nwindow\nwine\nwing\nwink\nwinner\nwinter\nwire\nwisdom\nwise\nwish\nwitness\nwolf\nwoman\nwonder\nwood\nwool\nword\nwork\nworld\nworry\nworth\nwrap\nwreck\nwrestle\nwrist\nwrite\nwrong\nyard\nyear\nyellow\nyou\nyoung\nyouth\nzebra\nzero\nzone\nzoo".split("\n")},458(t,e){"use strict";function n(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function r(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)}function i(t,...e){if(!((n=t)instanceof Uint8Array||null!=n&&"object"==typeof n&&"Uint8Array"===n.constructor.name))throw new Error("Expected Uint8Array");var n;if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function o(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");n(t.outputLen),n(t.blockLen)}function s(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function a(t,e){i(t);const n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(e,"__esModule",{value:!0}),e.output=e.exists=e.hash=e.bytes=e.bool=e.number=void 0,e.number=n,e.bool=r,e.bytes=i,e.hash=o,e.exists=s,e.output=a;const u={number:n,bool:r,bytes:i,hash:o,exists:s,output:a};e.default=u},876(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SHA2=void 0;const r=n(458),i=n(28);class o extends i.Hash{constructor(t,e,n,r){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,r.exists)(this);const{view:e,buffer:n,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let r=0;r<s;){const a=Math.min(o-this.pos,s-r);if(a===o){const e=(0,i.createView)(t);for(;o<=s-r;r+=o)this.process(e,r);continue}n.set(t.subarray(r,r+a),this.pos),this.pos+=a,r+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,r.exists)(this),(0,r.output)(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:o,isLE:s}=this;let{pos:a}=this;e[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(n,0),a=0);for(let t=a;t<o;t++)e[t]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),u=r?4:0,c=r?0:4;t.setUint32(e+u,s,r),t.setUint32(e+c,a,r)}(n,o-8,BigInt(8*this.length),s),this.process(n,0);const u=(0,i.createView)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<f;t++)u.setUint32(4*t,l[t],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return t.length=r,t.pos=s,t.finished=i,t.destroyed=o,r%e&&t.buffer.set(n),t}}e.SHA2=o},939(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.add5L=e.add5H=e.add4H=e.add4L=e.add3H=e.add3L=e.add=e.rotlBL=e.rotlBH=e.rotlSL=e.rotlSH=e.rotr32L=e.rotr32H=e.rotrBL=e.rotrBH=e.rotrSL=e.rotrSH=e.shrSL=e.shrSH=e.toBig=e.split=e.fromBig=void 0;const n=BigInt(2**32-1),r=BigInt(32);function i(t,e=!1){return e?{h:Number(t&n),l:Number(t>>r&n)}:{h:0|Number(t>>r&n),l:0|Number(t&n)}}function o(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let o=0;o<t.length;o++){const{h:s,l:a}=i(t[o],e);[n[o],r[o]]=[s,a]}return[n,r]}e.fromBig=i,e.split=o;const s=(t,e)=>BigInt(t>>>0)<<r|BigInt(e>>>0);e.toBig=s;const a=(t,e,n)=>t>>>n;e.shrSH=a;const u=(t,e,n)=>t<<32-n|e>>>n;e.shrSL=u;const c=(t,e,n)=>t>>>n|e<<32-n;e.rotrSH=c;const f=(t,e,n)=>t<<32-n|e>>>n;e.rotrSL=f;const l=(t,e,n)=>t<<64-n|e>>>n-32;e.rotrBH=l;const h=(t,e,n)=>t>>>n-32|e<<64-n;e.rotrBL=h;const d=(t,e)=>e;e.rotr32H=d;const p=(t,e)=>t;e.rotr32L=p;const y=(t,e,n)=>t<<n|e>>>32-n;e.rotlSH=y;const g=(t,e,n)=>e<<n|t>>>32-n;e.rotlSL=g;const w=(t,e,n)=>e<<n-32|t>>>64-n;e.rotlBH=w;const b=(t,e,n)=>t<<n-32|e>>>64-n;function v(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/2**32|0)|0,l:0|i}}e.rotlBL=b,e.add=v;const m=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0);e.add3L=m;const x=(t,e,n,r)=>e+n+r+(t/2**32|0)|0;e.add3H=x;const E=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0);e.add4L=E;const B=(t,e,n,r,i)=>e+n+r+i+(t/2**32|0)|0;e.add4H=B;const _=(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0);e.add5L=_;const A=(t,e,n,r,i,o)=>e+n+r+i+o+(t/2**32|0)|0;e.add5H=A;const I={fromBig:i,split:o,toBig:s,shrSH:a,shrSL:u,rotrSH:c,rotrSL:f,rotrBH:l,rotrBL:h,rotr32H:d,rotr32L:p,rotlSH:y,rotlSL:g,rotlBH:w,rotlBL:b,add:v,add3L:m,add3H:x,add4L:E,add4H:B,add5H:A,add5L:_};e.default=I},628(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},314(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const r=n(458),i=n(28);class o extends i.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,r.hash)(t);const n=(0,i.toBytes)(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let t=0;t<s.length;t++)s[t]^=54;this.iHash.update(s),this.oHash=t.create();for(let t=0;t<s.length;t++)s[t]^=106;this.oHash.update(s),s.fill(0)}update(t){return(0,r.exists)(this),this.iHash.update(t),this}digestInto(t){(0,r.exists)(this),(0,r.bytes)(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=r,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=o;e.hmac=(t,e,n)=>new o(t,e).update(n).digest(),e.hmac.create=(t,e)=>new o(t,e)},428(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.pbkdf2Async=e.pbkdf2=void 0;const r=n(458),i=n(314),o=n(28);function s(t,e,n,s){(0,r.hash)(t);const a=(0,o.checkOpts)({dkLen:32,asyncTick:10},s),{c:u,dkLen:c,asyncTick:f}=a;if((0,r.number)(u),(0,r.number)(c),(0,r.number)(f),u<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const l=(0,o.toBytes)(e),h=(0,o.toBytes)(n),d=new Uint8Array(c),p=i.hmac.create(t,l),y=p._cloneInto().update(h);return{c:u,dkLen:c,asyncTick:f,DK:d,PRF:p,PRFSalt:y}}function a(t,e,n,r,i){return t.destroy(),e.destroy(),r&&r.destroy(),i.fill(0),n}e.pbkdf2=function(t,e,n,r){const{c:i,dkLen:u,DK:c,PRF:f,PRFSalt:l}=s(t,e,n,r);let h;const d=new Uint8Array(4),p=(0,o.createView)(d),y=new Uint8Array(f.outputLen);for(let t=1,e=0;e<u;t++,e+=f.outputLen){const n=c.subarray(e,e+f.outputLen);p.setInt32(0,t,!1),(h=l._cloneInto(h)).update(d).digestInto(y),n.set(y.subarray(0,n.length));for(let t=1;t<i;t++){f._cloneInto(h).update(y).digestInto(y);for(let t=0;t<n.length;t++)n[t]^=y[t]}}return a(f,l,c,h,y)},e.pbkdf2Async=async function(t,e,n,r){const{c:i,dkLen:u,asyncTick:c,DK:f,PRF:l,PRFSalt:h}=s(t,e,n,r);let d;const p=new Uint8Array(4),y=(0,o.createView)(p),g=new Uint8Array(l.outputLen);for(let t=1,e=0;e<u;t++,e+=l.outputLen){const n=f.subarray(e,e+l.outputLen);y.setInt32(0,t,!1),(d=h._cloneInto(d)).update(p).digestInto(g),n.set(g.subarray(0,n.length)),await(0,o.asyncLoop)(i-1,c,()=>{l._cloneInto(d).update(g).digestInto(g);for(let t=0;t<n.length;t++)n[t]^=g[t]})}return a(l,h,f,d,g)}},750(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=void 0;const r=n(876),i=n(28),o=(t,e,n)=>t&e^~t&n,s=(t,e,n)=>t&e^t&n^e&n,a=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),u=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),c=new Uint32Array(64);class f extends r.SHA2{constructor(){super(64,32,8,!1),this.A=0|u[0],this.B=0|u[1],this.C=0|u[2],this.D=0|u[3],this.E=0|u[4],this.F=0|u[5],this.G=0|u[6],this.H=0|u[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[t,e,n,r,i,o,s,a]}set(t,e,n,r,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)c[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=c[t-15],n=c[t-2],r=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(n,17)^(0,i.rotr)(n,19)^n>>>10;c[t]=o+c[t-7]+r+c[t-16]|0}let{A:n,B:r,C:u,D:f,E:l,F:h,G:d,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(l,6)^(0,i.rotr)(l,11)^(0,i.rotr)(l,25))+o(l,h,d)+a[t]+c[t]|0,y=((0,i.rotr)(n,2)^(0,i.rotr)(n,13)^(0,i.rotr)(n,22))+s(n,r,u)|0;p=d,d=h,h=l,l=f+e|0,f=u,u=r,r=n,n=e+y|0}n=n+this.A|0,r=r+this.B|0,u=u+this.C|0,f=f+this.D|0,l=l+this.E|0,h=h+this.F|0,d=d+this.G|0,p=p+this.H|0,this.set(n,r,u,f,l,h,d,p)}roundClean(){c.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class l extends f{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)(()=>new f),e.sha224=(0,i.wrapConstructor)(()=>new l)},543(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sha384=e.sha512_256=e.sha512_224=e.sha512=e.SHA512=void 0;const r=n(876),i=n(939),o=n(28),[s,a]=i.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),u=new Uint32Array(80),c=new Uint32Array(80);class f extends r.SHA2{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:t,Al:e,Bh:n,Bl:r,Ch:i,Cl:o,Dh:s,Dl:a,Eh:u,El:c,Fh:f,Fl:l,Gh:h,Gl:d,Hh:p,Hl:y}=this;return[t,e,n,r,i,o,s,a,u,c,f,l,h,d,p,y]}set(t,e,n,r,i,o,s,a,u,c,f,l,h,d,p,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|u,this.El=0|c,this.Fh=0|f,this.Fl=0|l,this.Gh=0|h,this.Gl=0|d,this.Hh=0|p,this.Hl=0|y}process(t,e){for(let n=0;n<16;n++,e+=4)u[n]=t.getUint32(e),c[n]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|u[t-15],n=0|c[t-15],r=i.default.rotrSH(e,n,1)^i.default.rotrSH(e,n,8)^i.default.shrSH(e,n,7),o=i.default.rotrSL(e,n,1)^i.default.rotrSL(e,n,8)^i.default.shrSL(e,n,7),s=0|u[t-2],a=0|c[t-2],f=i.default.rotrSH(s,a,19)^i.default.rotrBH(s,a,61)^i.default.shrSH(s,a,6),l=i.default.rotrSL(s,a,19)^i.default.rotrBL(s,a,61)^i.default.shrSL(s,a,6),h=i.default.add4L(o,l,c[t-7],c[t-16]),d=i.default.add4H(h,r,f,u[t-7],u[t-16]);u[t]=0|d,c[t]=0|h}let{Ah:n,Al:r,Bh:o,Bl:f,Ch:l,Cl:h,Dh:d,Dl:p,Eh:y,El:g,Fh:w,Fl:b,Gh:v,Gl:m,Hh:x,Hl:E}=this;for(let t=0;t<80;t++){const e=i.default.rotrSH(y,g,14)^i.default.rotrSH(y,g,18)^i.default.rotrBH(y,g,41),B=i.default.rotrSL(y,g,14)^i.default.rotrSL(y,g,18)^i.default.rotrBL(y,g,41),_=y&w^~y&v,A=g&b^~g&m,I=i.default.add5L(E,B,A,a[t],c[t]),k=i.default.add5H(I,x,e,_,s[t],u[t]),S=0|I,U=i.default.rotrSH(n,r,28)^i.default.rotrBH(n,r,34)^i.default.rotrBH(n,r,39),O=i.default.rotrSL(n,r,28)^i.default.rotrBL(n,r,34)^i.default.rotrBL(n,r,39),R=n&o^n&l^o&l,L=r&f^r&h^f&h;x=0|v,E=0|m,v=0|w,m=0|b,w=0|y,b=0|g,({h:y,l:g}=i.default.add(0|d,0|p,0|k,0|S)),d=0|l,p=0|h,l=0|o,h=0|f,o=0|n,f=0|r;const C=i.default.add3L(S,O,L);n=i.default.add3H(C,k,U,R),r=0|C}({h:n,l:r}=i.default.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:o,l:f}=i.default.add(0|this.Bh,0|this.Bl,0|o,0|f)),({h:l,l:h}=i.default.add(0|this.Ch,0|this.Cl,0|l,0|h)),({h:d,l:p}=i.default.add(0|this.Dh,0|this.Dl,0|d,0|p)),({h:y,l:g}=i.default.add(0|this.Eh,0|this.El,0|y,0|g)),({h:w,l:b}=i.default.add(0|this.Fh,0|this.Fl,0|w,0|b)),({h:v,l:m}=i.default.add(0|this.Gh,0|this.Gl,0|v,0|m)),({h:x,l:E}=i.default.add(0|this.Hh,0|this.Hl,0|x,0|E)),this.set(n,r,o,f,l,h,d,p,y,g,w,b,v,m,x,E)}roundClean(){u.fill(0),c.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}e.SHA512=f;class l extends f{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class h extends f{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class d extends f{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}e.sha512=(0,o.wrapConstructor)(()=>new f),e.sha512_224=(0,o.wrapConstructor)(()=>new l),e.sha512_256=(0,o.wrapConstructor)(()=>new h),e.sha384=(0,o.wrapConstructor)(()=>new d)},28(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.isLE=e.rotr=e.createView=e.u32=e.u8=void 0;const r=n(628);e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength);function i(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength);if(e.rotr=(t,e)=>t<<32-e|t>>>e,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error("Non little-endian hardware is not supported");const o=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));e.bytesToHex=function(t){if(!i(t))throw new Error("Uint8Array expected");let e="";for(let n=0;n<t.length;n++)e+=o[t[n]];return e};const s=48,a=57,u=65,c=70,f=97,l=102;function h(t){return t>=s&&t<=a?t-s:t>=u&&t<=c?t-(u-10):t>=f&&t<=l?t-(f-10):void 0}e.hexToBytes=function(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length,n=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let e=0,i=0;e<n;e++,i+=2){const n=h(t.charCodeAt(i)),o=h(t.charCodeAt(i+1));if(void 0===n||void 0===o){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}r[e]=16*n+o}return r};function d(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function p(t){if("string"==typeof t&&(t=d(t)),!i(t))throw new Error("expected Uint8Array, got "+typeof t);return t}e.nextTick=async()=>{},e.asyncLoop=async function(t,n,r){let i=Date.now();for(let o=0;o<t;o++){r(o);const t=Date.now()-i;t>=0&&t<n||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=d,e.toBytes=p,e.concatBytes=function(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];if(!i(r))throw new Error("Uint8Array expected");e+=r.length}const n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const i=t[e];n.set(i,r),r+=i.length}return n};e.Hash=class{clone(){return this._cloneInto()}};const y={}.toString;e.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!==y.call(e))throw new Error("Options should be object or undefined");return Object.assign(t,e)},e.wrapConstructor=function(t){const e=e=>t().update(p(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,n)=>t(n).update(p(e)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,n)=>t(n).update(p(e)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(r.crypto&&"function"==typeof r.crypto.getRandomValues)return r.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}},723(t,e){"use strict";function n(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function r(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function i(...t){const e=t=>t,n=(t,e)=>n=>t(e(n));return{encode:t.map(t=>t.encode).reduceRight(n,e),decode:t.map(t=>t.decode).reduce(n,e)}}function o(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("alphabet.encode input should be an array of numbers");return e.map(e=>{if(n(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]})},decode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("alphabet.decode input should be array of strings");return e.map(e=>{if("string"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const n=t.indexOf(e);if(-1===n)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return n})}}}function s(t=""){if("string"!=typeof t)throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("join.encode input should be array of strings");for(let t of e)if("string"!=typeof t)throw new Error(`join.encode: non-string input=${t}`);return e.join(t)},decode:e=>{if("string"!=typeof e)throw new Error("join.decode input should be string");return e.split(t)}}}function a(t,e="="){if(n(t),"string"!=typeof e)throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let t of n)if("string"!=typeof t)throw new Error(`padding.encode: non-string input=${t}`);for(;n.length*t%8;)n.push(e);return n},decode(n){if(!Array.isArray(n)||n.length&&"string"!=typeof n[0])throw new Error("padding.encode input should be array of strings");for(let t of n)if("string"!=typeof t)throw new Error(`padding.decode: non-string input=${t}`);let r=n.length;if(r*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--)if(!((r-1)*t%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,r)}}}function u(t){if("function"!=typeof t)throw new Error("normalize fn should be function");return{encode:t=>t,decode:e=>t(e)}}function c(t,e,r){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let i=0;const o=[],s=Array.from(t);for(s.forEach(t=>{if(n(t),t<0||t>=e)throw new Error(`Wrong integer: ${t}`)});;){let t=0,n=!0;for(let o=i;o<s.length;o++){const a=s[o],u=e*t+a;if(!Number.isSafeInteger(u)||e*t/e!==t||u-a!==e*t)throw new Error("convertRadix: carry overflow");t=u%r;const c=Math.floor(u/r);if(s[o]=c,!Number.isSafeInteger(c)||c*r+t!==u)throw new Error("convertRadix: carry overflow");n&&(c?n=!1:i=o)}if(o.push(t),n)break}for(let e=0;e<t.length-1&&0===t[e];e++)o.push(0);return o.reverse()}Object.defineProperty(e,"__esModule",{value:!0}),e.bytes=e.stringToBytes=e.str=e.bytesToString=e.hex=e.utf8=e.bech32m=e.bech32=e.base58check=e.createBase58check=e.base58xmr=e.base58xrp=e.base58flickr=e.base58=e.base64urlnopad=e.base64url=e.base64nopad=e.base64=e.base32crockford=e.base32hexnopad=e.base32hex=e.base32nopad=e.base32=e.base16=e.utils=void 0,e.assertNumber=n;const f=(t,e)=>e?f(e,t%e):t,l=(t,e)=>t+(e-f(t,e));function h(t,e,r,i){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(l(e,r)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${r} carryBits=${l(e,r)}`);let o=0,s=0;const a=2**r-1,u=[];for(const i of t){if(n(i),i>=2**e)throw new Error(`convertRadix2: invalid data word=${i} from=${e}`);if(o=o<<e|i,s+e>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);for(s+=e;s>=r;s-=r)u.push((o>>s-r&a)>>>0);o&=2**s-1}if(o=o<<r-s&a,!i&&s>=e)throw new Error("Excess padding");if(!i&&o)throw new Error(`Non-zero padding: ${o}`);return i&&s>0&&u.push(o>>>0),u}function d(t){return n(t),{encode:e=>{if(!r(e))throw new Error("radix.encode input should be Uint8Array");return c(Array.from(e),256,t)},decode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(c(e,t,256))}}}function p(t,e=!1){if(n(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(l(8,t)>32||l(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!r(n))throw new Error("radix2.encode input should be Uint8Array");return h(Array.from(n),8,t,!e)},decode:n=>{if(!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(h(n,t,8,e))}}}function y(t){if("function"!=typeof t)throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch(t){}}}function g(t,e){if(n(t),"function"!=typeof e)throw new Error("checksum fn should be function");return{encode(n){if(!r(n))throw new Error("checksum.encode: input should be Uint8Array");const i=e(n).slice(0,t),o=new Uint8Array(n.length+t);return o.set(n),o.set(i,n.length),o},decode(n){if(!r(n))throw new Error("checksum.decode: input should be Uint8Array");const i=n.slice(0,-t),o=e(i).slice(0,t),s=n.slice(-t);for(let e=0;e<t;e++)if(o[e]!==s[e])throw new Error("Invalid checksum");return i}}}e.utils={alphabet:o,chain:i,checksum:g,convertRadix:c,convertRadix2:h,radix:d,radix2:p,join:s,padding:a},e.base16=i(p(4),o("0123456789ABCDEF"),s("")),e.base32=i(p(5),o("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),a(5),s("")),e.base32nopad=i(p(5),o("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),s("")),e.base32hex=i(p(5),o("0123456789ABCDEFGHIJKLMNOPQRSTUV"),a(5),s("")),e.base32hexnopad=i(p(5),o("0123456789ABCDEFGHIJKLMNOPQRSTUV"),s("")),e.base32crockford=i(p(5),o("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),s(""),u(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),e.base64=i(p(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),a(6),s("")),e.base64nopad=i(p(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),s("")),e.base64url=i(p(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),a(6),s("")),e.base64urlnopad=i(p(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),s(""));const w=t=>i(d(58),o(t),s(""));e.base58=w("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),e.base58flickr=w("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),e.base58xrp=w("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const b=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let n="";for(let r=0;r<t.length;r+=8){const i=t.subarray(r,r+8);n+=e.base58.encode(i).padStart(b[i.length],"1")}return n},decode(t){let n=[];for(let r=0;r<t.length;r+=11){const i=t.slice(r,r+11),o=b.indexOf(i.length),s=e.base58.decode(i);for(let t=0;t<s.length-o;t++)if(0!==s[t])throw new Error("base58xmr: wrong padding");n=n.concat(Array.from(s.slice(s.length-o)))}return Uint8Array.from(n)}};e.createBase58check=t=>i(g(4,e=>t(t(e))),e.base58),e.base58check=e.createBase58check;const v=i(o("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),s("")),m=[996825010,642813549,513874426,1027748829,705979059];function x(t){const e=t>>25;let n=(33554431&t)<<5;for(let t=0;t<m.length;t++)1==(e>>t&1)&&(n^=m[t]);return n}function E(t,e,n=1){const r=t.length;let i=1;for(let e=0;e<r;e++){const n=t.charCodeAt(e);if(n<33||n>126)throw new Error(`Invalid prefix (${t})`);i=x(i)^n>>5}i=x(i);for(let e=0;e<r;e++)i=x(i)^31&t.charCodeAt(e);for(let t of e)i=x(i)^t;for(let t=0;t<6;t++)i=x(i);return i^=n,v.encode(h([i%2**30],30,5,!1))}function B(t){const e="bech32"===t?1:734539939,n=p(5),r=n.decode,i=n.encode,o=y(r);function s(t,n,r=90){if("string"!=typeof t)throw new Error("bech32.encode prefix should be string, not "+typeof t);if(n instanceof Uint8Array&&(n=Array.from(n)),!Array.isArray(n)||n.length&&"number"!=typeof n[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof n);if(0===t.length)throw new TypeError(`Invalid prefix length ${t.length}`);const i=t.length+7+n.length;if(!1!==r&&i>r)throw new TypeError(`Length ${i} exceeds limit ${r}`);const o=t.toLowerCase(),s=E(o,n,e);return`${o}1${v.encode(n)}${s}`}function a(t,n=90){if("string"!=typeof t)throw new Error("bech32.decode input should be string, not "+typeof t);if(t.length<8||!1!==n&&t.length>n)throw new TypeError(`Wrong string length: ${t.length} (${t}). Expected (8..${n})`);const r=t.toLowerCase();if(t!==r&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=r.lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const o=r.slice(0,i),s=r.slice(i+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=v.decode(s).slice(0,-6),u=E(o,a,e);if(!s.endsWith(u))throw new Error(`Invalid checksum in ${t}: expected "${u}"`);return{prefix:o,words:a}}return{encode:s,decode:a,encodeFromBytes:function(t,e){return s(t,i(e))},decodeToBytes:function(t){const{prefix:e,words:n}=a(t,!1);return{prefix:e,words:n,bytes:r(n)}},decodeUnsafe:y(a),fromWords:r,fromWordsUnsafe:o,toWords:i}}e.bech32=B("bech32"),e.bech32m=B("bech32m"),e.utf8={encode:t=>(new TextDecoder).decode(t),decode:t=>(new TextEncoder).encode(t)},e.hex=i(p(4),o("0123456789abcdef"),s(""),u(t=>{if("string"!=typeof t||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()}));const _={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},A="Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr";e.bytesToString=(t,e)=>{if("string"!=typeof t||!_.hasOwnProperty(t))throw new TypeError(A);if(!r(e))throw new TypeError("bytesToString() expects Uint8Array");return _[t].encode(e)},e.str=e.bytesToString;e.stringToBytes=(t,e)=>{if(!_.hasOwnProperty(t))throw new TypeError(A);if("string"!=typeof e)throw new TypeError("stringToBytes() expects string");return _[t].decode(e)},e.bytes=e.stringToBytes},933(t,e){"use strict";e.byteLength=function(t){var e=a(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,o=a(t),s=o[0],u=o[1],c=new i(function(t,e,n){return 3*(e+n)/4-n}(0,s,u)),f=0,l=u>0?s-4:s;for(n=0;n<l;n+=4)e=r[t.charCodeAt(n)]<<18|r[t.charCodeAt(n+1)]<<12|r[t.charCodeAt(n+2)]<<6|r[t.charCodeAt(n+3)],c[f++]=e>>16&255,c[f++]=e>>8&255,c[f++]=255&e;2===u&&(e=r[t.charCodeAt(n)]<<2|r[t.charCodeAt(n+1)]>>4,c[f++]=255&e);1===u&&(e=r[t.charCodeAt(n)]<<10|r[t.charCodeAt(n+1)]<<4|r[t.charCodeAt(n+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e);return c},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=16383,a=0,u=r-i;a<u;a+=s)o.push(c(t,a,a+s>u?u:a+s));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)n[s]=o[s],r[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function u(t){return n[t>>18&63]+n[t>>12&63]+n[t>>6&63]+n[63&t]}function c(t,e,n){for(var r,i=[],o=e;o<n;o+=3)r=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(u(r));return i.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},533(t,e,n){"use strict";const r=n(933),i=n(328),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.hp=u,e.IS=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return c(t,e,n)}function c(t,e,n){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|y(t,e);let r=a(n);const i=r.write(t,e);i!==n&&(r=r.slice(0,i));return r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(G(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(G(t,ArrayBuffer)||t&&G(t.buffer,ArrayBuffer))return d(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(G(t,SharedArrayBuffer)||t&&G(t.buffer,SharedArrayBuffer)))return d(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return u.from(r,e,n);const i=function(t){if(u.isBuffer(t)){const e=0|p(t.length),n=a(e);return 0===n.length||t.copy(n,0,0,e),n}if(void 0!==t.length)return"number"!=typeof t.length||Y(t.length)?a(0):h(t);if("Buffer"===t.type&&Array.isArray(t.data))return h(t.data)}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function f(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return f(t),a(t<0?0:0|p(t))}function h(t){const e=t.length<0?0:0|p(t.length),n=a(e);for(let r=0;r<e;r+=1)n[r]=255&t[r];return n}function d(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,u.prototype),r}function p(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||G(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return W(t).length;default:if(i)return r?-1:V(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,n){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return O(this,e,n);case"utf8":case"utf-8":return I(this,e,n);case"ascii":return S(this,e,n);case"latin1":case"binary":return U(this,e,n);case"base64":return A(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function w(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function b(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),Y(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=u.from(e,r)),u.isBuffer(e))return 0===e.length?-1:v(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):v(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,n,r,i){let o,s=1,a=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,n/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let r=-1;for(o=n;o<a;o++)if(c(t,o)===c(e,-1===r?0:o-r)){if(-1===r&&(r=o),o-r+1===u)return r*s}else-1!==r&&(o-=o-r),r=-1}else for(n+u>a&&(n=a-u),o=n;o>=0;o--){let n=!0;for(let r=0;r<u;r++)if(c(t,o+r)!==c(e,r)){n=!1;break}if(n)return o}return-1}function m(t,e,n,r){n=Number(n)||0;const i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;const o=e.length;let s;for(r>o/2&&(r=o/2),s=0;s<r;++s){const r=parseInt(e.substr(2*s,2),16);if(Y(r))return s;t[n+s]=r}return s}function x(t,e,n,r){return Z(V(e,t.length-n),t,n,r)}function E(t,e,n,r){return Z(function(t){const e=[];for(let n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function B(t,e,n,r){return Z(W(e),t,n,r)}function _(t,e,n,r){return Z(function(t,e){let n,r,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function A(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function I(t,e,n){n=Math.min(t.length,n);const r=[];let i=e;for(;i<n;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=n){let n,r,a,u;switch(s){case 1:e<128&&(o=e);break;case 2:n=t[i+1],128==(192&n)&&(u=(31&e)<<6|63&n,u>127&&(o=u));break;case 3:n=t[i+1],r=t[i+2],128==(192&n)&&128==(192&r)&&(u=(15&e)<<12|(63&n)<<6|63&r,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:n=t[i+1],r=t[i+2],a=t[i+3],128==(192&n)&&128==(192&r)&&128==(192&a)&&(u=(15&e)<<18|(63&n)<<12|(63&r)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),i+=s}return function(t){const e=t.length;if(e<=k)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=k));return n}(r)}u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,n){return c(t,e,n)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,n){return function(t,e,n){return f(t),t<=0?a(t):void 0!==e?"string"==typeof n?a(t).fill(e,n):a(t).fill(e):a(t)}(t,e,n)},u.allocUnsafe=function(t){return l(t)},u.allocUnsafeSlow=function(t){return l(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(G(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),G(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,r=e.length;for(let i=0,o=Math.min(n,r);i<o;++i)if(t[i]!==e[i]){n=t[i],r=e[i];break}return n<r?-1:r<n?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const r=u.allocUnsafe(e);let i=0;for(n=0;n<t.length;++n){let e=t[n];if(G(e,Uint8Array))i+e.length>r.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(r,i)):Uint8Array.prototype.set.call(r,e,i);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,i)}i+=e.length}return r},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)w(this,e,e+1);return this},u.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)w(this,e,e+3),w(this,e+1,e+2);return this},u.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?I(this,0,t):g.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const n=e.IS;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(t,e,n,r,i){if(G(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;let o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(e>>>=0);const a=Math.min(o,s),c=this.slice(r,i),f=t.slice(e,n);for(let t=0;t<a;++t)if(c[t]!==f[t]){o=c[t],s=f[t];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},u.prototype.indexOf=function(t,e,n){return b(this,t,e,n,!0)},u.prototype.lastIndexOf=function(t,e,n){return b(this,t,e,n,!1)},u.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let o=!1;for(;;)switch(r){case"hex":return m(this,t,e,n);case"utf8":case"utf-8":return x(this,t,e,n);case"ascii":case"latin1":case"binary":return E(this,t,e,n);case"base64":return B(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const k=4096;function S(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(127&t[i]);return r}function U(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;i<n;++i)r+=String.fromCharCode(t[i]);return r}function O(t,e,n){const r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let i="";for(let r=e;r<n;++r)i+=X[t[r]];return i}function R(t,e,n){const r=t.slice(e,n);let i="";for(let t=0;t<r.length-1;t+=2)i+=String.fromCharCode(r[t]+256*r[t+1]);return i}function L(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function C(t,e,n,r,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function K(t,e,n,r,i){D(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function T(t,e,n,r,i){D(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n+7]=o,o>>=8,t[n+6]=o,o>>=8,t[n+5]=o,o>>=8,t[n+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function P(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function F(t,e,n,r,o){return e=+e,n>>>=0,o||P(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function H(t,e,n,r,o){return e=+e,n>>>=0,o||P(t,0,n,8),i.write(t,e,n,r,52,8),n+8}u.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const r=this.subarray(t,e);return Object.setPrototypeOf(r,u.prototype),r},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||L(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return r},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||L(t,e,this.length);let r=this[t+--e],i=1;for(;e>0&&(i*=256);)r+=this[t+--e]*i;return r},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||L(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||L(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||L(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||L(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||L(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=J(function(t){z(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||q(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=J(function(t){z(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||q(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||L(t,e,this.length);let r=this[t],i=1,o=0;for(;++o<e&&(i*=256);)r+=this[t+o]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*e)),r},u.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||L(t,e,this.length);let r=e,i=1,o=this[t+--r];for(;r>0&&(i*=256);)o+=this[t+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||L(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||L(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(t,e){t>>>=0,e||L(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||L(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=J(function(t){z(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||q(t,this.length-8);const r=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),u.prototype.readBigInt64BE=J(function(t){z(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||q(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+n)}),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||L(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||L(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||L(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||L(t,8,this.length),i.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,n,r){if(t=+t,e>>>=0,n>>>=0,!r){C(this,t,e,n,Math.pow(2,8*n)-1,0)}let i=1,o=0;for(this[e]=255&t;++o<n&&(i*=256);)this[e+o]=t/i&255;return e+n},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,n,r){if(t=+t,e>>>=0,n>>>=0,!r){C(this,t,e,n,Math.pow(2,8*n)-1,0)}let i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=J(function(t,e=0){return K(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=J(function(t,e=0){return T(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);C(this,t,e,n,r-1,-r)}let i=0,o=1,s=0;for(this[e]=255&t;++i<n&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o|0)-s&255;return e+n},u.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);C(this,t,e,n,r-1,-r)}let i=n-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o|0)-s&255;return e+n},u.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=J(function(t,e=0){return K(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=J(function(t,e=0){return T(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeFloatLE=function(t,e,n){return F(this,t,e,!0,n)},u.prototype.writeFloatBE=function(t,e,n){return F(this,t,e,!1,n)},u.prototype.writeDoubleLE=function(t,e,n){return H(this,t,e,!0,n)},u.prototype.writeDoubleBE=function(t,e,n){return H(this,t,e,!1,n)},u.prototype.copy=function(t,e,n,r){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);const i=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),i},u.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){const e=t.charCodeAt(0);("utf8"===r&&e<128||"latin1"===r)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let i;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i<n;++i)this[i]=t;else{const o=u.isBuffer(t)?t:u.from(t,r),s=o.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<n-e;++i)this[i+e]=o[i%s]}return this};const j={};function N(t,e,n){j[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function $(t){let e="",n=t.length;const r="-"===t[0]?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function D(t,e,n,r,i,o){if(t>n||t<e){const r="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`:`>= ${e}${r} and <= ${n}${r}`,new j.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,n){z(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||q(e,t.length-(n+1))}(r,i,o)}function z(t,e){if("number"!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,"number",t)}function q(t,e,n){if(Math.floor(t)!==t)throw z(t,n),new j.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new j.ERR_BUFFER_OUT_OF_BOUNDS;throw new j.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}N("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),N("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),N("ERR_OUT_OF_RANGE",function(t,e,n){let r=`The value of "${t}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=$(String(n)):"bigint"==typeof n&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=$(i)),i+="n"),r+=` It must be ${e}. Received ${i}`,r},RangeError);const M=/[^+/0-9A-Za-z-_]/g;function V(t,e){let n;e=e||1/0;const r=t.length;let i=null;const o=[];for(let s=0;s<r;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function W(t){return r.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Z(t,e,n,r){let i;for(i=0;i<r&&!(i+n>=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function G(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let i=0;i<16;++i)e[r+i]=t[n]+t[i]}return e}();function J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},328(t,e){e.read=function(t,e,n,r,i){var o,s,a=8*i-r-1,u=(1<<a)-1,c=u>>1,f=-7,l=n?i-1:0,h=n?-1:1,d=t[e+l];for(l+=h,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+t[e+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=r;f>0;s=256*s+t[e+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),o-=c}return(d?-1:1)*s*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var s,a,u,c=8*o-i-1,f=(1<<c)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(e*u-1)*Math.pow(2,i),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[n+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;t[n+d]=255&s,d+=p,s/=256,c-=8);t[n+d-p]|=128*y}},680(t,e,n){var r;t=n.nmd(t),function(){var i,o="Expected a function",s="__lodash_hash_undefined__",a="__lodash_placeholder__",u=16,c=32,f=64,l=128,h=256,d=1/0,p=9007199254740991,y=NaN,g=4294967295,w=[["ary",l],["bind",1],["bindKey",2],["curry",8],["curryRight",u],["flip",512],["partial",c],["partialRight",f],["rearg",h]],b="[object Arguments]",v="[object Array]",m="[object Boolean]",x="[object Date]",E="[object Error]",B="[object Function]",_="[object GeneratorFunction]",A="[object Map]",I="[object Number]",k="[object Object]",S="[object Promise]",U="[object RegExp]",O="[object Set]",R="[object String]",L="[object Symbol]",C="[object WeakMap]",K="[object ArrayBuffer]",T="[object DataView]",P="[object Float32Array]",F="[object Float64Array]",H="[object Int8Array]",j="[object Int16Array]",N="[object Int32Array]",$="[object Uint8Array]",D="[object Uint8ClampedArray]",z="[object Uint16Array]",q="[object Uint32Array]",M=/\b__p \+= '';/g,V=/\b(__p \+=) '' \+/g,W=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Z=/&(?:amp|lt|gt|quot|#39);/g,G=/[&<>"']/g,Y=RegExp(Z.source),X=RegExp(G.source),J=/<%-([\s\S]+?)%>/g,Q=/<%([\s\S]+?)%>/g,tt=/<%=([\s\S]+?)%>/g,et=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,nt=/^\w*$/,rt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,it=/[\\^$.*+?()[\]{}|]/g,ot=RegExp(it.source),st=/^\s+/,at=/\s/,ut=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ct=/\{\n\/\* \[wrapped with (.+)\] \*/,ft=/,? & /,lt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ht=/[()=,{}\[\]\/\s]/,dt=/\\(\\)?/g,pt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,yt=/\w*$/,gt=/^[-+]0x[0-9a-f]+$/i,wt=/^0b[01]+$/i,bt=/^\[object .+?Constructor\]$/,vt=/^0o[0-7]+$/i,mt=/^(?:0|[1-9]\d*)$/,xt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Et=/($^)/,Bt=/['\n\r\u2028\u2029\\]/g,_t="\\ud800-\\udfff",At="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",It="\\u2700-\\u27bf",kt="a-z\\xdf-\\xf6\\xf8-\\xff",St="A-Z\\xc0-\\xd6\\xd8-\\xde",Ut="\\ufe0e\\ufe0f",Ot="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Rt="['’]",Lt="["+_t+"]",Ct="["+Ot+"]",Kt="["+At+"]",Tt="\\d+",Pt="["+It+"]",Ft="["+kt+"]",Ht="[^"+_t+Ot+Tt+It+kt+St+"]",jt="\\ud83c[\\udffb-\\udfff]",Nt="[^"+_t+"]",$t="(?:\\ud83c[\\udde6-\\uddff]){2}",Dt="[\\ud800-\\udbff][\\udc00-\\udfff]",zt="["+St+"]",qt="\\u200d",Mt="(?:"+Ft+"|"+Ht+")",Vt="(?:"+zt+"|"+Ht+")",Wt="(?:['’](?:d|ll|m|re|s|t|ve))?",Zt="(?:['’](?:D|LL|M|RE|S|T|VE))?",Gt="(?:"+Kt+"|"+jt+")"+"?",Yt="["+Ut+"]?",Xt=Yt+Gt+("(?:"+qt+"(?:"+[Nt,$t,Dt].join("|")+")"+Yt+Gt+")*"),Jt="(?:"+[Pt,$t,Dt].join("|")+")"+Xt,Qt="(?:"+[Nt+Kt+"?",Kt,$t,Dt,Lt].join("|")+")",te=RegExp(Rt,"g"),ee=RegExp(Kt,"g"),ne=RegExp(jt+"(?="+jt+")|"+Qt+Xt,"g"),re=RegExp([zt+"?"+Ft+"+"+Wt+"(?="+[Ct,zt,"$"].join("|")+")",Vt+"+"+Zt+"(?="+[Ct,zt+Mt,"$"].join("|")+")",zt+"?"+Mt+"+"+Wt,zt+"+"+Zt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Tt,Jt].join("|"),"g"),ie=RegExp("["+qt+_t+At+Ut+"]"),oe=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,se=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ae=-1,ue={};ue[P]=ue[F]=ue[H]=ue[j]=ue[N]=ue[$]=ue[D]=ue[z]=ue[q]=!0,ue[b]=ue[v]=ue[K]=ue[m]=ue[T]=ue[x]=ue[E]=ue[B]=ue[A]=ue[I]=ue[k]=ue[U]=ue[O]=ue[R]=ue[C]=!1;var ce={};ce[b]=ce[v]=ce[K]=ce[T]=ce[m]=ce[x]=ce[P]=ce[F]=ce[H]=ce[j]=ce[N]=ce[A]=ce[I]=ce[k]=ce[U]=ce[O]=ce[R]=ce[L]=ce[$]=ce[D]=ce[z]=ce[q]=!0,ce[E]=ce[B]=ce[C]=!1;var fe={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},le=parseFloat,he=parseInt,de="object"==typeof globalThis&&globalThis&&globalThis.Object===Object&&globalThis,pe="object"==typeof self&&self&&self.Object===Object&&self,ye=de||pe||Function("return this")(),ge=e&&!e.nodeType&&e,we=ge&&t&&!t.nodeType&&t,be=we&&we.exports===ge,ve=be&&de.process,me=function(){try{var t=we&&we.require&&we.require("util").types;return t||ve&&ve.binding&&ve.binding("util")}catch(t){}}(),xe=me&&me.isArrayBuffer,Ee=me&&me.isDate,Be=me&&me.isMap,_e=me&&me.isRegExp,Ae=me&&me.isSet,Ie=me&&me.isTypedArray;function ke(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function Se(t,e,n,r){for(var i=-1,o=null==t?0:t.length;++i<o;){var s=t[i];e(r,s,n(s),t)}return r}function Ue(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}function Oe(t,e){for(var n=null==t?0:t.length;n--&&!1!==e(t[n],n,t););return t}function Re(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(!e(t[n],n,t))return!1;return!0}function Le(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var s=t[n];e(s,n,t)&&(o[i++]=s)}return o}function Ce(t,e){return!!(null==t?0:t.length)&&ze(t,e,0)>-1}function Ke(t,e,n){for(var r=-1,i=null==t?0:t.length;++r<i;)if(n(e,t[r]))return!0;return!1}function Te(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}function Pe(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}function Fe(t,e,n,r){var i=-1,o=null==t?0:t.length;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}function He(t,e,n,r){var i=null==t?0:t.length;for(r&&i&&(n=t[--i]);i--;)n=e(n,t[i],i,t);return n}function je(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}var Ne=We("length");function $e(t,e,n){var r;return n(t,function(t,n,i){if(e(t,n,i))return r=n,!1}),r}function De(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o<i;)if(e(t[o],o,t))return o;return-1}function ze(t,e,n){return e==e?function(t,e,n){var r=n-1,i=t.length;for(;++r<i;)if(t[r]===e)return r;return-1}(t,e,n):De(t,Me,n)}function qe(t,e,n,r){for(var i=n-1,o=t.length;++i<o;)if(r(t[i],e))return i;return-1}function Me(t){return t!=t}function Ve(t,e){var n=null==t?0:t.length;return n?Ye(t,e)/n:y}function We(t){return function(e){return null==e?i:e[t]}}function Ze(t){return function(e){return null==t?i:t[e]}}function Ge(t,e,n,r,i){return i(t,function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)}),n}function Ye(t,e){for(var n,r=-1,o=t.length;++r<o;){var s=e(t[r]);s!==i&&(n=n===i?s:n+s)}return n}function Xe(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}function Je(t){return t?t.slice(0,gn(t)+1).replace(st,""):t}function Qe(t){return function(e){return t(e)}}function tn(t,e){return Te(e,function(e){return t[e]})}function en(t,e){return t.has(e)}function nn(t,e){for(var n=-1,r=t.length;++n<r&&ze(e,t[n],0)>-1;);return n}function rn(t,e){for(var n=t.length;n--&&ze(e,t[n],0)>-1;);return n}var on=Ze({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),sn=Ze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function an(t){return"\\"+fe[t]}function un(t){return ie.test(t)}function cn(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}function fn(t,e){return function(n){return t(e(n))}}function ln(t,e){for(var n=-1,r=t.length,i=0,o=[];++n<r;){var s=t[n];s!==e&&s!==a||(t[n]=a,o[i++]=n)}return o}function hn(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}function dn(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=[t,t]}),n}function pn(t){return un(t)?function(t){var e=ne.lastIndex=0;for(;ne.test(t);)++e;return e}(t):Ne(t)}function yn(t){return un(t)?function(t){return t.match(ne)||[]}(t):function(t){return t.split("")}(t)}function gn(t){for(var e=t.length;e--&&at.test(t.charAt(e)););return e}var wn=Ze({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"});var bn=function t(e){var n,r=(e=null==e?ye:bn.defaults(ye.Object(),e,bn.pick(ye,se))).Array,at=e.Date,_t=e.Error,At=e.Function,It=e.Math,kt=e.Object,St=e.RegExp,Ut=e.String,Ot=e.TypeError,Rt=r.prototype,Lt=At.prototype,Ct=kt.prototype,Kt=e["__core-js_shared__"],Tt=Lt.toString,Pt=Ct.hasOwnProperty,Ft=0,Ht=(n=/[^.]+$/.exec(Kt&&Kt.keys&&Kt.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",jt=Ct.toString,Nt=Tt.call(kt),$t=ye._,Dt=St("^"+Tt.call(Pt).replace(it,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),zt=be?e.Buffer:i,qt=e.Symbol,Mt=e.Uint8Array,Vt=zt?zt.allocUnsafe:i,Wt=fn(kt.getPrototypeOf,kt),Zt=kt.create,Gt=Ct.propertyIsEnumerable,Yt=Rt.splice,Xt=qt?qt.isConcatSpreadable:i,Jt=qt?qt.iterator:i,Qt=qt?qt.toStringTag:i,ne=function(){try{var t=ho(kt,"defineProperty");return t({},"",{}),t}catch(t){}}(),ie=e.clearTimeout!==ye.clearTimeout&&e.clearTimeout,fe=at&&at.now!==ye.Date.now&&at.now,de=e.setTimeout!==ye.setTimeout&&e.setTimeout,pe=It.ceil,ge=It.floor,we=kt.getOwnPropertySymbols,ve=zt?zt.isBuffer:i,me=e.isFinite,Ne=Rt.join,Ze=fn(kt.keys,kt),vn=It.max,mn=It.min,xn=at.now,En=e.parseInt,Bn=It.random,_n=Rt.reverse,An=ho(e,"DataView"),In=ho(e,"Map"),kn=ho(e,"Promise"),Sn=ho(e,"Set"),Un=ho(e,"WeakMap"),On=ho(kt,"create"),Rn=Un&&new Un,Ln={},Cn=jo(An),Kn=jo(In),Tn=jo(kn),Pn=jo(Sn),Fn=jo(Un),Hn=qt?qt.prototype:i,jn=Hn?Hn.valueOf:i,Nn=Hn?Hn.toString:i;function $n(t){if(na(t)&&!Ms(t)&&!(t instanceof Mn)){if(t instanceof qn)return t;if(Pt.call(t,"__wrapped__"))return No(t)}return new qn(t)}var Dn=function(){function t(){}return function(e){if(!ea(e))return{};if(Zt)return Zt(e);t.prototype=e;var n=new t;return t.prototype=i,n}}();function zn(){}function qn(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=i}function Mn(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=g,this.__views__=[]}function Vn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Wn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Zn(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Gn(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new Zn;++e<n;)this.add(t[e])}function Yn(t){var e=this.__data__=new Wn(t);this.size=e.size}function Xn(t,e){var n=Ms(t),r=!n&&qs(t),i=!n&&!r&&Gs(t),o=!n&&!r&&!i&&fa(t),s=n||r||i||o,a=s?Xe(t.length,Ut):[],u=a.length;for(var c in t)!e&&!Pt.call(t,c)||s&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||mo(c,u))||a.push(c);return a}function Jn(t){var e=t.length;return e?t[Gr(0,e-1)]:i}function Qn(t,e){return Po(Oi(t),ur(e,0,t.length))}function tr(t){return Po(Oi(t))}function er(t,e,n){(n!==i&&!$s(t[e],n)||n===i&&!(e in t))&&sr(t,e,n)}function nr(t,e,n){var r=t[e];Pt.call(t,e)&&$s(r,n)&&(n!==i||e in t)||sr(t,e,n)}function rr(t,e){for(var n=t.length;n--;)if($s(t[n][0],e))return n;return-1}function ir(t,e,n,r){return dr(t,function(t,i,o){e(r,t,n(t),o)}),r}function or(t,e){return t&&Ri(e,La(e),t)}function sr(t,e,n){"__proto__"==e&&ne?ne(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function ar(t,e){for(var n=-1,o=e.length,s=r(o),a=null==t;++n<o;)s[n]=a?i:ka(t,e[n]);return s}function ur(t,e,n){return t==t&&(n!==i&&(t=t<=n?t:n),e!==i&&(t=t>=e?t:e)),t}function cr(t,e,n,r,o,s){var a,u=1&e,c=2&e,f=4&e;if(n&&(a=o?n(t,r,o,s):n(t)),a!==i)return a;if(!ea(t))return t;var l=Ms(t);if(l){if(a=function(t){var e=t.length,n=new t.constructor(e);e&&"string"==typeof t[0]&&Pt.call(t,"index")&&(n.index=t.index,n.input=t.input);return n}(t),!u)return Oi(t,a)}else{var h=go(t),d=h==B||h==_;if(Gs(t))return _i(t,u);if(h==k||h==b||d&&!o){if(a=c||d?{}:bo(t),!u)return c?function(t,e){return Ri(t,yo(t),e)}(t,function(t,e){return t&&Ri(e,Ca(e),t)}(a,t)):function(t,e){return Ri(t,po(t),e)}(t,or(a,t))}else{if(!ce[h])return o?t:{};a=function(t,e,n){var r=t.constructor;switch(e){case K:return Ai(t);case m:case x:return new r(+t);case T:return function(t,e){var n=e?Ai(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case P:case F:case H:case j:case N:case $:case D:case z:case q:return Ii(t,n);case A:return new r;case I:case R:return new r(t);case U:return function(t){var e=new t.constructor(t.source,yt.exec(t));return e.lastIndex=t.lastIndex,e}(t);case O:return new r;case L:return i=t,jn?kt(jn.call(i)):{}}var i}(t,h,u)}}s||(s=new Yn);var p=s.get(t);if(p)return p;s.set(t,a),aa(t)?t.forEach(function(r){a.add(cr(r,e,n,r,t,s))}):ra(t)&&t.forEach(function(r,i){a.set(i,cr(r,e,n,i,t,s))});var y=l?i:(f?c?oo:io:c?Ca:La)(t);return Ue(y||t,function(r,i){y&&(r=t[i=r]),nr(a,i,cr(r,e,n,i,t,s))}),a}function fr(t,e,n){var r=n.length;if(null==t)return!r;for(t=kt(t);r--;){var o=n[r],s=e[o],a=t[o];if(a===i&&!(o in t)||!s(a))return!1}return!0}function lr(t,e,n){if("function"!=typeof t)throw new Ot(o);return Lo(function(){t.apply(i,n)},e)}function hr(t,e,n,r){var i=-1,o=Ce,s=!0,a=t.length,u=[],c=e.length;if(!a)return u;n&&(e=Te(e,Qe(n))),r?(o=Ke,s=!1):e.length>=200&&(o=en,s=!1,e=new Gn(e));t:for(;++i<a;){var f=t[i],l=null==n?f:n(f);if(f=r||0!==f?f:0,s&&l==l){for(var h=c;h--;)if(e[h]===l)continue t;u.push(f)}else o(e,l,r)||u.push(f)}return u}$n.templateSettings={escape:J,evaluate:Q,interpolate:tt,variable:"",imports:{_:$n}},$n.prototype=zn.prototype,$n.prototype.constructor=$n,qn.prototype=Dn(zn.prototype),qn.prototype.constructor=qn,Mn.prototype=Dn(zn.prototype),Mn.prototype.constructor=Mn,Vn.prototype.clear=function(){this.__data__=On?On(null):{},this.size=0},Vn.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Vn.prototype.get=function(t){var e=this.__data__;if(On){var n=e[t];return n===s?i:n}return Pt.call(e,t)?e[t]:i},Vn.prototype.has=function(t){var e=this.__data__;return On?e[t]!==i:Pt.call(e,t)},Vn.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=On&&e===i?s:e,this},Wn.prototype.clear=function(){this.__data__=[],this.size=0},Wn.prototype.delete=function(t){var e=this.__data__,n=rr(e,t);return!(n<0)&&(n==e.length-1?e.pop():Yt.call(e,n,1),--this.size,!0)},Wn.prototype.get=function(t){var e=this.__data__,n=rr(e,t);return n<0?i:e[n][1]},Wn.prototype.has=function(t){return rr(this.__data__,t)>-1},Wn.prototype.set=function(t,e){var n=this.__data__,r=rr(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},Zn.prototype.clear=function(){this.size=0,this.__data__={hash:new Vn,map:new(In||Wn),string:new Vn}},Zn.prototype.delete=function(t){var e=fo(this,t).delete(t);return this.size-=e?1:0,e},Zn.prototype.get=function(t){return fo(this,t).get(t)},Zn.prototype.has=function(t){return fo(this,t).has(t)},Zn.prototype.set=function(t,e){var n=fo(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},Gn.prototype.add=Gn.prototype.push=function(t){return this.__data__.set(t,s),this},Gn.prototype.has=function(t){return this.__data__.has(t)},Yn.prototype.clear=function(){this.__data__=new Wn,this.size=0},Yn.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},Yn.prototype.get=function(t){return this.__data__.get(t)},Yn.prototype.has=function(t){return this.__data__.has(t)},Yn.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Wn){var r=n.__data__;if(!In||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new Zn(r)}return n.set(t,e),this.size=n.size,this};var dr=Ki(xr),pr=Ki(Er,!0);function yr(t,e){var n=!0;return dr(t,function(t,r,i){return n=!!e(t,r,i)}),n}function gr(t,e,n){for(var r=-1,o=t.length;++r<o;){var s=t[r],a=e(s);if(null!=a&&(u===i?a==a&&!ca(a):n(a,u)))var u=a,c=s}return c}function wr(t,e){var n=[];return dr(t,function(t,r,i){e(t,r,i)&&n.push(t)}),n}function br(t,e,n,r,i){var o=-1,s=t.length;for(n||(n=vo),i||(i=[]);++o<s;){var a=t[o];e>0&&n(a)?e>1?br(a,e-1,n,r,i):Pe(i,a):r||(i[i.length]=a)}return i}var vr=Ti(),mr=Ti(!0);function xr(t,e){return t&&vr(t,e,La)}function Er(t,e){return t&&mr(t,e,La)}function Br(t,e){return Le(e,function(e){return Js(t[e])})}function _r(t,e){for(var n=0,r=(e=mi(e,t)).length;null!=t&&n<r;)t=t[Ho(e[n++])];return n&&n==r?t:i}function Ar(t,e,n){var r=e(t);return Ms(t)?r:Pe(r,n(t))}function Ir(t){return null==t?t===i?"[object Undefined]":"[object Null]":Qt&&Qt in kt(t)?function(t){var e=Pt.call(t,Qt),n=t[Qt];try{t[Qt]=i;var r=!0}catch(t){}var o=jt.call(t);r&&(e?t[Qt]=n:delete t[Qt]);return o}(t):function(t){return jt.call(t)}(t)}function kr(t,e){return t>e}function Sr(t,e){return null!=t&&Pt.call(t,e)}function Ur(t,e){return null!=t&&e in kt(t)}function Or(t,e,n){for(var o=n?Ke:Ce,s=t[0].length,a=t.length,u=a,c=r(a),f=1/0,l=[];u--;){var h=t[u];u&&e&&(h=Te(h,Qe(e))),f=mn(h.length,f),c[u]=!n&&(e||s>=120&&h.length>=120)?new Gn(u&&h):i}h=t[0];var d=-1,p=c[0];t:for(;++d<s&&l.length<f;){var y=h[d],g=e?e(y):y;if(y=n||0!==y?y:0,!(p?en(p,g):o(l,g,n))){for(u=a;--u;){var w=c[u];if(!(w?en(w,g):o(t[u],g,n)))continue t}p&&p.push(g),l.push(y)}}return l}function Rr(t,e,n){var r=null==(t=Uo(t,e=mi(e,t)))?t:t[Ho(Xo(e))];return null==r?i:ke(r,t,n)}function Lr(t){return na(t)&&Ir(t)==b}function Cr(t,e,n,r,o){return t===e||(null==t||null==e||!na(t)&&!na(e)?t!=t&&e!=e:function(t,e,n,r,o,s){var a=Ms(t),u=Ms(e),c=a?v:go(t),f=u?v:go(e),l=(c=c==b?k:c)==k,h=(f=f==b?k:f)==k,d=c==f;if(d&&Gs(t)){if(!Gs(e))return!1;a=!0,l=!1}if(d&&!l)return s||(s=new Yn),a||fa(t)?no(t,e,n,r,o,s):function(t,e,n,r,i,o,s){switch(n){case T:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case K:return!(t.byteLength!=e.byteLength||!o(new Mt(t),new Mt(e)));case m:case x:case I:return $s(+t,+e);case E:return t.name==e.name&&t.message==e.message;case U:case R:return t==e+"";case A:var a=cn;case O:var u=1&r;if(a||(a=hn),t.size!=e.size&&!u)return!1;var c=s.get(t);if(c)return c==e;r|=2,s.set(t,e);var f=no(a(t),a(e),r,i,o,s);return s.delete(t),f;case L:if(jn)return jn.call(t)==jn.call(e)}return!1}(t,e,c,n,r,o,s);if(!(1&n)){var p=l&&Pt.call(t,"__wrapped__"),y=h&&Pt.call(e,"__wrapped__");if(p||y){var g=p?t.value():t,w=y?e.value():e;return s||(s=new Yn),o(g,w,n,r,s)}}if(!d)return!1;return s||(s=new Yn),function(t,e,n,r,o,s){var a=1&n,u=io(t),c=u.length,f=io(e),l=f.length;if(c!=l&&!a)return!1;var h=c;for(;h--;){var d=u[h];if(!(a?d in e:Pt.call(e,d)))return!1}var p=s.get(t),y=s.get(e);if(p&&y)return p==e&&y==t;var g=!0;s.set(t,e),s.set(e,t);var w=a;for(;++h<c;){var b=t[d=u[h]],v=e[d];if(r)var m=a?r(v,b,d,e,t,s):r(b,v,d,t,e,s);if(!(m===i?b===v||o(b,v,n,r,s):m)){g=!1;break}w||(w="constructor"==d)}if(g&&!w){var x=t.constructor,E=e.constructor;x==E||!("constructor"in t)||!("constructor"in e)||"function"==typeof x&&x instanceof x&&"function"==typeof E&&E instanceof E||(g=!1)}return s.delete(t),s.delete(e),g}(t,e,n,r,o,s)}(t,e,n,r,Cr,o))}function Kr(t,e,n,r){var o=n.length,s=o,a=!r;if(null==t)return!s;for(t=kt(t);o--;){var u=n[o];if(a&&u[2]?u[1]!==t[u[0]]:!(u[0]in t))return!1}for(;++o<s;){var c=(u=n[o])[0],f=t[c],l=u[1];if(a&&u[2]){if(f===i&&!(c in t))return!1}else{var h=new Yn;if(r)var d=r(f,l,c,t,e,h);if(!(d===i?Cr(l,f,3,r,h):d))return!1}}return!0}function Tr(t){return!(!ea(t)||(e=t,Ht&&Ht in e))&&(Js(t)?Dt:bt).test(jo(t));var e}function Pr(t){return"function"==typeof t?t:null==t?iu:"object"==typeof t?Ms(t)?Dr(t[0],t[1]):$r(t):du(t)}function Fr(t){if(!Ao(t))return Ze(t);var e=[];for(var n in kt(t))Pt.call(t,n)&&"constructor"!=n&&e.push(n);return e}function Hr(t){if(!ea(t))return function(t){var e=[];if(null!=t)for(var n in kt(t))e.push(n);return e}(t);var e=Ao(t),n=[];for(var r in t)("constructor"!=r||!e&&Pt.call(t,r))&&n.push(r);return n}function jr(t,e){return t<e}function Nr(t,e){var n=-1,i=Ws(t)?r(t.length):[];return dr(t,function(t,r,o){i[++n]=e(t,r,o)}),i}function $r(t){var e=lo(t);return 1==e.length&&e[0][2]?ko(e[0][0],e[0][1]):function(n){return n===t||Kr(n,t,e)}}function Dr(t,e){return Eo(t)&&Io(e)?ko(Ho(t),e):function(n){var r=ka(n,t);return r===i&&r===e?Sa(n,t):Cr(e,r,3)}}function zr(t,e,n,r,o){t!==e&&vr(e,function(s,a){if(o||(o=new Yn),ea(s))!function(t,e,n,r,o,s,a){var u=Oo(t,n),c=Oo(e,n),f=a.get(c);if(f)return void er(t,n,f);var l=s?s(u,c,n+"",t,e,a):i,h=l===i;if(h){var d=Ms(c),p=!d&&Gs(c),y=!d&&!p&&fa(c);l=c,d||p||y?Ms(u)?l=u:Zs(u)?l=Oi(u):p?(h=!1,l=_i(c,!0)):y?(h=!1,l=Ii(c,!0)):l=[]:oa(c)||qs(c)?(l=u,qs(u)?l=ba(u):ea(u)&&!Js(u)||(l=bo(c))):h=!1}h&&(a.set(c,l),o(l,c,r,s,a),a.delete(c));er(t,n,l)}(t,e,a,n,zr,r,o);else{var u=r?r(Oo(t,a),s,a+"",t,e,o):i;u===i&&(u=s),er(t,a,u)}},Ca)}function qr(t,e){var n=t.length;if(n)return mo(e+=e<0?n:0,n)?t[e]:i}function Mr(t,e,n){e=e.length?Te(e,function(t){return Ms(t)?function(e){return _r(e,1===t.length?t[0]:t)}:t}):[iu];var r=-1;e=Te(e,Qe(co()));var i=Nr(t,function(t,n,i){var o=Te(e,function(e){return e(t)});return{criteria:o,index:++r,value:t}});return function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}(i,function(t,e){return function(t,e,n){var r=-1,i=t.criteria,o=e.criteria,s=i.length,a=n.length;for(;++r<s;){var u=ki(i[r],o[r]);if(u)return r>=a?u:u*("desc"==n[r]?-1:1)}return t.index-e.index}(t,e,n)})}function Vr(t,e,n){for(var r=-1,i=e.length,o={};++r<i;){var s=e[r],a=_r(t,s);n(a,s)&&ti(o,mi(s,t),a)}return o}function Wr(t,e,n,r){var i=r?qe:ze,o=-1,s=e.length,a=t;for(t===e&&(e=Oi(e)),n&&(a=Te(t,Qe(n)));++o<s;)for(var u=0,c=e[o],f=n?n(c):c;(u=i(a,f,u,r))>-1;)a!==t&&Yt.call(a,u,1),Yt.call(t,u,1);return t}function Zr(t,e){for(var n=t?e.length:0,r=n-1;n--;){var i=e[n];if(n==r||i!==o){var o=i;mo(i)?Yt.call(t,i,1):hi(t,i)}}return t}function Gr(t,e){return t+ge(Bn()*(e-t+1))}function Yr(t,e){var n="";if(!t||e<1||e>p)return n;do{e%2&&(n+=t),(e=ge(e/2))&&(t+=t)}while(e);return n}function Xr(t,e){return Co(So(t,e,iu),t+"")}function Jr(t){return Jn($a(t))}function Qr(t,e){var n=$a(t);return Po(n,ur(e,0,n.length))}function ti(t,e,n,r){if(!ea(t))return t;for(var o=-1,s=(e=mi(e,t)).length,a=s-1,u=t;null!=u&&++o<s;){var c=Ho(e[o]),f=n;if("__proto__"===c||"constructor"===c||"prototype"===c)return t;if(o!=a){var l=u[c];(f=r?r(l,c,u):i)===i&&(f=ea(l)?l:mo(e[o+1])?[]:{})}nr(u,c,f),u=u[c]}return t}var ei=Rn?function(t,e){return Rn.set(t,e),t}:iu,ni=ne?function(t,e){return ne(t,"toString",{configurable:!0,enumerable:!1,value:eu(e),writable:!0})}:iu;function ri(t){return Po($a(t))}function ii(t,e,n){var i=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(n=n>o?o:n)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var s=r(o);++i<o;)s[i]=t[i+e];return s}function oi(t,e){var n;return dr(t,function(t,r,i){return!(n=e(t,r,i))}),!!n}function si(t,e,n){var r=0,i=null==t?r:t.length;if("number"==typeof e&&e==e&&i<=2147483647){for(;r<i;){var o=r+i>>>1,s=t[o];null!==s&&!ca(s)&&(n?s<=e:s<e)?r=o+1:i=o}return i}return ai(t,e,iu,n)}function ai(t,e,n,r){var o=0,s=null==t?0:t.length;if(0===s)return 0;for(var a=(e=n(e))!=e,u=null===e,c=ca(e),f=e===i;o<s;){var l=ge((o+s)/2),h=n(t[l]),d=h!==i,p=null===h,y=h==h,g=ca(h);if(a)var w=r||y;else w=f?y&&(r||d):u?y&&d&&(r||!p):c?y&&d&&!p&&(r||!g):!p&&!g&&(r?h<=e:h<e);w?o=l+1:s=l}return mn(s,4294967294)}function ui(t,e){for(var n=-1,r=t.length,i=0,o=[];++n<r;){var s=t[n],a=e?e(s):s;if(!n||!$s(a,u)){var u=a;o[i++]=0===s?0:s}}return o}function ci(t){return"number"==typeof t?t:ca(t)?y:+t}function fi(t){if("string"==typeof t)return t;if(Ms(t))return Te(t,fi)+"";if(ca(t))return Nn?Nn.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function li(t,e,n){var r=-1,i=Ce,o=t.length,s=!0,a=[],u=a;if(n)s=!1,i=Ke;else if(o>=200){var c=e?null:Yi(t);if(c)return hn(c);s=!1,i=en,u=new Gn}else u=e?[]:a;t:for(;++r<o;){var f=t[r],l=e?e(f):f;if(f=n||0!==f?f:0,s&&l==l){for(var h=u.length;h--;)if(u[h]===l)continue t;e&&u.push(l),a.push(f)}else i(u,l,n)||(u!==a&&u.push(l),a.push(f))}return a}function hi(t,e){var n=-1,r=(e=mi(e,t)).length;if(!r)return!0;for(var i=null==t||"object"!=typeof t&&"function"!=typeof t;++n<r;){var o=e[n];if("string"==typeof o){if("__proto__"===o&&!Pt.call(t,"__proto__"))return!1;if("constructor"===o&&n+1<r&&"string"==typeof e[n+1]&&"prototype"===e[n+1]){if(i&&0===n)continue;return!1}}}var s=Uo(t,e);return null==s||delete s[Ho(Xo(e))]}function di(t,e,n,r){return ti(t,e,n(_r(t,e)),r)}function pi(t,e,n,r){for(var i=t.length,o=r?i:-1;(r?o--:++o<i)&&e(t[o],o,t););return n?ii(t,r?0:o,r?o+1:i):ii(t,r?o+1:0,r?i:o)}function yi(t,e){var n=t;return n instanceof Mn&&(n=n.value()),Fe(e,function(t,e){return e.func.apply(e.thisArg,Pe([t],e.args))},n)}function gi(t,e,n){var i=t.length;if(i<2)return i?li(t[0]):[];for(var o=-1,s=r(i);++o<i;)for(var a=t[o],u=-1;++u<i;)u!=o&&(s[o]=hr(s[o]||a,t[u],e,n));return li(br(s,1),e,n)}function wi(t,e,n){for(var r=-1,o=t.length,s=e.length,a={};++r<o;){var u=r<s?e[r]:i;n(a,t[r],u)}return a}function bi(t){return Zs(t)?t:[]}function vi(t){return"function"==typeof t?t:iu}function mi(t,e){return Ms(t)?t:Eo(t,e)?[t]:Fo(va(t))}var xi=Xr;function Ei(t,e,n){var r=t.length;return n=n===i?r:n,!e&&n>=r?t:ii(t,e,n)}var Bi=ie||function(t){return ye.clearTimeout(t)};function _i(t,e){if(e)return t.slice();var n=t.length,r=Vt?Vt(n):new t.constructor(n);return t.copy(r),r}function Ai(t){var e=new t.constructor(t.byteLength);return new Mt(e).set(new Mt(t)),e}function Ii(t,e){var n=e?Ai(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function ki(t,e){if(t!==e){var n=t!==i,r=null===t,o=t==t,s=ca(t),a=e!==i,u=null===e,c=e==e,f=ca(e);if(!u&&!f&&!s&&t>e||s&&a&&c&&!u&&!f||r&&a&&c||!n&&c||!o)return 1;if(!r&&!s&&!f&&t<e||f&&n&&o&&!r&&!s||u&&n&&o||!a&&o||!c)return-1}return 0}function Si(t,e,n,i){for(var o=-1,s=t.length,a=n.length,u=-1,c=e.length,f=vn(s-a,0),l=r(c+f),h=!i;++u<c;)l[u]=e[u];for(;++o<a;)(h||o<s)&&(l[n[o]]=t[o]);for(;f--;)l[u++]=t[o++];return l}function Ui(t,e,n,i){for(var o=-1,s=t.length,a=-1,u=n.length,c=-1,f=e.length,l=vn(s-u,0),h=r(l+f),d=!i;++o<l;)h[o]=t[o];for(var p=o;++c<f;)h[p+c]=e[c];for(;++a<u;)(d||o<s)&&(h[p+n[a]]=t[o++]);return h}function Oi(t,e){var n=-1,i=t.length;for(e||(e=r(i));++n<i;)e[n]=t[n];return e}function Ri(t,e,n,r){var o=!n;n||(n={});for(var s=-1,a=e.length;++s<a;){var u=e[s],c=r?r(n[u],t[u],u,n,t):i;c===i&&(c=t[u]),o?sr(n,u,c):nr(n,u,c)}return n}function Li(t,e){return function(n,r){var i=Ms(n)?Se:ir,o=e?e():{};return i(n,t,co(r,2),o)}}function Ci(t){return Xr(function(e,n){var r=-1,o=n.length,s=o>1?n[o-1]:i,a=o>2?n[2]:i;for(s=t.length>3&&"function"==typeof s?(o--,s):i,a&&xo(n[0],n[1],a)&&(s=o<3?i:s,o=1),e=kt(e);++r<o;){var u=n[r];u&&t(e,u,r,s)}return e})}function Ki(t,e){return function(n,r){if(null==n)return n;if(!Ws(n))return t(n,r);for(var i=n.length,o=e?i:-1,s=kt(n);(e?o--:++o<i)&&!1!==r(s[o],o,s););return n}}function Ti(t){return function(e,n,r){for(var i=-1,o=kt(e),s=r(e),a=s.length;a--;){var u=s[t?a:++i];if(!1===n(o[u],u,o))break}return e}}function Pi(t){return function(e){var n=un(e=va(e))?yn(e):i,r=n?n[0]:e.charAt(0),o=n?Ei(n,1).join(""):e.slice(1);return r[t]()+o}}function Fi(t){return function(e){return Fe(Ja(qa(e).replace(te,"")),t,"")}}function Hi(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var n=Dn(t.prototype),r=t.apply(n,e);return ea(r)?r:n}}function ji(t){return function(e,n,r){var o=kt(e);if(!Ws(e)){var s=co(n,3);e=La(e),n=function(t){return s(o[t],t,o)}}var a=t(e,n,r);return a>-1?o[s?e[a]:a]:i}}function Ni(t){return ro(function(e){var n=e.length,r=n,s=qn.prototype.thru;for(t&&e.reverse();r--;){var a=e[r];if("function"!=typeof a)throw new Ot(o);if(s&&!u&&"wrapper"==ao(a))var u=new qn([],!0)}for(r=u?r:n;++r<n;){var c=ao(a=e[r]),f="wrapper"==c?so(a):i;u=f&&Bo(f[0])&&424==f[1]&&!f[4].length&&1==f[9]?u[ao(f[0])].apply(u,f[3]):1==a.length&&Bo(a)?u[c]():u.thru(a)}return function(){var t=arguments,r=t[0];if(u&&1==t.length&&Ms(r))return u.plant(r).value();for(var i=0,o=n?e[i].apply(this,t):r;++i<n;)o=e[i].call(this,o);return o}})}function $i(t,e,n,o,s,a,u,c,f,h){var d=e&l,p=1&e,y=2&e,g=24&e,w=512&e,b=y?i:Hi(t);return function l(){for(var v=arguments.length,m=r(v),x=v;x--;)m[x]=arguments[x];if(g)var E=uo(l),B=function(t,e){for(var n=t.length,r=0;n--;)t[n]===e&&++r;return r}(m,E);if(o&&(m=Si(m,o,s,g)),a&&(m=Ui(m,a,u,g)),v-=B,g&&v<h){var _=ln(m,E);return Zi(t,e,$i,l.placeholder,n,m,_,c,f,h-v)}var A=p?n:this,I=y?A[t]:t;return v=m.length,c?m=function(t,e){var n=t.length,r=mn(e.length,n),o=Oi(t);for(;r--;){var s=e[r];t[r]=mo(s,n)?o[s]:i}return t}(m,c):w&&v>1&&m.reverse(),d&&f<v&&(m.length=f),this&&this!==ye&&this instanceof l&&(I=b||Hi(I)),I.apply(A,m)}}function Di(t,e){return function(n,r){return function(t,e,n,r){return xr(t,function(t,i,o){e(r,n(t),i,o)}),r}(n,t,e(r),{})}}function zi(t,e){return function(n,r){var o;if(n===i&&r===i)return e;if(n!==i&&(o=n),r!==i){if(o===i)return r;"string"==typeof n||"string"==typeof r?(n=fi(n),r=fi(r)):(n=ci(n),r=ci(r)),o=t(n,r)}return o}}function qi(t){return ro(function(e){return e=Te(e,Qe(co())),Xr(function(n){var r=this;return t(e,function(t){return ke(t,r,n)})})})}function Mi(t,e){var n=(e=e===i?" ":fi(e)).length;if(n<2)return n?Yr(e,t):e;var r=Yr(e,pe(t/pn(e)));return un(e)?Ei(yn(r),0,t).join(""):r.slice(0,t)}function Vi(t){return function(e,n,o){return o&&"number"!=typeof o&&xo(e,n,o)&&(n=o=i),e=pa(e),n===i?(n=e,e=0):n=pa(n),function(t,e,n,i){for(var o=-1,s=vn(pe((e-t)/(n||1)),0),a=r(s);s--;)a[i?s:++o]=t,t+=n;return a}(e,n,o=o===i?e<n?1:-1:pa(o),t)}}function Wi(t){return function(e,n){return"string"==typeof e&&"string"==typeof n||(e=wa(e),n=wa(n)),t(e,n)}}function Zi(t,e,n,r,o,s,a,u,l,h){var d=8&e;e|=d?c:f,4&(e&=~(d?f:c))||(e&=-4);var p=[t,e,o,d?s:i,d?a:i,d?i:s,d?i:a,u,l,h],y=n.apply(i,p);return Bo(t)&&Ro(y,p),y.placeholder=r,Ko(y,t,e)}function Gi(t){var e=It[t];return function(t,n){if(t=wa(t),(n=null==n?0:mn(ya(n),292))&&me(t)){var r=(va(t)+"e").split("e");return+((r=(va(e(r[0]+"e"+(+r[1]+n)))+"e").split("e"))[0]+"e"+(+r[1]-n))}return e(t)}}var Yi=Sn&&1/hn(new Sn([,-0]))[1]==d?function(t){return new Sn(t)}:cu;function Xi(t){return function(e){var n=go(e);return n==A?cn(e):n==O?dn(e):function(t,e){return Te(e,function(e){return[e,t[e]]})}(e,t(e))}}function Ji(t,e,n,s,d,p,y,g){var w=2&e;if(!w&&"function"!=typeof t)throw new Ot(o);var b=s?s.length:0;if(b||(e&=-97,s=d=i),y=y===i?y:vn(ya(y),0),g=g===i?g:ya(g),b-=d?d.length:0,e&f){var v=s,m=d;s=d=i}var x=w?i:so(t),E=[t,e,n,s,d,v,m,p,y,g];if(x&&function(t,e){var n=t[1],r=e[1],i=n|r,o=i<131,s=r==l&&8==n||r==l&&n==h&&t[7].length<=e[8]||384==r&&e[7].length<=e[8]&&8==n;if(!o&&!s)return t;1&r&&(t[2]=e[2],i|=1&n?0:4);var u=e[3];if(u){var c=t[3];t[3]=c?Si(c,u,e[4]):u,t[4]=c?ln(t[3],a):e[4]}(u=e[5])&&(c=t[5],t[5]=c?Ui(c,u,e[6]):u,t[6]=c?ln(t[5],a):e[6]);(u=e[7])&&(t[7]=u);r&l&&(t[8]=null==t[8]?e[8]:mn(t[8],e[8]));null==t[9]&&(t[9]=e[9]);t[0]=e[0],t[1]=i}(E,x),t=E[0],e=E[1],n=E[2],s=E[3],d=E[4],!(g=E[9]=E[9]===i?w?0:t.length:vn(E[9]-b,0))&&24&e&&(e&=-25),e&&1!=e)B=8==e||e==u?function(t,e,n){var o=Hi(t);return function s(){for(var a=arguments.length,u=r(a),c=a,f=uo(s);c--;)u[c]=arguments[c];var l=a<3&&u[0]!==f&&u[a-1]!==f?[]:ln(u,f);return(a-=l.length)<n?Zi(t,e,$i,s.placeholder,i,u,l,i,i,n-a):ke(this&&this!==ye&&this instanceof s?o:t,this,u)}}(t,e,g):e!=c&&33!=e||d.length?$i.apply(i,E):function(t,e,n,i){var o=1&e,s=Hi(t);return function e(){for(var a=-1,u=arguments.length,c=-1,f=i.length,l=r(f+u),h=this&&this!==ye&&this instanceof e?s:t;++c<f;)l[c]=i[c];for(;u--;)l[c++]=arguments[++a];return ke(h,o?n:this,l)}}(t,e,n,s);else var B=function(t,e,n){var r=1&e,i=Hi(t);return function e(){return(this&&this!==ye&&this instanceof e?i:t).apply(r?n:this,arguments)}}(t,e,n);return Ko((x?ei:Ro)(B,E),t,e)}function Qi(t,e,n,r){return t===i||$s(t,Ct[n])&&!Pt.call(r,n)?e:t}function to(t,e,n,r,o,s){return ea(t)&&ea(e)&&(s.set(e,t),zr(t,e,i,to,s),s.delete(e)),t}function eo(t){return oa(t)?i:t}function no(t,e,n,r,o,s){var a=1&n,u=t.length,c=e.length;if(u!=c&&!(a&&c>u))return!1;var f=s.get(t),l=s.get(e);if(f&&l)return f==e&&l==t;var h=-1,d=!0,p=2&n?new Gn:i;for(s.set(t,e),s.set(e,t);++h<u;){var y=t[h],g=e[h];if(r)var w=a?r(g,y,h,e,t,s):r(y,g,h,t,e,s);if(w!==i){if(w)continue;d=!1;break}if(p){if(!je(e,function(t,e){if(!en(p,e)&&(y===t||o(y,t,n,r,s)))return p.push(e)})){d=!1;break}}else if(y!==g&&!o(y,g,n,r,s)){d=!1;break}}return s.delete(t),s.delete(e),d}function ro(t){return Co(So(t,i,Vo),t+"")}function io(t){return Ar(t,La,po)}function oo(t){return Ar(t,Ca,yo)}var so=Rn?function(t){return Rn.get(t)}:cu;function ao(t){for(var e=t.name+"",n=Ln[e],r=Pt.call(Ln,e)?n.length:0;r--;){var i=n[r],o=i.func;if(null==o||o==t)return i.name}return e}function uo(t){return(Pt.call($n,"placeholder")?$n:t).placeholder}function co(){var t=$n.iteratee||ou;return t=t===ou?Pr:t,arguments.length?t(arguments[0],arguments[1]):t}function fo(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function lo(t){for(var e=La(t),n=e.length;n--;){var r=e[n],i=t[r];e[n]=[r,i,Io(i)]}return e}function ho(t,e){var n=function(t,e){return null==t?i:t[e]}(t,e);return Tr(n)?n:i}var po=we?function(t){return null==t?[]:(t=kt(t),Le(we(t),function(e){return Gt.call(t,e)}))}:gu,yo=we?function(t){for(var e=[];t;)Pe(e,po(t)),t=Wt(t);return e}:gu,go=Ir;function wo(t,e,n){for(var r=-1,i=(e=mi(e,t)).length,o=!1;++r<i;){var s=Ho(e[r]);if(!(o=null!=t&&n(t,s)))break;t=t[s]}return o||++r!=i?o:!!(i=null==t?0:t.length)&&ta(i)&&mo(s,i)&&(Ms(t)||qs(t))}function bo(t){return"function"!=typeof t.constructor||Ao(t)?{}:Dn(Wt(t))}function vo(t){return Ms(t)||qs(t)||!!(Xt&&t&&t[Xt])}function mo(t,e){var n=typeof t;return!!(e=null==e?p:e)&&("number"==n||"symbol"!=n&&mt.test(t))&&t>-1&&t%1==0&&t<e}function xo(t,e,n){if(!ea(n))return!1;var r=typeof e;return!!("number"==r?Ws(n)&&mo(e,n.length):"string"==r&&e in n)&&$s(n[e],t)}function Eo(t,e){if(Ms(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!ca(t))||(nt.test(t)||!et.test(t)||null!=e&&t in kt(e))}function Bo(t){var e=ao(t),n=$n[e];if("function"!=typeof n||!(e in Mn.prototype))return!1;if(t===n)return!0;var r=so(n);return!!r&&t===r[0]}(An&&go(new An(new ArrayBuffer(1)))!=T||In&&go(new In)!=A||kn&&go(kn.resolve())!=S||Sn&&go(new Sn)!=O||Un&&go(new Un)!=C)&&(go=function(t){var e=Ir(t),n=e==k?t.constructor:i,r=n?jo(n):"";if(r)switch(r){case Cn:return T;case Kn:return A;case Tn:return S;case Pn:return O;case Fn:return C}return e});var _o=Kt?Js:wu;function Ao(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Ct)}function Io(t){return t==t&&!ea(t)}function ko(t,e){return function(n){return null!=n&&(n[t]===e&&(e!==i||t in kt(n)))}}function So(t,e,n){return e=vn(e===i?t.length-1:e,0),function(){for(var i=arguments,o=-1,s=vn(i.length-e,0),a=r(s);++o<s;)a[o]=i[e+o];o=-1;for(var u=r(e+1);++o<e;)u[o]=i[o];return u[e]=n(a),ke(t,this,u)}}function Uo(t,e){return e.length<2?t:_r(t,ii(e,0,-1))}function Oo(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}var Ro=To(ei),Lo=de||function(t,e){return ye.setTimeout(t,e)},Co=To(ni);function Ko(t,e,n){var r=e+"";return Co(t,function(t,e){var n=e.length;if(!n)return t;var r=n-1;return e[r]=(n>1?"& ":"")+e[r],e=e.join(n>2?", ":" "),t.replace(ut,"{\n/* [wrapped with "+e+"] */\n")}(r,function(t,e){return Ue(w,function(n){var r="_."+n[0];e&n[1]&&!Ce(t,r)&&t.push(r)}),t.sort()}(function(t){var e=t.match(ct);return e?e[1].split(ft):[]}(r),n)))}function To(t){var e=0,n=0;return function(){var r=xn(),o=16-(r-n);if(n=r,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(i,arguments)}}function Po(t,e){var n=-1,r=t.length,o=r-1;for(e=e===i?r:e;++n<e;){var s=Gr(n,o),a=t[s];t[s]=t[n],t[n]=a}return t.length=e,t}var Fo=function(t){var e=Ts(t,function(t){return 500===n.size&&n.clear(),t}),n=e.cache;return e}(function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(rt,function(t,n,r,i){e.push(r?i.replace(dt,"$1"):n||t)}),e});function Ho(t){if("string"==typeof t||ca(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function jo(t){if(null!=t){try{return Tt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function No(t){if(t instanceof Mn)return t.clone();var e=new qn(t.__wrapped__,t.__chain__);return e.__actions__=Oi(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}var $o=Xr(function(t,e){return Zs(t)?hr(t,br(e,1,Zs,!0)):[]}),Do=Xr(function(t,e){var n=Xo(e);return Zs(n)&&(n=i),Zs(t)?hr(t,br(e,1,Zs,!0),co(n,2)):[]}),zo=Xr(function(t,e){var n=Xo(e);return Zs(n)&&(n=i),Zs(t)?hr(t,br(e,1,Zs,!0),i,n):[]});function qo(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=null==n?0:ya(n);return i<0&&(i=vn(r+i,0)),De(t,co(e,3),i)}function Mo(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=r-1;return n!==i&&(o=ya(n),o=n<0?vn(r+o,0):mn(o,r-1)),De(t,co(e,3),o,!0)}function Vo(t){return(null==t?0:t.length)?br(t,1):[]}function Wo(t){return t&&t.length?t[0]:i}var Zo=Xr(function(t){var e=Te(t,bi);return e.length&&e[0]===t[0]?Or(e):[]}),Go=Xr(function(t){var e=Xo(t),n=Te(t,bi);return e===Xo(n)?e=i:n.pop(),n.length&&n[0]===t[0]?Or(n,co(e,2)):[]}),Yo=Xr(function(t){var e=Xo(t),n=Te(t,bi);return(e="function"==typeof e?e:i)&&n.pop(),n.length&&n[0]===t[0]?Or(n,i,e):[]});function Xo(t){var e=null==t?0:t.length;return e?t[e-1]:i}var Jo=Xr(Qo);function Qo(t,e){return t&&t.length&&e&&e.length?Wr(t,e):t}var ts=ro(function(t,e){var n=null==t?0:t.length,r=ar(t,e);return Zr(t,Te(e,function(t){return mo(t,n)?+t:t}).sort(ki)),r});function es(t){return null==t?t:_n.call(t)}var ns=Xr(function(t){return li(br(t,1,Zs,!0))}),rs=Xr(function(t){var e=Xo(t);return Zs(e)&&(e=i),li(br(t,1,Zs,!0),co(e,2))}),is=Xr(function(t){var e=Xo(t);return e="function"==typeof e?e:i,li(br(t,1,Zs,!0),i,e)});function os(t){if(!t||!t.length)return[];var e=0;return t=Le(t,function(t){if(Zs(t))return e=vn(t.length,e),!0}),Xe(e,function(e){return Te(t,We(e))})}function ss(t,e){if(!t||!t.length)return[];var n=os(t);return null==e?n:Te(n,function(t){return ke(e,i,t)})}var as=Xr(function(t,e){return Zs(t)?hr(t,e):[]}),us=Xr(function(t){return gi(Le(t,Zs))}),cs=Xr(function(t){var e=Xo(t);return Zs(e)&&(e=i),gi(Le(t,Zs),co(e,2))}),fs=Xr(function(t){var e=Xo(t);return e="function"==typeof e?e:i,gi(Le(t,Zs),i,e)}),ls=Xr(os);var hs=Xr(function(t){var e=t.length,n=e>1?t[e-1]:i;return n="function"==typeof n?(t.pop(),n):i,ss(t,n)});function ds(t){var e=$n(t);return e.__chain__=!0,e}function ps(t,e){return e(t)}var ys=ro(function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,o=function(e){return ar(e,t)};return!(e>1||this.__actions__.length)&&r instanceof Mn&&mo(n)?((r=r.slice(n,+n+(e?1:0))).__actions__.push({func:ps,args:[o],thisArg:i}),new qn(r,this.__chain__).thru(function(t){return e&&!t.length&&t.push(i),t})):this.thru(o)});var gs=Li(function(t,e,n){Pt.call(t,n)?++t[n]:sr(t,n,1)});var ws=ji(qo),bs=ji(Mo);function vs(t,e){return(Ms(t)?Ue:dr)(t,co(e,3))}function ms(t,e){return(Ms(t)?Oe:pr)(t,co(e,3))}var xs=Li(function(t,e,n){Pt.call(t,n)?t[n].push(e):sr(t,n,[e])});var Es=Xr(function(t,e,n){var i=-1,o="function"==typeof e,s=Ws(t)?r(t.length):[];return dr(t,function(t){s[++i]=o?ke(e,t,n):Rr(t,e,n)}),s}),Bs=Li(function(t,e,n){sr(t,n,e)});function _s(t,e){return(Ms(t)?Te:Nr)(t,co(e,3))}var As=Li(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]});var Is=Xr(function(t,e){if(null==t)return[];var n=e.length;return n>1&&xo(t,e[0],e[1])?e=[]:n>2&&xo(e[0],e[1],e[2])&&(e=[e[0]]),Mr(t,br(e,1),[])}),ks=fe||function(){return ye.Date.now()};function Ss(t,e,n){return e=n?i:e,e=t&&null==e?t.length:e,Ji(t,l,i,i,i,i,e)}function Us(t,e){var n;if("function"!=typeof e)throw new Ot(o);return t=ya(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=i),n}}var Os=Xr(function(t,e,n){var r=1;if(n.length){var i=ln(n,uo(Os));r|=c}return Ji(t,r,e,n,i)}),Rs=Xr(function(t,e,n){var r=3;if(n.length){var i=ln(n,uo(Rs));r|=c}return Ji(e,r,t,n,i)});function Ls(t,e,n){var r,s,a,u,c,f,l=0,h=!1,d=!1,p=!0;if("function"!=typeof t)throw new Ot(o);function y(e){var n=r,o=s;return r=s=i,l=e,u=t.apply(o,n)}function g(t){var n=t-f;return f===i||n>=e||n<0||d&&t-l>=a}function w(){var t=ks();if(g(t))return b(t);c=Lo(w,function(t){var n=e-(t-f);return d?mn(n,a-(t-l)):n}(t))}function b(t){return c=i,p&&r?y(t):(r=s=i,u)}function v(){var t=ks(),n=g(t);if(r=arguments,s=this,f=t,n){if(c===i)return function(t){return l=t,c=Lo(w,e),h?y(t):u}(f);if(d)return Bi(c),c=Lo(w,e),y(f)}return c===i&&(c=Lo(w,e)),u}return e=wa(e)||0,ea(n)&&(h=!!n.leading,a=(d="maxWait"in n)?vn(wa(n.maxWait)||0,e):a,p="trailing"in n?!!n.trailing:p),v.cancel=function(){c!==i&&Bi(c),l=0,r=f=s=c=i},v.flush=function(){return c===i?u:b(ks())},v}var Cs=Xr(function(t,e){return lr(t,1,e)}),Ks=Xr(function(t,e,n){return lr(t,wa(e)||0,n)});function Ts(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new Ot(o);var n=function(){var r=arguments,i=e?e.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=t.apply(this,r);return n.cache=o.set(i,s)||o,s};return n.cache=new(Ts.Cache||Zn),n}function Ps(t){if("function"!=typeof t)throw new Ot(o);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}Ts.Cache=Zn;var Fs=xi(function(t,e){var n=(e=1==e.length&&Ms(e[0])?Te(e[0],Qe(co())):Te(br(e,1),Qe(co()))).length;return Xr(function(r){for(var i=-1,o=mn(r.length,n);++i<o;)r[i]=e[i].call(this,r[i]);return ke(t,this,r)})}),Hs=Xr(function(t,e){var n=ln(e,uo(Hs));return Ji(t,c,i,e,n)}),js=Xr(function(t,e){var n=ln(e,uo(js));return Ji(t,f,i,e,n)}),Ns=ro(function(t,e){return Ji(t,h,i,i,i,e)});function $s(t,e){return t===e||t!=t&&e!=e}var Ds=Wi(kr),zs=Wi(function(t,e){return t>=e}),qs=Lr(function(){return arguments}())?Lr:function(t){return na(t)&&Pt.call(t,"callee")&&!Gt.call(t,"callee")},Ms=r.isArray,Vs=xe?Qe(xe):function(t){return na(t)&&Ir(t)==K};function Ws(t){return null!=t&&ta(t.length)&&!Js(t)}function Zs(t){return na(t)&&Ws(t)}var Gs=ve||wu,Ys=Ee?Qe(Ee):function(t){return na(t)&&Ir(t)==x};function Xs(t){if(!na(t))return!1;var e=Ir(t);return e==E||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!oa(t)}function Js(t){if(!ea(t))return!1;var e=Ir(t);return e==B||e==_||"[object AsyncFunction]"==e||"[object Proxy]"==e}function Qs(t){return"number"==typeof t&&t==ya(t)}function ta(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=p}function ea(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function na(t){return null!=t&&"object"==typeof t}var ra=Be?Qe(Be):function(t){return na(t)&&go(t)==A};function ia(t){return"number"==typeof t||na(t)&&Ir(t)==I}function oa(t){if(!na(t)||Ir(t)!=k)return!1;var e=Wt(t);if(null===e)return!0;var n=Pt.call(e,"constructor")&&e.constructor;return"function"==typeof n&&n instanceof n&&Tt.call(n)==Nt}var sa=_e?Qe(_e):function(t){return na(t)&&Ir(t)==U};var aa=Ae?Qe(Ae):function(t){return na(t)&&go(t)==O};function ua(t){return"string"==typeof t||!Ms(t)&&na(t)&&Ir(t)==R}function ca(t){return"symbol"==typeof t||na(t)&&Ir(t)==L}var fa=Ie?Qe(Ie):function(t){return na(t)&&ta(t.length)&&!!ue[Ir(t)]};var la=Wi(jr),ha=Wi(function(t,e){return t<=e});function da(t){if(!t)return[];if(Ws(t))return ua(t)?yn(t):Oi(t);if(Jt&&t[Jt])return function(t){for(var e,n=[];!(e=t.next()).done;)n.push(e.value);return n}(t[Jt]());var e=go(t);return(e==A?cn:e==O?hn:$a)(t)}function pa(t){return t?(t=wa(t))===d||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function ya(t){var e=pa(t),n=e%1;return e==e?n?e-n:e:0}function ga(t){return t?ur(ya(t),0,g):0}function wa(t){if("number"==typeof t)return t;if(ca(t))return y;if(ea(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=ea(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Je(t);var n=wt.test(t);return n||vt.test(t)?he(t.slice(2),n?2:8):gt.test(t)?y:+t}function ba(t){return Ri(t,Ca(t))}function va(t){return null==t?"":fi(t)}var ma=Ci(function(t,e){if(Ao(e)||Ws(e))Ri(e,La(e),t);else for(var n in e)Pt.call(e,n)&&nr(t,n,e[n])}),xa=Ci(function(t,e){Ri(e,Ca(e),t)}),Ea=Ci(function(t,e,n,r){Ri(e,Ca(e),t,r)}),Ba=Ci(function(t,e,n,r){Ri(e,La(e),t,r)}),_a=ro(ar);var Aa=Xr(function(t,e){t=kt(t);var n=-1,r=e.length,o=r>2?e[2]:i;for(o&&xo(e[0],e[1],o)&&(r=1);++n<r;)for(var s=e[n],a=Ca(s),u=-1,c=a.length;++u<c;){var f=a[u],l=t[f];(l===i||$s(l,Ct[f])&&!Pt.call(t,f))&&(t[f]=s[f])}return t}),Ia=Xr(function(t){return t.push(i,to),ke(Ta,i,t)});function ka(t,e,n){var r=null==t?i:_r(t,e);return r===i?n:r}function Sa(t,e){return null!=t&&wo(t,e,Ur)}var Ua=Di(function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=jt.call(e)),t[e]=n},eu(iu)),Oa=Di(function(t,e,n){null!=e&&"function"!=typeof e.toString&&(e=jt.call(e)),Pt.call(t,e)?t[e].push(n):t[e]=[n]},co),Ra=Xr(Rr);function La(t){return Ws(t)?Xn(t):Fr(t)}function Ca(t){return Ws(t)?Xn(t,!0):Hr(t)}var Ka=Ci(function(t,e,n){zr(t,e,n)}),Ta=Ci(function(t,e,n,r){zr(t,e,n,r)}),Pa=ro(function(t,e){var n={};if(null==t)return n;var r=!1;e=Te(e,function(e){return e=mi(e,t),r||(r=e.length>1),e}),Ri(t,oo(t),n),r&&(n=cr(n,7,eo));for(var i=e.length;i--;)hi(n,e[i]);return n});var Fa=ro(function(t,e){return null==t?{}:function(t,e){return Vr(t,e,function(e,n){return Sa(t,n)})}(t,e)});function Ha(t,e){if(null==t)return{};var n=Te(oo(t),function(t){return[t]});return e=co(e),Vr(t,n,function(t,n){return e(t,n[0])})}var ja=Xi(La),Na=Xi(Ca);function $a(t){return null==t?[]:tn(t,La(t))}var Da=Fi(function(t,e,n){return e=e.toLowerCase(),t+(n?za(e):e)});function za(t){return Xa(va(t).toLowerCase())}function qa(t){return(t=va(t))&&t.replace(xt,on).replace(ee,"")}var Ma=Fi(function(t,e,n){return t+(n?"-":"")+e.toLowerCase()}),Va=Fi(function(t,e,n){return t+(n?" ":"")+e.toLowerCase()}),Wa=Pi("toLowerCase");var Za=Fi(function(t,e,n){return t+(n?"_":"")+e.toLowerCase()});var Ga=Fi(function(t,e,n){return t+(n?" ":"")+Xa(e)});var Ya=Fi(function(t,e,n){return t+(n?" ":"")+e.toUpperCase()}),Xa=Pi("toUpperCase");function Ja(t,e,n){return t=va(t),(e=n?i:e)===i?function(t){return oe.test(t)}(t)?function(t){return t.match(re)||[]}(t):function(t){return t.match(lt)||[]}(t):t.match(e)||[]}var Qa=Xr(function(t,e){try{return ke(t,i,e)}catch(t){return Xs(t)?t:new _t(t)}}),tu=ro(function(t,e){return Ue(e,function(e){e=Ho(e),sr(t,e,Os(t[e],t))}),t});function eu(t){return function(){return t}}var nu=Ni(),ru=Ni(!0);function iu(t){return t}function ou(t){return Pr("function"==typeof t?t:cr(t,1))}var su=Xr(function(t,e){return function(n){return Rr(n,t,e)}}),au=Xr(function(t,e){return function(n){return Rr(t,n,e)}});function uu(t,e,n){var r=La(e),i=Br(e,r);null!=n||ea(e)&&(i.length||!r.length)||(n=e,e=t,t=this,i=Br(e,La(e)));var o=!(ea(n)&&"chain"in n&&!n.chain),s=Js(t);return Ue(i,function(n){var r=e[n];t[n]=r,s&&(t.prototype[n]=function(){var e=this.__chain__;if(o||e){var n=t(this.__wrapped__);return(n.__actions__=Oi(this.__actions__)).push({func:r,args:arguments,thisArg:t}),n.__chain__=e,n}return r.apply(t,Pe([this.value()],arguments))})}),t}function cu(){}var fu=qi(Te),lu=qi(Re),hu=qi(je);function du(t){return Eo(t)?We(Ho(t)):function(t){return function(e){return _r(e,t)}}(t)}var pu=Vi(),yu=Vi(!0);function gu(){return[]}function wu(){return!1}var bu=zi(function(t,e){return t+e},0),vu=Gi("ceil"),mu=zi(function(t,e){return t/e},1),xu=Gi("floor");var Eu,Bu=zi(function(t,e){return t*e},1),_u=Gi("round"),Au=zi(function(t,e){return t-e},0);return $n.after=function(t,e){if("function"!=typeof e)throw new Ot(o);return t=ya(t),function(){if(--t<1)return e.apply(this,arguments)}},$n.ary=Ss,$n.assign=ma,$n.assignIn=xa,$n.assignInWith=Ea,$n.assignWith=Ba,$n.at=_a,$n.before=Us,$n.bind=Os,$n.bindAll=tu,$n.bindKey=Rs,$n.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Ms(t)?t:[t]},$n.chain=ds,$n.chunk=function(t,e,n){e=(n?xo(t,e,n):e===i)?1:vn(ya(e),0);var o=null==t?0:t.length;if(!o||e<1)return[];for(var s=0,a=0,u=r(pe(o/e));s<o;)u[a++]=ii(t,s,s+=e);return u},$n.compact=function(t){for(var e=-1,n=null==t?0:t.length,r=0,i=[];++e<n;){var o=t[e];o&&(i[r++]=o)}return i},$n.concat=function(){var t=arguments.length;if(!t)return[];for(var e=r(t-1),n=arguments[0],i=t;i--;)e[i-1]=arguments[i];return Pe(Ms(n)?Oi(n):[n],br(e,1))},$n.cond=function(t){var e=null==t?0:t.length,n=co();return t=e?Te(t,function(t){if("function"!=typeof t[1])throw new Ot(o);return[n(t[0]),t[1]]}):[],Xr(function(n){for(var r=-1;++r<e;){var i=t[r];if(ke(i[0],this,n))return ke(i[1],this,n)}})},$n.conforms=function(t){return function(t){var e=La(t);return function(n){return fr(n,t,e)}}(cr(t,1))},$n.constant=eu,$n.countBy=gs,$n.create=function(t,e){var n=Dn(t);return null==e?n:or(n,e)},$n.curry=function t(e,n,r){var o=Ji(e,8,i,i,i,i,i,n=r?i:n);return o.placeholder=t.placeholder,o},$n.curryRight=function t(e,n,r){var o=Ji(e,u,i,i,i,i,i,n=r?i:n);return o.placeholder=t.placeholder,o},$n.debounce=Ls,$n.defaults=Aa,$n.defaultsDeep=Ia,$n.defer=Cs,$n.delay=Ks,$n.difference=$o,$n.differenceBy=Do,$n.differenceWith=zo,$n.drop=function(t,e,n){var r=null==t?0:t.length;return r?ii(t,(e=n||e===i?1:ya(e))<0?0:e,r):[]},$n.dropRight=function(t,e,n){var r=null==t?0:t.length;return r?ii(t,0,(e=r-(e=n||e===i?1:ya(e)))<0?0:e):[]},$n.dropRightWhile=function(t,e){return t&&t.length?pi(t,co(e,3),!0,!0):[]},$n.dropWhile=function(t,e){return t&&t.length?pi(t,co(e,3),!0):[]},$n.fill=function(t,e,n,r){var o=null==t?0:t.length;return o?(n&&"number"!=typeof n&&xo(t,e,n)&&(n=0,r=o),function(t,e,n,r){var o=t.length;for((n=ya(n))<0&&(n=-n>o?0:o+n),(r=r===i||r>o?o:ya(r))<0&&(r+=o),r=n>r?0:ga(r);n<r;)t[n++]=e;return t}(t,e,n,r)):[]},$n.filter=function(t,e){return(Ms(t)?Le:wr)(t,co(e,3))},$n.flatMap=function(t,e){return br(_s(t,e),1)},$n.flatMapDeep=function(t,e){return br(_s(t,e),d)},$n.flatMapDepth=function(t,e,n){return n=n===i?1:ya(n),br(_s(t,e),n)},$n.flatten=Vo,$n.flattenDeep=function(t){return(null==t?0:t.length)?br(t,d):[]},$n.flattenDepth=function(t,e){return(null==t?0:t.length)?br(t,e=e===i?1:ya(e)):[]},$n.flip=function(t){return Ji(t,512)},$n.flow=nu,$n.flowRight=ru,$n.fromPairs=function(t){for(var e=-1,n=null==t?0:t.length,r={};++e<n;){var i=t[e];r[i[0]]=i[1]}return r},$n.functions=function(t){return null==t?[]:Br(t,La(t))},$n.functionsIn=function(t){return null==t?[]:Br(t,Ca(t))},$n.groupBy=xs,$n.initial=function(t){return(null==t?0:t.length)?ii(t,0,-1):[]},$n.intersection=Zo,$n.intersectionBy=Go,$n.intersectionWith=Yo,$n.invert=Ua,$n.invertBy=Oa,$n.invokeMap=Es,$n.iteratee=ou,$n.keyBy=Bs,$n.keys=La,$n.keysIn=Ca,$n.map=_s,$n.mapKeys=function(t,e){var n={};return e=co(e,3),xr(t,function(t,r,i){sr(n,e(t,r,i),t)}),n},$n.mapValues=function(t,e){var n={};return e=co(e,3),xr(t,function(t,r,i){sr(n,r,e(t,r,i))}),n},$n.matches=function(t){return $r(cr(t,1))},$n.matchesProperty=function(t,e){return Dr(t,cr(e,1))},$n.memoize=Ts,$n.merge=Ka,$n.mergeWith=Ta,$n.method=su,$n.methodOf=au,$n.mixin=uu,$n.negate=Ps,$n.nthArg=function(t){return t=ya(t),Xr(function(e){return qr(e,t)})},$n.omit=Pa,$n.omitBy=function(t,e){return Ha(t,Ps(co(e)))},$n.once=function(t){return Us(2,t)},$n.orderBy=function(t,e,n,r){return null==t?[]:(Ms(e)||(e=null==e?[]:[e]),Ms(n=r?i:n)||(n=null==n?[]:[n]),Mr(t,e,n))},$n.over=fu,$n.overArgs=Fs,$n.overEvery=lu,$n.overSome=hu,$n.partial=Hs,$n.partialRight=js,$n.partition=As,$n.pick=Fa,$n.pickBy=Ha,$n.property=du,$n.propertyOf=function(t){return function(e){return null==t?i:_r(t,e)}},$n.pull=Jo,$n.pullAll=Qo,$n.pullAllBy=function(t,e,n){return t&&t.length&&e&&e.length?Wr(t,e,co(n,2)):t},$n.pullAllWith=function(t,e,n){return t&&t.length&&e&&e.length?Wr(t,e,i,n):t},$n.pullAt=ts,$n.range=pu,$n.rangeRight=yu,$n.rearg=Ns,$n.reject=function(t,e){return(Ms(t)?Le:wr)(t,Ps(co(e,3)))},$n.remove=function(t,e){var n=[];if(!t||!t.length)return n;var r=-1,i=[],o=t.length;for(e=co(e,3);++r<o;){var s=t[r];e(s,r,t)&&(n.push(s),i.push(r))}return Zr(t,i),n},$n.rest=function(t,e){if("function"!=typeof t)throw new Ot(o);return Xr(t,e=e===i?e:ya(e))},$n.reverse=es,$n.sampleSize=function(t,e,n){return e=(n?xo(t,e,n):e===i)?1:ya(e),(Ms(t)?Qn:Qr)(t,e)},$n.set=function(t,e,n){return null==t?t:ti(t,e,n)},$n.setWith=function(t,e,n,r){return r="function"==typeof r?r:i,null==t?t:ti(t,e,n,r)},$n.shuffle=function(t){return(Ms(t)?tr:ri)(t)},$n.slice=function(t,e,n){var r=null==t?0:t.length;return r?(n&&"number"!=typeof n&&xo(t,e,n)?(e=0,n=r):(e=null==e?0:ya(e),n=n===i?r:ya(n)),ii(t,e,n)):[]},$n.sortBy=Is,$n.sortedUniq=function(t){return t&&t.length?ui(t):[]},$n.sortedUniqBy=function(t,e){return t&&t.length?ui(t,co(e,2)):[]},$n.split=function(t,e,n){return n&&"number"!=typeof n&&xo(t,e,n)&&(e=n=i),(n=n===i?g:n>>>0)?(t=va(t))&&("string"==typeof e||null!=e&&!sa(e))&&!(e=fi(e))&&un(t)?Ei(yn(t),0,n):t.split(e,n):[]},$n.spread=function(t,e){if("function"!=typeof t)throw new Ot(o);return e=null==e?0:vn(ya(e),0),Xr(function(n){var r=n[e],i=Ei(n,0,e);return r&&Pe(i,r),ke(t,this,i)})},$n.tail=function(t){var e=null==t?0:t.length;return e?ii(t,1,e):[]},$n.take=function(t,e,n){return t&&t.length?ii(t,0,(e=n||e===i?1:ya(e))<0?0:e):[]},$n.takeRight=function(t,e,n){var r=null==t?0:t.length;return r?ii(t,(e=r-(e=n||e===i?1:ya(e)))<0?0:e,r):[]},$n.takeRightWhile=function(t,e){return t&&t.length?pi(t,co(e,3),!1,!0):[]},$n.takeWhile=function(t,e){return t&&t.length?pi(t,co(e,3)):[]},$n.tap=function(t,e){return e(t),t},$n.throttle=function(t,e,n){var r=!0,i=!0;if("function"!=typeof t)throw new Ot(o);return ea(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),Ls(t,e,{leading:r,maxWait:e,trailing:i})},$n.thru=ps,$n.toArray=da,$n.toPairs=ja,$n.toPairsIn=Na,$n.toPath=function(t){return Ms(t)?Te(t,Ho):ca(t)?[t]:Oi(Fo(va(t)))},$n.toPlainObject=ba,$n.transform=function(t,e,n){var r=Ms(t),i=r||Gs(t)||fa(t);if(e=co(e,4),null==n){var o=t&&t.constructor;n=i?r?new o:[]:ea(t)&&Js(o)?Dn(Wt(t)):{}}return(i?Ue:xr)(t,function(t,r,i){return e(n,t,r,i)}),n},$n.unary=function(t){return Ss(t,1)},$n.union=ns,$n.unionBy=rs,$n.unionWith=is,$n.uniq=function(t){return t&&t.length?li(t):[]},$n.uniqBy=function(t,e){return t&&t.length?li(t,co(e,2)):[]},$n.uniqWith=function(t,e){return e="function"==typeof e?e:i,t&&t.length?li(t,i,e):[]},$n.unset=function(t,e){return null==t||hi(t,e)},$n.unzip=os,$n.unzipWith=ss,$n.update=function(t,e,n){return null==t?t:di(t,e,vi(n))},$n.updateWith=function(t,e,n,r){return r="function"==typeof r?r:i,null==t?t:di(t,e,vi(n),r)},$n.values=$a,$n.valuesIn=function(t){return null==t?[]:tn(t,Ca(t))},$n.without=as,$n.words=Ja,$n.wrap=function(t,e){return Hs(vi(e),t)},$n.xor=us,$n.xorBy=cs,$n.xorWith=fs,$n.zip=ls,$n.zipObject=function(t,e){return wi(t||[],e||[],nr)},$n.zipObjectDeep=function(t,e){return wi(t||[],e||[],ti)},$n.zipWith=hs,$n.entries=ja,$n.entriesIn=Na,$n.extend=xa,$n.extendWith=Ea,uu($n,$n),$n.add=bu,$n.attempt=Qa,$n.camelCase=Da,$n.capitalize=za,$n.ceil=vu,$n.clamp=function(t,e,n){return n===i&&(n=e,e=i),n!==i&&(n=(n=wa(n))==n?n:0),e!==i&&(e=(e=wa(e))==e?e:0),ur(wa(t),e,n)},$n.clone=function(t){return cr(t,4)},$n.cloneDeep=function(t){return cr(t,5)},$n.cloneDeepWith=function(t,e){return cr(t,5,e="function"==typeof e?e:i)},$n.cloneWith=function(t,e){return cr(t,4,e="function"==typeof e?e:i)},$n.conformsTo=function(t,e){return null==e||fr(t,e,La(e))},$n.deburr=qa,$n.defaultTo=function(t,e){return null==t||t!=t?e:t},$n.divide=mu,$n.endsWith=function(t,e,n){t=va(t),e=fi(e);var r=t.length,o=n=n===i?r:ur(ya(n),0,r);return(n-=e.length)>=0&&t.slice(n,o)==e},$n.eq=$s,$n.escape=function(t){return(t=va(t))&&X.test(t)?t.replace(G,sn):t},$n.escapeRegExp=function(t){return(t=va(t))&&ot.test(t)?t.replace(it,"\\$&"):t},$n.every=function(t,e,n){var r=Ms(t)?Re:yr;return n&&xo(t,e,n)&&(e=i),r(t,co(e,3))},$n.find=ws,$n.findIndex=qo,$n.findKey=function(t,e){return $e(t,co(e,3),xr)},$n.findLast=bs,$n.findLastIndex=Mo,$n.findLastKey=function(t,e){return $e(t,co(e,3),Er)},$n.floor=xu,$n.forEach=vs,$n.forEachRight=ms,$n.forIn=function(t,e){return null==t?t:vr(t,co(e,3),Ca)},$n.forInRight=function(t,e){return null==t?t:mr(t,co(e,3),Ca)},$n.forOwn=function(t,e){return t&&xr(t,co(e,3))},$n.forOwnRight=function(t,e){return t&&Er(t,co(e,3))},$n.get=ka,$n.gt=Ds,$n.gte=zs,$n.has=function(t,e){return null!=t&&wo(t,e,Sr)},$n.hasIn=Sa,$n.head=Wo,$n.identity=iu,$n.includes=function(t,e,n,r){t=Ws(t)?t:$a(t),n=n&&!r?ya(n):0;var i=t.length;return n<0&&(n=vn(i+n,0)),ua(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&ze(t,e,n)>-1},$n.indexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=null==n?0:ya(n);return i<0&&(i=vn(r+i,0)),ze(t,e,i)},$n.inRange=function(t,e,n){return e=pa(e),n===i?(n=e,e=0):n=pa(n),function(t,e,n){return t>=mn(e,n)&&t<vn(e,n)}(t=wa(t),e,n)},$n.invoke=Ra,$n.isArguments=qs,$n.isArray=Ms,$n.isArrayBuffer=Vs,$n.isArrayLike=Ws,$n.isArrayLikeObject=Zs,$n.isBoolean=function(t){return!0===t||!1===t||na(t)&&Ir(t)==m},$n.isBuffer=Gs,$n.isDate=Ys,$n.isElement=function(t){return na(t)&&1===t.nodeType&&!oa(t)},$n.isEmpty=function(t){if(null==t)return!0;if(Ws(t)&&(Ms(t)||"string"==typeof t||"function"==typeof t.splice||Gs(t)||fa(t)||qs(t)))return!t.length;var e=go(t);if(e==A||e==O)return!t.size;if(Ao(t))return!Fr(t).length;for(var n in t)if(Pt.call(t,n))return!1;return!0},$n.isEqual=function(t,e){return Cr(t,e)},$n.isEqualWith=function(t,e,n){var r=(n="function"==typeof n?n:i)?n(t,e):i;return r===i?Cr(t,e,i,n):!!r},$n.isError=Xs,$n.isFinite=function(t){return"number"==typeof t&&me(t)},$n.isFunction=Js,$n.isInteger=Qs,$n.isLength=ta,$n.isMap=ra,$n.isMatch=function(t,e){return t===e||Kr(t,e,lo(e))},$n.isMatchWith=function(t,e,n){return n="function"==typeof n?n:i,Kr(t,e,lo(e),n)},$n.isNaN=function(t){return ia(t)&&t!=+t},$n.isNative=function(t){if(_o(t))throw new _t("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Tr(t)},$n.isNil=function(t){return null==t},$n.isNull=function(t){return null===t},$n.isNumber=ia,$n.isObject=ea,$n.isObjectLike=na,$n.isPlainObject=oa,$n.isRegExp=sa,$n.isSafeInteger=function(t){return Qs(t)&&t>=-9007199254740991&&t<=p},$n.isSet=aa,$n.isString=ua,$n.isSymbol=ca,$n.isTypedArray=fa,$n.isUndefined=function(t){return t===i},$n.isWeakMap=function(t){return na(t)&&go(t)==C},$n.isWeakSet=function(t){return na(t)&&"[object WeakSet]"==Ir(t)},$n.join=function(t,e){return null==t?"":Ne.call(t,e)},$n.kebabCase=Ma,$n.last=Xo,$n.lastIndexOf=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var o=r;return n!==i&&(o=(o=ya(n))<0?vn(r+o,0):mn(o,r-1)),e==e?function(t,e,n){for(var r=n+1;r--;)if(t[r]===e)return r;return r}(t,e,o):De(t,Me,o,!0)},$n.lowerCase=Va,$n.lowerFirst=Wa,$n.lt=la,$n.lte=ha,$n.max=function(t){return t&&t.length?gr(t,iu,kr):i},$n.maxBy=function(t,e){return t&&t.length?gr(t,co(e,2),kr):i},$n.mean=function(t){return Ve(t,iu)},$n.meanBy=function(t,e){return Ve(t,co(e,2))},$n.min=function(t){return t&&t.length?gr(t,iu,jr):i},$n.minBy=function(t,e){return t&&t.length?gr(t,co(e,2),jr):i},$n.stubArray=gu,$n.stubFalse=wu,$n.stubObject=function(){return{}},$n.stubString=function(){return""},$n.stubTrue=function(){return!0},$n.multiply=Bu,$n.nth=function(t,e){return t&&t.length?qr(t,ya(e)):i},$n.noConflict=function(){return ye._===this&&(ye._=$t),this},$n.noop=cu,$n.now=ks,$n.pad=function(t,e,n){t=va(t);var r=(e=ya(e))?pn(t):0;if(!e||r>=e)return t;var i=(e-r)/2;return Mi(ge(i),n)+t+Mi(pe(i),n)},$n.padEnd=function(t,e,n){t=va(t);var r=(e=ya(e))?pn(t):0;return e&&r<e?t+Mi(e-r,n):t},$n.padStart=function(t,e,n){t=va(t);var r=(e=ya(e))?pn(t):0;return e&&r<e?Mi(e-r,n)+t:t},$n.parseInt=function(t,e,n){return n||null==e?e=0:e&&(e=+e),En(va(t).replace(st,""),e||0)},$n.random=function(t,e,n){if(n&&"boolean"!=typeof n&&xo(t,e,n)&&(e=n=i),n===i&&("boolean"==typeof e?(n=e,e=i):"boolean"==typeof t&&(n=t,t=i)),t===i&&e===i?(t=0,e=1):(t=pa(t),e===i?(e=t,t=0):e=pa(e)),t>e){var r=t;t=e,e=r}if(n||t%1||e%1){var o=Bn();return mn(t+o*(e-t+le("1e-"+((o+"").length-1))),e)}return Gr(t,e)},$n.reduce=function(t,e,n){var r=Ms(t)?Fe:Ge,i=arguments.length<3;return r(t,co(e,4),n,i,dr)},$n.reduceRight=function(t,e,n){var r=Ms(t)?He:Ge,i=arguments.length<3;return r(t,co(e,4),n,i,pr)},$n.repeat=function(t,e,n){return e=(n?xo(t,e,n):e===i)?1:ya(e),Yr(va(t),e)},$n.replace=function(){var t=arguments,e=va(t[0]);return t.length<3?e:e.replace(t[1],t[2])},$n.result=function(t,e,n){var r=-1,o=(e=mi(e,t)).length;for(o||(o=1,t=i);++r<o;){var s=null==t?i:t[Ho(e[r])];s===i&&(r=o,s=n),t=Js(s)?s.call(t):s}return t},$n.round=_u,$n.runInContext=t,$n.sample=function(t){return(Ms(t)?Jn:Jr)(t)},$n.size=function(t){if(null==t)return 0;if(Ws(t))return ua(t)?pn(t):t.length;var e=go(t);return e==A||e==O?t.size:Fr(t).length},$n.snakeCase=Za,$n.some=function(t,e,n){var r=Ms(t)?je:oi;return n&&xo(t,e,n)&&(e=i),r(t,co(e,3))},$n.sortedIndex=function(t,e){return si(t,e)},$n.sortedIndexBy=function(t,e,n){return ai(t,e,co(n,2))},$n.sortedIndexOf=function(t,e){var n=null==t?0:t.length;if(n){var r=si(t,e);if(r<n&&$s(t[r],e))return r}return-1},$n.sortedLastIndex=function(t,e){return si(t,e,!0)},$n.sortedLastIndexBy=function(t,e,n){return ai(t,e,co(n,2),!0)},$n.sortedLastIndexOf=function(t,e){if(null==t?0:t.length){var n=si(t,e,!0)-1;if($s(t[n],e))return n}return-1},$n.startCase=Ga,$n.startsWith=function(t,e,n){return t=va(t),n=null==n?0:ur(ya(n),0,t.length),e=fi(e),t.slice(n,n+e.length)==e},$n.subtract=Au,$n.sum=function(t){return t&&t.length?Ye(t,iu):0},$n.sumBy=function(t,e){return t&&t.length?Ye(t,co(e,2)):0},$n.template=function(t,e,n){var r=$n.templateSettings;n&&xo(t,e,n)&&(e=i),t=va(t),e=Ea({},e,r,Qi);var o,s,a=Ea({},e.imports,r.imports,Qi),u=La(a),c=tn(a,u),f=0,l=e.interpolate||Et,h="__p += '",d=St((e.escape||Et).source+"|"+l.source+"|"+(l===tt?pt:Et).source+"|"+(e.evaluate||Et).source+"|$","g"),p="//# sourceURL="+(Pt.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++ae+"]")+"\n";t.replace(d,function(e,n,r,i,a,u){return r||(r=i),h+=t.slice(f,u).replace(Bt,an),n&&(o=!0,h+="' +\n__e("+n+") +\n'"),a&&(s=!0,h+="';\n"+a+";\n__p += '"),r&&(h+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),f=u+e.length,e}),h+="';\n";var y=Pt.call(e,"variable")&&e.variable;if(y){if(ht.test(y))throw new _t("Invalid `variable` option passed into `_.template`")}else h="with (obj) {\n"+h+"\n}\n";h=(s?h.replace(M,""):h).replace(V,"$1").replace(W,"$1;"),h="function("+(y||"obj")+") {\n"+(y?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(o?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+h+"return __p\n}";var g=Qa(function(){return At(u,p+"return "+h).apply(i,c)});if(g.source=h,Xs(g))throw g;return g},$n.times=function(t,e){if((t=ya(t))<1||t>p)return[];var n=g,r=mn(t,g);e=co(e),t-=g;for(var i=Xe(r,e);++n<t;)e(n);return i},$n.toFinite=pa,$n.toInteger=ya,$n.toLength=ga,$n.toLower=function(t){return va(t).toLowerCase()},$n.toNumber=wa,$n.toSafeInteger=function(t){return t?ur(ya(t),-9007199254740991,p):0===t?t:0},$n.toString=va,$n.toUpper=function(t){return va(t).toUpperCase()},$n.trim=function(t,e,n){if((t=va(t))&&(n||e===i))return Je(t);if(!t||!(e=fi(e)))return t;var r=yn(t),o=yn(e);return Ei(r,nn(r,o),rn(r,o)+1).join("")},$n.trimEnd=function(t,e,n){if((t=va(t))&&(n||e===i))return t.slice(0,gn(t)+1);if(!t||!(e=fi(e)))return t;var r=yn(t);return Ei(r,0,rn(r,yn(e))+1).join("")},$n.trimStart=function(t,e,n){if((t=va(t))&&(n||e===i))return t.replace(st,"");if(!t||!(e=fi(e)))return t;var r=yn(t);return Ei(r,nn(r,yn(e))).join("")},$n.truncate=function(t,e){var n=30,r="...";if(ea(e)){var o="separator"in e?e.separator:o;n="length"in e?ya(e.length):n,r="omission"in e?fi(e.omission):r}var s=(t=va(t)).length;if(un(t)){var a=yn(t);s=a.length}if(n>=s)return t;var u=n-pn(r);if(u<1)return r;var c=a?Ei(a,0,u).join(""):t.slice(0,u);if(o===i)return c+r;if(a&&(u+=c.length-u),sa(o)){if(t.slice(u).search(o)){var f,l=c;for(o.global||(o=St(o.source,va(yt.exec(o))+"g")),o.lastIndex=0;f=o.exec(l);)var h=f.index;c=c.slice(0,h===i?u:h)}}else if(t.indexOf(fi(o),u)!=u){var d=c.lastIndexOf(o);d>-1&&(c=c.slice(0,d))}return c+r},$n.unescape=function(t){return(t=va(t))&&Y.test(t)?t.replace(Z,wn):t},$n.uniqueId=function(t){var e=++Ft;return va(t)+e},$n.upperCase=Ya,$n.upperFirst=Xa,$n.each=vs,$n.eachRight=ms,$n.first=Wo,uu($n,(Eu={},xr($n,function(t,e){Pt.call($n.prototype,e)||(Eu[e]=t)}),Eu),{chain:!1}),$n.VERSION="4.17.23",Ue(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){$n[t].placeholder=$n}),Ue(["drop","take"],function(t,e){Mn.prototype[t]=function(n){n=n===i?1:vn(ya(n),0);var r=this.__filtered__&&!e?new Mn(this):this.clone();return r.__filtered__?r.__takeCount__=mn(n,r.__takeCount__):r.__views__.push({size:mn(n,g),type:t+(r.__dir__<0?"Right":"")}),r},Mn.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Ue(["filter","map","takeWhile"],function(t,e){var n=e+1,r=1==n||3==n;Mn.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:co(t,3),type:n}),e.__filtered__=e.__filtered__||r,e}}),Ue(["head","last"],function(t,e){var n="take"+(e?"Right":"");Mn.prototype[t]=function(){return this[n](1).value()[0]}}),Ue(["initial","tail"],function(t,e){var n="drop"+(e?"":"Right");Mn.prototype[t]=function(){return this.__filtered__?new Mn(this):this[n](1)}}),Mn.prototype.compact=function(){return this.filter(iu)},Mn.prototype.find=function(t){return this.filter(t).head()},Mn.prototype.findLast=function(t){return this.reverse().find(t)},Mn.prototype.invokeMap=Xr(function(t,e){return"function"==typeof t?new Mn(this):this.map(function(n){return Rr(n,t,e)})}),Mn.prototype.reject=function(t){return this.filter(Ps(co(t)))},Mn.prototype.slice=function(t,e){t=ya(t);var n=this;return n.__filtered__&&(t>0||e<0)?new Mn(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==i&&(n=(e=ya(e))<0?n.dropRight(-e):n.take(e-t)),n)},Mn.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Mn.prototype.toArray=function(){return this.take(g)},xr(Mn.prototype,function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),o=$n[r?"take"+("last"==e?"Right":""):e],s=r||/^find/.test(e);o&&($n.prototype[e]=function(){var e=this.__wrapped__,a=r?[1]:arguments,u=e instanceof Mn,c=a[0],f=u||Ms(e),l=function(t){var e=o.apply($n,Pe([t],a));return r&&h?e[0]:e};f&&n&&"function"==typeof c&&1!=c.length&&(u=f=!1);var h=this.__chain__,d=!!this.__actions__.length,p=s&&!h,y=u&&!d;if(!s&&f){e=y?e:new Mn(this);var g=t.apply(e,a);return g.__actions__.push({func:ps,args:[l],thisArg:i}),new qn(g,h)}return p&&y?t.apply(this,a):(g=this.thru(l),p?r?g.value()[0]:g.value():g)})}),Ue(["pop","push","shift","sort","splice","unshift"],function(t){var e=Rt[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);$n.prototype[t]=function(){var t=arguments;if(r&&!this.__chain__){var i=this.value();return e.apply(Ms(i)?i:[],t)}return this[n](function(n){return e.apply(Ms(n)?n:[],t)})}}),xr(Mn.prototype,function(t,e){var n=$n[e];if(n){var r=n.name+"";Pt.call(Ln,r)||(Ln[r]=[]),Ln[r].push({name:e,func:n})}}),Ln[$i(i,2).name]=[{name:"wrapper",func:i}],Mn.prototype.clone=function(){var t=new Mn(this.__wrapped__);return t.__actions__=Oi(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Oi(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Oi(this.__views__),t},Mn.prototype.reverse=function(){if(this.__filtered__){var t=new Mn(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Mn.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,n=Ms(t),r=e<0,i=n?t.length:0,o=function(t,e,n){var r=-1,i=n.length;for(;++r<i;){var o=n[r],s=o.size;switch(o.type){case"drop":t+=s;break;case"dropRight":e-=s;break;case"take":e=mn(e,t+s);break;case"takeRight":t=vn(t,e-s)}}return{start:t,end:e}}(0,i,this.__views__),s=o.start,a=o.end,u=a-s,c=r?a:s-1,f=this.__iteratees__,l=f.length,h=0,d=mn(u,this.__takeCount__);if(!n||!r&&i==u&&d==u)return yi(t,this.__actions__);var p=[];t:for(;u--&&h<d;){for(var y=-1,g=t[c+=e];++y<l;){var w=f[y],b=w.iteratee,v=w.type,m=b(g);if(2==v)g=m;else if(!m){if(1==v)continue t;break t}}p[h++]=g}return p},$n.prototype.at=ys,$n.prototype.chain=function(){return ds(this)},$n.prototype.commit=function(){return new qn(this.value(),this.__chain__)},$n.prototype.next=function(){this.__values__===i&&(this.__values__=da(this.value()));var t=this.__index__>=this.__values__.length;return{done:t,value:t?i:this.__values__[this.__index__++]}},$n.prototype.plant=function(t){for(var e,n=this;n instanceof zn;){var r=No(n);r.__index__=0,r.__values__=i,e?o.__wrapped__=r:e=r;var o=r;n=n.__wrapped__}return o.__wrapped__=t,e},$n.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Mn){var e=t;return this.__actions__.length&&(e=new Mn(this)),(e=e.reverse()).__actions__.push({func:ps,args:[es],thisArg:i}),new qn(e,this.__chain__)}return this.thru(es)},$n.prototype.toJSON=$n.prototype.valueOf=$n.prototype.value=function(){return yi(this.__wrapped__,this.__actions__)},$n.prototype.first=$n.prototype.head,Jt&&($n.prototype[Jt]=function(){return this}),$n}();ye._=bn,(r=function(){return bn}.call(e,n,e,t))===i||(t.exports=r)}.call(this)}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={id:r,loaded:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var r={};(()=>{"use strict";n.r(r),n.d(r,{onRpcRequest:()=>wf});var t={};n.r(t),n.d(t,{compressPublicKey:()=>wo,compressedPublicKeyLength:()=>xo,curve:()=>uo,decompressPublicKey:()=>bo,deriveUnhardenedKeys:()=>ho,getPublicKey:()=>yo,isValidPrivateKey:()=>lo,masterNodeGenerationSpec:()=>mo,name:()=>co,privateKeyLength:()=>vo,publicAdd:()=>go,publicKeyLength:()=>po,secret:()=>fo});var e={};n.r(e),n.d(e,{bytesToNumberLE:()=>Uo,compressPublicKey:()=>Co,compressedPublicKeyLength:()=>Fo,curve:()=>Eo,decompressPublicKey:()=>Ko,deriveUnhardenedKeys:()=>ko,getPublicKey:()=>Ro,isValidPrivateKey:()=>Io,masterNodeGenerationSpec:()=>Po,multiplyWithBase:()=>Oo,name:()=>Bo,privateKeyLength:()=>To,publicAdd:()=>Lo,publicKeyLength:()=>So,secret:()=>_o});var i={};n.r(i),n.d(i,{deriveChildKey:()=>ms,privateKeyToEthAddress:()=>bs,publicKeyToEthAddress:()=>vs});var o={};n.r(o),n.d(o,{bip39MnemonicToMultipath:()=>Is,createBip39KeyFromSeed:()=>Os,deriveChildKey:()=>Us,entropyToCip3MasterNode:()=>Rs,getDerivationPathWithSeed:()=>Ss,mnemonicToSeed:()=>As,multipathToBip39Mnemonic:()=>ks});var s={};n.r(s),n.d(s,{add:()=>Hs,bigIntToBytes:()=>Ks,bytesToBigInt:()=>Cs,deriveChainCode:()=>Ms,deriveChildKey:()=>Zs,derivePrivateKey:()=>Ds,derivePublicKey:()=>Ws,getKeyExtension:()=>js,mod2Pow256:()=>Fs,padEnd32Bytes:()=>Ts,toReversed:()=>Ls,trunc28Mul8:()=>Ps});var a={};n.r(a),n.d(a,{deriveChildKey:()=>Gs});var u={};n.r(u),n.d(u,{compressPublicKey:()=>Da,compressedPublicKeyLength:()=>Va,curve:()=>Ka,decompressPublicKey:()=>za,deriveUnhardenedKeys:()=>Fa,getPublicKey:()=>Na,isValidPrivateKey:()=>ja,masterNodeGenerationSpec:()=>Ma,name:()=>Ta,privateKeyLength:()=>qa,publicAdd:()=>$a,publicKeyLength:()=>Ha,secret:()=>Pa});class c extends TypeError{constructor(t,e){let n;const{message:r,explanation:i,...o}=t,{path:s}=t,a=0===s.length?r:`At path: ${s.join(".")} -- ${r}`;super(i??a),null!=i&&(this.cause=a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[t,...e()])}}function f(t){return"object"==typeof t&&null!==t}function l(t){return"symbol"==typeof t?t.toString():"string"==typeof t?JSON.stringify(t):`${t}`}function h(t,e,n,r){if(!0===t)return;!1===t?t={}:"string"==typeof t&&(t={message:t});const{path:i,branch:o}=e,{type:s}=n,{refinement:a,message:u=`Expected a value of type \`${s}\`${a?` with refinement \`${a}\``:""}, but received: \`${l(r)}\``}=t;return{value:r,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...t,message:u}}function*d(t,e,n,r){(function(t){return f(t)&&"function"==typeof t[Symbol.iterator]})(t)||(t=[t]);for(const i of t){const t=h(i,e,n,r);t&&(yield t)}}function*p(t,e,n={}){const{path:r=[],branch:i=[t],coerce:o=!1,mask:s=!1}=n,a={path:r,branch:i};if(o&&(t=e.coercer(t,a),s&&"type"!==e.type&&f(e.schema)&&f(t)&&!Array.isArray(t)))for(const n in t)void 0===e.schema[n]&&delete t[n];let u="valid";for(const r of e.validator(t,a))r.explanation=n.message,u="not_valid",yield[r,void 0];for(let[c,l,h]of e.entries(t,a)){const e=p(l,h,{path:void 0===c?r:[...r,c],branch:void 0===c?i:[...i,l],coerce:o,mask:s,message:n.message});for(const n of e)n[0]?(u=null===n[0].refinement||void 0===n[0].refinement?"not_valid":"not_refined",yield[n[0],void 0]):o&&(l=n[1],void 0===c?t=l:t instanceof Map?t.set(c,l):t instanceof Set?t.add(l):f(t)&&(void 0!==l||c in t)&&(t[c]=l))}if("not_valid"!==u)for(const r of e.refiner(t,a))r.explanation=n.message,u="not_refined",yield[r,void 0];"valid"===u&&(yield[void 0,t])}class y{constructor(t){const{type:e,schema:n,validator:r,refiner:i,coercer:o=t=>t,entries:s=function*(){}}=t;this.type=e,this.schema=n,this.entries=s,this.coercer=o,this.validator=r?(t,e)=>d(r(t,e),e,this,t):()=>[],this.refiner=i?(t,e)=>d(i(t,e),e,this,t):()=>[]}assert(t,e){return b(t,this,e)}create(t,e){return function(t,e,n){const r=v(t,e,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}(t,this,e)}is(t){return function(t,e){const n=v(t,e);return!n[0]}(t,this)}mask(t,e){return function(t,e,n){const r=v(t,e,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}(t,this,e)}validate(t,e={}){return v(t,this,e)}}const g="EXACT_OPTIONAL";class w extends y{constructor(t){super({...t,type:`exact optional ${t.type}`}),this.brand=g}static isExactOptional(t){return f(t)&&"brand"in t&&t.brand===g}}function b(t,e,n){const r=v(t,e,{message:n});if(r[0])throw r[0]}function v(t,e,n={}){const r=p(t,e,n),i=function(t){const{done:e,value:n}=t.next();return e?void 0:n}(r);if(i[0]){return[new c(i[0],function*(){for(const t of r)t[0]&&(yield t[0])}),void 0]}return[void 0,i[1]]}function m(t){return new y({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[n,r]of e.entries())yield[n,r,t]},coercer:t=>Array.isArray(t)?t.slice():t,validator:t=>Array.isArray(t)||`Expected an array value, but received: ${l(t)}`})}function x(){return S("boolean",t=>"boolean"==typeof t)}function E(){return S("never",()=>!1)}function B(t){const e=t?Object.keys(t):[],n=E();return new y({type:"object",schema:t??null,*entries(r){if(t&&f(r)){const i=new Set(Object.keys(r));for(const n of e){i.delete(n);const e=t[n];w.isExactOptional(e)&&!Object.prototype.hasOwnProperty.call(r,n)||(yield[n,r[n],t[n]])}for(const t of i)yield[t,r[t],n]}},validator:t=>f(t)||`Expected an object, but received: ${l(t)}`,coercer:t=>f(t)?{...t}:t})}function _(t){return new y({...t,validator:(e,n)=>void 0===e||t.validator(e,n),refiner:(e,n)=>void 0===e||t.refiner(e,n)})}function A(){return S("string",t=>"string"==typeof t||`Expected a string, but received: ${l(t)}`)}function I(t){const e=t.map(t=>t.type).join(" | ");return new y({type:"union",schema:null,coercer(e){for(const n of t){const[t,r]=n.validate(e,{coerce:!0});if(!t)return r}return e},validator(n,r){const i=[];for(const e of t){const[...t]=p(n,e,r),[o]=t;if(!o?.[0])return[];for(const[e]of t)e&&i.push(e)}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${l(n)}`,...i]}})}function k(...t){const e="type"===t[0]?.type,n=t.map(({schema:t})=>t),r=Object.assign({},...n);return e?function(t){const e=Object.keys(t);return new y({type:"type",schema:t,*entries(n){if(f(n))for(const r of e)yield[r,n[r],t[r]]},validator:t=>f(t)||`Expected an object, but received: ${l(t)}`,coercer:t=>f(t)?{...t}:t})}(r):B(r)}function S(t,e){return new y({type:t,schema:null,validator:e})}function U(t,e){return O(t,"pattern",n=>e.test(n)||`Expected a ${t.type} matching \`/${e.source}/\` but received "${n}"`)}function O(t,e,n){return new y({...t,*refiner(r,i){yield*t.refiner(r,i);const o=d(n(r,i),i,t,r);for(const t of o)yield{...t,refinement:e}}})}const R=BigInt(2**32-1),L=BigInt(32);function C(t,e=!1){return e?{h:Number(t&R),l:Number(t>>L&R)}:{h:0|Number(t>>L&R),l:0|Number(t&R)}}function K(t,e=!1){const n=t.length;let r=new Uint32Array(n),i=new Uint32Array(n);for(let o=0;o<n;o++){const{h:n,l:s}=C(t[o],e);[r[o],i[o]]=[n,s]}return[r,i]}const T=(t,e,n)=>t>>>n,P=(t,e,n)=>t<<32-n|e>>>n,F=(t,e,n)=>t>>>n|e<<32-n,H=(t,e,n)=>t<<32-n|e>>>n,j=(t,e,n)=>t<<64-n|e>>>n-32,N=(t,e,n)=>t>>>n-32|e<<64-n,$=(t,e,n)=>t<<n|e>>>32-n,D=(t,e,n)=>e<<n|t>>>32-n,z=(t,e,n)=>e<<n-32|t>>>64-n,q=(t,e,n)=>t<<n-32|e>>>64-n;function M(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/2**32|0)|0,l:0|i}}const V=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),W=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,Z=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),G=(t,e,n,r,i)=>e+n+r+i+(t/2**32|0)|0,Y=(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0),X=(t,e,n,r,i,o)=>e+n+r+i+o+(t/2**32|0)|0,J="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Q(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function tt(t,...e){if(!((n=t)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function et(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.createHasher");Q(t.outputLen),Q(t.blockLen)}function nt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function rt(t,e){tt(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function it(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function ot(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function st(t,e){return t<<32-e|t>>>e}function at(t,e){return t<<e|t>>>32-e>>>0}const ut=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function ct(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const ft=ut?t=>t:function(t){for(let e=0;e<t.length;e++)t[e]=ct(t[e]);return t};Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));const lt=async()=>{};async function ht(t,e,n){let r=Date.now();for(let i=0;i<t;i++){n(i);const t=Date.now()-r;t>=0&&t<e||(await lt(),r+=t)}}function dt(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}function pt(t){return"string"==typeof t&&(t=dt(t)),tt(t),t}function yt(t){return"string"==typeof t&&(t=dt(t)),tt(t),t}class gt{}function wt(t){const e=e=>t().update(pt(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function bt(t=32){if(J&&"function"==typeof J.getRandomValues)return J.getRandomValues(new Uint8Array(t));if(J&&"function"==typeof J.randomBytes)return Uint8Array.from(J.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const vt=BigInt(0),mt=BigInt(1),xt=BigInt(2),Et=BigInt(7),Bt=BigInt(256),_t=BigInt(113),At=[],It=[],kt=[];for(let t=0,e=mt,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],At.push(2*(5*r+n)),It.push((t+1)*(t+2)/2%64);let i=vt;for(let t=0;t<7;t++)e=(e<<mt^(e>>Et)*_t)%Bt,e&xt&&(i^=mt<<(mt<<BigInt(t))-mt);kt.push(i)}const St=K(kt,!0),Ut=St[0],Ot=St[1],Rt=(t,e,n)=>n>32?z(t,e,n):$(t,e,n),Lt=(t,e,n)=>n>32?q(t,e,n):D(t,e,n);class Ct extends gt{constructor(t,e,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=r,this.rounds=i,Q(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");var o;this.state=new Uint8Array(200),this.state32=(o=this.state,new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4)))}clone(){return this._cloneInto()}keccak(){ft(this.state32),function(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let e=0;e<10;e++)n[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const r=(e+8)%10,i=(e+2)%10,o=n[i],s=n[i+1],a=Rt(o,s,1)^n[r],u=Lt(o,s,1)^n[r+1];for(let n=0;n<50;n+=10)t[e+n]^=a,t[e+n+1]^=u}let e=t[2],i=t[3];for(let n=0;n<24;n++){const r=It[n],o=Rt(e,i,r),s=Lt(e,i,r),a=At[n];e=t[a],i=t[a+1],t[a]=o,t[a+1]=s}for(let e=0;e<50;e+=10){for(let r=0;r<10;r++)n[r]=t[e+r];for(let r=0;r<10;r++)t[e+r]^=~n[(r+2)%10]&n[(r+4)%10]}t[0]^=Ut[r],t[1]^=Ot[r]}it(n)}(this.state32,this.rounds),ft(this.state32),this.posOut=0,this.pos=0}update(t){nt(this),tt(t=pt(t));const{blockLen:e,state:n}=this,r=t.length;for(let i=0;i<r;){const o=Math.min(e-this.pos,r-i);for(let e=0;e<o;e++)n[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:r}=this;t[n]^=e,128&e&&n===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){nt(this,!1),tt(t),this.finish();const e=this.state,{blockLen:n}=this;for(let r=0,i=t.length;r<i;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,i-r);t.set(e.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Q(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(rt(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,it(this.state)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:r,rounds:i,enableXOF:o}=this;return t||(t=new Ct(e,n,r,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=n,t.outputLen=r,t.enableXOF=o,t.destroyed=this.destroyed,t}}const Kt=(t,e,n)=>wt(()=>new Ct(e,t,n)),Tt=Kt(1,136,32);var Pt=n(680);Error;function Ft(t){return Boolean(t)&&"object"==typeof t&&!Array.isArray(t)}const Ht=(t,e)=>Object.hasOwnProperty.call(t,e);var jt;!function(t){t[t.Null=4]="Null",t[t.Comma=1]="Comma",t[t.Wrapper=1]="Wrapper",t[t.True=4]="True",t[t.False=5]="False",t[t.Quote=1]="Quote",t[t.Colon=1]="Colon",t[t.Date=24]="Date"}(jt=jt||(jt={}));function Nt(t){return function(t){return function(t){return"object"==typeof t&&null!==t&&"message"in t}(t)&&"string"==typeof t.message?t.message:null==t?"":String(t)}(t).replace(/\.$/u,"")}function $t(t,e){return n=t,Boolean("string"==typeof n?.prototype?.constructor?.name)?new t({message:e}):t({message:e});var n}class Dt extends Error{constructor(t){super(t.message),this.code="ERR_ASSERTION"}}function zt(t,e="Assertion failed.",n=Dt){if(!t){if(e instanceof Error)throw e;throw $t(n,e)}}function qt(t,e,n="Assertion failed",r=Dt){try{b(t,e)}catch(t){throw $t(r,`${n}: ${Nt(t)}.`)}}function Mt(t){throw new Error("Invalid branch reached. Should be detected during compilation.")}const{memoize:Vt}=Pt,Wt=/^(?:0x)?[0-9a-f]+$/iu,Zt=/^0x[0-9a-f]+$/iu,Gt=/^0x[0-9a-f]{40}$/u,Yt=/^0x[0-9a-fA-F]{40}$/u,Xt=(U(A(),Wt),U(A(),Zt),U(A(),Gt),U(A(),Yt)),Jt=t=>"string"==typeof t;function Qt(t){return Jt(t)&&Yt.test(t)}function te(t){zt(function(t){return Jt(t)&&Wt.test(t)}(t),"Value must be a hexadecimal string.")}const ee=Vt(function(t){zt(Qt(t),"Invalid hex address.");const e=ie(t).toLowerCase(),n=Tt(e),{length:r}=e,i=new Array(r);for(let t=0;t<r;t++){const r=1&t,o=n[t>>1],s=0===r?o>>4:15&o;i[t]=s>=8?e[t].toUpperCase():e[t]}return`0x${i.join("")}`});const ne=Vt(function(t){return!!Qt(t)&&ee(t)===t});Vt(function(t){return Jt(e=t)&&Gt.test(e)||ne(t);var e});function re(t){return t.startsWith("0x")?t:t.startsWith("0X")?`0x${t.substring(2)}`:`0x${t}`}function ie(t){return t.startsWith("0x")||t.startsWith("0X")?t.substring(2):t}var oe;function se(t){return S(JSON.stringify(t),function(t){const e=l(t),n=typeof t;return new y({type:"literal",schema:"string"===n||"number"===n||"boolean"===n?t:null,validator:n=>n===t||`Expected the literal \`${e}\`, but received: ${l(n)}`})}(t).validator)}function ae(t){return se(t)}function ue(t,e,n=[]){return(...r)=>{if(1===r.length&&function(t){if("object"!=typeof t||null===t)return!1;try{let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}catch(t){return!1}}(r[0])){const n={...r[0],type:t};return qt(n,e,`Invalid ${t} component`),n}const i=n.reduce((t,e,n)=>void 0!==r[n]?{...t,[e]:r[n]}:t,{type:t});return qt(i,e,`Invalid ${t} component`),i}}!function(t){t.Copyable="copyable",t.Divider="divider",t.Heading="heading",t.Panel="panel",t.Spinner="spinner",t.Text="text",t.Image="image",t.Row="row",t.Address="address",t.Button="button",t.Input="input",t.Form="form"}(oe||(oe={}));const ce=B({type:A()}),fe=k(ce,B({value:S("unknown",()=>!0)})),le=k(fe,B({type:se(oe.Address),value:Xt}));ue(oe.Address,le,["value"]);var he,de;!function(t){t.Primary="primary",t.Secondary="secondary"}(he||(he={})),function(t){t.Button="button",t.Submit="submit"}(de||(de={}));const pe=k(fe,B({type:se(oe.Button),value:A(),variant:_(I([ae(he.Primary),ae(he.Secondary)])),buttonType:_(I([ae(de.Button),ae(de.Submit)])),name:_(A())})),ye=(ue(oe.Button,pe,["value","buttonType","name","variant"]),k(fe,B({type:se(oe.Copyable),value:A(),sensitive:_(x())}))),ge=(ue(oe.Copyable,ye,["value","sensitive"]),k(ce,B({type:se(oe.Divider)}))),we=ue(oe.Divider,ge);var be;!function(t){t.Text="text",t.Number="number",t.Password="password"}(be||(be={}));const ve=k(fe,B({type:se(oe.Input),value:_(A()),name:A(),inputType:_(I([ae(be.Text),ae(be.Password),ae(be.Number)])),placeholder:_(A()),label:_(A()),error:_(A())})),me=(ue(oe.Input,ve,["name","inputType","placeholder","value","label"]),I([ve,pe])),xe=k(ce,B({type:se(oe.Form),children:m(me),name:A()})),Ee=(ue(oe.Form,xe,["name","children"]),k(fe,B({type:se(oe.Heading),value:A()}))),Be=ue(oe.Heading,Ee,["value"]);const _e=k(ce,B({type:se(oe.Image),value:O(A(),"SVG",t=>!!t.includes("<svg")||"Value is not a valid SVG.")})),Ae=(ue(oe.Image,_e,["value"]),k(fe,B({type:se(oe.Text),value:A(),markdown:_(x())}))),Ie=ue(oe.Text,Ae,["value","markdown"]);var ke;!function(t){t.Default="default",t.Critical="critical",t.Warning="warning"}(ke||(ke={}));const Se=I([_e,Ae,le]),Ue=k(fe,B({type:se(oe.Row),variant:_(I([ae(ke.Default),ae(ke.Critical),ae(ke.Warning)])),label:A(),value:Se})),Oe=(ue(oe.Row,Ue,["label","value","variant"]),k(ce,B({type:se(oe.Spinner)}))),Re=(ue(oe.Spinner,Oe),k(ce,B({children:m(function(t){let e;return new y({type:"lazy",schema:null,*entries(n,r){e??(e=t()),yield*e.entries(n,r)},validator:(n,r)=>(e??(e=t()),e.validator(n,r)),coercer:(n,r)=>(e??(e=t()),e.coercer(n,r)),refiner:(n,r)=>(e??(e=t()),e.refiner(n,r))})}(()=>Ke))}))),Le=k(Re,B({type:se(oe.Panel)})),Ce=ue(oe.Panel,Le,["children"]),Ke=function(t){const e=t.map(t=>"union"===t.type&&Array.isArray(t.schema)?t.schema:t).flat(1/0),n=e.map(({schema:t})=>t.type.type),r=e.reduce((t,e)=>(t[JSON.parse(e.schema.type.type)]=e,t),{});return new y({type:"union",schema:e,*entries(t,e){if(!Ft(t)||!Ht(t,"type")||"string"!=typeof t.type)return;const{type:n}=t,i=r[n];if(i)for(const n of i.entries(t,e))yield n},coercer(t,e){if(!Ft(t)||!Ht(t,"type")||"string"!=typeof t.type)return t;const{type:n}=t,i=r[n];return i?i.coercer(t,e):t},*refiner(t,e){const n=r[t.type];yield*n.refiner(t,e)},validator(t,e){if(!Ft(t)||!Ht(t,"type")||"string"!=typeof t.type)return`Expected type to be one of: ${n.join(", ")}, but received: undefined`;const{type:i}=t,o=r[i];return o?o.validator(t,e):`Expected type to be one of: ${n.join(", ")}, but received: "${i}"`}})}([ye,ge,Ee,_e,Le,Oe,Ae,Ue,le,ve,xe,pe]),Te=32,Pe=4294967295,Fe="bip32:44'",He=/^\d+$/u,je=/^bip32:\d+'?$/u,Ne=/^slip10:\d+'?$/u,$e=/^cip3:\d+'?$/u,De=/^bip39:([a-z]+){1}( [a-z]+){11,23}$/u,ze=2147483648;var qe=n(533).hp;const Me=48,Ve=58,We=87;const Ze=function(){const t=[];return()=>{if(0===t.length)for(let e=0;e<256;e++)t.push(e.toString(16).padStart(2,"0"));return t}}();function Ge(t){return t instanceof Uint8Array}function Ye(t){zt(Ge(t),"Value must be a Uint8Array.")}function Xe(t){if(Ye(t),0===t.length)return"0x";const e=Ze(),n=new Array(t.length);for(let r=0;r<t.length;r++)n[r]=e[t[r]];return re(n.join(""))}function Je(t){Ye(t);const e=Xe(t);return BigInt(e)}function Qe(t){if("0x"===t?.toLowerCase?.())return new Uint8Array;te(t);const e=ie(t).toLowerCase(),n=e.length%2==0?e:`0${e}`,r=new Uint8Array(n.length/2);for(let t=0;t<r.length;t++){const e=n.charCodeAt(2*t),i=n.charCodeAt(2*t+1),o=e-(e<Ve?Me:We),s=i-(i<Ve?Me:We);r[t]=16*o+s}return r}function tn(t){return zt("string"==typeof t,"Value must be a string."),(new TextEncoder).encode(t)}function en(t){if("bigint"==typeof t)return function(t){return zt("bigint"==typeof t,"Value must be a bigint."),zt(t>=BigInt(0),"Value must be a non-negative bigint."),Qe(t.toString(16))}(t);if("number"==typeof t)return function(t){return zt("number"==typeof t,"Value must be a number."),zt(t>=0,"Value must be a non-negative number."),zt(Number.isSafeInteger(t),"Value is not a safe integer. Use `bigIntToBytes` instead."),Qe(t.toString(16))}(t);if("string"==typeof t)return t.startsWith("0x")?Qe(t):tn(t);if(Ge(t))return t;throw new TypeError(`Unsupported value type: "${typeof t}".`)}function nn(t){const e=new Array(t.length);let n=0;for(let r=0;r<t.length;r++){const i=en(t[r]);e[r]=i,n+=i.length}const r=new Uint8Array(n);for(let t=0,n=0;t<e.length;t++)r.set(e[t],n),n+=e[t].length;return r}function rn(t){if(void 0!==qe&&t instanceof qe){const e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return new DataView(e)}return new DataView(t.buffer,t.byteOffset,t.byteLength)}function on(t,e,n){return t&e^~t&n}function sn(t,e,n){return t&e^t&n^e&n}class an extends gt{constructor(t,e,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(t),this.view=ot(this.buffer)}update(t){nt(this),tt(t=pt(t));const{view:e,buffer:n,blockLen:r}=this,i=t.length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s===r){const e=ot(t);for(;r<=i-o;o+=r)this.process(e,o);continue}n.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){nt(this),rt(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;e[o++]=128,it(this.buffer.subarray(o)),this.padOffset>r-o&&(this.process(n,0),o=0);for(let t=o;t<r;t++)e[t]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),u=r?4:0,c=r?0:4;t.setUint32(e+u,s,r),t.setUint32(e+c,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=ot(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)s.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return t.destroyed=o,t.finished=i,t.length=r,t.pos=s,r%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const un=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),cn=(Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]));const fn=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ln=new Uint32Array(64);class hn extends an{constructor(t=32){super(64,t,8,!1),this.A=0|un[0],this.B=0|un[1],this.C=0|un[2],this.D=0|un[3],this.E=0|un[4],this.F=0|un[5],this.G=0|un[6],this.H=0|un[7]}get(){const{A:t,B:e,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[t,e,n,r,i,o,s,a]}set(t,e,n,r,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)ln[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=ln[t-15],n=ln[t-2],r=st(e,7)^st(e,18)^e>>>3,i=st(n,17)^st(n,19)^n>>>10;ln[t]=i+ln[t-7]+r+ln[t-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(st(s,6)^st(s,11)^st(s,25))+on(s,a,u)+fn[t]+ln[t]|0,f=(st(n,2)^st(n,13)^st(n,22))+sn(n,r,i)|0;c=u,u=a,a=s,s=o+e|0,o=i,i=r,r=n,n=e+f|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(n,r,i,o,s,a,u,c)}roundClean(){it(ln)}destroy(){this.set(0,0,0,0,0,0,0,0),it(this.buffer)}}const dn=K(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),pn=dn[0],yn=dn[1],gn=new Uint32Array(80),wn=new Uint32Array(80);class bn extends an{constructor(t=64){super(128,t,16,!1),this.Ah=0|cn[0],this.Al=0|cn[1],this.Bh=0|cn[2],this.Bl=0|cn[3],this.Ch=0|cn[4],this.Cl=0|cn[5],this.Dh=0|cn[6],this.Dl=0|cn[7],this.Eh=0|cn[8],this.El=0|cn[9],this.Fh=0|cn[10],this.Fl=0|cn[11],this.Gh=0|cn[12],this.Gl=0|cn[13],this.Hh=0|cn[14],this.Hl=0|cn[15]}get(){const{Ah:t,Al:e,Bh:n,Bl:r,Ch:i,Cl:o,Dh:s,Dl:a,Eh:u,El:c,Fh:f,Fl:l,Gh:h,Gl:d,Hh:p,Hl:y}=this;return[t,e,n,r,i,o,s,a,u,c,f,l,h,d,p,y]}set(t,e,n,r,i,o,s,a,u,c,f,l,h,d,p,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|u,this.El=0|c,this.Fh=0|f,this.Fl=0|l,this.Gh=0|h,this.Gl=0|d,this.Hh=0|p,this.Hl=0|y}process(t,e){for(let n=0;n<16;n++,e+=4)gn[n]=t.getUint32(e),wn[n]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|gn[t-15],n=0|wn[t-15],r=F(e,n,1)^F(e,n,8)^T(e,0,7),i=H(e,n,1)^H(e,n,8)^P(e,n,7),o=0|gn[t-2],s=0|wn[t-2],a=F(o,s,19)^j(o,s,61)^T(o,0,6),u=H(o,s,19)^N(o,s,61)^P(o,s,6),c=Z(i,u,wn[t-7],wn[t-16]),f=G(c,r,a,gn[t-7],gn[t-16]);gn[t]=0|f,wn[t]=0|c}let{Ah:n,Al:r,Bh:i,Bl:o,Ch:s,Cl:a,Dh:u,Dl:c,Eh:f,El:l,Fh:h,Fl:d,Gh:p,Gl:y,Hh:g,Hl:w}=this;for(let t=0;t<80;t++){const e=F(f,l,14)^F(f,l,18)^j(f,l,41),b=H(f,l,14)^H(f,l,18)^N(f,l,41),v=f&h^~f&p,m=Y(w,b,l&d^~l&y,yn[t],wn[t]),x=X(m,g,e,v,pn[t],gn[t]),E=0|m,B=F(n,r,28)^j(n,r,34)^j(n,r,39),_=H(n,r,28)^N(n,r,34)^N(n,r,39),A=n&i^n&s^i&s,I=r&o^r&a^o&a;g=0|p,w=0|y,p=0|h,y=0|d,h=0|f,d=0|l,({h:f,l}=M(0|u,0|c,0|x,0|E)),u=0|s,c=0|a,s=0|i,a=0|o,i=0|n,o=0|r;const k=V(E,_,I);n=W(k,x,B,A),r=0|k}({h:n,l:r}=M(0|this.Ah,0|this.Al,0|n,0|r)),({h:i,l:o}=M(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=M(0|this.Ch,0|this.Cl,0|s,0|a)),({h:u,l:c}=M(0|this.Dh,0|this.Dl,0|u,0|c)),({h:f,l}=M(0|this.Eh,0|this.El,0|f,0|l)),({h,l:d}=M(0|this.Fh,0|this.Fl,0|h,0|d)),({h:p,l:y}=M(0|this.Gh,0|this.Gl,0|p,0|y)),({h:g,l:w}=M(0|this.Hh,0|this.Hl,0|g,0|w)),this.set(n,r,i,o,s,a,u,c,f,l,h,d,p,y,g,w)}roundClean(){it(gn,wn)}destroy(){it(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);const vn=wt(()=>new hn),mn=wt(()=>new bn);class xn extends gt{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,et(t);const n=pt(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?t.create().update(n).digest():n);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),it(i)}update(t){return nt(this),this.iHash.update(t),this}digestInto(t){nt(this),tt(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=r,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const En=(t,e,n)=>new xn(t,e).update(n).digest();En.create=(t,e)=>new xn(t,e);const Bn=BigInt(0),_n=BigInt(1);function An(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function In(t){if(!An(t))throw new Error("Uint8Array expected")}function kn(t,e){if("boolean"!=typeof e)throw new Error(t+" boolean expected, got "+e)}function Sn(t){const e=t.toString(16);return 1&e.length?"0"+e:e}function Un(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return""===t?Bn:BigInt("0x"+t)}const On="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,Rn=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ln(t){if(In(t),On)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=Rn[t[n]];return e}const Cn=48,Kn=57,Tn=65,Pn=70,Fn=97,Hn=102;function jn(t){return t>=Cn&&t<=Kn?t-Cn:t>=Tn&&t<=Pn?t-(Tn-10):t>=Fn&&t<=Hn?t-(Fn-10):void 0}function Nn(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);if(On)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let e=0,i=0;e<n;e++,i+=2){const n=jn(t.charCodeAt(i)),o=jn(t.charCodeAt(i+1));if(void 0===n||void 0===o){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}r[e]=16*n+o}return r}function $n(t){return Un(Ln(t))}function Dn(t){return In(t),Un(Ln(Uint8Array.from(t).reverse()))}function zn(t,e){return Nn(t.toString(16).padStart(2*e,"0"))}function qn(t,e){return zn(t,e).reverse()}function Mn(t,e,n){let r;if("string"==typeof e)try{r=Nn(e)}catch(e){throw new Error(t+" must be hex string or Uint8Array, cause: "+e)}else{if(!An(e))throw new Error(t+" must be hex string or Uint8Array");r=Uint8Array.from(e)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(t+" of length "+n+" expected, got "+i);return r}function Vn(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];In(r),e+=r.length}const n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const i=t[e];n.set(i,r),r+=i.length}return n}const Wn=t=>"bigint"==typeof t&&Bn<=t;function Zn(t,e,n){return Wn(t)&&Wn(e)&&Wn(n)&&e<=t&&t<n}function Gn(t,e,n,r){if(!Zn(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}const Yn=t=>(_n<<BigInt(t))-_n,Xn=t=>new Uint8Array(t),Jn=t=>Uint8Array.from(t);const Qn={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||An(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function tr(t,e,n={}){const r=(e,n,r)=>{const i=Qn[n];if("function"!=typeof i)throw new Error("invalid validator function");const o=t[e];if(!(r&&void 0===o||i(o,t)))throw new Error("param "+String(e)+" is invalid. Expected "+n+", got "+o)};for(const[t,n]of Object.entries(e))r(t,n,!1);for(const[t,e]of Object.entries(n))r(t,e,!0);return t}function er(t){const e=new WeakMap;return(n,...r)=>{const i=e.get(n);if(void 0!==i)return i;const o=t(n,...r);return e.set(n,o),o}}const nr=BigInt(0),rr=BigInt(1),ir=BigInt(2),or=BigInt(3),sr=BigInt(4),ar=BigInt(5),ur=BigInt(8);function cr(t,e){const n=t%e;return n>=nr?n:e+n}function fr(t,e,n){let r=t;for(;e-- >nr;)r*=r,r%=n;return r}function lr(t,e){if(t===nr)throw new Error("invert: expected non-zero number");if(e<=nr)throw new Error("invert: expected positive modulus, got "+e);let n=cr(t,e),r=e,i=nr,o=rr,s=rr,a=nr;for(;n!==nr;){const t=r/n,e=r%n,u=i-s*t,c=o-a*t;r=n,n=e,i=s,o=a,s=u,a=c}if(r!==rr)throw new Error("invert: does not exist");return cr(i,e)}function hr(t,e){const n=(t.ORDER+rr)/sr,r=t.pow(e,n);if(!t.eql(t.sqr(r),e))throw new Error("Cannot find square root");return r}function dr(t,e){const n=(t.ORDER-ar)/ur,r=t.mul(e,ir),i=t.pow(r,n),o=t.mul(e,i),s=t.mul(t.mul(o,ir),i),a=t.mul(o,t.sub(s,t.ONE));if(!t.eql(t.sqr(a),e))throw new Error("Cannot find square root");return a}function pr(t){return t%sr===or?hr:t%ur===ar?dr:function(t){if(t<BigInt(3))throw new Error("sqrt is not defined for small field");let e=t-rr,n=0;for(;e%ir===nr;)e/=ir,n++;let r=ir;const i=mr(t);for(;1===br(i,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return hr;let o=i.pow(r,e);const s=(e+rr)/ir;return function(t,r){if(t.is0(r))return r;if(1!==br(t,r))throw new Error("Cannot find square root");let i=n,a=t.mul(t.ONE,o),u=t.pow(r,e),c=t.pow(r,s);for(;!t.eql(u,t.ONE);){if(t.is0(u))return t.ZERO;let e=1,n=t.sqr(u);for(;!t.eql(n,t.ONE);)if(e++,n=t.sqr(n),e===i)throw new Error("Cannot find square root");const r=rr<<BigInt(i-e-1),o=t.pow(a,r);i=e,a=t.sqr(o),u=t.mul(u,a),c=t.mul(c,o)}return c}}(t)}const yr=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function gr(t,e,n){if(n<nr)throw new Error("invalid exponent, negatives unsupported");if(n===nr)return t.ONE;if(n===rr)return e;let r=t.ONE,i=e;for(;n>nr;)n&rr&&(r=t.mul(r,i)),i=t.sqr(i),n>>=rr;return r}function wr(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),i=e.reduce((e,n,i)=>t.is0(n)?e:(r[i]=e,t.mul(e,n)),t.ONE),o=t.inv(i);return e.reduceRight((e,n,i)=>t.is0(n)?e:(r[i]=t.mul(e,r[i]),t.mul(e,n)),o),r}function br(t,e){const n=(t.ORDER-rr)/ir,r=t.pow(e,n),i=t.eql(r,t.ONE),o=t.eql(r,t.ZERO),s=t.eql(r,t.neg(t.ONE));if(!i&&!o&&!s)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}function vr(t,e){void 0!==e&&Q(e);const n=void 0!==e?e:t.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function mr(t,e,n=!1,r={}){if(t<=nr)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:i,nByteLength:o}=vr(t,e);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s;const a=Object.freeze({ORDER:t,isLE:n,BITS:i,BYTES:o,MASK:Yn(i),ZERO:nr,ONE:rr,create:e=>cr(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("invalid field element: expected bigint, got "+typeof e);return nr<=e&&e<t},is0:t=>t===nr,isOdd:t=>(t&rr)===rr,neg:e=>cr(-e,t),eql:(t,e)=>t===e,sqr:e=>cr(e*e,t),add:(e,n)=>cr(e+n,t),sub:(e,n)=>cr(e-n,t),mul:(e,n)=>cr(e*n,t),pow:(t,e)=>gr(a,t,e),div:(e,n)=>cr(e*lr(n,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>lr(e,t),sqrt:r.sqrt||(e=>(s||(s=pr(t)),s(a,e))),toBytes:t=>n?qn(t,o):zn(t,o),fromBytes:t=>{if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);return n?Dn(t):$n(t)},invertBatch:t=>wr(a,t),cmov:(t,e,n)=>n?e:t});return Object.freeze(a)}function xr(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Er(t){const e=xr(t);return e+Math.ceil(e/2)}const Br=BigInt(0),_r=BigInt(1);function Ar(t,e){const n=e.negate();return t?n:e}function Ir(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function kr(t,e){Ir(t,e);const n=2**t;return{windows:Math.ceil(e/t)+1,windowSize:2**(t-1),mask:Yn(t),maxNumber:n,shiftBy:BigInt(t)}}function Sr(t,e,n){const{windowSize:r,mask:i,maxNumber:o,shiftBy:s}=n;let a=Number(t&i),u=t>>s;a>r&&(a-=o,u+=_r);const c=e*r;return{nextN:u,offset:c+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:e%2!=0,offsetF:c}}function Ur(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((t,n)=>{if(!(t instanceof e))throw new Error("invalid point at index "+n)})}function Or(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((t,n)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+n)})}const Rr=new WeakMap,Lr=new WeakMap;function Cr(t){return Lr.get(t)||1}function Kr(t,e){return{constTimeNegate:Ar,hasPrecomputes:t=>1!==Cr(t),unsafeLadder(e,n,r=t.ZERO){let i=e;for(;n>Br;)n&_r&&(r=r.add(i)),i=i.double(),n>>=_r;return r},precomputeWindow(t,n){const{windows:r,windowSize:i}=kr(n,e),o=[];let s=t,a=s;for(let t=0;t<r;t++){a=s,o.push(a);for(let t=1;t<i;t++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(n,r,i){let o=t.ZERO,s=t.BASE;const a=kr(n,e);for(let t=0;t<a.windows;t++){const{nextN:e,offset:n,isZero:u,isNeg:c,isNegF:f,offsetF:l}=Sr(i,t,a);i=e,u?s=s.add(Ar(f,r[l])):o=o.add(Ar(c,r[n]))}return{p:o,f:s}},wNAFUnsafe(n,r,i,o=t.ZERO){const s=kr(n,e);for(let t=0;t<s.windows&&i!==Br;t++){const{nextN:e,offset:n,isZero:a,isNeg:u}=Sr(i,t,s);if(i=e,!a){const t=r[n];o=o.add(u?t.negate():t)}}return o},getPrecomputes(t,e,n){let r=Rr.get(e);return r||(r=this.precomputeWindow(e,t),1!==t&&Rr.set(e,n(r))),r},wNAFCached(t,e,n){const r=Cr(t);return this.wNAF(r,this.getPrecomputes(r,t,n),e)},wNAFCachedUnsafe(t,e,n,r){const i=Cr(t);return 1===i?this.unsafeLadder(t,e,r):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),e,r)},setWindowSize(t,n){Ir(n,e),Lr.set(t,n),Rr.delete(t)}}}function Tr(t,e,n,r){Ur(n,t),Or(r,e);const i=n.length,o=r.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");const s=t.ZERO,a=function(t){let e;for(e=0;t>Bn;t>>=_n,e+=1);return e}(BigInt(i));let u=1;a>12?u=a-3:a>4?u=a-2:a>0&&(u=2);const c=Yn(u),f=new Array(Number(c)+1).fill(s);let l=s;for(let t=Math.floor((e.BITS-1)/u)*u;t>=0;t-=u){f.fill(s);for(let e=0;e<o;e++){const i=r[e],o=Number(i>>BigInt(t)&c);f[o]=f[o].add(n[e])}let e=s;for(let t=f.length-1,n=s;t>0;t--)n=n.add(f[t]),e=e.add(n);if(l=l.add(e),0!==t)for(let t=0;t<u;t++)l=l.double()}return l}function Pr(t){return function(t){const e=yr.reduce((t,e)=>(t[e]="function",t),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});tr(t,e)}(t.Fp),tr(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...vr(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function Fr(t){void 0!==t.lowS&&kn("lowS",t.lowS),void 0!==t.prehash&&kn("prehash",t.prehash)}class Hr extends Error{constructor(t=""){super(t)}}const jr={Err:Hr,_tlv:{encode:(t,e)=>{const{Err:n}=jr;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(1&e.length)throw new n("tlv.encode: unpadded data");const r=e.length/2,i=Sn(r);if(i.length/2&128)throw new n("tlv.encode: long form length too big");const o=r>127?Sn(i.length/2|128):"";return Sn(t)+o+i+e},decode(t,e){const{Err:n}=jr;let r=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");const i=e[r++];let o=0;if(!!(128&i)){const t=127&i;if(!t)throw new n("tlv.decode(long): indefinite length not supported");if(t>4)throw new n("tlv.decode(long): byte length is too big");const s=e.subarray(r,r+t);if(s.length!==t)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(const t of s)o=o<<8|t;if(r+=t,o<128)throw new n("tlv.decode(long): not minimal encoding")}else o=i;const s=e.subarray(r,r+o);if(s.length!==o)throw new n("tlv.decode: wrong value length");return{v:s,l:e.subarray(r+o)}}},_int:{encode(t){const{Err:e}=jr;if(t<$r)throw new e("integer: negative integers are not allowed");let n=Sn(t);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:e}=jr;if(128&t[0])throw new e("invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new e("invalid signature integer: unnecessary leading zero");return $n(t)}},toSig(t){const{Err:e,_int:n,_tlv:r}=jr,i=Mn("signature",t),{v:o,l:s}=r.decode(48,i);if(s.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:u}=r.decode(2,o),{v:c,l:f}=r.decode(2,u);if(f.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(c)}},hexFromSig(t){const{_tlv:e,_int:n}=jr,r=e.encode(2,n.encode(t.r))+e.encode(2,n.encode(t.s));return e.encode(48,r)}};function Nr(t,e){return Ln(zn(t,e))}const $r=BigInt(0),Dr=BigInt(1),zr=(BigInt(2),BigInt(3)),qr=BigInt(4);function Mr(t){const e=function(t){const e=Pr(t);tr(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:n,Fp:r,a:i}=e;if(n){if(!r.eql(i,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}(t),{Fp:n}=e,r=mr(e.n,e.nBitLength),i=e.toBytes||((t,e,r)=>{const i=e.toAffine();return Vn(Uint8Array.from([4]),n.toBytes(i.x),n.toBytes(i.y))}),o=e.fromBytes||(t=>{const e=t.subarray(1);return{x:n.fromBytes(e.subarray(0,n.BYTES)),y:n.fromBytes(e.subarray(n.BYTES,2*n.BYTES))}});function s(t){const{a:r,b:i}=e,o=n.sqr(t),s=n.mul(o,t);return n.add(n.add(s,n.mul(t,r)),i)}function a(t,e){const r=n.sqr(e),i=s(t);return n.eql(r,i)}if(!a(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const u=n.mul(n.pow(e.a,zr),qr),c=n.mul(n.sqr(e.b),BigInt(27));if(n.is0(n.add(u,c)))throw new Error("bad curve params: a or b");function f(t){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:i,n:o}=e;if(n&&"bigint"!=typeof t){if(An(t)&&(t=Ln(t)),"string"!=typeof t||!n.includes(t.length))throw new Error("invalid private key");t=t.padStart(2*r,"0")}let s;try{s="bigint"==typeof t?t:$n(Mn("private key",t,r))}catch(e){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof t)}return i&&(s=cr(s,o)),Gn("private key",s,Dr,o),s}function l(t){if(!(t instanceof p))throw new Error("ProjectivePoint expected")}const h=er((t,e)=>{const{px:r,py:i,pz:o}=t;if(n.eql(o,n.ONE))return{x:r,y:i};const s=t.is0();null==e&&(e=s?n.ONE:n.inv(o));const a=n.mul(r,e),u=n.mul(i,e),c=n.mul(o,e);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw new Error("invZ was invalid");return{x:a,y:u}}),d=er(t=>{if(t.is0()){if(e.allowInfinityPoint&&!n.is0(t.py))return;throw new Error("bad point: ZERO")}const{x:r,y:i}=t.toAffine();if(!n.isValid(r)||!n.isValid(i))throw new Error("bad point: x or y not FE");if(!a(r,i))throw new Error("bad point: equation left != right");if(!t.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class p{constructor(t,e,r){if(null==t||!n.isValid(t))throw new Error("x required");if(null==e||!n.isValid(e)||n.is0(e))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required");this.px=t,this.py=e,this.pz=r,Object.freeze(this)}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!n.isValid(e)||!n.isValid(r))throw new Error("invalid affine point");if(t instanceof p)throw new Error("projective point not allowed");const i=t=>n.eql(t,n.ZERO);return i(e)&&i(r)?p.ZERO:new p(e,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=wr(n,t.map(t=>t.pz));return t.map((t,n)=>t.toAffine(e[n])).map(p.fromAffine)}static fromHex(t){const e=p.fromAffine(o(Mn("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return p.BASE.multiply(f(t))}static msm(t,e){return Tr(p,r,t,e)}_setWindowSize(t){w.setWindowSize(this,t)}assertValidity(){d(this)}hasEvenY(){const{y:t}=this.toAffine();if(n.isOdd)return!n.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){l(t);const{px:e,py:r,pz:i}=this,{px:o,py:s,pz:a}=t,u=n.eql(n.mul(e,a),n.mul(o,i)),c=n.eql(n.mul(r,a),n.mul(s,i));return u&&c}negate(){return new p(this.px,n.neg(this.py),this.pz)}double(){const{a:t,b:r}=e,i=n.mul(r,zr),{px:o,py:s,pz:a}=this;let u=n.ZERO,c=n.ZERO,f=n.ZERO,l=n.mul(o,o),h=n.mul(s,s),d=n.mul(a,a),y=n.mul(o,s);return y=n.add(y,y),f=n.mul(o,a),f=n.add(f,f),u=n.mul(t,f),c=n.mul(i,d),c=n.add(u,c),u=n.sub(h,c),c=n.add(h,c),c=n.mul(u,c),u=n.mul(y,u),f=n.mul(i,f),d=n.mul(t,d),y=n.sub(l,d),y=n.mul(t,y),y=n.add(y,f),f=n.add(l,l),l=n.add(f,l),l=n.add(l,d),l=n.mul(l,y),c=n.add(c,l),d=n.mul(s,a),d=n.add(d,d),l=n.mul(d,y),u=n.sub(u,l),f=n.mul(d,h),f=n.add(f,f),f=n.add(f,f),new p(u,c,f)}add(t){l(t);const{px:r,py:i,pz:o}=this,{px:s,py:a,pz:u}=t;let c=n.ZERO,f=n.ZERO,h=n.ZERO;const d=e.a,y=n.mul(e.b,zr);let g=n.mul(r,s),w=n.mul(i,a),b=n.mul(o,u),v=n.add(r,i),m=n.add(s,a);v=n.mul(v,m),m=n.add(g,w),v=n.sub(v,m),m=n.add(r,o);let x=n.add(s,u);return m=n.mul(m,x),x=n.add(g,b),m=n.sub(m,x),x=n.add(i,o),c=n.add(a,u),x=n.mul(x,c),c=n.add(w,b),x=n.sub(x,c),h=n.mul(d,m),c=n.mul(y,b),h=n.add(c,h),c=n.sub(w,h),h=n.add(w,h),f=n.mul(c,h),w=n.add(g,g),w=n.add(w,g),b=n.mul(d,b),m=n.mul(y,m),w=n.add(w,b),b=n.sub(g,b),b=n.mul(d,b),m=n.add(m,b),g=n.mul(w,m),f=n.add(f,g),g=n.mul(x,m),c=n.mul(v,c),c=n.sub(c,g),g=n.mul(v,w),h=n.mul(x,h),h=n.add(h,g),new p(c,f,h)}subtract(t){return this.add(t.negate())}is0(){return this.equals(p.ZERO)}wNAF(t){return w.wNAFCached(this,t,p.normalizeZ)}multiplyUnsafe(t){const{endo:r,n:i}=e;Gn("scalar",t,$r,i);const o=p.ZERO;if(t===$r)return o;if(this.is0()||t===Dr)return this;if(!r||w.hasPrecomputes(this))return w.wNAFCachedUnsafe(this,t,p.normalizeZ);let{k1neg:s,k1:a,k2neg:u,k2:c}=r.splitScalar(t),f=o,l=o,h=this;for(;a>$r||c>$r;)a&Dr&&(f=f.add(h)),c&Dr&&(l=l.add(h)),h=h.double(),a>>=Dr,c>>=Dr;return s&&(f=f.negate()),u&&(l=l.negate()),l=new p(n.mul(l.px,r.beta),l.py,l.pz),f.add(l)}multiply(t){const{endo:r,n:i}=e;let o,s;if(Gn("scalar",t,Dr,i),r){const{k1neg:e,k1:i,k2neg:a,k2:u}=r.splitScalar(t);let{p:c,f}=this.wNAF(i),{p:l,f:h}=this.wNAF(u);c=w.constTimeNegate(e,c),l=w.constTimeNegate(a,l),l=new p(n.mul(l.px,r.beta),l.py,l.pz),o=c.add(l),s=f.add(h)}else{const{p:e,f:n}=this.wNAF(t);o=e,s=n}return p.normalizeZ([o,s])[0]}multiplyAndAddUnsafe(t,e,n){const r=p.BASE,i=(t,e)=>e!==$r&&e!==Dr&&t.equals(r)?t.multiply(e):t.multiplyUnsafe(e),o=i(this,e).add(i(t,n));return o.is0()?void 0:o}toAffine(t){return h(this,t)}isTorsionFree(){const{h:t,isTorsionFree:n}=e;if(t===Dr)return!0;if(n)return n(p,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:n}=e;return t===Dr?this:n?n(p,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return kn("isCompressed",t),this.assertValidity(),i(p,this,t)}toHex(t=!0){return kn("isCompressed",t),Ln(this.toRawBytes(t))}}p.BASE=new p(e.Gx,e.Gy,n.ONE),p.ZERO=new p(n.ZERO,n.ONE,n.ZERO);const{endo:y,nBitLength:g}=e,w=Kr(p,y?Math.ceil(g/2):g);return{CURVE:e,ProjectivePoint:p,normPrivateKeyToScalar:f,weierstrassEquation:s,isWithinCurveOrder:function(t){return Zn(t,Dr,e.n)}}}function Vr(t){const e=function(t){const e=Pr(t);return tr(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:n,n:r,nByteLength:i,nBitLength:o}=e,s=n.BYTES+1,a=2*n.BYTES+1;function u(t){return cr(t,r)}function c(t){return lr(t,r)}const{ProjectivePoint:f,normPrivateKeyToScalar:l,weierstrassEquation:h,isWithinCurveOrder:d}=Mr({...e,toBytes(t,e,r){const i=e.toAffine(),o=n.toBytes(i.x),s=Vn;return kn("isCompressed",r),r?s(Uint8Array.from([e.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,n.toBytes(i.y))},fromBytes(t){const e=t.length,r=t[0],i=t.subarray(1);if(e!==s||2!==r&&3!==r){if(e===a&&4===r){return{x:n.fromBytes(i.subarray(0,n.BYTES)),y:n.fromBytes(i.subarray(n.BYTES,2*n.BYTES))}}throw new Error("invalid Point, expected length of "+s+", or uncompressed "+a+", got "+e)}{const t=$n(i);if(!Zn(t,Dr,n.ORDER))throw new Error("Point is not on curve");const e=h(t);let o;try{o=n.sqrt(e)}catch(t){const e=t instanceof Error?": "+t.message:"";throw new Error("Point is not on curve"+e)}return!(1&~r)!==((o&Dr)===Dr)&&(o=n.neg(o)),{x:t,y:o}}}});function p(t){return t>r>>Dr}const y=(t,e,n)=>$n(t.slice(e,n));class g{constructor(t,e,n){Gn("r",t,Dr,r),Gn("s",e,Dr,r),this.r=t,this.s=e,null!=n&&(this.recovery=n),Object.freeze(this)}static fromCompact(t){const e=i;return t=Mn("compactSignature",t,2*e),new g(y(t,0,e),y(t,e,2*e))}static fromDER(t){const{r:e,s:n}=jr.toSig(Mn("DER",t));return new g(e,n)}assertValidity(){}addRecoveryBit(t){return new g(this.r,this.s,t)}recoverPublicKey(t){const{r,s:i,recovery:o}=this,s=m(Mn("msgHash",t));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const a=2===o||3===o?r+e.n:r;if(a>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const l=1&o?"03":"02",h=f.fromHex(l+Nr(a,n.BYTES)),d=c(a),p=u(-s*d),y=u(i*d),g=f.BASE.multiplyAndAddUnsafe(h,p,y);if(!g)throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,u(-this.s),this.recovery):this}toDERRawBytes(){return Nn(this.toDERHex())}toDERHex(){return jr.hexFromSig(this)}toCompactRawBytes(){return Nn(this.toCompactHex())}toCompactHex(){const t=i;return Nr(this.r,t)+Nr(this.s,t)}}const w={isValidPrivateKey(t){try{return l(t),!0}catch(t){return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const t=Er(e.n);return function(t,e,n=!1){const r=t.length,i=xr(e),o=Er(e);if(r<16||r<o||r>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+r);const s=cr(n?Dn(t):$n(t),e-rr)+rr;return n?qn(s,i):zn(s,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=f.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function b(t){if("bigint"==typeof t)return!1;if(t instanceof f)return!0;const r=Mn("key",t).length,o=n.BYTES,s=o+1,a=2*o+1;return e.allowedPrivateKeyLengths||i===s?void 0:r===s||r===a}const v=e.bits2int||function(t){if(t.length>8192)throw new Error("input is too large");const e=$n(t),n=8*t.length-o;return n>0?e>>BigInt(n):e},m=e.bits2int_modN||function(t){return u(v(t))},x=Yn(o);function E(t){return Gn("num < 2^"+o,t,$r,x),zn(t,i)}function B(t,r,i=_){if(["recovered","canonical"].some(t=>t in i))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:s}=e;let{lowS:a,prehash:h,extraEntropy:y}=i;null==a&&(a=!0),t=Mn("msgHash",t),Fr(i),h&&(t=Mn("prehashed msgHash",o(t)));const w=m(t),b=l(r),x=[E(b),E(w)];if(null!=y&&!1!==y){const t=!0===y?s(n.BYTES):y;x.push(Mn("extraEntropy",t))}const B=Vn(...x),A=w;return{seed:B,k2sig:function(t){const e=v(t);if(!d(e))return;const n=c(e),r=f.BASE.multiply(e).toAffine(),i=u(r.x);if(i===$r)return;const o=u(n*u(A+i*b));if(o===$r)return;let s=(r.x===i?0:2)|Number(r.y&Dr),l=o;return a&&p(o)&&(l=function(t){return p(t)?u(-t):t}(o),s^=1),new g(i,l,s)}}}const _={lowS:e.lowS,prehash:!1},A={lowS:e.lowS,prehash:!1};return f.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return f.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,n=!0){if(!0===b(t))throw new Error("first arg must be private key");if(!1===b(e))throw new Error("second arg must be public key");return f.fromHex(e).multiply(l(t)).toRawBytes(n)},sign:function(t,n,r=_){const{seed:i,k2sig:o}=B(t,n,r),s=e,a=function(t,e,n){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=Xn(t),i=Xn(t),o=0;const s=()=>{r.fill(1),i.fill(0),o=0},a=(...t)=>n(i,r,...t),u=(t=Xn(0))=>{i=a(Jn([0]),t),r=a(),0!==t.length&&(i=a(Jn([1]),t),r=a())},c=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const n=[];for(;t<e;){r=a();const e=r.slice();n.push(e),t+=r.length}return Vn(...n)};return(t,e)=>{let n;for(s(),u(t);!(n=e(c()));)u();return s(),n}}(s.hash.outputLen,s.nByteLength,s.hmac);return a(i,o)},verify:function(t,n,r,i=A){const o=t;n=Mn("msgHash",n),r=Mn("publicKey",r);const{lowS:s,prehash:a,format:l}=i;if(Fr(i),"strict"in i)throw new Error("options.strict was renamed to lowS");if(void 0!==l&&"compact"!==l&&"der"!==l)throw new Error("format must be compact or der");const h="string"==typeof o||An(o),d=!h&&!l&&"object"==typeof o&&null!==o&&"bigint"==typeof o.r&&"bigint"==typeof o.s;if(!h&&!d)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let p,y;try{if(d&&(p=new g(o.r,o.s)),h){try{"compact"!==l&&(p=g.fromDER(o))}catch(t){if(!(t instanceof jr.Err))throw t}p||"der"===l||(p=g.fromCompact(o))}y=f.fromHex(r)}catch(t){return!1}if(!p)return!1;if(s&&p.hasHighS())return!1;a&&(n=e.hash(n));const{r:w,s:b}=p,v=m(n),x=c(b),E=u(v*x),B=u(w*x),_=f.BASE.multiplyAndAddUnsafe(y,E,B)?.toAffine();return!!_&&u(_.x)===w},ProjectivePoint:f,Signature:g,utils:w}}function Wr(t){return{hash:t,hmac:(e,...n)=>En(t,e,function(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];tt(r),e+=r.length}const n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const i=t[e];n.set(i,r),r+=i.length}return n}(...n)),randomBytes:bt}}const Zr=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Gr=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Yr=BigInt(0),Xr=BigInt(1),Jr=BigInt(2),Qr=(t,e)=>(t+e/Jr)/e;function ti(t){const e=Zr,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),u=BigInt(88),c=t*t*t%e,f=c*c*t%e,l=fr(f,n,e)*f%e,h=fr(l,n,e)*f%e,d=fr(h,Jr,e)*c%e,p=fr(d,i,e)*d%e,y=fr(p,o,e)*p%e,g=fr(y,a,e)*y%e,w=fr(g,u,e)*g%e,b=fr(w,a,e)*y%e,v=fr(b,n,e)*f%e,m=fr(v,s,e)*p%e,x=fr(m,r,e)*c%e,E=fr(x,Jr,e);if(!ei.eql(ei.sqr(E),t))throw new Error("Cannot find square root");return E}const ei=mr(Zr,void 0,void 0,{sqrt:ti}),ni=function(t,e){const n=e=>Vr({...t,...Wr(e)});return{...n(e),create:n}}({a:Yr,b:BigInt(7),Fp:ei,n:Gr,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Gr,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Xr*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=n,s=BigInt("0x100000000000000000000000000000000"),a=Qr(o*t,e),u=Qr(-r*t,e);let c=cr(t-a*n-u*i,e),f=cr(-a*r-u*o,e);const l=c>s,h=f>s;if(l&&(c=e-c),h&&(f=e-f),c>s||f>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:c,k2neg:h,k2:f}}}},vn);var ri=n(943);function ii(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function oi(t,...e){if(!ii(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function si(t,e){return!!Array.isArray(e)&&(0===e.length||(t?e.every(t=>"string"==typeof t):e.every(t=>Number.isSafeInteger(t))))}function ai(t){if("function"!=typeof t)throw new Error("function expected");return!0}function ui(t,e){if("string"!=typeof e)throw new Error(`${t}: string expected`);return!0}function ci(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function fi(t){if(!Array.isArray(t))throw new Error("array expected")}function li(t,e){if(!si(!0,e))throw new Error(`${t}: array of strings expected`)}function hi(t,e){if(!si(!1,e))throw new Error(`${t}: array of numbers expected`)}function di(...t){const e=t=>t,n=(t,e)=>n=>t(e(n));return{encode:t.map(t=>t.encode).reduceRight(n,e),decode:t.map(t=>t.decode).reduce(n,e)}}function pi(t){const e="string"==typeof t?t.split(""):t,n=e.length;li("alphabet",e);const r=new Map(e.map((t,e)=>[t,e]));return{encode:r=>(fi(r),r.map(r=>{if(!Number.isSafeInteger(r)||r<0||r>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${r}". Allowed: ${t}`);return e[r]})),decode:e=>(fi(e),e.map(e=>{ui("alphabet.decode",e);const n=r.get(e);if(void 0===n)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return n}))}}function yi(t=""){return ui("join",t),{encode:e=>(li("join.decode",e),e.join(t)),decode:e=>(ui("join.decode",e),e.split(t))}}function gi(t,e="="){return ci(t),ui("padding",e),{encode(n){for(li("padding.encode",n);n.length*t%8;)n.push(e);return n},decode(n){li("padding.decode",n);let r=n.length;if(r*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;r>0&&n[r-1]===e;r--){if((r-1)*t%8==0)throw new Error("padding: invalid, string has too much padding")}return n.slice(0,r)}}}function wi(t){return ai(t),{encode:t=>t,decode:e=>t(e)}}function bi(t,e,n){if(e<2)throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(fi(t),!t.length)return[];let r=0;const i=[],o=Array.from(t,t=>{if(ci(t),t<0||t>=e)throw new Error(`invalid integer: ${t}`);return t}),s=o.length;for(;;){let t=0,a=!0;for(let i=r;i<s;i++){const s=o[i],u=e*t,c=u+s;if(!Number.isSafeInteger(c)||u/e!==t||c-s!==u)throw new Error("convertRadix: carry overflow");const f=c/n;t=c%n;const l=Math.floor(f);if(o[i]=l,!Number.isSafeInteger(l)||l*n+t!==c)throw new Error("convertRadix: carry overflow");a&&(l?a=!1:r=i)}if(i.push(t),a)break}for(let e=0;e<t.length-1&&0===t[e];e++)i.push(0);return i.reverse()}const vi=(t,e)=>0===e?t:vi(e,t%e),mi=(t,e)=>t+(e-vi(t,e)),xi=(()=>{let t=[];for(let e=0;e<40;e++)t.push(2**e);return t})();function Ei(t,e,n,r){if(fi(t),e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(mi(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${mi(e,n)}`);let i=0,o=0;const s=xi[e],a=xi[n]-1,u=[];for(const r of t){if(ci(r),r>=s)throw new Error(`convertRadix2: invalid data word=${r} from=${e}`);if(i=i<<e|r,o+e>32)throw new Error(`convertRadix2: carry overflow pos=${o} from=${e}`);for(o+=e;o>=n;o-=n)u.push((i>>o-n&a)>>>0);const t=xi[o];if(void 0===t)throw new Error("invalid carry");i&=t-1}if(i=i<<n-o&a,!r&&o>=e)throw new Error("Excess padding");if(!r&&i>0)throw new Error(`Non-zero padding: ${i}`);return r&&o>0&&u.push(i>>>0),u}function Bi(t){ci(t);return{encode:e=>{if(!ii(e))throw new Error("radix.encode input should be Uint8Array");return bi(Array.from(e),256,t)},decode:e=>(hi("radix.decode",e),Uint8Array.from(bi(e,t,256)))}}function _i(t,e=!1){if(ci(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(mi(8,t)>32||mi(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!ii(n))throw new Error("radix2.encode input should be Uint8Array");return Ei(Array.from(n),8,t,!e)},decode:n=>(hi("radix2.decode",n),Uint8Array.from(Ei(n,t,8,e)))}}function Ai(t){return ai(t),function(...e){try{return t.apply(null,e)}catch(t){}}}function Ii(t,e){return ci(t),ai(e),{encode(n){if(!ii(n))throw new Error("checksum.encode: input should be Uint8Array");const r=e(n).slice(0,t),i=new Uint8Array(n.length+t);return i.set(n),i.set(r,n.length),i},decode(n){if(!ii(n))throw new Error("checksum.decode: input should be Uint8Array");const r=n.slice(0,-t),i=n.slice(-t),o=e(r).slice(0,t);for(let e=0;e<t;e++)if(o[e]!==i[e])throw new Error("Invalid checksum");return r}}}const ki=di(_i(4),pi("0123456789ABCDEF"),yi("")),Si=di(_i(5),pi("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),gi(5),yi("")),Ui=(di(_i(5),pi("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),yi("")),di(_i(5),pi("0123456789ABCDEFGHIJKLMNOPQRSTUV"),gi(5),yi("")),di(_i(5),pi("0123456789ABCDEFGHIJKLMNOPQRSTUV"),yi("")),di(_i(5),pi("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),yi(""),wi(t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),"function"==typeof Uint8Array.from([]).toBase64&&"function"==typeof Uint8Array.fromBase64),Oi=(t,e)=>{ui("base64",t);const n=e?/^[A-Za-z0-9=_-]+$/:/^[A-Za-z0-9=+/]+$/,r=e?"base64url":"base64";if(t.length>0&&!n.test(t))throw new Error("invalid base64");return Uint8Array.fromBase64(t,{alphabet:r,lastChunkHandling:"strict"})},Ri=Ui?{encode:t=>(oi(t),t.toBase64()),decode:t=>Oi(t,!1)}:di(_i(6),pi("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),gi(6),yi("")),Li=(di(_i(6),pi("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),yi("")),Ui?{encode:t=>(oi(t),t.toBase64({alphabet:"base64url"})),decode:t=>Oi(t,!0)}:di(_i(6),pi("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),gi(6),yi(""))),Ci=(di(_i(6),pi("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),yi("")),t=>di(Bi(58),pi(t),yi(""))),Ki=Ci("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Ti=(Ci("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),Ci("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"),[0,2,3,5,6,7,9,10,11]),Pi={encode(t){let e="";for(let n=0;n<t.length;n+=8){const r=t.subarray(n,n+8);e+=Ki.encode(r).padStart(Ti[r.length],"1")}return e},decode(t){let e=[];for(let n=0;n<t.length;n+=11){const r=t.slice(n,n+11),i=Ti.indexOf(r.length),o=Ki.decode(r);for(let t=0;t<o.length-i;t++)if(0!==o[t])throw new Error("base58xmr: wrong padding");e=e.concat(Array.from(o.slice(o.length-i)))}return Uint8Array.from(e)}},Fi=t=>di(Ii(4,e=>t(t(e))),Ki),Hi=di(pi("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),yi("")),ji=[996825010,642813549,513874426,1027748829,705979059];function Ni(t){const e=t>>25;let n=(33554431&t)<<5;for(let t=0;t<ji.length;t++)1==(e>>t&1)&&(n^=ji[t]);return n}function $i(t,e,n=1){const r=t.length;let i=1;for(let e=0;e<r;e++){const n=t.charCodeAt(e);if(n<33||n>126)throw new Error(`Invalid prefix (${t})`);i=Ni(i)^n>>5}i=Ni(i);for(let e=0;e<r;e++)i=Ni(i)^31&t.charCodeAt(e);for(let t of e)i=Ni(i)^t;for(let t=0;t<6;t++)i=Ni(i);return i^=n,Hi.encode(Ei([i%xi[30]],30,5,!1))}function Di(t){const e="bech32"===t?1:734539939,n=_i(5),r=n.decode,i=n.encode,o=Ai(r);function s(t,n,r=90){ui("bech32.encode prefix",t),ii(n)&&(n=Array.from(n)),hi("bech32.encode",n);const i=t.length;if(0===i)throw new TypeError(`Invalid prefix length ${i}`);const o=i+7+n.length;if(!1!==r&&o>r)throw new TypeError(`Length ${o} exceeds limit ${r}`);const s=t.toLowerCase(),a=$i(s,n,e);return`${s}1${Hi.encode(n)}${a}`}function a(t,n=90){ui("bech32.decode input",t);const r=t.length;if(r<8||!1!==n&&r>n)throw new TypeError(`invalid string length: ${r} (${t}). Expected (8..${n})`);const i=t.toLowerCase();if(t!==i&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const o=i.lastIndexOf("1");if(0===o||-1===o)throw new Error('Letter "1" must be present between prefix and data only');const s=i.slice(0,o),a=i.slice(o+1);if(a.length<6)throw new Error("Data must be at least 6 characters long");const u=Hi.decode(a).slice(0,-6),c=$i(s,u,e);if(!a.endsWith(c))throw new Error(`Invalid checksum in ${t}: expected "${c}"`);return{prefix:s,words:u}}return{encode:s,decode:a,encodeFromBytes:function(t,e){return s(t,i(e))},decodeToBytes:function(t){const{prefix:e,words:n}=a(t,!1);return{prefix:e,words:n,bytes:r(n)}},decodeUnsafe:Ai(a),fromWords:r,fromWordsUnsafe:o,toWords:i}}Di("bech32"),Di("bech32m");const zi={encode:t=>(new TextDecoder).decode(t),decode:t=>(new TextEncoder).encode(t)},qi=("function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex||di(_i(4),pi("0123456789abcdef"),yi(""),wi(t=>{if("string"!=typeof t||t.length%2!=0)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})),BigInt(0)),Mi=BigInt(1),Vi=BigInt(2),Wi=BigInt(8),Zi={zip215:!0};function Gi(t){const e=function(t){const e=Pr(t);return tr(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}(t),{Fp:n,n:r,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:u}=e,c=Vi<<BigInt(8*a)-Mi,f=n.create,l=mr(e.n,e.nBitLength);if(!function(t,r){const i=n.sqr(t),o=n.sqr(r),s=n.add(n.mul(e.a,i),o),a=n.add(n.ONE,n.mul(e.d,n.mul(i,o)));return n.eql(s,a)}(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const h=e.uvRatio||((t,e)=>{try{return{isValid:!0,value:n.sqrt(t*n.inv(e))}}catch(t){return{isValid:!1,value:qi}}}),d=e.adjustScalarBytes||(t=>t),p=e.domain||((t,e,n)=>{if(kn("phflag",n),e.length||n)throw new Error("Contexts/pre-hash are not supported");return t});function y(t,e,n=!1){Gn("coordinate "+t,e,n?Mi:qi,c)}function g(t){if(!(t instanceof v))throw new Error("ExtendedPoint expected")}const w=er((t,e)=>{const{ex:r,ey:i,ez:o}=t,s=t.is0();null==e&&(e=s?Wi:n.inv(o));const a=f(r*e),u=f(i*e),c=f(o*e);if(s)return{x:qi,y:Mi};if(c!==Mi)throw new Error("invZ was invalid");return{x:a,y:u}}),b=er(t=>{const{a:n,d:r}=e;if(t.is0())throw new Error("bad point: ZERO");const{ex:i,ey:o,ez:s,et:a}=t,u=f(i*i),c=f(o*o),l=f(s*s),h=f(l*l),d=f(u*n);if(f(l*f(d+c))!==f(h+f(r*f(u*c))))throw new Error("bad point: equation left != right (1)");if(f(i*o)!==f(s*a))throw new Error("bad point: equation left != right (2)");return!0});class v{constructor(t,e,n,r){y("x",t),y("y",e),y("z",n,!0),y("t",r),this.ex=t,this.ey=e,this.ez=n,this.et=r,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(t){if(t instanceof v)throw new Error("extended point not allowed");const{x:e,y:n}=t||{};return y("x",e),y("y",n),new v(e,n,Mi,f(e*n))}static normalizeZ(t){const e=wr(n,t.map(t=>t.ez));return t.map((t,n)=>t.toAffine(e[n])).map(v.fromAffine)}static msm(t,e){return Tr(v,l,t,e)}_setWindowSize(t){E.setWindowSize(this,t)}assertValidity(){b(this)}equals(t){g(t);const{ex:e,ey:n,ez:r}=this,{ex:i,ey:o,ez:s}=t,a=f(e*s),u=f(i*r),c=f(n*s),l=f(o*r);return a===u&&c===l}is0(){return this.equals(v.ZERO)}negate(){return new v(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){const{a:t}=e,{ex:n,ey:r,ez:i}=this,o=f(n*n),s=f(r*r),a=f(Vi*f(i*i)),u=f(t*o),c=n+r,l=f(f(c*c)-o-s),h=u+s,d=h-a,p=u-s,y=f(l*d),g=f(h*p),w=f(l*p),b=f(d*h);return new v(y,g,b,w)}add(t){g(t);const{a:n,d:r}=e,{ex:i,ey:o,ez:s,et:a}=this,{ex:u,ey:c,ez:l,et:h}=t,d=f(i*u),p=f(o*c),y=f(a*r*h),w=f(s*l),b=f((i+o)*(u+c)-d-p),m=w-y,x=w+y,E=f(p-n*d),B=f(b*m),_=f(x*E),A=f(b*E),I=f(m*x);return new v(B,_,I,A)}subtract(t){return this.add(t.negate())}wNAF(t){return E.wNAFCached(this,t,v.normalizeZ)}multiply(t){const e=t;Gn("scalar",e,Mi,r);const{p:n,f:i}=this.wNAF(e);return v.normalizeZ([n,i])[0]}multiplyUnsafe(t,e=v.ZERO){const n=t;return Gn("scalar",n,qi,r),n===qi?x:this.is0()||n===Mi?this:E.wNAFCachedUnsafe(this,n,v.normalizeZ,e)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return E.unsafeLadder(this,r).is0()}toAffine(t){return w(this,t)}clearCofactor(){const{h:t}=e;return t===Mi?this:this.multiplyUnsafe(t)}static fromHex(t,r=!1){const{d:i,a:o}=e,s=n.BYTES;t=Mn("pointHex",t,s),kn("zip215",r);const a=t.slice(),u=t[s-1];a[s-1]=-129&u;const l=Dn(a),d=r?c:n.ORDER;Gn("pointHex.y",l,qi,d);const p=f(l*l),y=f(p-Mi),g=f(i*p-o);let{isValid:w,value:b}=h(y,g);if(!w)throw new Error("Point.fromHex: invalid y coordinate");const m=(b&Mi)===Mi,x=!!(128&u);if(!r&&b===qi&&x)throw new Error("Point.fromHex: x=0 and x_0=1");return x!==m&&(b=f(-b)),v.fromAffine({x:b,y:l})}static fromPrivateKey(t){const{scalar:e}=A(t);return m.multiply(e)}toRawBytes(){const{x:t,y:e}=this.toAffine(),r=qn(e,n.BYTES);return r[r.length-1]|=t&Mi?128:0,r}toHex(){return Ln(this.toRawBytes())}}v.BASE=new v(e.Gx,e.Gy,Mi,f(e.Gx*e.Gy)),v.ZERO=new v(qi,Mi,Mi,qi);const{BASE:m,ZERO:x}=v,E=Kr(v,8*a);function B(t){return cr(t,r)}function _(t){return B(Dn(t))}function A(t){const e=n.BYTES;t=Mn("private key",t,e);const r=Mn("hashed private key",o(t),2*e),i=d(r.slice(0,e));return{head:i,prefix:r.slice(e,2*e),scalar:_(i)}}function I(t){const{head:e,prefix:n,scalar:r}=A(t),i=m.multiply(r),o=i.toRawBytes();return{head:e,prefix:n,scalar:r,point:i,pointBytes:o}}function k(t=Uint8Array.of(),...e){const n=Vn(...e);return _(o(p(n,Mn("context",t),!!i)))}const S=Zi;m._setWindowSize(8);return{CURVE:e,getPublicKey:function(t){return I(t).pointBytes},sign:function(t,e,o={}){t=Mn("message",t),i&&(t=i(t));const{prefix:s,scalar:a,pointBytes:u}=I(e),c=k(o.context,s,t),f=m.multiply(c).toRawBytes(),l=B(c+k(o.context,f,u,t)*a);return Gn("signature.s",l,qi,r),Mn("result",Vn(f,qn(l,n.BYTES)),2*n.BYTES)},verify:function(t,e,r,o=S){const{context:s,zip215:a}=o,u=n.BYTES;t=Mn("signature",t,2*u),e=Mn("message",e),r=Mn("publicKey",r,u),void 0!==a&&kn("zip215",a),i&&(e=i(e));const c=Dn(t.slice(u,2*u));let f,l,h;try{f=v.fromHex(r,a),l=v.fromHex(t.slice(0,u),a),h=m.multiplyUnsafe(c)}catch(t){return!1}if(!a&&f.isSmallOrder())return!1;const d=k(s,l.toRawBytes(),f.toRawBytes(),e);return l.add(f.multiplyUnsafe(d)).subtract(h).clearCofactor().equals(v.ZERO)},ExtendedPoint:v,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>s(n.BYTES),precompute:(t=8,e=v.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)}}}const Yi=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Xi=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Ji=(BigInt(0),BigInt(1)),Qi=BigInt(2),to=(BigInt(3),BigInt(5)),eo=BigInt(8);function no(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),o=Yi,s=t*t%o*t%o,a=fr(s,Qi,o)*s%o,u=fr(a,Ji,o)*t%o,c=fr(u,to,o)*u%o,f=fr(c,e,o)*c%o,l=fr(f,n,o)*f%o,h=fr(l,r,o)*l%o,d=fr(h,i,o)*h%o,p=fr(d,i,o)*h%o,y=fr(p,e,o)*c%o;return{pow_p_5_8:fr(y,Qi,o)*t%o,b2:s}}function ro(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function io(t,e){const n=Yi,r=cr(e*e*e,n),i=cr(r*r*e,n);let o=cr(t*r*no(t*i).pow_p_5_8,n);const s=cr(e*o*o,n),a=o,u=cr(o*Xi,n),c=s===t,f=s===cr(-t,n),l=s===cr(-t*Xi,n);return c&&(o=a),(f||l)&&(o=u),((t,e)=>(cr(t,e)&rr)===rr)(o,n)&&(o=cr(-o,n)),{isValid:c||f,value:o}}const oo=mr(Yi,void 0,!0),so={a:oo.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:oo,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:eo,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:mn,randomBytes:bt,adjustScalarBytes:ro,uvRatio:io},ao=Gi(so);const uo=ao.CURVE,co="ed25519",fo=tn("ed25519 seed"),lo=t=>!0,ho=!1,po=33,yo=(()=>{let t=!1;return(e,n)=>{t||(ao.ExtendedPoint.BASE._setWindowSize(4),t=!0);const r=ao.getPublicKey(e);return nn([new Uint8Array([0]),r])}})(),go=(t,e)=>{throw new Error("Ed25519 does not support public key derivation.")},wo=t=>t,bo=t=>t,vo=32,mo="slip10",xo=33;const Eo=ao.CURVE,Bo="ed25519Bip32",_o=tn("");function Ao(t,e){const n=t[e];return zt(void 0!==n,"Private key is too short."),n}const Io=t=>!(7&Ao(t,0))&&(!(128&Ao(t,31))&&!(64&~Ao(t,31))),ko=!0,So=32,Uo=t=>{return te(e=Xe(Uint8Array.from(t).reverse())),BigInt(re(e));var e},Oo=t=>{const e=cr(Uo(t),Eo.n);return ao.ExtendedPoint.BASE.multiply(e).toRawBytes()},Ro=(t,e)=>Oo(t.slice(0,32)),Lo=(t,e)=>ao.ExtendedPoint.fromHex(ie(Xe(t))).add(ao.ExtendedPoint.fromHex(ie(Xe(e)))).toRawBytes(),Co=t=>t,Ko=t=>t,To=64,Po="cip3",Fo=32,Ho={secp256k1:u,ed25519:t,ed25519Bip32:e};function jo(t){return Ho[t]}function No(t,e,n,r){et(t);const i=function(t,e){if(void 0!==e&&"[object Object]"!=={}.toString.call(e))throw new Error("options should be object or undefined");return Object.assign(t,e)}({dkLen:32,asyncTick:10},r),{c:o,dkLen:s,asyncTick:a}=i;if(Q(o),Q(s),Q(a),o<1)throw new Error("iterations (c) should be >= 1");const u=yt(e),c=yt(n),f=new Uint8Array(s),l=En.create(t,u),h=l._cloneInto().update(c);return{c:o,dkLen:s,asyncTick:a,DK:f,PRF:l,PRFSalt:h}}function $o(t,e,n,r,i){return t.destroy(),e.destroy(),r&&r.destroy(),it(i),n}const Do=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]);new Uint32Array(80);const zo=Math.pow(2,32);Array.from({length:64},(t,e)=>Math.floor(zo*Math.abs(Math.sin(e+1)))),Do.slice(0,4),new Uint32Array(16);const qo=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Mo=Uint8Array.from(new Array(16).fill(0).map((t,e)=>e)),Vo=Mo.map(t=>(9*t+5)%16),Wo=(()=>{const t=[[Mo],[Vo]];for(let e=0;e<4;e++)for(let n of t)n.push(n[e].map(t=>qo[t]));return t})(),Zo=Wo[0],Go=Wo[1],Yo=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(t=>Uint8Array.from(t)),Xo=Zo.map((t,e)=>t.map(t=>Yo[e][t])),Jo=Go.map((t,e)=>t.map(t=>Yo[e][t])),Qo=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),ts=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function es(t,e,n,r){return 0===t?e^n^r:1===t?e&n|~e&r:2===t?(e|~n)^r:3===t?e&r|n&~r:e^(n|~r)}const ns=new Uint32Array(16);class rs extends an{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:n,h3:r,h4:i}=this;return[t,e,n,r,i]}set(t,e,n,r,i){this.h0=0|t,this.h1=0|e,this.h2=0|n,this.h3=0|r,this.h4=0|i}process(t,e){for(let n=0;n<16;n++,e+=4)ns[n]=t.getUint32(e,!0);let n=0|this.h0,r=n,i=0|this.h1,o=i,s=0|this.h2,a=s,u=0|this.h3,c=u,f=0|this.h4,l=f;for(let t=0;t<5;t++){const e=4-t,h=Qo[t],d=ts[t],p=Zo[t],y=Go[t],g=Xo[t],w=Jo[t];for(let e=0;e<16;e++){const r=at(n+es(t,i,s,u)+ns[p[e]]+h,g[e])+f|0;n=f,f=u,u=0|at(s,10),s=i,i=r}for(let t=0;t<16;t++){const n=at(r+es(e,o,a,c)+ns[y[t]]+d,w[t])+l|0;r=l,l=c,c=0|at(a,10),a=o,o=n}}this.set(this.h1+s+c|0,this.h2+u+l|0,this.h3+f+r|0,this.h4+n+o|0,this.h0+i+a|0)}roundClean(){it(ns)}destroy(){this.destroyed=!0,it(this.buffer),this.set(0,0,0,0,0)}}const is=wt(()=>new rs);const os=vn;const ss=mn;async function as(t,e,n={}){if(n.hmacSha512)return await n.hmacSha512(t,e);if(La()){const n=await crypto.subtle.importKey("raw",t,{name:"HMAC",hash:"SHA-512"},!1,["sign"]),r=await crypto.subtle.sign("HMAC",n,e);return new Uint8Array(r)}return En(ss,t,e)}async function us(t,e,n,r,i={}){if(i.pbkdf2Sha512)return await i.pbkdf2Sha512(t,e,n,r);if(La()){const i=await crypto.subtle.importKey("raw",t,{name:"PBKDF2"},!1,["deriveBits"]),o=await crypto.subtle.deriveBits({name:"PBKDF2",salt:e,iterations:n,hash:{name:"SHA-512"}},i,8*r);return new Uint8Array(o)}return await async function(t,e,n,r){const{c:i,dkLen:o,asyncTick:s,DK:a,PRF:u,PRFSalt:c}=No(t,e,n,r);let f;const l=new Uint8Array(4),h=ot(l),d=new Uint8Array(u.outputLen);for(let t=1,e=0;e<o;t++,e+=u.outputLen){const n=a.subarray(e,e+u.outputLen);h.setInt32(0,t,!1),(f=c._cloneInto(f)).update(l).digestInto(d),n.set(d.subarray(0,n.length)),await ht(i-1,s,()=>{u._cloneInto(f).update(d).digestInto(d);for(let t=0;t<n.length;t++)n[t]^=d[t]})}return $o(u,c,a,f,d)}(ss,t,e,{c:n,dkLen:r})}function cs(t){return os(t)}const fs=Symbol("Public key guard. Do not export this from the module.");async function ls({path:t,node:e,curve:n,network:r},i,o){gs(e);const{childIndex:s,isHardened:a}=ws(t,e,n),u={chainCode:e.chainCodeBytes,childIndex:s,isHardened:a,depth:e.depth,parentFingerprint:e.fingerprint,masterFingerprint:e.masterFingerprint,curve:n,network:r};if(e.privateKeyBytes){const t=await ds({privateKey:e.privateKeyBytes,get publicKey(){return e.compressedPublicKeyBytes},childIndex:s,isHardened:a,curve:n}),r=await ys({chainCode:e.chainCodeBytes,extension:t},o);return await hs({privateKey:e.privateKeyBytes,get publicKey(){return e.publicKeyBytes},entropy:r,...u},i,o)}const c=ps({parentPublicKey:e.compressedPublicKeyBytes,childIndex:s}),f=await ys({chainCode:e.chainCodeBytes,extension:c},o);return await hs({publicKey:e.compressedPublicKeyBytes,entropy:f,...u},i,o)}async function hs(t,e,n){const{privateKey:r,publicKey:i,entropy:o,childIndex:s,isHardened:a,depth:u,parentFingerprint:c,masterFingerprint:f,curve:l,network:h}=t;try{return r?await async function({entropy:t,privateKey:e,depth:n,masterFingerprint:r,parentFingerprint:i,childIndex:o,isHardened:s,curve:a,network:u},c){const f=o+(s?ze:0),{privateKey:l,chainCode:h}=function({privateKey:t,entropy:e,curve:n}){const r=e.slice(0,32),i=e.slice(32);if("ed25519"===n.name)return{privateKey:r,chainCode:i};const o=function(t,e,n){zt(_a(e,32),"Invalid tweak: Tweak must be a non-zero 32-byte Uint8Array.");const r=Je(t),i=Je(e);if(i>=n.curve.n)throw new Error("Invalid tweak: Tweak is larger than the curve order.");const o=cr(r+i,n.curve.n),s=Qe(o.toString(16).padStart(64,"0"));if(!n.isValidPrivateKey(s))throw new Error("Invalid private key or tweak: The resulting private key is invalid.");return s}(t,r,n);return{privateKey:o,chainCode:i}}({privateKey:e,entropy:t,curve:a});return await sa.fromExtendedKey({privateKey:l,chainCode:h,depth:n+1,masterFingerprint:r,parentFingerprint:i,index:f,curve:a.name,network:u,guard:fs},c)}({entropy:o,privateKey:r,depth:u,masterFingerprint:f,parentFingerprint:c,childIndex:s,isHardened:a,curve:l,network:h},n):await async function({entropy:t,publicKey:e,depth:n,masterFingerprint:r,parentFingerprint:i,childIndex:o,curve:s,network:a},u){const{publicKey:c,chainCode:f}=function({publicKey:t,entropy:e,curve:n}){const r=e.slice(0,32),i=e.slice(32),o=n.publicAdd(t,r);return{publicKey:o,chainCode:i}}({publicKey:e,entropy:t,curve:s});return await sa.fromExtendedKey({publicKey:c,chainCode:f,depth:n+1,masterFingerprint:r,parentFingerprint:i,index:o,curve:s.name,network:a},u)}({entropy:o,publicKey:i,depth:u,masterFingerprint:f,parentFingerprint:c,childIndex:s,curve:l,network:h},n)}catch(r){return await hs(await e(r,t,n),e,n)}}async function ds({privateKey:t,publicKey:e,childIndex:n,isHardened:r,curve:i}){return r?nn([new Uint8Array([0]),t,Ra(n+ze)]):(Sa(e,i.compressedPublicKeyLength),ps({parentPublicKey:e,childIndex:n}))}function ps({parentPublicKey:t,childIndex:e}){return nn([t,Ra(e)])}async function ys({chainCode:t,extension:e},n){return await as(t,e,n)}function gs(t){zt(t,"Invalid parameters: Must specify a node to derive from.")}function ws(t,e,n){!function(t,e,n){zt("string"==typeof t,"Invalid path: Must be a string.");const r=t.endsWith("'");zt(!r||e.privateKey,"Invalid parameters: Cannot derive hardened child keys without a private key."),zt(r||n.deriveUnhardenedKeys,`Invalid path: Cannot derive unhardened child keys with ${n.name}.`)}(t,e,n);const r=t.split("'")[0];zt(r);const i=parseInt(r,10);if(!He.test(r)||!Number.isInteger(i)||i<0||i>=ze)throw new Error(`Invalid path: The index must be a non-negative decimal integer less than ${ze}.`);return{childIndex:i,isHardened:t.includes("'")}}function bs(t){zt(t instanceof Uint8Array&&_a(t,Te),"Invalid key: The key must be a 32-byte, non-zero Uint8Array.");return vs(Na(t,!1))}function vs(t){return zt(t instanceof Uint8Array&&_a(t,Ha),"Invalid key: The key must be a 65-byte, non-zero Uint8Array."),(e=t.slice(1),Tt(e)).slice(-20);var e}async function ms(t,e){return zt("secp256k1"===t.curve.name,"Invalid curve: Only secp256k1 is supported by BIP-32."),ls(t,xs,e)}async function xs(t,e,n){const{childIndex:r,privateKey:i,publicKey:o,isHardened:s,chainCode:a,curve:u}=e;if(ma(r+1),i){const t=await ds({privateKey:i,publicKey:u.compressPublicKey(o),childIndex:r+1,isHardened:s,curve:u}),c=await ys({chainCode:a,extension:t},n);return{...e,childIndex:r+1,entropy:c}}const c=ps({parentPublicKey:o,childIndex:r+1}),f=await ys({chainCode:a,extension:c});return{...e,childIndex:r+1,entropy:f}}var Es=n(101);const Bs=[12,15,18,21,24];function _s(t){const e=t.split(" ");zt(Bs.includes(e.length),"Invalid mnemonic phrase: The mnemonic phrase must consist of 12, 15, 18, 21, or 24 words."),zt(e.every(t=>ri.p.includes(t)),"Invalid mnemonic phrase: The mnemonic phrase contains an unknown word.")}async function As(t,e="",n){const r=`mnemonic${e}`.normalize("NFKD");return await us(function(t,e){if("string"==typeof t)return _s(t),tn(t.normalize("NFKD"));const n=Array.from(new Uint16Array(t.buffer)).map(t=>e[t]).join(" ");return _s(n),tn(n)}(t,ri.p),tn(r),2048,64,n)}function Is(t){return`bip39:${t.toLowerCase().trim()}`}function ks(t){return t instanceof Uint8Array?t:(zt(t.startsWith("bip39:"),'Invalid HD path segment: The BIP-39 path must start with "bip39:".'),t.slice(6))}async function Ss({path:t,curve:e},n){const[r,...i]=t,o=ks(r),s=jo(e);switch(s.masterNodeGenerationSpec){case"slip10":return[await As(o,"",n),...i];case"cip3":return[(0,Es.x2)(o,ri.p),...i];default:return Mt()}}async function Us({path:t,curve:e,network:n},r){switch(zt(t instanceof Uint8Array,"Invalid path: The path must be a Uint8Array."),e.masterNodeGenerationSpec){case"slip10":return Os(t,e,n,r);case"cip3":return Rs(t,e,n,r);default:throw new Error("Unsupported master node generation spec.")}}async function Os(t,e,n,r){zt(t.length>=16&&t.length<=64,"Invalid seed: The seed must be between 16 and 64 bytes long.");const i=await as(e.secret,t,r),o=i.slice(0,Te),s=i.slice(Te);zt(e.isValidPrivateKey(o),"Invalid private key: The private key must greater than 0 and less than the curve order.");const a=e.getPublicKey(o,!1),u=Ua(e.compressPublicKey(a),e.compressedPublicKeyLength);return sa.fromExtendedKey({privateKey:o,publicKey:a,chainCode:s,masterFingerprint:u,network:n,depth:0,parentFingerprint:0,index:0,curve:e.name,guard:fs},r)}async function Rs(t,e,n,r){zt(t.length>=16&&t.length<=64,"Invalid entropy: The entropy must be between 16 and 64 bytes long.");const i=await us(e.secret,t,4096,96,r);i[0]&=248,i[31]&=31,i[31]|=64;const o=i.slice(0,e.privateKeyLength),s=i.slice(e.privateKeyLength);zt(e.isValidPrivateKey(o),"Invalid private key.");const a=e.getPublicKey(o,!1),u=Ua(e.compressPublicKey(a),e.compressedPublicKeyLength);return sa.fromExtendedKey({privateKey:o,publicKey:a,chainCode:s,masterFingerprint:u,network:n,depth:0,parentFingerprint:0,index:0,curve:e.name,guard:fs},r)}const Ls=t=>t.slice().reverse(),Cs=t=>{const e=Xe(Ls(t));return BigInt(e)},Ks=t=>{const e=t.toString(16);return Ls(Qe(e))},Ts=t=>nn([t,new Uint8Array(Math.max(32-t.length,0)).fill(0)]),Ps=t=>{const e=Cs(t.slice(0,28))*BigInt(8);return Ts(Ks(e))},Fs=t=>Ts(Ks(cr(Cs(t),BigInt(2)**BigInt(256)))),Hs=(t,e)=>{const n=Cs(t)+Cs(e);return Ts(Ks(n)).slice(0,32)},js=(t,e,n)=>nn([new Uint8Array([t]),e,Ra(n,!0)]),Ns=2,$s=0,Ds=async({parentNode:t,childIndex:e,isHardened:n},r)=>{const i=n?js($s,t.privateKeyBytes,e+ze):js(Ns,t.publicKeyBytes,e),o=await ys({chainCode:t.chainCodeBytes,extension:i},r),s=o.subarray(0,32),a=o.subarray(32),u=t.privateKeyBytes.subarray(0,32),c=t.privateKeyBytes.subarray(32);return nn([Hs(Ps(s),u),Hs(a,c)])},zs=3,qs=1,Ms=async({parentNode:t,childIndex:e,isHardened:n},r)=>{const i=n?js(qs,t.privateKeyBytes,e+ze):js(zs,t.publicKeyBytes,e);return(await ys({chainCode:t.chainCodeBytes,extension:i},r)).subarray(32)},Vs=2,Ws=async({parentNode:t,childIndex:e,curve:n},r)=>{const i=js(Vs,t.publicKeyBytes,e),o=(await ys({chainCode:t.chainCodeBytes,extension:i},r)).slice(0,32),s=n.getPublicKey(Ps(o));return n.publicAdd(t.publicKeyBytes,s)};async function Zs(t,e){const{curve:n,node:r,path:i}=t;gs(r);const{childIndex:o,isHardened:s}=ws(i,r,n);if("ed25519Bip32"!==n.name||!r)throw new Error("Unsupported curve: Only ed25519Bip32 is supported by CIP3.");const a=o+(s?ze:0),{privateKeyBytes:u,chainCodeBytes:c,publicKeyBytes:f,masterFingerprint:l,depth:h,fingerprint:d}=r;if(u){const t={privateKeyBytes:u,chainCodeBytes:c,publicKeyBytes:f},r=await Ds({parentNode:t,childIndex:o,isHardened:s},e),i=await Ms({parentNode:t,childIndex:o,isHardened:s},e);return sa.fromExtendedKey({privateKey:Xe(r),chainCode:Xe(i),masterFingerprint:l,depth:h+1,parentFingerprint:d,index:a,curve:n.name},e)}zt(!s,"Invalid parameters: Cannot derive hardened child keys without a private key.");const p={chainCodeBytes:c,publicKeyBytes:f},y=await Ws({parentNode:p,childIndex:o,isHardened:!1,curve:n},e),g=await Ms({parentNode:p,childIndex:o,isHardened:!1},e);return sa.fromExtendedKey({publicKey:Xe(y),chainCode:Xe(g),masterFingerprint:l,depth:h+1,parentFingerprint:d,index:a,curve:n.name},e)}async function Gs(t,e){return await ls(t,Ys,e)}async function Ys(t,e,n){const{curve:r,isHardened:i,childIndex:o,entropy:s,chainCode:a}=e;if("ed25519"===r.name)throw t;const u=i?o+ze:o,c=await ys({chainCode:a,extension:nn([1,s.slice(32,64),Ra(u)])},n);return{...e,entropy:c}}const Xs={bip32:i,bip39:o,slip10:a,cip3:s};async function Js(t,e){const{path:n,depth:r=n.length}=t,i="node"in t?t.node:void 0,o="network"in t?t.network:i?.network,s="curve"in t?t.curve:i?.curve;if(i&&!(i instanceof sa)&&!(i instanceof nu)&&!(i instanceof ha))throw new Error("Invalid arguments: Node must be a SLIP-10 node or a BIP-44 node when provided.");if(!s)throw new Error("Invalid arguments: Must specify either a parent node or curve.");return function(t,e,n){if(0===t.length)throw new Error("Invalid HD path segment: The segment must not be empty.");let r=!1;if(t.forEach((t,e)=>{if(0===e){if(r=t instanceof Uint8Array||De.test(t),!(t instanceof Uint8Array||r||je.test(t)||Ne.test(t)||$e.test(t)))throw Qs()}else if(t instanceof Uint8Array||!je.test(t)&&!Ne.test(t)&&!$e.test(t))throw Qs()}),0===n&&(!r||1!==t.length))throw new Error(`Invalid HD path segment: The segment must consist of a single BIP-39 node for depths of 0. Received: "${String(t)}".`);if(!e&&!r)throw new Error("Invalid derivation parameters: Must specify parent key if the first node of the path segment is not a BIP-39 node.");if(e&&r)throw new Error("Invalid derivation parameters: May not specify parent key if the path segment starts with a BIP-39 node.");const i=r?t.slice(1):t;if(i.length>0){const t=i[0]?.split(":")[0];zt(t),zt(i.every(e=>e.startsWith(`${t}:`)),"Invalid HD path segment: Cannot mix 'bip32' and 'slip10' path segments.")}}(n,Boolean(i?.privateKey)||Boolean(i?.publicKey),r),await n.reduce(async(t,n,r)=>{const i=await t;if("string"==typeof n){const[t,r]=n.split(":");zt(t),zt(r),zt(function(t){return t in Xs}(t),`Unknown derivation type: "${t}".`);const a=Xs[t];return await a.deriveChildKey({path:r,node:i,curve:jo(s),network:o},e)}return zt(0===r,Qs()),await Xs.bip39.deriveChildKey({path:n,node:i,curve:jo(s),network:o},e)},Promise.resolve(i))}function Qs(){return new Error("Invalid HD path segment: The path segment is malformed.")}var ta,ea,na,ra,ia=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)},oa=function(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n};class sa{static async fromJSON(t,e){return ta.fromExtendedKey(t,e)}static async fromExtendedKey(t,e){if("string"==typeof t){const n=Xa(t),{chainCode:r,depth:i,parentFingerprint:o,index:s}=n;if("private"===n.type){const{privateKey:t}=n;return ta.fromExtendedKey({depth:i,parentFingerprint:o,index:s,privateKey:t,chainCode:r,curve:"secp256k1"},e)}const{publicKey:a}=n;return ta.fromExtendedKey({depth:i,parentFingerprint:o,index:s,publicKey:a,chainCode:r,curve:"secp256k1"},e)}const{depth:n,masterFingerprint:r,parentFingerprint:i,index:o,network:s,privateKey:a,publicKey:u,chainCode:c,curve:f,guard:l}=t,h=Ia(c,Te);Oa(f),aa(n),ma(o),function(t,e){if(0===e&&0!==t)throw new Error(`Invalid index: The index of the root node must be 0. Received: "${String(t)}".`)}(o,n),function(t){if(void 0===t)return;if("string"!=typeof t)throw new Error("Invalid network: Must be a string if specified.");if(!["mainnet","testnet"].includes(t))throw new Error('Invalid network: Must be either "mainnet" or "testnet" if specified.')}(s),function(t,e){if(!Aa(t))throw new Error(`Invalid parent fingerprint: The fingerprint must be a positive integer. Received: "${String(t)}".`);if(0===e&&0!==t)throw new Error(`Invalid parent fingerprint: The fingerprint of the root node must be 0. Received: "${String(t)}".`);if(e>0&&0===t)throw new Error(`Invalid parent fingerprint: The fingerprint of a child node must not be 0. Received: "${String(t)}".`)}(i,n),function(t,e,n){if(!t)return;if(n>=2&&t===e)throw new Error(`Invalid parent fingerprint: The fingerprint of a child node cannot be equal to the master fingerprint. Received: "${String(e)}".`)}(r,i,n);const d=jo(f);if(a){const t=ka(a,d.privateKeyLength);zt(d.isValidPrivateKey(t),`Invalid private key: Value is not a valid ${f} private key.`);const c=l===fs&&u?Ia(u,d.publicKeyLength):void 0;return new ta({depth:n,masterFingerprint:r,parentFingerprint:i,index:o,network:s,chainCode:h,privateKey:t,publicKey:c,curve:f},e,ia(this,ta,"f",ea))}if(u){const t=Ia(u,d.publicKeyLength);return new ta({depth:n,masterFingerprint:r,parentFingerprint:i,index:o,network:s,chainCode:h,publicKey:t,curve:f},e,ia(this,ta,"f",ea))}throw new Error("Invalid options: Must provide either a private key or a public key.")}static async fromDerivationPath({derivationPath:t,network:e,curve:n},r){if(Oa(n),!t)throw new Error("Invalid options: Must provide a derivation path.");if(0===t.length)throw new Error("Invalid derivation path: May not specify an empty derivation path.");const i=await Ss({path:t,curve:n},r);return await Js({path:i,depth:t.length-1,network:e,curve:n},r)}static async fromSeed({derivationPath:t,network:e,curve:n},r){if(Oa(n),"ed25519Bip32"===n)throw new Error('Invalid curve: The curve "ed25519Bip32" is not supported by the `fromSeed` function.');if(!t)throw new Error("Invalid options: Must provide a derivation path.");if(0===t.length)throw new Error("Invalid derivation path: May not specify an empty derivation path.");return await Js({path:t,depth:t.length-1,network:e,curve:n},r)}constructor({depth:t,masterFingerprint:e,parentFingerprint:n,index:r,network:i="mainnet",chainCode:o,privateKey:s,publicKey:a,curve:u},c={},f){na.set(this,void 0),ra.set(this,void 0),zt(f===ia(ta,ta,"f",ea),"SLIP10Node can only be constructed using `SLIP10Node.fromJSON`, `SLIP10Node.fromExtendedKey`, `SLIP10Node.fromDerivationPath`, or `SLIP10Node.fromSeed`."),zt(void 0!==s||void 0!==a,"SLIP10Node requires either a private key or a public key to be set."),this.depth=t,this.masterFingerprint=e,this.parentFingerprint=n,this.index=r,this.network=i,this.chainCodeBytes=o,this.privateKeyBytes=s,this.curve=u,oa(this,na,a,"f"),oa(this,ra,c,"f"),Object.freeze(this)}get chainCode(){return Xe(this.chainCodeBytes)}get privateKey(){if(this.privateKeyBytes)return Xe(this.privateKeyBytes)}get publicKey(){return Xe(this.publicKeyBytes)}get publicKeyBytes(){return void 0!==ia(this,na,"f")||(zt(this.privateKeyBytes,"Either a private key or public key is required."),oa(this,na,jo(this.curve).getPublicKey(this.privateKeyBytes),"f")),ia(this,na,"f")}get compressedPublicKeyBytes(){return jo(this.curve).compressPublicKey(this.publicKeyBytes)}get compressedPublicKey(){return Xe(this.compressedPublicKeyBytes)}get address(){if("secp256k1"!==this.curve)throw new Error("Unable to get address for this node: Only secp256k1 is supported.");return Xe(vs(this.publicKeyBytes))}get fingerprint(){return Ua(this.compressedPublicKeyBytes,jo(this.curve).compressedPublicKeyLength)}get extendedKey(){zt("secp256k1"===this.curve,"Unable to get extended key for this node: Only secp256k1 is supported.");const t={depth:this.depth,parentFingerprint:this.parentFingerprint,index:this.index,network:this.network,chainCode:this.chainCodeBytes};return this.privateKeyBytes?Ja({...t,type:"private",privateKey:this.privateKeyBytes}):Ja({...t,type:"public",publicKey:this.publicKeyBytes})}neuter(){return new ta({depth:this.depth,masterFingerprint:this.masterFingerprint,parentFingerprint:this.parentFingerprint,index:this.index,chainCode:this.chainCodeBytes,publicKey:this.publicKeyBytes,curve:this.curve,network:this.network},ia(this,ra,"f"),ia(ta,ta,"f",ea))}async derive(t){return await ua({path:t,node:this},ia(this,ra,"f"))}toJSON(){return{depth:this.depth,masterFingerprint:this.masterFingerprint,parentFingerprint:this.parentFingerprint,index:this.index,network:this.network,curve:this.curve,privateKey:this.privateKey,publicKey:this.publicKey,chainCode:this.chainCode}}}function aa(t){if(!Aa(t))throw new Error(`Invalid HD tree path depth: The depth must be a positive integer. Received: "${String(t)}".`)}async function ua({path:t,node:e},n){if(0===t.length)throw new Error("Invalid HD tree derivation path: Deriving a path of length 0 is not defined.");const r=e.depth+t.length;return aa(r),await Js({path:t,node:e,depth:r},n)}ta=sa,na=new WeakMap,ra=new WeakMap,ea={value:Symbol("SLIP10Node.constructor")};var ca,fa=function(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n},la=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)};class ha{static async fromJSON(t,e,n){pa(e),da(t.depth);const r=await nu.fromExtendedKey({depth:t.depth,index:t.index,network:t.network,parentFingerprint:t.parentFingerprint,chainCode:Ea(t.chainCode),privateKey:Ba(t.privateKey),publicKey:Ea(t.publicKey)},n);return new ha(r,e)}static async fromDerivationPath(t,e,n){da(t.length-1);const r=await nu.fromDerivationPath({derivationPath:t,network:e},n),i=Ca(t);return new ha(r,i)}static async fromSeed({derivationPath:t,network:e},n){da(t.length-1);const r=await nu.fromSeed({derivationPath:t,network:e},n),i=Ca(t);return new ha(r,i)}static async fromNode(t,e){if(!(t instanceof nu))throw new Error("Invalid node: Expected an instance of BIP44Node.");return pa(e),da(t.depth),Promise.resolve(new ha(t,e))}constructor(t,e){ca.set(this,void 0),fa(this,ca,t,"f"),this.coin_type=e,this.path=function(t){return`m / ${Fe} / ${wa(t)}`}(e),Object.freeze(this)}get depth(){return la(this,ca,"f").depth}get privateKeyBytes(){return la(this,ca,"f").privateKeyBytes}get publicKeyBytes(){return la(this,ca,"f").publicKeyBytes}get chainCodeBytes(){return la(this,ca,"f").chainCodeBytes}get privateKey(){return la(this,ca,"f").privateKey}get publicKey(){return la(this,ca,"f").publicKey}get compressedPublicKey(){return la(this,ca,"f").compressedPublicKey}get compressedPublicKeyBytes(){return la(this,ca,"f").compressedPublicKeyBytes}get chainCode(){return la(this,ca,"f").chainCode}get address(){return la(this,ca,"f").address}get masterFingerprint(){return la(this,ca,"f").masterFingerprint}get parentFingerprint(){return la(this,ca,"f").parentFingerprint}get fingerprint(){return la(this,ca,"f").fingerprint}get index(){return la(this,ca,"f").index}get network(){return la(this,ca,"f").network}get curve(){return la(this,ca,"f").curve}get extendedKey(){return la(this,ca,"f").extendedKey}async deriveBIP44AddressKey({account:t=0,change:e=0,address_index:n}){return await la(this,ca,"f").derive(function({account:t=0,change:e=0,address_index:n}){return[wa(t),va(e),va(n)]}({account:t,change:e,address_index:n}))}toJSON(){return{...la(this,ca,"f").toJSON(),coin_type:this.coin_type,path:this.path}}}function da(t){if(2!==t)throw new Error(`Invalid depth: Coin type nodes must be of depth 2. Received: "${t}"`)}function pa(t){if("number"!=typeof t||!Number.isInteger(t)||t<0)throw new Error("Invalid coin type: The specified coin type must be a non-negative integer number.")}async function ya(t,e,n){const{account:r=0,change:i=0}=e??{},o=await ga(t,n),s=wa(r),a=va(i),u=async(t,e=!1)=>{const r=await ua({path:[s,a,e?wa(t):ba(t)],node:o},n);return new nu(r)};var c;return u.coin_type=o.coin_type,u.path=`${o.path} / ${wa((c={account:r,change:i}).account??0)} / ${va(c.change??0)}`,Object.freeze(u),u}async function ga(t,e){if(t instanceof ha)return da(t.depth),t;if("string"==typeof t){const n=await nu.fromExtendedKey(t,e),r=await ha.fromNode(n,n.index-ze);return da(r.depth),r}return ha.fromJSON(t,t.coin_type,e)}function wa(t){return ma(t),`${ba(t)}'`}function ba(t){return ma(t),`bip32:${t}`}function va(t){if("number"==typeof t)return ba(t);if(!t||!Number.isInteger(t.index)||"boolean"!=typeof t.hardened)throw new Error("Invalid BIP-32 index: Must be an object containing the index and whether it is hardened.");return t.hardened?wa(t.index):ba(t.index)}function ma(t){if(!(Aa(e=t)&&e<=Pe))throw new Error("Invalid BIP-32 index: Must be a non-negative integer.");var e}function xa(t){return t.endsWith("'")}function Ea(t){return t instanceof Uint8Array?t:Qe(t)}function Ba(t){if(void 0!==t)return Ea(t)}function _a(t,e){if(t.length!==e)return!1;for(const e of t)if(0!==e)return!0;return!1}function Aa(t){return"number"==typeof t&&Number.isInteger(t)&&t>=0}function Ia(t,e){if(t instanceof Uint8Array)return Sa(t,e),t;if("string"==typeof t){const n=Qe(t);return Sa(n,e),n}throw new Error("Invalid value: Expected an instance of Uint8Array or hexadecimal string.")}function ka(t,e){if(t instanceof Uint8Array)return zt(t.length===e,`Invalid value: Must be a ${e}-byte byte array.`),t;if("string"==typeof t)return ka(Qe(t),e);throw new Error("Invalid value: Expected an instance of Uint8Array or hexadecimal string.")}function Sa(t,e){if(!_a(t,e))throw new Error(`Invalid value: Must be a non-zero ${e}-byte byte array.`)}ca=new WeakMap;const Ua=(t,e)=>{if(!_a(t,e))throw new Error(`Invalid public key: The key must be a ${e}-byte, non-zero byte array.`);var n;return rn((n=cs(t),is(n))).getUint32(0,!1)};function Oa(t){if(!t||"string"!=typeof t)throw new Error("Invalid curve: Must specify a curve.");if(!Object.keys(Ho).includes(t))throw new Error(`Invalid curve: Only the following curves are supported: ${Object.keys(Ho).join(", ")}.`)}function Ra(t,e=!1){const n=new Uint8Array(4);return rn(n).setUint32(0,t,e),n}function La(){return Boolean(globalThis.crypto?.subtle)}function Ca(t){const e=t[2].split(":")[1]?.replace("'","");zt(e,"Invalid derivation path: Coin type is not specified.");const n=Number.parseInt(e,10);return zt(Aa(n),"Invalid derivation path: Coin type is not a valid integer."),n}const Ka=ni.CURVE,Ta="secp256k1",Pa=tn("Bitcoin seed"),Fa=!0,Ha=65,ja=t=>ni.utils.isValidPrivateKey(t),Na=(()=>{let t=!1;return(e,n=!1)=>(t||(ni.ProjectivePoint.BASE._setWindowSize(4),t=!0),ni.getPublicKey(e,n))})(),$a=(t,e)=>{zt(_a(e,32),"Invalid tweak: Tweak must be a non-zero 32-byte Uint8Array.");const n=ni.ProjectivePoint.fromHex(t).add(ni.ProjectivePoint.fromPrivateKey(e));return n.assertValidity(),n.toRawBytes(!1)},Da=t=>ni.ProjectivePoint.fromHex(t).toRawBytes(!0),za=t=>ni.ProjectivePoint.fromHex(t).toRawBytes(!1),qa=32,Ma="slip10",Va=33,Wa=76067358,Za=76066276,Ga=70617039,Ya=70615956;const Xa=t=>{const e=(t=>{const e=Fi(cs);try{return e.decode(t)}catch{throw new Error("Invalid extended key: Value is not base58-encoded, or the checksum is invalid.")}})(t);if(78!==e.length)throw new Error(`Invalid extended key: Expected a length of 78, got ${e.length}.`);const n=rn(e),r=n.getUint32(0,!1),{network:i,type:o}=function(t){switch(t){case Wa:return{type:"public",network:"mainnet"};case Ga:return{type:"public",network:"testnet"};case Za:return{type:"private",network:"mainnet"};case Ya:return{type:"private",network:"testnet"};default:throw new Error("Invalid extended key: Expected a public (xpub) or private key (xprv) version.")}}(r),s=n.getUint8(4);ru(s);const a=n.getUint32(5,!1),u=n.getUint32(9,!1),c=e.slice(13,45);if(!_a(c,32))throw new Error("Invalid extended key: Chain code must be a 32-byte non-zero byte array.");const f=e.slice(45,78);if(!_a(f,33))throw new Error("Invalid extended key: Key must be a 33-byte non-zero byte array.");const l=rn(f);if("public"===o){if(2!==l.getUint8(0)&&3!==l.getUint8(0))throw new Error("Invalid extended key: Public key must start with 0x02 or 0x03.");return{type:o,depth:s,parentFingerprint:a,index:u,network:i,chainCode:c,publicKey:za(f)}}if(0!==l.getUint8(0))throw new Error("Invalid extended key: Private key must start with 0x00.");return{type:o,depth:s,parentFingerprint:a,index:u,network:i,chainCode:c,privateKey:f.slice(1)}},Ja=t=>{const{type:e,depth:n,parentFingerprint:r,index:i,network:o,chainCode:s}=t,a=new Uint8Array(78),u=rn(a),c=function(t,e){switch(t){case"mainnet":return"public"===e?Wa:Za;case"testnet":return"public"===e?Ga:Ya;default:return Mt()}}(o,e);if(u.setUint32(0,c,!1),u.setUint8(4,n),u.setUint32(5,r,!1),u.setUint32(9,i,!1),a.set(s,13),"public"===e){const{publicKey:e}=t,n=Da(e);a.set(n,45)}if("private"===e){const{privateKey:e}=t;a.set(e,46)}return f=a,Fi(cs).encode(f);var f};var Qa,tu=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)},eu=function(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n};class nu{static async fromJSON(t,e){return nu.fromExtendedKey(t,e)}static async fromExtendedKey(t,e){if("string"==typeof t){const n=Xa(t),{type:r,chainCode:i,depth:o,parentFingerprint:s,index:a,network:u}=n;if("private"===r){const{privateKey:t}=n;return nu.fromExtendedKey({depth:o,parentFingerprint:s,index:a,network:u,privateKey:t,chainCode:i},e)}const{publicKey:c}=n;return nu.fromExtendedKey({depth:o,parentFingerprint:s,index:a,network:u,publicKey:c,chainCode:i},e)}const{privateKey:n,publicKey:r,chainCode:i,depth:o,parentFingerprint:s,index:a,network:u}=t;ru(o);const c=await sa.fromExtendedKey({privateKey:n,publicKey:r,chainCode:i,depth:o,parentFingerprint:s,index:a,network:u,curve:"secp256k1"},e);return new nu(c)}static async fromDerivationPath({derivationPath:t,network:e},n){ru(t.length-1),iu(t,0);const r=await sa.fromDerivationPath({derivationPath:t,network:e,curve:"secp256k1"},n);return new nu(r)}static async fromSeed({derivationPath:t,network:e},n){ru(t.length-1),iu(t,0);const r=await sa.fromSeed({derivationPath:t,network:e,curve:"secp256k1"},n);return new nu(r)}get depth(){return tu(this,Qa,"f").depth}get privateKeyBytes(){return tu(this,Qa,"f").privateKeyBytes}get publicKeyBytes(){return tu(this,Qa,"f").publicKeyBytes}get chainCodeBytes(){return tu(this,Qa,"f").chainCodeBytes}get privateKey(){return tu(this,Qa,"f").privateKey}get publicKey(){return tu(this,Qa,"f").publicKey}get compressedPublicKey(){return tu(this,Qa,"f").compressedPublicKey}get compressedPublicKeyBytes(){return tu(this,Qa,"f").compressedPublicKeyBytes}get chainCode(){return tu(this,Qa,"f").chainCode}get address(){return tu(this,Qa,"f").address}get masterFingerprint(){return tu(this,Qa,"f").masterFingerprint}get parentFingerprint(){return tu(this,Qa,"f").parentFingerprint}get fingerprint(){return tu(this,Qa,"f").fingerprint}get index(){return tu(this,Qa,"f").index}get network(){return tu(this,Qa,"f").network}get extendedKey(){return tu(this,Qa,"f").extendedKey}get curve(){return tu(this,Qa,"f").curve}constructor(t){Qa.set(this,void 0),eu(this,Qa,t,"f"),Object.freeze(this)}neuter(){const t=tu(this,Qa,"f").neuter();return new nu(t)}async derive(t){if(5===this.depth)throw new Error("Illegal operation: This HD tree node is already a leaf node.");ru(this.depth+t.length),iu(t,this.depth+1);const e=await tu(this,Qa,"f").derive(t);return new nu(e)}toJSON(){return{depth:this.depth,masterFingerprint:this.masterFingerprint,parentFingerprint:this.parentFingerprint,index:this.index,network:this.network,privateKey:this.privateKey,publicKey:this.publicKey,chainCode:this.chainCode}}}function ru(t){if(aa(t),t<0||t>5)throw new Error(`Invalid HD tree path depth: The depth must be a positive integer N such that 0 <= N <= 5. Received: "${t}"`)}function iu(t,e){t.forEach((t,n)=>{const r=e+n;if(0!==r)switch(zt("string"==typeof t),r){case 1:if(t!==Fe)throw new Error(`Invalid derivation path: The "purpose" node (depth 1) must be the string "${Fe}".`);break;case 2:if(!je.test(t)||!xa(t))throw new Error('Invalid derivation path: The "coin_type" node (depth 2) must be a hardened BIP-32 node.');break;case 3:if(!je.test(t)||!xa(t))throw new Error('Invalid derivation path: The "account" node (depth 3) must be a hardened BIP-32 node.');break;case 4:if(!je.test(t))throw new Error('Invalid derivation path: The "change" node (depth 4) must be a BIP-32 node.');break;case 5:if(!je.test(t))throw new Error('Invalid derivation path: The "address_index" node (depth 5) must be a BIP-32 node.')}else if(!(t instanceof Uint8Array||De.test(t)))throw new Error('Invalid derivation path: The "m" / seed node (depth 0) must be a BIP-39 node.')})}function ou(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function su(t,e=""){if(!Number.isSafeInteger(t)||t<0){throw new Error(`${e&&`"${e}" `}expected integer >= 0, got ${t}`)}}function au(t,e,n=""){const r=ou(t),i=t?.length,o=void 0!==e;if(!r||o&&i!==e){throw new Error((n&&`"${n}" `)+"expected Uint8Array"+(o?` of length ${e}`:"")+", got "+(r?`length=${i}`:"type="+typeof t))}return t}function uu(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash must wrapped by utils.createHasher");su(t.outputLen),su(t.blockLen)}function cu(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function fu(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function lu(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function hu(t,e){return t<<32-e|t>>>e}Qa=new WeakMap;const du="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,pu=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function yu(t){if(au(t),du)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=pu[t[n]];return e}const gu=48,wu=57,bu=65,vu=70,mu=97,xu=102;function Eu(t){return t>=gu&&t<=wu?t-gu:t>=bu&&t<=vu?t-(bu-10):t>=mu&&t<=xu?t-(mu-10):void 0}function Bu(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);if(du)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let e=0,i=0;e<n;e++,i+=2){const n=Eu(t.charCodeAt(i)),o=Eu(t.charCodeAt(i+1));if(void 0===n||void 0===o){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}r[e]=16*n+o}return r}function _u(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];au(r),e+=r.length}const n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const i=t[e];n.set(i,r),r+=i.length}return n}function Au(t=32){const e="object"==typeof globalThis?globalThis.crypto:null;if("function"!=typeof e?.getRandomValues)throw new Error("crypto.getRandomValues must be defined");return e.getRandomValues(new Uint8Array(t))}function Iu(t,e,n){return t&e^~t&n}function ku(t,e,n){return t&e^t&n^e&n}class Su{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,e,n,r){this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(t),this.view=lu(this.buffer)}update(t){cu(this),au(t);const{view:e,buffer:n,blockLen:r}=this,i=t.length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s===r){const e=lu(t);for(;r<=i-o;o+=r)this.process(e,o);continue}n.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){cu(this),function(t,e){au(t,void 0,"digestInto() output");const n=e.outputLen;if(t.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;e[o++]=128,fu(this.buffer.subarray(o)),this.padOffset>r-o&&(this.process(n,0),o=0);for(let t=o;t<r;t++)e[t]=0;n.setBigUint64(r-8,BigInt(8*this.length),i),this.process(n,0);const s=lu(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)s.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:i,destroyed:o,pos:s}=this;return t.destroyed=o,t.finished=i,t.length=r,t.pos=s,r%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const Uu=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ou=(Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),BigInt(2**32-1)),Ru=BigInt(32);function Lu(t,e=!1){return e?{h:Number(t&Ou),l:Number(t>>Ru&Ou)}:{h:0|Number(t>>Ru&Ou),l:0|Number(t&Ou)}}function Cu(t,e=!1){const n=t.length;let r=new Uint32Array(n),i=new Uint32Array(n);for(let o=0;o<n;o++){const{h:n,l:s}=Lu(t[o],e);[r[o],i[o]]=[n,s]}return[r,i]}const Ku=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Tu=new Uint32Array(64);class Pu extends Su{constructor(t){super(64,t,8,!1)}get(){const{A:t,B:e,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[t,e,n,r,i,o,s,a]}set(t,e,n,r,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let n=0;n<16;n++,e+=4)Tu[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=Tu[t-15],n=Tu[t-2],r=hu(e,7)^hu(e,18)^e>>>3,i=hu(n,17)^hu(n,19)^n>>>10;Tu[t]=i+Tu[t-7]+r+Tu[t-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(hu(s,6)^hu(s,11)^hu(s,25))+Iu(s,a,u)+Ku[t]+Tu[t]|0,f=(hu(n,2)^hu(n,13)^hu(n,22))+ku(n,r,i)|0;c=u,u=a,a=s,s=o+e|0,o=i,i=r,r=n,n=e+f|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(n,r,i,o,s,a,u,c)}roundClean(){fu(Tu)}destroy(){this.set(0,0,0,0,0,0,0,0),fu(this.buffer)}}class Fu extends Pu{A=0|Uu[0];B=0|Uu[1];C=0|Uu[2];D=0|Uu[3];E=0|Uu[4];F=0|Uu[5];G=0|Uu[6];H=0|Uu[7];constructor(){super(32)}}const Hu=Cu(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t)));Hu[0],Hu[1],new Uint32Array(80),new Uint32Array(80);Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);const ju=function(t,e={}){const n=(e,n)=>t(n).update(e).digest(),r=t(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.create=e=>t(e),Object.assign(n,e),Object.freeze(n)}(()=>new Fu,(Nu=1,{oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,Nu])}));var Nu;const $u=BigInt(0),Du=BigInt(1);function zu(t,e=""){if("boolean"!=typeof t){throw new Error((e&&`"${e}" `)+"expected boolean, got type="+typeof t)}return t}function qu(t){if("bigint"==typeof t){if(!Xu(t))throw new Error("positive bigint expected, got "+t)}else su(t);return t}function Mu(t){const e=qu(t).toString(16);return 1&e.length?"0"+e:e}function Vu(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return""===t?$u:BigInt("0x"+t)}function Wu(t){return Vu(yu(t))}function Zu(t){return Vu(yu(function(t){return Uint8Array.from(t)}(au(t)).reverse()))}function Gu(t,e){su(e);const n=Bu((t=qu(t)).toString(16).padStart(2*e,"0"));if(n.length!==e)throw new Error("number too large");return n}function Yu(t,e){return Gu(t,e).reverse()}const Xu=t=>"bigint"==typeof t&&$u<=t;function Ju(t,e,n,r){if(!function(t,e,n){return Xu(t)&&Xu(e)&&Xu(n)&&e<=t&&t<n}(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}const Qu=t=>(Du<<BigInt(t))-Du;function tc(t,e={},n={}){if(!t||"object"!=typeof t)throw new Error("expected valid options object");const r=(e,n)=>Object.entries(e).forEach(([e,r])=>function(e,n,r){const i=t[e];if(r&&void 0===i)return;const o=typeof i;if(o!==n||null===i)throw new Error(`param "${e}" is invalid: expected ${n}, got ${o}`)}(e,r,n));r(e,!1),r(n,!0)}function ec(t){const e=new WeakMap;return(n,...r)=>{const i=e.get(n);if(void 0!==i)return i;const o=t(n,...r);return e.set(n,o),o}}const nc=BigInt(0),rc=BigInt(1),ic=BigInt(2),oc=BigInt(3),sc=BigInt(4),ac=BigInt(5),uc=BigInt(7),cc=BigInt(8),fc=BigInt(9),lc=BigInt(16);function hc(t,e){const n=t%e;return n>=nc?n:e+n}function dc(t,e,n){let r=t;for(;e-- >nc;)r*=r,r%=n;return r}function pc(t,e){if(t===nc)throw new Error("invert: expected non-zero number");if(e<=nc)throw new Error("invert: expected positive modulus, got "+e);let n=hc(t,e),r=e,i=nc,o=rc,s=rc,a=nc;for(;n!==nc;){const t=r/n,e=r%n,u=i-s*t,c=o-a*t;r=n,n=e,i=s,o=a,s=u,a=c}if(r!==rc)throw new Error("invert: does not exist");return hc(i,e)}function yc(t,e,n){if(!t.eql(t.sqr(e),n))throw new Error("Cannot find square root")}function gc(t,e){const n=(t.ORDER+rc)/sc,r=t.pow(e,n);return yc(t,r,e),r}function wc(t,e){const n=(t.ORDER-ac)/cc,r=t.mul(e,ic),i=t.pow(r,n),o=t.mul(e,i),s=t.mul(t.mul(o,ic),i),a=t.mul(o,t.sub(s,t.ONE));return yc(t,a,e),a}function bc(t){if(t<oc)throw new Error("sqrt is not defined for small field");let e=t-rc,n=0;for(;e%ic===nc;)e/=ic,n++;let r=ic;const i=Ac(t);for(;1===Bc(i,r);)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return gc;let o=i.pow(r,e);const s=(e+rc)/ic;return function(t,r){if(t.is0(r))return r;if(1!==Bc(t,r))throw new Error("Cannot find square root");let i=n,a=t.mul(t.ONE,o),u=t.pow(r,e),c=t.pow(r,s);for(;!t.eql(u,t.ONE);){if(t.is0(u))return t.ZERO;let e=1,n=t.sqr(u);for(;!t.eql(n,t.ONE);)if(e++,n=t.sqr(n),e===i)throw new Error("Cannot find square root");const r=rc<<BigInt(i-e-1),o=t.pow(a,r);i=e,a=t.sqr(o),u=t.mul(u,a),c=t.mul(c,o)}return c}}function vc(t){return t%sc===oc?gc:t%cc===ac?wc:t%lc===fc?function(t){const e=Ac(t),n=bc(t),r=n(e,e.neg(e.ONE)),i=n(e,r),o=n(e,e.neg(r)),s=(t+uc)/lc;return(t,e)=>{let n=t.pow(e,s),a=t.mul(n,r);const u=t.mul(n,i),c=t.mul(n,o),f=t.eql(t.sqr(a),e),l=t.eql(t.sqr(u),e);n=t.cmov(n,a,f),a=t.cmov(c,u,l);const h=t.eql(t.sqr(a),e),d=t.cmov(n,a,h);return yc(t,d,e),d}}(t):bc(t)}const mc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function xc(t,e,n){if(n<nc)throw new Error("invalid exponent, negatives unsupported");if(n===nc)return t.ONE;if(n===rc)return e;let r=t.ONE,i=e;for(;n>nc;)n&rc&&(r=t.mul(r,i)),i=t.sqr(i),n>>=rc;return r}function Ec(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),i=e.reduce((e,n,i)=>t.is0(n)?e:(r[i]=e,t.mul(e,n)),t.ONE),o=t.inv(i);return e.reduceRight((e,n,i)=>t.is0(n)?e:(r[i]=t.mul(e,r[i]),t.mul(e,n)),o),r}function Bc(t,e){const n=(t.ORDER-rc)/ic,r=t.pow(e,n),i=t.eql(r,t.ONE),o=t.eql(r,t.ZERO),s=t.eql(r,t.neg(t.ONE));if(!i&&!o&&!s)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}class _c{ORDER;BITS;BYTES;isLE;ZERO=nc;ONE=rc;_lengths;_sqrt;_mod;constructor(t,e={}){if(t<=nc)throw new Error("invalid field: expected ORDER > 0, got "+t);let n;this.isLE=!1,null!=e&&"object"==typeof e&&("number"==typeof e.BITS&&(n=e.BITS),"function"==typeof e.sqrt&&(this.sqrt=e.sqrt),"boolean"==typeof e.isLE&&(this.isLE=e.isLE),e.allowedLengths&&(this._lengths=e.allowedLengths?.slice()),"boolean"==typeof e.modFromBytes&&(this._mod=e.modFromBytes));const{nBitLength:r,nByteLength:i}=function(t,e){void 0!==e&&su(e);const n=void 0!==e?e:t.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}(t,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=r,this.BYTES=i,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return hc(t,this.ORDER)}isValid(t){if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return nc<=t&&t<this.ORDER}is0(t){return t===nc}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&rc)===rc}neg(t){return hc(-t,this.ORDER)}eql(t,e){return t===e}sqr(t){return hc(t*t,this.ORDER)}add(t,e){return hc(t+e,this.ORDER)}sub(t,e){return hc(t-e,this.ORDER)}mul(t,e){return hc(t*e,this.ORDER)}pow(t,e){return xc(this,t,e)}div(t,e){return hc(t*pc(e,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,e){return t+e}subN(t,e){return t-e}mulN(t,e){return t*e}inv(t){return pc(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=vc(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?Yu(t,this.BYTES):Gu(t,this.BYTES)}fromBytes(t,e=!1){au(t);const{_lengths:n,BYTES:r,isLE:i,ORDER:o,_mod:s}=this;if(n){if(!n.includes(t.length)||t.length>r)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);const e=new Uint8Array(r);e.set(t,i?0:e.length-t.length),t=e}if(t.length!==r)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+t.length);let a=i?Zu(t):Wu(t);if(s&&(a=hc(a,o)),!e&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(t){return Ec(this,t)}cmov(t,e,n){return n?e:t}}function Ac(t,e={}){return new _c(t,e)}function Ic(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function kc(t){const e=Ic(t);return e+Math.ceil(e/2)}class Sc{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,e){if(uu(t),au(e,void 0,"key"),this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,r=new Uint8Array(n);r.set(e.length>n?t.create().update(e).digest():e);for(let t=0;t<r.length;t++)r[t]^=54;this.iHash.update(r),this.oHash=t.create();for(let t=0;t<r.length;t++)r[t]^=106;this.oHash.update(r),fu(r)}update(t){return cu(this),this.iHash.update(t),this}digestInto(t){cu(this),au(t,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});const{oHash:e,iHash:n,finished:r,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=r,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Uc=(t,e,n)=>new Sc(t,e).update(n).digest();Uc.create=(t,e)=>new Sc(t,e);const Oc=BigInt(0),Rc=BigInt(1);function Lc(t,e){const n=e.negate();return t?n:e}function Cc(t,e){const n=Ec(t.Fp,e.map(t=>t.Z));return e.map((e,r)=>t.fromAffine(e.toAffine(n[r])))}function Kc(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Tc(t,e){Kc(t,e);const n=2**t;return{windows:Math.ceil(e/t)+1,windowSize:2**(t-1),mask:Qu(t),maxNumber:n,shiftBy:BigInt(t)}}function Pc(t,e,n){const{windowSize:r,mask:i,maxNumber:o,shiftBy:s}=n;let a=Number(t&i),u=t>>s;a>r&&(a-=o,u+=Rc);const c=e*r;return{nextN:u,offset:c+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:e%2!=0,offsetF:c}}const Fc=new WeakMap,Hc=new WeakMap;function jc(t){return Hc.get(t)||1}function Nc(t){if(t!==Oc)throw new Error("invalid wNAF")}class $c{BASE;ZERO;Fn;bits;constructor(t,e){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=e}_unsafeLadder(t,e,n=this.ZERO){let r=t;for(;e>Oc;)e&Rc&&(n=n.add(r)),r=r.double(),e>>=Rc;return n}precomputeWindow(t,e){const{windows:n,windowSize:r}=Tc(e,this.bits),i=[];let o=t,s=o;for(let t=0;t<n;t++){s=o,i.push(s);for(let t=1;t<r;t++)s=s.add(o),i.push(s);o=s.double()}return i}wNAF(t,e,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let r=this.ZERO,i=this.BASE;const o=Tc(t,this.bits);for(let t=0;t<o.windows;t++){const{nextN:s,offset:a,isZero:u,isNeg:c,isNegF:f,offsetF:l}=Pc(n,t,o);n=s,u?i=i.add(Lc(f,e[l])):r=r.add(Lc(c,e[a]))}return Nc(n),{p:r,f:i}}wNAFUnsafe(t,e,n,r=this.ZERO){const i=Tc(t,this.bits);for(let t=0;t<i.windows&&n!==Oc;t++){const{nextN:o,offset:s,isZero:a,isNeg:u}=Pc(n,t,i);if(n=o,!a){const t=e[s];r=r.add(u?t.negate():t)}}return Nc(n),r}getPrecomputes(t,e,n){let r=Fc.get(e);return r||(r=this.precomputeWindow(e,t),1!==t&&("function"==typeof n&&(r=n(r)),Fc.set(e,r))),r}cached(t,e,n){const r=jc(t);return this.wNAF(r,this.getPrecomputes(r,t,n),e)}unsafe(t,e,n,r){const i=jc(t);return 1===i?this._unsafeLadder(t,e,r):this.wNAFUnsafe(i,this.getPrecomputes(i,t,n),e,r)}createCache(t,e){Kc(e,this.bits),Hc.set(t,e),Fc.delete(t)}hasCache(t){return 1!==jc(t)}}function Dc(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(t){const e=mc.reduce((t,e)=>(t[e]="function",t),{ORDER:"bigint",BYTES:"number",BITS:"number"});tc(t,e)}(e),e}return Ac(t,{isLE:n})}const zc=(t,e)=>(t+(t>=0?e:-e)/Xc)/e;function qc(t,e,n){const[[r,i],[o,s]]=e,a=zc(s*t,n),u=zc(-i*t,n);let c=t-a*r-u*o,f=-a*i-u*s;const l=c<Gc,h=f<Gc;l&&(c=-c),h&&(f=-f);const d=Qu(Math.ceil(function(t){let e;for(e=0;t>$u;t>>=Du,e+=1);return e}(n)/2))+Yc;if(c<Gc||c>=d||f<Gc||f>=d)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:l,k1:c,k2neg:h,k2:f}}function Mc(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Vc(t,e){const n={};for(let r of Object.keys(e))n[r]=void 0===t[r]?e[r]:t[r];return zu(n.lowS,"lowS"),zu(n.prehash,"prehash"),void 0!==n.format&&Mc(n.format),n}class Wc extends Error{constructor(t=""){super(t)}}const Zc={Err:Wc,_tlv:{encode:(t,e)=>{const{Err:n}=Zc;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(1&e.length)throw new n("tlv.encode: unpadded data");const r=e.length/2,i=Mu(r);if(i.length/2&128)throw new n("tlv.encode: long form length too big");const o=r>127?Mu(i.length/2|128):"";return Mu(t)+o+i+e},decode(t,e){const{Err:n}=Zc;let r=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");const i=e[r++];let o=0;if(!!(128&i)){const t=127&i;if(!t)throw new n("tlv.decode(long): indefinite length not supported");if(t>4)throw new n("tlv.decode(long): byte length is too big");const s=e.subarray(r,r+t);if(s.length!==t)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(const t of s)o=o<<8|t;if(r+=t,o<128)throw new n("tlv.decode(long): not minimal encoding")}else o=i;const s=e.subarray(r,r+o);if(s.length!==o)throw new n("tlv.decode: wrong value length");return{v:s,l:e.subarray(r+o)}}},_int:{encode(t){const{Err:e}=Zc;if(t<Gc)throw new e("integer: negative integers are not allowed");let n=Mu(t);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:e}=Zc;if(128&t[0])throw new e("invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new e("invalid signature integer: unnecessary leading zero");return Wu(t)}},toSig(t){const{Err:e,_int:n,_tlv:r}=Zc,i=au(t,void 0,"signature"),{v:o,l:s}=r.decode(48,i);if(s.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:u}=r.decode(2,o),{v:c,l:f}=r.decode(2,u);if(f.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(c)}},hexFromSig(t){const{_tlv:e,_int:n}=Zc,r=e.encode(2,n.encode(t.r))+e.encode(2,n.encode(t.s));return e.encode(48,r)}},Gc=BigInt(0),Yc=BigInt(1),Xc=BigInt(2),Jc=BigInt(3),Qc=BigInt(4);function tf(t){return Uint8Array.of(t?2:3)}function ef(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function nf(t,e={}){const{Fn:n}=t,r=e.randomBytes||Au,i=Object.assign(ef(t.Fp,n),{seed:kc(n.ORDER)});function o(t=r(i.seed)){return function(t,e,n=!1){au(t);const r=t.length,i=Ic(e),o=kc(e);if(r<16||r<o||r>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+r);const s=hc(n?Zu(t):Wu(t),e-rc)+rc;return n?Yu(s,i):Gu(s,i)}(au(t,i.seed,"seed"),n.ORDER)}function s(e,r=!0){return t.BASE.multiply(n.fromBytes(e)).toBytes(r)}function a(t){const{secretKey:e,publicKey:r,publicKeyUncompressed:o}=i;if(!ou(t))return;if("_lengths"in n&&n._lengths||e===r)return;const s=au(t,void 0,"key").length;return s===r||s===o}const u={isValidSecretKey:function(t){try{const e=n.fromBytes(t);return n.isValidNot0(e)}catch(t){return!1}},isValidPublicKey:function(e,n){const{publicKey:r,publicKeyUncompressed:o}=i;try{const i=e.length;return(!0!==n||i===r)&&((!1!==n||i===o)&&!!t.fromBytes(e))}catch(t){return!1}},randomSecretKey:o},c=function(t,e){return function(n){const r=t(n);return{secretKey:r,publicKey:e(r)}}}(o,s);return Object.freeze({getPublicKey:s,getSharedSecret:function(e,r,i=!0){if(!0===a(e))throw new Error("first arg must be private key");if(!1===a(r))throw new Error("second arg must be public key");const o=n.fromBytes(e);return t.fromBytes(r).multiply(o).toBytes(i)},keygen:c,Point:t,utils:u,lengths:i})}const rf={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},of={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},sf=BigInt(2);const af=Ac(rf.p,{sqrt:function(t){const e=rf.p,n=BigInt(3),r=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),u=BigInt(88),c=t*t*t%e,f=c*c*t%e,l=dc(f,n,e)*f%e,h=dc(l,n,e)*f%e,d=dc(h,sf,e)*c%e,p=dc(d,i,e)*d%e,y=dc(p,o,e)*p%e,g=dc(y,a,e)*y%e,w=dc(g,u,e)*g%e,b=dc(w,a,e)*y%e,v=dc(b,n,e)*f%e,m=dc(v,s,e)*p%e,x=dc(m,r,e)*c%e,E=dc(x,sf,e);if(!af.eql(af.sqr(E),t))throw new Error("Cannot find square root");return E}}),uf=function(t,e={}){const n=function(t,e,n={},r){if(void 0===r&&(r="edwards"===t),!e||"object"!=typeof e)throw new Error(`expected valid ${t} CURVE object`);for(const t of["p","n","h"]){const n=e[t];if(!("bigint"==typeof n&&n>Oc))throw new Error(`CURVE.${t} must be positive bigint`)}const i=Dc(e.p,n.Fp,r),o=Dc(e.n,n.Fn,r),s=["Gx","Gy","a","weierstrass"===t?"b":"d"];for(const t of s)if(!i.isValid(e[t]))throw new Error(`CURVE.${t} must be valid field element of CURVE.Fp`);return{CURVE:e=Object.freeze(Object.assign({},e)),Fp:i,Fn:o}}("weierstrass",t,e),{Fp:r,Fn:i}=n;let o=n.CURVE;const{h:s,n:a}=o;tc(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});const{endo:u}=e;if(u&&(!r.is0(o.a)||"bigint"!=typeof u.beta||!Array.isArray(u.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const c=ef(r,i);function f(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const l=e.toBytes||function(t,e,n){const{x:i,y:o}=e.toAffine(),s=r.toBytes(i);if(zu(n,"isCompressed"),n){f();return _u(tf(!r.isOdd(o)),s)}return _u(Uint8Array.of(4),s,r.toBytes(o))},h=e.fromBytes||function(t){au(t,void 0,"Point");const{publicKey:e,publicKeyUncompressed:n}=c,i=t.length,o=t[0],s=t.subarray(1);if(i!==e||2!==o&&3!==o){if(i===n&&4===o){const t=r.BYTES,e=r.fromBytes(s.subarray(0,t)),n=r.fromBytes(s.subarray(t,2*t));if(!p(e,n))throw new Error("bad point: is not on curve");return{x:e,y:n}}throw new Error(`bad point: got length ${i}, expected compressed=${e} or uncompressed=${n}`)}{const t=r.fromBytes(s);if(!r.isValid(t))throw new Error("bad point: is not on curve, wrong x");const e=d(t);let n;try{n=r.sqrt(e)}catch(t){const e=t instanceof Error?": "+t.message:"";throw new Error("bad point: is not on curve, sqrt error"+e)}f();return!(1&~o)!==r.isOdd(n)&&(n=r.neg(n)),{x:t,y:n}}};function d(t){const e=r.sqr(t),n=r.mul(e,t);return r.add(r.add(n,r.mul(t,o.a)),o.b)}function p(t,e){const n=r.sqr(e),i=d(t);return r.eql(n,i)}if(!p(o.Gx,o.Gy))throw new Error("bad curve params: generator point");const y=r.mul(r.pow(o.a,Jc),Qc),g=r.mul(r.sqr(o.b),BigInt(27));if(r.is0(r.add(y,g)))throw new Error("bad curve params: a or b");function w(t,e,n=!1){if(!r.isValid(e)||n&&r.is0(e))throw new Error(`bad point coordinate ${t}`);return e}function b(t){if(!(t instanceof B))throw new Error("Weierstrass Point expected")}function v(t){if(!u||!u.basises)throw new Error("no endo");return qc(t,u.basises,i.ORDER)}const m=ec((t,e)=>{const{X:n,Y:i,Z:o}=t;if(r.eql(o,r.ONE))return{x:n,y:i};const s=t.is0();null==e&&(e=s?r.ONE:r.inv(o));const a=r.mul(n,e),u=r.mul(i,e),c=r.mul(o,e);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(c,r.ONE))throw new Error("invZ was invalid");return{x:a,y:u}}),x=ec(t=>{if(t.is0()){if(e.allowInfinityPoint&&!r.is0(t.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:i}=t.toAffine();if(!r.isValid(n)||!r.isValid(i))throw new Error("bad point: x or y not field elements");if(!p(n,i))throw new Error("bad point: equation left != right");if(!t.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function E(t,e,n,i,o){return n=new B(r.mul(n.X,t),n.Y,n.Z),e=Lc(i,e),n=Lc(o,n),e.add(n)}class B{static BASE=new B(o.Gx,o.Gy,r.ONE);static ZERO=new B(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=i;X;Y;Z;constructor(t,e,n){this.X=w("x",t),this.Y=w("y",e,!0),this.Z=w("z",n),Object.freeze(this)}static CURVE(){return o}static fromAffine(t){const{x:e,y:n}=t||{};if(!t||!r.isValid(e)||!r.isValid(n))throw new Error("invalid affine point");if(t instanceof B)throw new Error("projective point not allowed");return r.is0(e)&&r.is0(n)?B.ZERO:new B(e,n,r.ONE)}static fromBytes(t){const e=B.fromAffine(h(au(t,void 0,"point")));return e.assertValidity(),e}static fromHex(t){return B.fromBytes(Bu(t))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(t=8,e=!0){return A.createCache(this,t),e||this.multiply(Jc),this}assertValidity(){x(this)}hasEvenY(){const{y:t}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(t)}equals(t){b(t);const{X:e,Y:n,Z:i}=this,{X:o,Y:s,Z:a}=t,u=r.eql(r.mul(e,a),r.mul(o,i)),c=r.eql(r.mul(n,a),r.mul(s,i));return u&&c}negate(){return new B(this.X,r.neg(this.Y),this.Z)}double(){const{a:t,b:e}=o,n=r.mul(e,Jc),{X:i,Y:s,Z:a}=this;let u=r.ZERO,c=r.ZERO,f=r.ZERO,l=r.mul(i,i),h=r.mul(s,s),d=r.mul(a,a),p=r.mul(i,s);return p=r.add(p,p),f=r.mul(i,a),f=r.add(f,f),u=r.mul(t,f),c=r.mul(n,d),c=r.add(u,c),u=r.sub(h,c),c=r.add(h,c),c=r.mul(u,c),u=r.mul(p,u),f=r.mul(n,f),d=r.mul(t,d),p=r.sub(l,d),p=r.mul(t,p),p=r.add(p,f),f=r.add(l,l),l=r.add(f,l),l=r.add(l,d),l=r.mul(l,p),c=r.add(c,l),d=r.mul(s,a),d=r.add(d,d),l=r.mul(d,p),u=r.sub(u,l),f=r.mul(d,h),f=r.add(f,f),f=r.add(f,f),new B(u,c,f)}add(t){b(t);const{X:e,Y:n,Z:i}=this,{X:s,Y:a,Z:u}=t;let c=r.ZERO,f=r.ZERO,l=r.ZERO;const h=o.a,d=r.mul(o.b,Jc);let p=r.mul(e,s),y=r.mul(n,a),g=r.mul(i,u),w=r.add(e,n),v=r.add(s,a);w=r.mul(w,v),v=r.add(p,y),w=r.sub(w,v),v=r.add(e,i);let m=r.add(s,u);return v=r.mul(v,m),m=r.add(p,g),v=r.sub(v,m),m=r.add(n,i),c=r.add(a,u),m=r.mul(m,c),c=r.add(y,g),m=r.sub(m,c),l=r.mul(h,v),c=r.mul(d,g),l=r.add(c,l),c=r.sub(y,l),l=r.add(y,l),f=r.mul(c,l),y=r.add(p,p),y=r.add(y,p),g=r.mul(h,g),v=r.mul(d,v),y=r.add(y,g),g=r.sub(p,g),g=r.mul(h,g),v=r.add(v,g),p=r.mul(y,v),f=r.add(f,p),p=r.mul(m,v),c=r.mul(w,c),c=r.sub(c,p),p=r.mul(w,y),l=r.mul(m,l),l=r.add(l,p),new B(c,f,l)}subtract(t){return this.add(t.negate())}is0(){return this.equals(B.ZERO)}multiply(t){const{endo:n}=e;if(!i.isValidNot0(t))throw new Error("invalid scalar: out of range");let r,o;const s=t=>A.cached(this,t,t=>Cc(B,t));if(n){const{k1neg:e,k1:i,k2neg:a,k2:u}=v(t),{p:c,f}=s(i),{p:l,f:h}=s(u);o=f.add(h),r=E(n.beta,c,l,e,a)}else{const{p:e,f:n}=s(t);r=e,o=n}return Cc(B,[r,o])[0]}multiplyUnsafe(t){const{endo:n}=e,r=this;if(!i.isValid(t))throw new Error("invalid scalar: out of range");if(t===Gc||r.is0())return B.ZERO;if(t===Yc)return r;if(A.hasCache(this))return this.multiply(t);if(n){const{k1neg:e,k1:i,k2neg:o,k2:s}=v(t),{p1:a,p2:u}=function(t,e,n,r){let i=e,o=t.ZERO,s=t.ZERO;for(;n>Oc||r>Oc;)n&Rc&&(o=o.add(i)),r&Rc&&(s=s.add(i)),i=i.double(),n>>=Rc,r>>=Rc;return{p1:o,p2:s}}(B,r,i,s);return E(n.beta,a,u,e,o)}return A.unsafe(r,t)}toAffine(t){return m(this,t)}isTorsionFree(){const{isTorsionFree:t}=e;return s===Yc||(t?t(B,this):A.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:t}=e;return s===Yc?this:t?t(B,this):this.multiplyUnsafe(s)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}toBytes(t=!0){return zu(t,"isCompressed"),this.assertValidity(),l(B,this,t)}toHex(t=!0){return yu(this.toBytes(t))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const _=i.BITS,A=new $c(B,e.endo?Math.ceil(_/2):_);return B.BASE.precompute(8),B}(rf,{Fp:af,endo:of}),cf=function(t,e,n={}){uu(e),tc(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=(n=Object.assign({},n)).randomBytes||Au,i=n.hmac||((t,n)=>Uc(e,t,n)),{Fp:o,Fn:s}=t,{ORDER:a,BITS:u}=s,{keygen:c,getPublicKey:f,getSharedSecret:l,utils:h,lengths:d}=nf(t,n),p={prehash:!0,lowS:"boolean"!=typeof n.lowS||n.lowS,format:"compact",extraEntropy:!1},y=a*Xc<o.ORDER;function g(t){return t>a>>Yc}function w(t,e){if(!s.isValidNot0(e))throw new Error(`invalid signature ${t}: out of range 1..Point.Fn.ORDER`);return e}function b(){if(y)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function v(t,e){Mc(e);const n=d.signature;return au(t,"compact"===e?n:"recovered"===e?n+1:void 0)}class m{r;s;recovery;constructor(t,e,n){if(this.r=w("r",t),this.s=w("s",e),null!=n){if(b(),![0,1,2,3].includes(n))throw new Error("invalid recovery id");this.recovery=n}Object.freeze(this)}static fromBytes(t,e=p.format){let n;if(v(t,e),"der"===e){const{r:e,s:n}=Zc.toSig(au(t));return new m(e,n)}"recovered"===e&&(n=t[0],e="compact",t=t.subarray(1));const r=d.signature/2,i=t.subarray(0,r),o=t.subarray(r,2*r);return new m(s.fromBytes(i),s.fromBytes(o),n)}static fromHex(t,e){return this.fromBytes(Bu(t),e)}assertRecovery(){const{recovery:t}=this;if(null==t)throw new Error("invalid recovery id: must be present");return t}addRecoveryBit(t){return new m(this.r,this.s,t)}recoverPublicKey(e){const{r:n,s:r}=this,i=this.assertRecovery(),u=2===i||3===i?n+a:n;if(!o.isValid(u))throw new Error("invalid recovery id: sig.r+curve.n != R.x");const c=o.toBytes(u),f=t.fromBytes(_u(tf(!(1&i)),c)),l=s.inv(u),h=E(au(e,void 0,"msgHash")),d=s.create(-h*l),p=s.create(r*l),y=t.BASE.multiplyUnsafe(d).add(f.multiplyUnsafe(p));if(y.is0())throw new Error("invalid recovery: point at infinify");return y.assertValidity(),y}hasHighS(){return g(this.s)}toBytes(t=p.format){if(Mc(t),"der"===t)return Bu(Zc.hexFromSig(this));const{r:e,s:n}=this,r=s.toBytes(e),i=s.toBytes(n);return"recovered"===t?(b(),_u(Uint8Array.of(this.assertRecovery()),r,i)):_u(r,i)}toHex(t){return yu(this.toBytes(t))}}const x=n.bits2int||function(t){if(t.length>8192)throw new Error("input is too large");const e=Wu(t),n=8*t.length-u;return n>0?e>>BigInt(n):e},E=n.bits2int_modN||function(t){return s.create(x(t))},B=Qu(u);function _(t){return Ju("num < 2^"+u,t,Gc,B),s.toBytes(t)}function A(t,n){return au(t,void 0,"message"),n?au(e(t),void 0,"prehashed message"):t}return Object.freeze({keygen:c,getPublicKey:f,getSharedSecret:l,utils:h,lengths:d,Point:t,sign:function(n,o,a={}){const{seed:u,k2sig:c}=function(e,n,i){const{lowS:o,prehash:a,extraEntropy:u}=Vc(i,p);e=A(e,a);const c=E(e),f=s.fromBytes(n);if(!s.isValidNot0(f))throw new Error("invalid private key");const l=[_(f),_(c)];if(null!=u&&!1!==u){const t=!0===u?r(d.secretKey):u;l.push(au(t,void 0,"extraEntropy"))}const h=_u(...l),w=c;return{seed:h,k2sig:function(e){const n=x(e);if(!s.isValidNot0(n))return;const r=s.inv(n),i=t.BASE.multiply(n).toAffine(),a=s.create(i.x);if(a===Gc)return;const u=s.create(r*s.create(w+a*f));if(u===Gc)return;let c=(i.x===a?0:2)|Number(i.y&Yc),l=u;return o&&g(u)&&(l=s.neg(u),c^=1),new m(a,l,y?void 0:c)}}}(n,o,a),f=function(t,e,n){if(su(t,"hashLen"),su(e,"qByteLen"),"function"!=typeof n)throw new Error("hmacFn must be a function");const r=t=>new Uint8Array(t),i=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1);let a=r(t),u=r(t),c=0;const f=()=>{a.fill(1),u.fill(0),c=0},l=(...t)=>n(u,_u(a,...t)),h=(t=i)=>{u=l(o,t),a=l(),0!==t.length&&(u=l(s,t),a=l())},d=()=>{if(c++>=1e3)throw new Error("drbg: tried max amount of iterations");let t=0;const n=[];for(;t<e;){a=l();const e=a.slice();n.push(e),t+=a.length}return _u(...n)};return(t,e)=>{let n;for(f(),h(t);!(n=e(d()));)h();return f(),n}}(e.outputLen,s.BYTES,i);return f(u,c).toBytes(a.format)},verify:function(e,n,r,i={}){const{lowS:o,prehash:a,format:u}=Vc(i,p);if(r=au(r,void 0,"publicKey"),n=A(n,a),!ou(e)){throw new Error("verify expects Uint8Array signature"+(e instanceof m?", use sig.toBytes()":""))}v(e,u);try{const i=m.fromBytes(e,u),a=t.fromBytes(r);if(o&&i.hasHighS())return!1;const{r:c,s:f}=i,l=E(n),h=s.inv(f),d=s.create(l*h),p=s.create(c*h),y=t.BASE.multiplyUnsafe(d).add(a.multiplyUnsafe(p));if(y.is0())return!1;return s.create(y.x)===c}catch(t){return!1}},recoverPublicKey:function(t,e,n={}){const{prehash:r}=Vc(n,p);return e=A(e,r),m.fromBytes(t,"recovered").recoverPublicKey(e).toBytes()},Signature:m,hash:e})}(uf,ju);function ff(t){return`0x${Array.from(t,t=>t.toString(16).padStart(2,"0")).join("")}`}function lf(t,e=10,n=8){return t.length<=e+n+1?t:`${t.slice(0,e)}…${t.slice(-n)}`}function hf(t){if("string"!=typeof t)throw new Error("account must be a 0x-prefixed hex address string");const e=t.trim();if(!/^0x[0-9a-fA-F]{40}$/.test(e))throw new Error("account must be a 20-byte hex address");return e}async function df(t){if(!await snap.request({method:"snap_dialog",params:{type:"confirmation",content:Ce([Be(t.title),Ie(`Origin: ${t.origin}`),we(),...t.body.map(t=>Ie(t))])}}))throw new Error("User rejected request.")}let pf=null;const yf=new Map;async function gf(t){const e=t.toLowerCase(),n=await async function(){return pf||(pf=(async()=>{const t=await snap.request({method:"snap_getBip44Entropy",params:{coinType:60}});return await ya(t,{account:0,change:0})})()),pf}(),r=yf.get(e);if(void 0!==r){const t=await n(r);if(t.address.toLowerCase()===e){const e=t.privateKeyBytes;if(!e)throw new Error("private key unavailable for derived account");return e}yf.delete(e)}for(let t=0;t<100;t++){const r=await n(t);if(r.address.toLowerCase()===e){const n=r.privateKeyBytes;if(!n)throw new Error("private key unavailable for derived account");return yf.set(e,t),n}}throw new Error("Account not found among the first 100 MetaMask HD accounts. Imported accounts and hardware wallets are not supported.")}const wf=async({origin:t,request:e})=>{const n=e;switch(n.method){case"erc5630_getInfo":case"eip5630_getInfo":return{name:"ERC-5630 ECDH Snap",methods:["eth_getEncryptionPublicKey","eth_performECDH"],notes:["This snap implements ERC-5630-style methods via wallet_invokeSnap, not as top-level wallet RPC methods.","It uses snap_getBip44Entropy (coinType 60) to derive the secp256k1 key for MetaMask HD accounts.","Imported accounts and hardware wallets are not supported."]};case"eth_getEncryptionPublicKey":{const{account:e}=function(t){if(!t)throw new Error("Missing params. Expected [account].");if(Array.isArray(t)){const[e]=t;return{account:hf(e)}}if("object"==typeof t&&null!==t)return{account:hf(t.account)};throw new Error("Invalid params. Expected [account] or { account }.")}(n.params);await df({origin:t,title:"ERC-5630: Share encryption public key?",body:[`Account: ${e}`,"This will share a compressed secp256k1 public key for the selected account.","The snap will derive this from your MetaMask HD seed (BIP-44 coinType 60).","Only approve if you trust this site."]});const r=await gf(e);return ff(cf.getPublicKey(r,!0))}case"eth_performECDH":{const{account:e,ephemeralKey:r}=function(t){if(!t)throw new Error("Missing params. Expected [account, ephemeralKey].");if(Array.isArray(t)){const[e,n]=t;if("string"!=typeof n)throw new Error("ephemeralKey must be a 0x-prefixed hex string");return{account:hf(e),ephemeralKey:n.trim()}}if("object"==typeof t&&null!==t){const e=t;if("string"!=typeof e.ephemeralKey)throw new Error("ephemeralKey must be a 0x-prefixed hex string");return{account:hf(e.account),ephemeralKey:e.ephemeralKey.trim()}}throw new Error("Invalid params. Expected [account, ephemeralKey] or { account, ephemeralKey }.")}(n.params);await df({origin:t,title:"ERC-5630: Perform ECDH?",body:[`Account: ${e}`,"This will return key material (the ECDH shared secret x-coordinate) for the selected account.","The snap will derive the account key from your MetaMask HD seed (BIP-44 coinType 60).","Only approve if you trust this site.",`Ephemeral key: ${lf(r)}`]});const i=function(t){if("string"!=typeof t||!t.startsWith("0x"))throw new Error("hex must start with 0x");const e=t.slice(2);if(e.length%2!=0)throw new Error("hex must have an even length");const n=new Uint8Array(e.length/2);for(let t=0;t<n.length;t++){const r=Number.parseInt(e.slice(2*t,2*t+2),16);if(!Number.isFinite(r))throw new Error("invalid hex");n[t]=r}return n}(r);if(!cf.utils.isValidPublicKey(i,!0))throw new Error("Invalid compressed secp256k1 pubkey.");const o=await gf(e);return ff(cf.getSharedSecret(o,i,!0).slice(1))}default:throw new Error("Method not found.")}}})(),module.exports=r})();
@@ -0,0 +1,14 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
2
+ <defs>
3
+ <linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
4
+ <stop offset="0" stop-color="#8ab4ff"/>
5
+ <stop offset="1" stop-color="#6ee7b7"/>
6
+ </linearGradient>
7
+ </defs>
8
+ <rect x="8" y="8" width="112" height="112" rx="28" fill="url(#g)"/>
9
+ <rect x="16" y="16" width="96" height="96" rx="24" fill="rgba(11,15,23,0.78)"/>
10
+ <path d="M64 26c18.7 0 34 15.3 34 34 0 18.7-15.3 34-34 34S30 78.7 30 60c0-18.7 15.3-34 34-34Z" fill="rgba(255,255,255,0.10)"/>
11
+ <path d="M64 44c7.7 0 14 6.3 14 14s-6.3 14-14 14-14-6.3-14-14 6.3-14 14-14Z" fill="rgba(255,255,255,0.18)"/>
12
+ <text x="64" y="104" text-anchor="middle" font-family="ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace" font-size="22" font-weight="700" fill="#e7eaf0">DDRP</text>
13
+ </svg>
14
+
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "erc5630-snap",
3
+ "version": "0.1.2",
4
+ "description": "ERC-5630-style wallet ECDH helpers for MetaMask Snaps (eth_getEncryptionPublicKey + eth_performECDH).",
5
+ "type": "module",
6
+ "license": "UNLICENSED",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/pierce403/ddrp",
10
+ "directory": "snaps/ddrp-snap"
11
+ },
12
+ "homepage": "https://ddrp.io/#/snap",
13
+ "bugs": {
14
+ "url": "https://github.com/pierce403/ddrp/issues"
15
+ },
16
+ "keywords": [
17
+ "metamask",
18
+ "snaps",
19
+ "eip-5630",
20
+ "erc-5630",
21
+ "ecdh",
22
+ "secp256k1"
23
+ ],
24
+ "scripts": {
25
+ "build": "mm-snap build",
26
+ "serve": "mm-snap serve --port 8081",
27
+ "watch": "mm-snap watch --port 8081"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "images",
32
+ "snap.manifest.json",
33
+ "README.md",
34
+ "src"
35
+ ],
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "dependencies": {
40
+ "@metamask/snaps-sdk": "^6.0.0",
41
+ "@metamask/key-tree": "^10.1.1",
42
+ "@noble/curves": "^2.0.1",
43
+ "@noble/hashes": "^2.0.1"
44
+ },
45
+ "devDependencies": {
46
+ "@metamask/snaps-cli": "^6.0.0",
47
+ "prettier": "^3.8.1",
48
+ "typescript": "~5.9.3"
49
+ }
50
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "version": "0.1.2",
3
+ "description": "ERC-5630-style encryption/decryption helpers: eth_getEncryptionPublicKey + eth_performECDH.",
4
+ "proposedName": "ERC-5630 ECDH",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/pierce403/ddrp",
8
+ "directory": "snaps/ddrp-snap"
9
+ },
10
+ "source": {
11
+ "shasum": "quv3nKx5E91xfySW3Wa45Q4hxuRasx6mAnopbhay78k=",
12
+ "location": {
13
+ "npm": {
14
+ "filePath": "dist/bundle.js",
15
+ "iconPath": "images/icon.svg",
16
+ "packageName": "erc5630-snap",
17
+ "registry": "https://registry.npmjs.org/"
18
+ }
19
+ }
20
+ },
21
+ "initialPermissions": {
22
+ "snap_dialog": {},
23
+ "snap_getBip44Entropy": [
24
+ {
25
+ "coinType": 60
26
+ }
27
+ ]
28
+ },
29
+ "platformVersion": "6.24.0",
30
+ "manifestVersion": "0.1"
31
+ }
package/src/index.ts ADDED
@@ -0,0 +1,198 @@
1
+ import type { OnRpcRequestHandler } from '@metamask/snaps-sdk';
2
+ import { divider, heading, panel, text } from '@metamask/snaps-sdk';
3
+ import type { BIP44AddressKeyDeriver, JsonBIP44CoinTypeNode } from '@metamask/key-tree';
4
+ import { getBIP44AddressKeyDeriver } from '@metamask/key-tree';
5
+ import { secp256k1 } from '@noble/curves/secp256k1.js';
6
+
7
+ type SnapRequest = Readonly<{
8
+ method: string;
9
+ params?: unknown;
10
+ }>;
11
+
12
+ declare const snap: Readonly<{
13
+ request: (args: SnapRequest) => Promise<unknown>;
14
+ }>;
15
+
16
+ const ETHEREUM_COIN_TYPE = 60;
17
+ const MAX_ACCOUNT_SCAN = 100;
18
+
19
+ function bytesToHex(bytes: Uint8Array): string {
20
+ return `0x${Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('')}`;
21
+ }
22
+
23
+ function hexToBytes(hex: string): Uint8Array {
24
+ if (typeof hex !== 'string' || !hex.startsWith('0x')) throw new Error('hex must start with 0x');
25
+ const body = hex.slice(2);
26
+ if (body.length % 2 !== 0) throw new Error('hex must have an even length');
27
+ const out = new Uint8Array(body.length / 2);
28
+ for (let i = 0; i < out.length; i++) {
29
+ const byte = Number.parseInt(body.slice(i * 2, i * 2 + 2), 16);
30
+ if (!Number.isFinite(byte)) throw new Error('invalid hex');
31
+ out[i] = byte;
32
+ }
33
+ return out;
34
+ }
35
+
36
+ function truncateHex(value: string, start = 10, end = 8): string {
37
+ if (value.length <= start + end + 1) return value;
38
+ return `${value.slice(0, start)}…${value.slice(-end)}`;
39
+ }
40
+
41
+ function parseAddress(value: unknown): string {
42
+ if (typeof value !== 'string') throw new Error('account must be a 0x-prefixed hex address string');
43
+ const trimmed = value.trim();
44
+ if (!/^0x[0-9a-fA-F]{40}$/.test(trimmed)) throw new Error('account must be a 20-byte hex address');
45
+ return trimmed;
46
+ }
47
+
48
+ function parseEthGetEncryptionPublicKeyParams(params: unknown): { account: string } {
49
+ if (!params) throw new Error('Missing params. Expected [account].');
50
+ if (Array.isArray(params)) {
51
+ const [account] = params;
52
+ return { account: parseAddress(account) };
53
+ }
54
+ if (typeof params === 'object' && params !== null) {
55
+ const maybe = (params as { account?: unknown }).account;
56
+ return { account: parseAddress(maybe) };
57
+ }
58
+ throw new Error('Invalid params. Expected [account] or { account }.');
59
+ }
60
+
61
+ function parseEthPerformEcdhParams(params: unknown): { account: string; ephemeralKey: string } {
62
+ if (!params) throw new Error('Missing params. Expected [account, ephemeralKey].');
63
+ if (Array.isArray(params)) {
64
+ const [account, ephemeralKey] = params;
65
+ if (typeof ephemeralKey !== 'string') throw new Error('ephemeralKey must be a 0x-prefixed hex string');
66
+ return { account: parseAddress(account), ephemeralKey: ephemeralKey.trim() };
67
+ }
68
+ if (typeof params === 'object' && params !== null) {
69
+ const obj = params as { account?: unknown; ephemeralKey?: unknown };
70
+ if (typeof obj.ephemeralKey !== 'string') throw new Error('ephemeralKey must be a 0x-prefixed hex string');
71
+ return { account: parseAddress(obj.account), ephemeralKey: obj.ephemeralKey.trim() };
72
+ }
73
+ throw new Error('Invalid params. Expected [account, ephemeralKey] or { account, ephemeralKey }.');
74
+ }
75
+
76
+ async function confirm(args: { origin: string; title: string; body: string[] }): Promise<void> {
77
+ const ok = (await snap.request({
78
+ method: 'snap_dialog',
79
+ params: {
80
+ type: 'confirmation',
81
+ content: panel([
82
+ heading(args.title),
83
+ text(`Origin: ${args.origin}`),
84
+ divider(),
85
+ ...args.body.map((line) => text(line)),
86
+ ]),
87
+ },
88
+ })) as boolean;
89
+ if (!ok) throw new Error('User rejected request.');
90
+ }
91
+
92
+ let cachedEthereumDeriverPromise: Promise<BIP44AddressKeyDeriver> | null = null;
93
+ const accountIndexByAddress = new Map<string, number>();
94
+
95
+ async function getEthereumAddressDeriver(): Promise<BIP44AddressKeyDeriver> {
96
+ if (!cachedEthereumDeriverPromise) {
97
+ cachedEthereumDeriverPromise = (async () => {
98
+ const coinTypeNode = (await snap.request({
99
+ method: 'snap_getBip44Entropy',
100
+ params: { coinType: ETHEREUM_COIN_TYPE },
101
+ })) as JsonBIP44CoinTypeNode;
102
+ return await getBIP44AddressKeyDeriver(coinTypeNode, { account: 0, change: 0 });
103
+ })();
104
+ }
105
+ return cachedEthereumDeriverPromise;
106
+ }
107
+
108
+ async function getAccountPrivateKey(account: string): Promise<Uint8Array> {
109
+ const target = account.toLowerCase();
110
+ const deriver = await getEthereumAddressDeriver();
111
+
112
+ const cachedIndex = accountIndexByAddress.get(target);
113
+ if (cachedIndex !== undefined) {
114
+ const node = await deriver(cachedIndex);
115
+ if (node.address.toLowerCase() === target) {
116
+ const priv = node.privateKeyBytes;
117
+ if (!priv) throw new Error('private key unavailable for derived account');
118
+ return priv;
119
+ }
120
+ accountIndexByAddress.delete(target);
121
+ }
122
+
123
+ for (let index = 0; index < MAX_ACCOUNT_SCAN; index++) {
124
+ const node = await deriver(index);
125
+ if (node.address.toLowerCase() === target) {
126
+ const priv = node.privateKeyBytes;
127
+ if (!priv) throw new Error('private key unavailable for derived account');
128
+ accountIndexByAddress.set(target, index);
129
+ return priv;
130
+ }
131
+ }
132
+
133
+ throw new Error(
134
+ `Account not found among the first ${MAX_ACCOUNT_SCAN} MetaMask HD accounts. Imported accounts and hardware wallets are not supported.`,
135
+ );
136
+ }
137
+
138
+ export const onRpcRequest: OnRpcRequestHandler = async ({ origin, request }) => {
139
+ const req = request as { method: string; params?: unknown };
140
+
141
+ switch (req.method) {
142
+ case 'erc5630_getInfo':
143
+ case 'eip5630_getInfo': {
144
+ return {
145
+ name: 'ERC-5630 ECDH Snap',
146
+ methods: ['eth_getEncryptionPublicKey', 'eth_performECDH'],
147
+ notes: [
148
+ 'This snap implements ERC-5630-style methods via wallet_invokeSnap, not as top-level wallet RPC methods.',
149
+ 'It uses snap_getBip44Entropy (coinType 60) to derive the secp256k1 key for MetaMask HD accounts.',
150
+ 'Imported accounts and hardware wallets are not supported.',
151
+ ],
152
+ };
153
+ }
154
+
155
+ case 'eth_getEncryptionPublicKey': {
156
+ const { account } = parseEthGetEncryptionPublicKeyParams(req.params);
157
+ await confirm({
158
+ origin,
159
+ title: 'ERC-5630: Share encryption public key?',
160
+ body: [
161
+ `Account: ${account}`,
162
+ 'This will share a compressed secp256k1 public key for the selected account.',
163
+ `The snap will derive this from your MetaMask HD seed (BIP-44 coinType ${ETHEREUM_COIN_TYPE}).`,
164
+ 'Only approve if you trust this site.',
165
+ ],
166
+ });
167
+ const privKey = await getAccountPrivateKey(account);
168
+ const pubkeyCompressed = secp256k1.getPublicKey(privKey, true);
169
+ return bytesToHex(pubkeyCompressed);
170
+ }
171
+
172
+ case 'eth_performECDH': {
173
+ const { account, ephemeralKey } = parseEthPerformEcdhParams(req.params);
174
+ await confirm({
175
+ origin,
176
+ title: 'ERC-5630: Perform ECDH?',
177
+ body: [
178
+ `Account: ${account}`,
179
+ 'This will return key material (the ECDH shared secret x-coordinate) for the selected account.',
180
+ `The snap will derive the account key from your MetaMask HD seed (BIP-44 coinType ${ETHEREUM_COIN_TYPE}).`,
181
+ 'Only approve if you trust this site.',
182
+ `Ephemeral key: ${truncateHex(ephemeralKey)}`,
183
+ ],
184
+ });
185
+
186
+ const ephBytes = hexToBytes(ephemeralKey);
187
+ if (!secp256k1.utils.isValidPublicKey(ephBytes, true)) throw new Error('Invalid compressed secp256k1 pubkey.');
188
+
189
+ const privKey = await getAccountPrivateKey(account);
190
+ const sharedCompressed = secp256k1.getSharedSecret(privKey, ephBytes, true);
191
+ const sharedX = sharedCompressed.slice(1);
192
+ return bytesToHex(sharedX);
193
+ }
194
+
195
+ default:
196
+ throw new Error('Method not found.');
197
+ }
198
+ };